Skip to content

Barbara - The Reply Model

One Emotion Token, Then Her Words

Summary: Barbara’s reply model is Qwen3-0.6B, fine-tuned to read a module’s facts and what I said, and to answer with one emotion token, then a short reply in her voice. Her character and the emotion rules are not in its prompt: they are in its weights, learned from about 3,000 examples written by a bigger model running at home, Qwen3-32B. This part is my journal of how I wrote the rules, generated and balanced the data, trained the model on the Orin, measured it, and served it with a safe fallback.

Where it sits in a voice turn:

<weather>
context + my words
<happy>Sunny all afternoon...
first token: <happy>
the words
'Barbara, what's the weather like?'
Speech to text
Router
Weather module: the forecast
Reply model
Barbara splits it
Robot: a happy move
Text to speech: her voice

The router (part 2) picks the module, the module fetches the facts, and the reply model does the rest: it picks the emotion and writes the words, in one answer. Barbara cuts that answer in two. The first token becomes a move, the words are spoken, and both start together. For chat, the context is empty: the emotion then comes only from my words.

From Prompts to Weights

In part 1, each module had its own prompt, and the module chose the emotion: sun was happy, rain was sad, and chat stayed neutral, because a small model given a list of emotions in its prompt picked them badly. Two things bothered me. The prompts were long, so the model re-read the same instructions at every request. And the emotion only followed the subject, never the content: “sunny tomorrow” and “40°C tomorrow” both came out happy.

Now the reply model reads only two things:

  • a context: the facts a module gives, in the module’s own format, or nothing for chat;
  • what I said, as the speech recognition wrote it.

It answers like this:

context Forecast:
- today afternoon: 22°C sunny
user what's the weather like
reply <happy>Sunny all afternoon, 22°C. Perfect for a walk!

The first token, <happy>, drives the robot’s move; the rest is spoken. The model chooses it, for chat, compliments and thanks, the weather and the indoor climate.

Now
Reply model: character and rules in its weights
Context + my words
<happy> + her words
Before (part 1)
Base model
Long prompt: her character, the rules, the module's facts, my words
Her words
Module code: sun, so happy
The move

Before, the words and the emotion came from two places that never talked: the model wrote, the module’s code picked the move from the subject. Now one model reads the facts and does both, and its prompt holds only the facts and my words.

This is context distillation. A big model reads a long instruction (the rules and her character) and writes examples. A small model is trained on those examples without the instruction, until it behaves as if it had read it. The instruction ends up in the weights: the prompt holds only the facts.

rules.md + her character: the long instruction
Teacher: Qwen3-32B
Scenarios: a context and my words
About 3,000 rows: context + words → emotion + reply
Student: Qwen3-0.6B, trained on the rows only
Served: reads only the context and my words

The instruction appears only on the teacher’s side. The student never reads it; it learns its effect from the rows.

The Emotion Rules

I wrote the rules in one file, rules.md. The teacher reads it before every label and every reply; the student never sees it. Nine tokens:

TokenWhenExample
<neutral>Routine facts; the default when unsurethe metro in 4 minutes; “I don’t have tomorrow’s forecast”
<happy>Good for me or for peoplesunny and 22°C
<excited>Very good, or looked forward toholidays start tomorrow
<dance>A celebrationNew Year; a birthday; a final won
<sad>Bad for me or for peoplea death in the news; 40°C; a cancelled trip
<loving>Affection, or thanks said to her”thank you for being here”
<coquin>A compliment or flirting, answered with teasing”you’re so cute”
<yes>She agrees to do something, or did it”Done, milk is on the list”
<no>She refuses, or can’t do an action”I can’t order pizza”

coquin is French for cheeky. “Frustrated” is not a token: when something breaks, the code says so with its own fixed sentence.

The decisions that shaped the data:

  • Generic common sense, the same everywhere. A killing in the news is always sad, the New Year is always a dance, sun is happy but 40°C is sad. No module overrides the rules. A mistake now and then is fine; the opposite emotion, dancing at a death, is not.
  • Neutral is the default. Unsure between an emotion and neutral: neutral. Unsure between two emotions: the milder one (happy before excited, excited before dance). A small robot that overreacts is worse than one that stays calm.
  • Yes and no only for actions. “The train is in 2 minutes” is neutral, even if it reassures me. “I don’t have tomorrow’s forecast” is neutral too: a missing fact is not a refusal. <no> is for “I can’t switch the garage light”.
  • Thanks is loving. Only compliments and flirting are coquin.
  • The most serious content wins. One killing among good headlines makes the reply sad. Degree matters: light rain on a free day is neutral, rain that ruins my picnic is gently sad. My own words count: “it’s my birthday” sets the emotion as much as the context.

Her character (part 1) became rules the teacher can follow: one sentence when it is enough, two at most; only facts from the context or from me; never offering what she can’t do (“shall I check again later?”); a light joke in about one reply out of four, never on sad news, and no exclamation mark when the news is sad.

The Teacher

The teacher is Qwen3-32B-AWQ, Qwen3-32B with its weights compressed to 4 bits, on the Orin. It takes about 19 GB, so it fits beside Barbara’s running services, and nothing leaves the house.

It is slow: about 8.5 tokens (pieces of words) per second for one request. A GPU is much better at many requests at once than at one, so the generator sends up to 32 at a time, for about 165 tokens per second in total. A finished example costs about 1,500 tokens (three labels with their reasoning, a reply and a check), so the first full dataset, 10,356 rows, took about 23 hours. It runs on the Orin itself, in a container that resumes where it stopped: the first night, it ran from my laptop, which went to sleep, and the teacher sat idle for 13 hours.

Generating the Dataset

no majority
the majority is the label
pass
fail
invents
yes
no
grounded
Plan a round: which emotion is still missing, in which domain
Context: written by code in the module's format, or empty
Teacher: what the user says, aiming at the emotion
Barbara's own text path: lowercase, no punctuation, numbers in words
Teacher votes 3 times, blind
Dropped: disputed
Teacher writes the reply for that emotion
Checks by code: numbers, length, characters for speech
Teacher checks: does the reply invent anything?
Under 3 tries?
Dropped: still fails after 3 tries
Row saved

Blue steps are the teacher, grey steps are code, red boxes are where a scenario dies. The teacher writes and judges; code plans, formats and checks everything that can be checked without understanding the text.

Each row is one scenario in one domain (chat, compliments and thanks, weather, indoor climate, news, calendar, shopping list, reminders, metro, something she can’t do, and later music). Four ideas make the data usable.

Three blind votes

The scenario is written for an emotion, but that target is never the label. The teacher labels it three times, without knowing the target, with its reasoning turned on, and the majority wins. Without a majority, the row is “disputed” and dropped. 79% of the votes were unanimous.

This matters because the teacher doesn’t write what it’s asked for. When asked for an excited scenario, it wrote something it then labelled excited only 6% of the time:

Scenarios whose blind vote kept the emotion they were written for (%)lovingyesnosadcoquinneutralhappydanceexcited1009080706050403020100Kept (%)

From the first full run. 4,356 scenarios were written for excited; the votes made 2,825 of them happy and 1,076 neutral. Neutral’s low score has another cause: 484 of its scenarios were things she can’t do, voted no.

Read it as a drift toward the milder emotion: excited becomes happy, dance becomes happy, happy becomes neutral. It is my own milder-choice rule, applied by a cautious model. Labelling by the vote keeps the labels honest; the cost is time.

Quotas on the vote

The generator works in rounds. Each round counts what every voted emotion still lacks, against a quota of 450 rows (900 for neutral, the default), and asks for more scenarios where the teacher often labels otherwise: an emotion kept a quarter of the time is asked four times as often. A domain that already gave many rows of an emotion goes last.

Count usable rows per voted emotion
What each emotion lacks: quota 450, neutral 900
Weight by the keep rate: kept 1 time in 4, asked 4 times as often
Domains that gave few rows of it go first
Write, vote and check a batch

One round. The count uses the blind vote, never the target, so an emotion the teacher keeps rarely gets more scenarios instead of fake rows.

Even so, the run stopped at 437 usable excited rows out of 450: after five hours without a single new one, the teacher labelled nearly every excited scenario happy. Close enough. And happy itself overflowed to 4,517 rows, 80% of them weather.

Contexts written by code

At first, the teacher wrote the contexts too. It was a mistake, and a subtle one: the format of a context changed with the emotion it aimed at. Its two-to-four-line forecasts were all celebrations. A model learns that instantly: count the lines, guess the emotion. The format gives the label away, and the model learns nothing about the weather.

Now: code writes it
The weather module's own forecast, facts leaning to rain or 38°C
Target: sad
The blind vote decides the label
Same format for every emotion: the student has to read the facts
First try: the teacher writes the context
A short forecast, 2 to 4 lines
Target: a celebration
The student learns: few lines, so dance

So code writes the contexts with the modules’ own functions: the weather module’s forecast, in Home Assistant’s condition names and the module’s periods of the day, the indoor module’s readings. The facts are random, leaning toward the target (a sad forecast is more often rain or 38°C), and the blind vote still decides the label. For news and the calendar, the teacher invents the headlines and events, and code formats them. When a later top-up replaced the weather data, it replaced every weather row, so no old format survived to give labels away.

The same goes for my words: the teacher writes “Twenty degrees?”, the speech recognition writes “twenty degrees”. So its sentences go through Barbara’s own text path: lowercase, no punctuation, numbers as words. I checked those rules against real transcripts by counting characters, without reading them: no digit and no curly apostrophe ever appeared.

Grounding checks

The teacher invents. In its jokes, it promised things (“shall I turn on the patio lights?”) or made up facts about people (“he said he loves you”). So each reply goes through two filters:

  • code: no number that isn’t in the context, at most two sentences and 30 words, only characters the speech synthesis reads well (no emoji, no em dash), no exclamation mark on sad news;
  • a second teacher pass, which answers grounded: yes/no and why: does the reply state a fact nobody gave her, or offer something she can’t do?

A rejected reply is written again, three times at most. In the first full run, 244 rows still invented something after three tries, and 146 had an exclamation mark on sad news: all dropped.

For experts: the labels use thinking mode and a plain two-line answer (emotion: / reason:) parsed by code. I first combined thinking with a JSON schema, and the constrained grammar let the model loop on whitespace until its token limit: one answer cost eight minutes. JSON schemas are only used without thinking, to write scenarios in batches.

From 10,356 rows to about 3,000

The first full run gave 10,356 rows, wildly unbalanced: 4,517 happy, 451 excited. Then the training keeps only what follows today’s rules:

  • <yes> only after a “Done:” context, <no> only where she can refuse (chat, things she can’t do); elsewhere, the teacher’s yes or no was a plain answer;
  • one row per (context, words): some compliments and thanks were repeated up to 40 times, and their copies landed in test;
  • at most 450 rows per emotion (900 neutral), taken a domain at a time, so each domain gives its share. A plain random cap would have kept mostly weather rows for happy, and taught “weather means happy”.

A statistics file, regenerated after every round, flags shortcuts: a single word or domain that predicts one emotion 90% of the time or more. Some are true to life: “thank” is always loving, by my rule, and “something she can’t do” is always <no>, because that context only exists when she can’t. Others need contrast scenarios: a list read out is neutral, a sad birthday is sad, a thanks can follow an ordinary answer.

Two top-ups followed. Weather (933 rows): the first data was almost all fine days, with two cloudy, two foggy and about ten light-rain forecasts among 681 balanced rows. The top-up drew the temperature apart from the condition, and added my new rules: rain that spoils a plan is gently sad, cold sun can go either way as long as the reply matches. Music (891 rows written, 394 usable after the checks): while her speaker plays a song, she can talk about it, knowing only its title and artist, and she never claims she started or stopped it.

The whole path, from the generated rows to the three splits:

First full run: 10,356 rows; 4,517 happy, 451 excited
Usable rows: a majority vote, every check passed
Weather top-up: 933 rows, replacing every old weather row
Music: 891 rows written, 394 usable
Yes and no only where they belong
One row per context and words
At most 450 per emotion, 900 for neutral, a domain at a time
Split by the request that wrote the rows
Train: 3,002
Test: 367, decides
Eval: 390, reports

The final training set: 3,002 rows, with 367 for test and 390 for eval.

Training: a Full Fine-Tune

The emotion tokens

Each emotion is a real token of the model’s vocabulary, so the choice is one step, and the first token of the reply is the emotion. Qwen3’s tokenizer has 151,669 tokens but its embedding table has 151,936 rows, so the nine new tokens fit in unused rows without resizing anything. (An embedding is the row of numbers the model reads for a token; the table has spare rows.) Each one starts from the embedding of its word: <happy> starts where ” happy” is, so the model doesn’t learn its meaning from nothing.

Embedding table: 151,936 rows
Rows 151,669 to 151,935: unused
copied once, before training
Rows 0 to 151,668: the tokenizer's 151,669 tokens
<happy>, and the eight other emotion tokens
The row of ' happy'

The nine emotion tokens take nine spare rows, and nothing is resized: the model keeps its shape. When a word is several tokens, its row starts as the average of theirs. Training then moves each new row from its word toward what the emotion means in Barbara’s replies.

Why not LoRA

My first plan was LoRA: freeze the model, train small adapter matrices beside some layers, and serve the adapter on top of the base model that Barbara already ran. One model in memory, two behaviours.

It failed on a detail of Qwen3-0.6B: its embeddings are tied. The table that turns a token into numbers at the input is the same matrix that scores every token at the output. The new tokens need their rows trained, and the library I used for LoRA and the one for training clashed on that shared matrix.

one matrix, used twice
A token: <happy>
Embedding table: token → its row of numbers
Transformer blocks
Output: a score for every token, using the same table
The next token

Training the new rows changes both ends at once: how the model reads <happy>, and how likely it is to write it.

For experts: PEFT’s trainable_token_indices trains only a few rows of the embedding table; TRL’s SFTTrainer computes the output layer and the loss in one fused step to save memory. Together, on the tied matrix, they broke.

Then TRL failed on the Orin for a different reason: it imports torch.distributed, and the Jetson’s PyTorch is built without it. So I dropped both and wrote the training with transformers’ plain Trainer. And with 0.6B parameters, there was no need for LoRA at all: the whole model trains on the Orin in about 8 GB. A full fine-tune is simpler, every weight can carry the persona, and the price is a second copy of the model, served apart from the base one.

Settings

  • The loss counts only the answer, <emotion>reply<|im_end|>: the prompt’s tokens are masked, so the model learns to reply, not to repeat contexts.

System: the context
User: my words
<happy>
Sunny all afternoon, 22°C...
<|im_end|>

One training row. The model reads all of it; the loss only counts the green part. The emotion token is the first counted token, so every row trains the choice of emotion, then the words, then where to stop.

  • The prompt is Qwen3’s chat template with thinking off, exactly what Barbara sends: the context as the system message (none when empty), then my words.
  • The model sees 16 examples at a time (a batch), and makes 3 passes over the data (epochs). The learning rate, 2e-5, is the size of each correction; it shrinks smoothly to zero along a cosine curve.
  • Every 50 steps, the loss (how surprised the model is by the right answer) is measured on test, and the saved weights (checkpoint) with the lowest one are kept.
  • The data is split by the request that wrote the rows: rows written together are often alike, so they stay in the same split. One request in ten goes to test, one in ten to eval, as for the router (part 2): test decides, eval only reports.

A run takes about 19 minutes on the Orin’s GPU. The deployment stops the teacher first, since both don’t fit in memory, trains, and publishes the model only if it passes the promotion gate of part 3: a test macro-F1 of at least 0.75, and no more than 0.03 below the model it replaces.

yes
no
Stop the teacher
Train: about 19 min on the GPU
Promotion gate: test macro-F1 ≥ 0.75, and at most 0.03 below the served model
Publish the new model
Keep the served model

For experts: the first run trained in pure bf16. bf16 keeps about three significant digits, so a weight near 0.5 can’t move by 1e-5: at this learning rate, most updates rounded to nothing. The weights are now kept in fp32, with bf16 only for the computation (autocast), and the saved model is converted to bf16 for serving. The save also needed two fixes for vLLM’s older transformers; part 3 tells the silent one.

Results

What the numbers measure

For each test row, I read the model’s first token and keep the emotion it ranks highest. Emotion accuracy is the share of rows where it matches the teacher’s vote. Macro-F1 scores each emotion on its own and averages them, so the small classes weigh as much as neutral; the brackets are 95% intervals from a bootstrap over requests, explained in part 2.

One thing to keep in mind: the reference is the teacher’s vote, not the truth. 84% means “agrees with the 32B model 84% of the time”, and the teacher doesn’t always agree with itself.

Three runs

Emotion accuracy on test (%)Untrained (latest test)First run+ weather, fp32+ music1009080706050403020100Test accuracy (%)

Each run has its own test set (373, 366 and 367 rows), so the gaps are indicative. The intervals are about ±4 points.

  • Untrained, 14.5% to 15.3% depending on the test set: the base model, asked the same way, barely beats picking one of nine tokens at random (11%).
  • First run, 83.1% (79.0–87.1), macro-F1 0.82. Its weakest emotion was happy, recognized only 54% of the time: almost all happy rows were weather, and almost all weather was fine days, so happy meant “a forecast” more than “good news”.
  • Weather top-up and fp32, 85.2% (80.8–89.2), macro-F1 0.85. Happy recall went from 54% to 79%: with rainy, foggy and hot days in the data, happy now has to mean something. I changed the data and the precision in the same run, so I can’t split the credit.
  • Music, 84.2% (79.5–88.5), macro-F1 0.84; eval 87.2%. The same within the intervals, with a new skill: talking about the song playing without inventing anything about it. Neutral dipped, though (82% → 74% recall), mostly toward sad and no; I’m watching it.

The latest run, emotion by emotion:

Recall per emotion on test (%)neutralhappyexciteddancesadlovingcoquinyesno1009080706050403020100Recall (%)

Recall: of the rows whose label is that emotion, the share the model found. Each bar rests on 27 to 78 rows, so one row moves a small bar by about 4 points.

What the confusions mean

The errors are not random; they sit between neighbours:

The 15 most frequent confusions on test (rows)neutral → happyneutral → sadexcited → happydance → happyneutral → nocoquin → lovingexcited → danceloving → coquindance → neutraldance → excitedhappy → yeshappy → excitedhappy → danceno → coquinsad → happy012345678910Test rows

Latest run. Each bar is the teacher’s label, then the model’s choice. Together, 50 of the 58 wrong rows; the bullets below group them.

  • Along the mildness scale. neutral → happy (8), excited → happy (5), dance → happy (4), excited → dance (3). The border between “nice” and “very nice” is where the teacher hesitated too. For a robot, a happy nod instead of an excited one is a small miss.
  • neutral → sad (6). Mostly weather: plain rain is neutral, rain that ruins a plan is gently sad, and the line depends on a few words of mine.
  • coquin ↔ loving (3 each way). “I like the way you smile” was voted coquin, the model said loving. Compliment or affection: people would hesitate too.
  • The forbidden kind. sad → happy, the opposite emotion my rules exclude: 2 of 48 sad rows on test. Rare, but the one I watch.

Beyond the emotion, 98% of 300 greedy test replies (the most likely word at each step) pass every code check, and an emotion token comes first in 100% of them. Reading the replies shows what the numbers don’t:

  • To “you’re just as pretty as the flowers outside”, she answers “You’re just as pretty as the flowers outside?”: a parrot, not a reply.
  • To “tonight is winter solstice”, with a clear forecast, the teacher danced, the student stayed neutral: “It’s 11°C and clear tonight. Not too chilly for a blanket!” Arguably the milder choice.
  • A headline of a won final gave “The team won the gold medal, let’s cheer!” twice in a row.

Serving, With a Safe Fallback

The reply model runs on its own vLLM on the Orin, beside the base model. The modules send their context only, and Barbara reads the stream:

  • the first token is the emotion; it opens the robot’s move as the first sentence is spoken (<neutral> plays none);
  • in about 2% of the replies of the first run, a word was written as its token: “The<dance> party”. It is a side effect of starting each token from its word’s embedding. Barbara turns any emotion token after the first back into its word;
  • any other tag is removed, so the voice never reads it and the robot never plays it.

A new model in the loop is a new way to fail, so the old path stays:

no
yes
error or nothing
yes
fails mid-reply
A module asks for a reply
Reply model on, and not resting?
Base model with the module's old prompt
First words within the timeout?
Rest 60 s
Stream the reply
The reply ends where it got to; rest 60 s

The connection timeout is one second, because the Orin is on my home network: a dead port fails fast, and a reply from the old prompts is better than silence. Without its address in the configuration, Barbara runs exactly as before. The background jobs (calendar keywords, news translation, the digest) keep the base model.

What’s Next

  • Smaller and faster models. I’m about to benchmark two Liquid AI models, LFM2.5-350M and LFM2.5-1.2B, on the same data. A better model must keep the same perceived speed and give better answers. Reinforcement learning may come later, on the most promising one.
  • The time to the first word, measured against the old long prompts on the same simulated conversations. The prompt is much shorter now; I haven’t measured what that buys.
  • Excited and dance weather: the weather top-up asked only for neutral, happy and sad, so “a clearly special day” has almost no weather rows left.
  • Real sentences. As for the router, the exchange log will give labelled sentences that no teacher wrote.

Next, part 5: architecture and modules.