CharacterBERT and Self-Teaching for Improving the Robustness of Dense Retrievers on Queries with Typos

Shengyao Zhuang, Guido ZucconarXiv 2022 · DOI

Search engines have become incredibly good at understanding what we mean, even when we don't use the exact right words. However, "Dense Retrievers" (DRs)—the modern, AI-powered engines behind this magic—have a surprising Achilles' heel: they are remarkably fragile when it comes to simple typos.

In their paper, "CharacterBERT and Self-Teaching for Improving the Robustness of Dense Retrievers on Queries with Typos," Shengyao Zhuang and Guido Zuccon explore why a single misplaced letter can tank a search engine's performance and offer a clever two-part solution to fix it.

TL;DR

Standard AI search models fail on typos because their tokenizers break misspelled words into nonsensical fragments. This paper introduces CharacterBERT-DR combined with a "Self-Teaching" training regime, allowing models to ignore typos and maintain high search accuracy without needing expensive external spell-checkers.

What Problem Does This Paper Address?

Most modern search models rely on BERT, which uses a strategy called WordPiece tokenization. WordPiece breaks words into common sub-units to handle a large vocabulary efficiently. For example, the word "information" is a single token. But if you type "infromation," the tokenizer gets confused and breaks it into four fragments: ['in', 'fr', 'oma', 'tion'].

The authors demonstrate that this "tokenization difference" creates a massive shift in the input embeddings. Because the input looks completely different to the model, the resulting search results are often irrelevant. In fact, injecting just one character-level typo into a query can cause the effectiveness of a dense retriever to plummet far below that of traditional, "dumb" keyword matching (like BM25).

Figure 2: Analysis of MRR drop rate (Δ𝑀𝑅𝑅) and encoding similarity for different values of tokenization difference. Shaded area is stan- dard deviation across queries in the 10 typos variations. Tokeniza- tion difference of 6 and 7 are discarded from this analysis as these bins contain too few samples (and thus large variance), although they still fit the trends observed for smaller tokenization difference values.

Methods

The authors propose a two-pronged approach to build a typo-robust retriever:

  1. CharacterBERT as the Backbone: Instead of using WordPiece, they use CharacterBERT. This model uses a Character-CNN module to build word embeddings directly from characters. This means "information" and "infromation" result in a single word embedding rather than being split into different numbers of sub-tokens. This makes the model's input naturally more stable.
  2. Self-Teaching (ST): This is a novel training regime inspired by Knowledge Distillation. Usually, you need a "teacher" model to show a "student" model the ropes. In Self-Teaching, the model acts as its own teacher. During training, the model sees a clean query ($q$) and a version with a synthetic typo ($q'$). It then tries to minimize the difference between the search scores it produces for both. Essentially, it teaches itself that the typo version should result in the same ranking as the clean version.
Figure 1: Our CharacterBERT + Self-Teaching training approach.

Datasets

The researchers evaluated their methods on several standard benchmarks and one new one:

  • MS MARCO & TREC DL (2019/2020): Standard large-scale passage retrieval datasets where typos were synthetically injected for testing.
  • DL-typo (New): A new benchmark created by the authors containing 60 real-world query pairs (typo vs. corrected) mined from the AOL search logs, complete with human relevance assessments.

Key Insights and Ideas

  • The Tokenizer is the Culprit: The "aha moment" is the realization that the model's "brain" (the transformer layers) isn't necessarily the problem; it's the "eyes" (the tokenizer). By changing how the model "sees" words, we solve the root cause of the fragility.
  • Invariance is Key: The goal of Self-Teaching is to make the query encoder embedding-invariant. A robust model should produce nearly identical vectors for "apple" and "aple."
  • Efficiency Gains: Surprisingly, CharacterBERT-DR is only about 1ms slower than standard BERT on a GPU and actually has fewer parameters (105M vs 110M) because it doesn't need to store a massive WordPiece vocabulary.

Key Results

The results show a dramatic improvement in robustness. On the MS MARCO dataset with typos:

  • Standard BERT-DR saw its effectiveness (MRR@10) drop from .325 to a measly .136.
  • CharacterBERT-DR + ST maintained a much higher score of .263.

On the real-world DL-typo dataset, the proposed model outperformed not only standard retrievers but also pipelines that used basic rule-based spell-checkers.

Figure 3: Detailed results across datasets. CharacterBERT-DR+ST (run 'r') consistently provides the best performance on queries with typos while remaining competitive on clean queries.

Limitations and Future Work

While the proposed method is a huge step forward, it doesn't yet beat the "gold standard" of massive, proprietary systems like the Microsoft Bing spell-checking API (which is trained on gargantuan amounts of private web data).

The authors also note that they tested this on a "vanilla" dense retriever. A promising next step would be applying the Self-Teaching method to more advanced retrieval architectures like ANCE or TCT-ColBERTv2 to see if the robustness gains stack with state-of-the-art performance.

Summary updated

BibTeX
@misc{zhuang2022characterbert,
  author = {Shengyao Zhuang and Guido Zuccon},
  title = {{CharacterBERT and Self-Teaching for Improving the Robustness of Dense Retrievers on Queries with Typos}},
  year = {2022},
  eprint = {2204.00716},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2204.00716},
}
Figure