Search & IR · intro
Tokenization
Splitting text into terms: lowercasing, stemming, stop words, n-grams.
Mental model
Tokenization decides what counts as a 'word' for search. The same analyzer must run at index time and query time, or the query term will never match the indexed term.
How to study Tokenization
Begin by restating the mental model in your own words, then connect it to a concrete system you have built or operated. Name the mechanism, the constraint it addresses, and the trade-off it introduces. Use Introduction to Information Retrieval (Manning et al.) — §2.2.1 Tokenization, Let's build the GPT Tokenizer (Karpathy) to check details, but close the source before writing your explanation. Retrieval is the learning step; rereading is only preparation.
Next, compare Tokenization with Inverted Index, BM25, Tokenization (LLM). Ask what changes in correctness, latency, resource use, operability, and failure recovery. Complete Build a search tokenizer and preserve the command, input, output, and one failed attempt as evidence. Finish by explaining the idea without jargon to someone who has not studied the track.
Proof of understanding
- Explain the mechanism from first principles and identify the state it reads or changes.
- Give one situation where the concept is the right choice and one where it is not.
- Predict a realistic failure mode before running the drill, then compare the prediction with evidence.
- Connect the result to a roadmap or build artifact instead of treating the concept as isolated trivia.
Where it matters
Elasticsearch/Lucene analyzers, Tantivy tokenizers, every lexical search engine.
Common mistakes
- Using different analyzers for indexing and querying
- Stemming too aggressively so distinct words collide
- Dropping stop words that carry meaning in short queries
Learn from primary sources
Practice and explain it back
Build a search tokenizer
Write a tokenizer that lowercases, splits on non-alphanumerics, removes a small stop-word set, and applies simple suffix stemming. Use the exact same function for indexing and querying.
Expected evidence: tokenize('The Quick Brown Foxes!') → ['quick','brown','fox']
Open the interactive drill →Review prompts
- Why must the same analyzer run at index time and query time?
Build evidence
Implement BM25 search in HighSignal
Index a corpus of articles and serve ranked keyword search using BM25.
- Index at least 100 documents
- Support keyword search with a tokenizer shared by index and query
- Return top-k ranked results scored by BM25
- Add a small set of eval queries with expected results
Prerequisites
None assigned yet.