How does keyword boosting help ASR recognize domain words?
- Authors
- Name
- Amit Shekhar
- Published on
Keyword boosting helps ASR recognize domain words by giving a small extra score to the words we list in advance, so that when the model is unsure between a common word and our special word, it picks our special word.
In this blog, we will learn about how keyword boosting helps ASR recognize domain words. We will also see why ASR gets domain words wrong, how ASR picks one word over another using scores, how a boost changes those scores during decoding, how a word gets boosted piece by piece, how to pick the right boost strength, and where keyword boosting works well and where it fails.
We will cover the following:
- What is ASR?
- Why does ASR get domain words wrong?
- What is keyword boosting?
- How does ASR pick one word over another?
- How does keyword boosting change the scores?
- Boosting a word piece by piece
- How strong should the boost be?
- Keyword boosting in a voice agent
- Where keyword boosting works well and where it fails
I am Amit Shekhar, Founder @ Outcome School, I have taught and mentored many developers, and their efforts landed them high-paying tech jobs, helped many tech companies in solving their unique problems, and created many open-source libraries being used by top companies. I am passionate about sharing knowledge through open-source, blogs, and videos.
I teach AI and Machine Learning at Outcome School.
Let's get started.
What is ASR?
ASR (Automatic Speech Recognition) is a model that listens to spoken audio and writes down the words as text.
In a typical voice agent, ASR is the first step. The caller speaks, the ASR turns the speech into text, the LLM reads that text and decides what to say, and a text-to-speech model speaks the reply.
So, if the ASR writes down the wrong word, everything after it goes wrong. The LLM can only work with the text it receives.
Why does ASR get domain words wrong?
A domain word is a word that belongs to one business or one field, and that is rarely used in daily life. For example:
- A medicine name like "Atorvastatin"
- A product name like "Zyvora Pro"
- A company name like "Outcome School"
- A technical term like "Kubernetes"
- A person's name like "Anirudh"
An ASR model learns from a huge amount of recorded speech and its text. Common words like "water", "order", and "tomorrow" appear millions of times in that data. Let's say "Zyvora" is a product that was launched last month. This name appears zero times in that data.
So, when a caller says "Zyvora", the model hears a sound that it has never learned as one word. It tries to match the sound with words it knows well, and it writes something like "zero ra" or "Savora".
Let's say a caller says:
"I want to cancel my Zyvora Pro plan."
The ASR writes:
"I want to cancel my zero ra pro plan."
Now, the LLM has no idea which plan the caller is talking about.
We cannot retrain the ASR model every time a business launches a new product or hires a new doctor. Retraining is slow and costly. We need something that we can change in a few seconds.
One simple idea is to fix the text after the ASR, by replacing "zero ra" with "Zyvora". But the ASR does not make the same mistake every time. One caller gets "zero ra", another caller gets "Savora", and a third caller gets "Ziva ra". We cannot list every wrong spelling in advance.
Here comes keyword boosting into the picture.
What is keyword boosting?
Keyword boosting is a way to give an ASR model a list of important words, so that the model prefers these words when the audio sounds close to them.
The same idea is also called contextual biasing or phrase hints, depending on the speech provider.
We do not change the model itself. We only pass a small list of words along with the audio, like below:
keywords = ["Zyvora Pro", "Atorvastatin", "Outcome School"]
Here, a keyword can be a single word like "Atorvastatin" or a short phrase like "Zyvora Pro".
Then, the ASR uses this list while it is deciding which words to write. In this blog, we will focus on the most common way to do this, which is adding a bonus score while the ASR picks the words. Some newer speech models also read the keyword list as a text prompt along with the audio, but the goal is the same.
Planning your move into AI?
No matter which tech domain you work in today, with your effort, you can transition to these roles:
- AI Engineer
- Forward Deployed Engineer
- AI Agent Engineer
- Harness Engineer
- Voice AI Engineer
- AI Architect
- LLM Engineer
- LLM Inference Engineer
- Gen AI Engineer
- MLOps Engineer
- ML Engineer
- Deep Learning Engineer
Our AI and Machine Learning Program at Outcome School takes you there.
To understand how a list of words can change the output, we must first understand how ASR picks one word over another.
How does ASR pick one word over another?
An ASR model does not know the answer for sure. For every piece of audio, it guesses many possible words and gives each guess a score. A higher score means the model believes that guess more.
The best way to learn this is by taking an example. Let's say the caller says the sound "zy-vo-ra". The model can produce scores like below:
| Guess | Score |
|---|---|
| zero ra | 0.45 |
| Savora | 0.35 |
| Zyvora | 0.20 |
Here, "zero ra" has the highest score, because "zero" is a very common word that the model has heard many times. "Zyvora" still appears as a weak guess, because the model can build a new word from small pieces of text, like "Zy", "vo", and "ra", even when it has never seen that full word before. We will learn more about these small pieces later in this blog.
But the model does not simply pick the top guess and forget the rest. It keeps a few of the best candidate sentences alive at the same time, and keeps adding words to each of them. This process is called beam search.
So, at any moment, the ASR has a short list of candidate sentences, like below:
- "I want to cancel my zero ra"
- "I want to cancel my Savora"
- "I want to cancel my Zyvora"
Each candidate sentence has a total score. At the end, the candidate with the highest total score becomes the final text.
This process of turning scores into the final text is called decoding.
Now, let's see where the boost goes.
How does keyword boosting change the scores?
Keyword boosting works during decoding. Whenever a candidate sentence contains a word from our list, the ASR adds a small bonus to the score of that candidate.
Let's take the same example. Assume that our keyword list contains "Zyvora Pro", and the bonus for the word "Zyvora" is 0.30, just for the sake of understanding.
Step 1: The model produces its normal scores, the same as in the earlier table. "zero ra" is at 0.45, "Savora" is at 0.35, and "Zyvora" is at 0.20.
Step 2: The ASR checks each guess against the keyword list. Only "Zyvora" is part of the list, so only "Zyvora" gets the bonus.
| Guess | Score | Bonus | New Score |
|---|---|---|---|
| zero ra | 0.45 | 0.00 | 0.45 |
| Savora | 0.35 | 0.00 | 0.35 |
| Zyvora | 0.20 | 0.30 | 0.50 |
Step 3: The ASR picks the highest new score. Now, "Zyvora" wins with 0.50 against 0.45.
The final text becomes:
"I want to cancel my Zyvora Pro plan."
Note: Real systems keep these scores on a different scale, called log probabilities, and add the bonus on that scale. The idea stays the same: the listed word gets a higher score.
Here, we can notice that the bonus did not create the word "Zyvora" from nothing. The model already had "Zyvora" as one of its guesses, with a score of 0.20. The boost only helped this weak guess win.
This means keyword boosting works best when the audio already sounds close to the word. If the caller says something completely different, a small bonus is not enough to change the result.
The flow looks like the diagram below:
Caller audio
↓
ASR model gives guesses
and their scores
↓
Decoding checks the keyword list
↓
Listed words get a bonus
↓
Highest total score wins
↓
Final text
A quick note for you
No matter which tech domain you work in, get familiar with these topics:
- LLM
- RAG
- MCP
- Agent
- Fine-tuning
- Quantization
We put it all together in one video:
AI Engineering Explained: LLM, RAG, MCP, Agent, Fine-Tuning, and Quantization
No need to stop reading - bookmark it and watch later when you get time. Future you will thank you.
Now, let's get back to the topic.
Boosting a word piece by piece
Now, the next big question is: when does the ASR add the bonus?
So far, for the sake of understanding, we treated each guess as a full word. But many ASR models do not write full words in one go. They write small pieces of words, called tokens. For example, "Zyvora" can be written as three tokens: "Zy", "vo", and "ra".
If the ASR waits until the full word "Zyvora" is written before adding the bonus, there is a problem. After the first token "Zy", the candidate sentence still has a low score, and beam search can throw it away before it ever reaches "ra". The bonus never gets a chance to help.
So, the solution is to add the bonus piece by piece. This is called prefix boosting.
Step 1: The candidate sentence adds the token "Zy". This matches the start of "Zyvora", so it gets a part of the bonus.
Step 2: The candidate sentence adds the token "vo". "Zyvo" still matches the start of "Zyvora", so it gets more of the bonus.
Step 3: The candidate sentence adds the token "ra". The full word "Zyvora" is complete, so it gets the rest of the bonus.
This way, the candidate gets help from the very first token, so it has a much better chance of staying alive in beam search.
Now, let's see another case. What if the candidate sentence adds "Zy", gets a part of the bonus, and then adds "lo" instead of "vo"? "Zylo" is not in our list. In this case, the ASR takes back the part of the bonus that it gave earlier. Means, a candidate keeps the bonus only if it completes a listed word.
Without taking back the bonus, the ASR would reward every word that starts with "Zy", even when it is not our keyword.
To learn Tokenization and how to Design a Real-Time Voice AI Agent from the ground up, check out our AI and Machine Learning Program at Outcome School.
How strong should the boost be?
Many speech providers let us set the strength of the boost, either for each word or for the whole list. A higher strength means a bigger bonus.
Let's see what happens when the boost is too weak and when it is too strong.
If the boost is too weak: The bonus is too small to beat the common words. "zero ra" still wins, and the boost has no effect.
If the boost is too strong: The bonus is so big that the ASR starts writing our keyword even when the caller did not say it. Let's say "Zyvora" has a very strong boost. The caller says "I saw it on the zero balance screen", and the ASR writes "I saw it on the Zyvora balance screen". This is called a false positive: the ASR writes a word that was never spoken.
So, we must pick a boost that is strong enough to fix the real mistakes, but not so strong that it creates new ones.
The same problem appears when the keyword list is too long. If we add thousands of words, many of them sound close to normal words, and the ASR starts mixing them into normal sentences. So, we must keep the list small and focused on the words that matter for the current call.
The best way to find the right strength is by testing. We take a set of recorded test calls, run the ASR on them with different boost strengths, and count two things:
- How many domain words became correct
- How many new wrong words appeared
Then, we pick the strength that gives the best balance between the two.
Keyword boosting in a voice agent
Now, let's take a real use case in a voice agent.
Assume that we are building a voice agent for a clinic. The clinic has a list of doctors and a list of medicines. The words that matter change from call to call. When a caller is booking an appointment, the doctor names matter. When a caller is asking about a refill, the medicine names matter.
So, instead of passing one fixed list, the voice agent can build the keyword list for each call, or even for each step of the call. For example, right after the agent asks "Which doctor would you like to see?", it passes only the doctor names as keywords for the next reply.
Let's see the code for the decoding part, written in a very simple way just for the sake of understanding:
def apply_boost(candidates, keywords, bonus):
boosted = []
for text, score in candidates:
new_score = score
for keyword in keywords:
if keyword.lower() in text.lower():
new_score += bonus
boosted.append((text, new_score))
# pick the candidate with the highest score
return max(boosted, key=lambda item: item[1])
candidates = [
("refill my a torva statin", 0.50),
("refill my Atorvastatin", 0.30),
]
keywords = ["Atorvastatin", "Dr. Anirudh"]
print(apply_boost(candidates, keywords, bonus=0.30))
Here, we have:
candidates: the candidate sentences from the ASR, each with its scorekeywords: the list of domain words for this callbonus: how much extra score a listed word getsapply_boost: adds the bonus to every candidate that contains a listed word, and then picks the candidate with the highest score
It will print the following:
('refill my Atorvastatin', 0.6)
Here, we can see that "refill my Atorvastatin" started with a lower score of 0.30, got a bonus of 0.30, and won with 0.60 against 0.50.
Note: A real ASR adds the bonus inside beam search, token by token, as we learned earlier with prefix boosting. It does not wait for the full sentence. This code only shows the core idea of adding a bonus and picking the highest score.
In a real voice agent, we do not write this decoding code ourselves. We pass the keyword list, and the boost strength if the provider supports it, to the speech provider along with the audio. The provider applies the boost inside its own decoder.
To build the list, the voice agent can use the things it already knows:
- The names of the doctors in the clinic
- The medicines in the caller's past orders
- The name of the caller, taken from the clinic records
This way, the list stays small, and every word in the list has a real chance of being spoken in this call.
Stay updated: Subscribe to our newsletter to get our latest AI and Machine Learning blogs straight to your inbox.
Where keyword boosting works well and where it fails
Now, let's see where keyword boosting works well.
- New product names: The model has never heard them, but they sound close to its guesses.
- Names of people and places: These are hard to spell from sound alone, and boosting picks the right spelling.
- Technical terms: Medicine names and software names rarely appear in normal speech, so the model needs the bonus to pick them.
- Fast changes: We can update the list in seconds, without retraining the model.
And, let's see where it fails.
- The word is not in the guesses at all: If the audio is very noisy, or the caller's accent makes the word sound completely different, the model does not produce the word as a guess. The bonus has nothing to raise.
- Too strong a boost: The ASR writes the keyword where it was never spoken.
- Too many keywords: The list starts competing with normal words and creates false positives.
- Very short keywords: A short keyword like "Zeno" sounds close to many normal words like "zero" and "see no", so boosting it creates more false positives than boosting a long word like "Atorvastatin".
- Words that sound like common words: If a product is called "Kloud", a strong boost can turn every spoken "cloud" into "Kloud", even when the caller is talking about the weather.
When keyword boosting is not enough, one of the ways is to fine-tune the ASR model on recorded audio that contains these domain words. That is slower and costlier, but it teaches the model the sound of the word itself.
We have a detailed blog on pronunciation dictionaries for TTS that explains how a voice agent says these same domain words correctly.
Now we must have understood how keyword boosting helps ASR recognize domain words, how it adds a bonus during decoding, and where it works well and where it fails.
Frequently Asked Questions
Is keyword boosting the same as contextual biasing?
Yes. Keyword boosting is also called contextual biasing or phrase hints, depending on the speech provider. In all cases, we pass a small list of important words along with the audio, and the ASR prefers these words when the audio sounds close to them. The model itself does not change.
Do we need to retrain the ASR model to use keyword boosting?
No. Keyword boosting does not change the model. We only pass a list of words, and the ASR uses it while decoding. This is why we can update the list in seconds, while retraining the model every time a business launches a new product or hires a new doctor is slow and costly.
Why not just fix the wrong words in the text after ASR?
Because the ASR does not make the same mistake every time. One caller gets "zero ra", another gets "Savora", and a third gets "Ziva ra" for the same word "Zyvora". We cannot list every wrong spelling in advance. Keyword boosting works during decoding instead, so the right word wins before the text is written.
How many keywords should we pass to the ASR?
We should keep the list small and focused on the words that matter for the current call. If we add thousands of words, many of them sound close to normal words, and the ASR starts writing them into normal sentences. A voice agent can build a fresh list for each call, or even for each step of the call.
What can we do when keyword boosting is not enough?
We can fine-tune the ASR model on recorded audio that contains the domain words. Keyword boosting can only raise a word that the model already produces as a guess, so it fails when noise or a strong accent makes the word sound completely different. Fine-tuning is slower and costlier, but it teaches the model the sound of the word itself.
That's it for now.
Thanks
Amit Shekhar
Founder @ Outcome School
You can connect with me on:
Follow Outcome School on:
