Building a Voice Assistant Knowledge Pipeline for Festivals and Wildlife
System DesignModel answerLast updated
Design an end-to-end knowledge pipeline for a voice assistant answering holiday and animal questions, fix mis-routed queries, and build a framework for debugging failures.
You are designing the backend knowledge layer for a voice assistant used worldwide. It must answer factual questions in two areas, and you must also show how you would keep quality high over time.
Part 1: Holidays. Design an end-to-end data pipeline that lets the assistant answer questions about holidays and observances in any country. Cover:
- data sources
- ingestion
- normalization
- storage
- the query layer
Explain how you would reconcile different calendar systems (Gregorian, lunar or lunisolar, and government-defined or observed-day rules) and how you would keep the content up to date.
Part 2: Animals. Extend the pipeline to answer animal questions. Explain:
- which additional data elements, taxonomies, or ML models you need
- how you would detect and fix queries that are wrongly routed to the animal domain, such as a request about a children's cartoon pig character that only looks like an animal question because of one word
Part 3: Debugging. Error logs show that the assistant fails on certain animal queries. Propose a framework to:
- categorize the errors
- trace root causes
- prioritize fixes
State your assumptions about scale and latency, and be explicit about trade-offs.
Hints
Hint 1
Think about what you store for a holiday: a rule that produces dates, or only the dates themselves? Consider fixed dates, nth-weekday rules, moveable feasts, moon-sighting holidays, and weekend-shift rules.
Hint 2
For the mis-routing problem, ask what a classifier sees when only a partial span matches an animal. Think about scoring every entity type on the full span, and about what to do when the top score is low or the top two are close.
Hint 3
For debugging, assign each failure to the first pipeline stage where output diverges from the correct one (speech recognition, domain routing, entity linking, knowledge lookup, response generation). Then rank clusters by frequency times customer impact divided by fix effort.
Model answer
Hard Try it yourself first — then compare your approach, complexity and edge cases.
1. Clarify requirements and scale
Sample utterances: "When is Diwali this year?", "Is Monday a holiday in Germany?", "What holidays are in December?", "Why do we celebrate Juneteenth?"
Functional needs
- Answers depend on locale and jurisdiction, including subdivisions (Bavaria differs from Berlin).
- Multilingual names and aliases ("Lunar New Year" and "Chinese New Year" are one holiday).
- Answers must convey certainty: expected, confirmed, or observed on a shifted day.
Assumed scale
- About 10M holiday queries per day, with 10x spikes before major holidays.
- Knowledge lookup around 100 ms p99 inside a roughly 1 s end-to-end budget.
- Data is small: about 250 countries, 5K subdivisions, about 30 holidays each, so roughly 50K rules and under 1M materialized instances for ±10 years. The hard problems are correctness and freshness, not size.
2. Holiday pipeline
Core decision: store rules, derive dates. A holiday is an entity with a computation rule, and dates are generated instances.
| Rule type | Example | How computed |
|---|---|---|
| Fixed Gregorian | Dec 25 | Direct |
| Nth weekday | 4th Thursday of November | Calendar arithmetic |
| Offset from a movable feast | Easter minus 2 days | Computus |
| Lunisolar | Lunar New Year, Diwali | Conversion library or tables |
| Observational lunar | Eid al-Fitr | Moon sighting, confirmed days before |
| Observed-day shift | Saturday moves to Friday | Per-jurisdiction post-processing |
| Proclamation or one-off | Special bank holiday | Editorial or government feed |
Stages
- Sources: official government publications (highest trust), licensed holiday providers, Wikidata for multilingual names, astronomical libraries, religious authority announcements, and an editorial team.
- Ingestion: scheduled crawlers plus push feeds. Keep raw versioned snapshots so every answer is traceable, and run diff detection against the previous snapshot.
- Normalization: canonical
holiday_id, per-language alias merging, ISO 3166-1/2 jurisdiction codes, a type label (public, bank, religious, observance), and rules in a small DSL. A date engine emits local calendar dates (ISO 8601, no time zone, since a holiday is a local day) withstatus = estimated | confirmed. - Reconciliation: rank sources per jurisdiction (government over aggregator), cross-check computed dates against at least two sources, and send disagreements to human review rather than auto-publishing.
- Storage: a knowledge graph for entities, relations and descriptions; a key-value store keyed by
(jurisdiction, year)and(holiday_id, year)for fast lookups; a search index for alias and fuzzy matching; a cache in front. - Query layer: intents such as
HolidayDate,IsHoliday,ListHolidays,HolidayInfo. Fill missing jurisdiction from device locale and address, and resolve "this year" from the current date. Use hedged templates: "Eid al-Fitr is expected on April 10, subject to moon sighting."
Freshness
- Materialize at least 12 months ahead and alert on gaps.
- Poll volatile holidays (observational, proclamation-based) more often near their windows.
- Release diffs, not full reloads, gated by a golden regression set of thousands of known (holiday, jurisdiction, year) answers, then canary.
- Use customer signals ("that's wrong", quick rephrase) as live monitors per holiday.
3. Extending to animals
The pattern is the same (source, normalize, graph, query) with new entities.
Extra data
- Taxonomy from sources such as ITIS, GBIF or NCBI so "Is a whale a fish?" becomes graph traversal.
- Common names, many-to-many and multilingual: "panther" maps to several species and "buffalo" varies by region.
- Attributes (diet, lifespan, size, range, speed, conservation status) with units and provenance.
- Media such as animal sounds, and kid-safe flags.
ML components
- Entity linking from text span to graph node across all entity types.
- Attribute extraction from encyclopedic text with confidence scores, low-confidence facts going to review.
- QA/ranking for long-tail questions structured lookup cannot answer.
Mis-routing example: a cartoon pig character. The word "pig" triggers the animal domain, yet the full span is a fictional character. Similar traps: a car brand named after a cat, a sports team, a programming language, a video game hedgehog.
Detection
- Score all entity types on the full span. A complete match to a fictional-character or media node should beat a partial match to an animal.
- Add context features: words like "episode" or "watch", kid profiles, recent video playback.
- Mine implicit feedback offline (barge-in, "no", rephrase within 30 s, switch to a video request) and cluster by entity.
Correction
- Thresholds: if the top domain score is below τ, or the gap between the top two hypotheses is below δ, send the utterance to a cross-domain re-ranker rather than committing to animals. Tune τ and δ on labeled data to balance precision and recall.
- Short term: a gazetteer or override list of fictional animals that blocks the animal domain.
- Long term: retrain with mined hard negatives and an entity-type feature.
- Validation: shadow-score the change, then A/B test on defect rate.
4. Debugging framework
Categorize by first diverging stage
| Stage | Example failure |
|---|---|
| Speech recognition | "gnu" heard as "new" |
| Domain/intent routing | Cartoon pig sent to animals |
| Entity linking | Ambiguous common name resolved to the wrong species |
| Knowledge lookup | Missing or wrong attribute |
| Response generation | Wrong unit, awkward phrasing, no sound clip |
Trace root causes
- Log each stage's input, output, and confidence per request, with a trace ID.
- Replay failing utterances through the pipeline to find the first stage where output deviates from a human-labeled expectation.
- Cluster by entity, pattern, locale, and device type to see whether the issue is systemic or long-tail.
- Confirm the cause with a counterfactual: fix that stage in isolation and see if the final answer becomes correct.
Prioritize
- Score each cluster by frequency × customer impact (e.g. kids, wrong answer vs. no answer) ÷ fix effort.
- Wrong confident answers outrank "I don't know", since they damage trust.
- Fix classes of errors (a rule, a threshold, a model feature) before individual facts, and add every fixed case to the regression set.
Monitor: dashboards for defect rate per stage and domain, alerts on spikes, and a weekly review of top clusters.
Common mistakes
- Storing only dates and not rules, which makes yearly refresh manual and error-prone.
- Attaching time zones to holiday dates.
- Treating all sources as equally trustworthy.
- Letting the domain classifier commit on a single keyword.
- Debugging only the final answer instead of attributing errors to a stage.
- Giving no metrics for success.