# Experimenting with Specialized Small Language Models

2026-11-30

I've been experimenting with specialized small language models for a while. I
tried many different ways to design and train them. They ended up with some
interesting characteristics:

- Easy to train. Models can be trained independently and each covers one or more
  domains.
- Composable. Models can be loaded and unloaded at any time and run side by
  side.
- Accurate. Models can be pretty accurate within their domains.

Here's what it looks like in a short demo. It starts with nothing loaded:

```text
$ demo
Type a message or /help for the commands.

> hi
No model is loaded. Use /list and /load MODEL
```

No model, no response. Let's load one:

```text
> /load conversation
Loaded conversation - 40M - 157MiB - 73ms
```

The model has about 40 million parameters. It loaded in 73ms[^1] and takes
157MiB of GPU memory. That's with unquantized weights.

Obviously this is a very small model and can't hold a deep conversation. Think
of it as an NPC (non-player character) in a game. It knows greetings, thanks and
a bit of small talk.

```text
> hi
Hello
conversation - 86ms - 487 tokens/s

> how are you doing today?
I'm doing well. How are you?
conversation - 127ms - 513 tokens/s

> pretty good
Glad to hear it.
conversation - 113ms - 495 tokens/s
```

This `conversation` model handles greetings, thanks and small talk. But it
doesn't know anything else. For example:

```text
> what is 6 * 7?
No response.
```

No response is expected because the conversation model doesn't know anything
about arithmetic. That being said there is an arithmetic model. Let's load it:

```text
> /load arithmetic
Loaded arithmetic - 40M - 156MiB - 97ms
```

It reminds me:

> - I know kung fu.
> - Show me.

```text
> what is 6 * 7?
42
arithmetic - 125ms (128ms) - 441 tokens/s (709 tokens/s)

> what is 12 * 6 * (30 - 2) + 1?
2017
arithmetic - 186ms (188ms) - 501 tokens/s (682 tokens/s)
```

Now we get a response. It comes from the arithmetic model we just loaded. The
conversation model still receives the prompt and still returns no response.

You may notice multiple response time and token stats under each answer. The
values in brackets represent the total response time and tokens per second for
all loaded models. Models run in parallel and each one spends some time and
tokens even when it has no response.

Let's do the same with algebra:

```text
> 14x + 15 = 71
No response.

> /load algebra
Loaded algebra - 40M - 156MiB - 140ms

> 14x + 15 = 71
x = 4
algebra - 632ms (636ms) - 563 tokens/s (669 tokens/s)
```

So far we loaded three models for conversation, arithmetic and algebra. Together
they take about 469MiB of GPU memory.

```text
> /list
Model         Status  Params  Memory Init  Memory Peak  Load time
conversation  loaded     40M       157MiB       217MiB       73ms
arithmetic    loaded     40M       156MiB       212MiB       97ms
algebra       loaded     40M       156MiB       212MiB      140ms
```

Models can be unloaded at any time too. Let's unload the arithmetic model:

```text
> /unload arithmetic
Unloaded arithmetic

> what is 12 * 6 * (30 - 2) + 1?
No response.

> how are you?
I'm doing well. How are you?
conversation - 138ms (141ms) - 464 tokens/s (707 tokens/s)
```

The arithmetic model is unloaded so we get no response again. The rest stay
loaded and keep working.

## How is this different than model routing?

Model routing is a common way to work with more than one language model. A
router sits in front of the models and decides where each prompt goes. In most
of these setups the models are general and any of them can answer the prompt.
The router picks one that is good enough, cheap enough or available.

There is no model router here so nothing reads the prompt first and decides
where it goes. Every loaded model gets the prompt. The models are specialized
and only the ones that know the domain answer the prompt. No model is picked in
advance.

One may argue that sending prompts to all loaded models costs more than routing
them. That is a fair point. But the models are so small and they load and unload
almost instantly. And remember that a model uses only a small number of tokens
when it doesn't know the domain. By the way a model router can still sit in
front of these models. In fact I'm thinking about implementing a model router
specifically for these small models.

## What is this good for?

These models are good for specialized tasks. They are pretty accurate within
their domains and they are reluctant to answer anything else. That matters when
a wrong answer is worse than no answer. For example a support assistant for a
product or a learning app for children shouldn't answer questions about anything
else.

They are also good when different capabilities are needed at different times.
Models can be loaded and unloaded as needed. For example an NPC in a game only
needs the models that match its role and an app only needs the models for the
feature in use.

## Technical Details

The three models have the same size. Each one has 12 layers, about 40 million
parameters and is trained on its own dataset.

| Model        | Training examples | Validation examples | Training time[^1] | Validation accuracy |
| ------------ | ----------------- | ------------------- | ----------------- | ------------------- |
| conversation | 22,500            | 2,500               | 1h 13m            | 99.4%               |
| arithmetic   | 64,881            | 7,209               | 22h 6m            | 98.8%               |
| algebra      | 46,718            | 5,191               | 14h 6m            | 84.8%               |

Validation accuracy is the share of the validation examples that the model got
right. These examples are kept out of training.

I'm pretty sure that accuracy can go higher with larger datasets, longer
training, different batch sizes and other training parameters. Nevertheless
these are still great numbers for training on a single 16GB GPU[^1].

* * *

There is more to specialized small language models than a demo can show. If you
have any questions or comments feel free to reach out to me on
[X](https://x.com/devfacet).

[^1]: RTX 5060 Ti 16GB

---

https://devfacet.com/blog/p/2/experimenting-with-specialized-small-language-models

Copyright (c) 2026 Fatih Cetinkaya
