Design an address autofill system
I was asked this
No reports yet. Sign in to say where you were asked it.
An AI/ML design interview question asked at Google, Amazon and Uber. It tests autocomplete, ranking and geospatial.
Design the model behind an address box that completes what the user is typing. After each keystroke the system suggests a short list of full, valid addresses, ranked by how likely the user means each one. Rankings use the typed prefix, the user's location and their own history. Suggestions must keep up with typing on phones and desktops, across many countries and address formats.
Requirements
- Functional: return the top few address suggestions for a partial input after every keystroke; every suggestion is a real, deliverable address; personalize by the user's current location, past addresses and the surface (rides, delivery, shipping); tolerate typos, abbreviations ("st" for "street") and out-of-order parts (zip before street).
- Non-functional: suggestions in well under 100 ms end to end; the address catalog holds hundreds of millions of entries; works per country and language; quality measured by how often the user picks a suggestion, and how early.
Clarifying questions
- Which product is this for, and does a wrong address cost a failed delivery or only a retry?
- Do we own an address catalog (geocoder, postal data), or do we only see what users typed before?
- How many keystrokes do users usually type before they pick, and on which devices?
- May we use precise location and order history, and in which regions are there privacy limits?
- Must every suggestion be a full street address, or can we suggest a place name ("Central Station") that maps to one?
What a strong answer covers
- Two stages: fast candidate retrieval from a prefix index (trie or n-gram index over normalized address tokens, plus a fuzzy match for typos) and nearby addresses from a geo index, then a learned ranker over a few hundred candidates.
- Ranker features: how well the prefix matches, distance from the user, popularity of the address in the area, the user's own past addresses and recency, the time of day and the surface. Labels come from logged suggestions and which one was picked, with position bias corrected.
- Offline metrics (mean reciprocal rank, top-k accuracy, keystrokes saved) and online metrics (pick rate, keystrokes to pick, failed deliveries or address edits after the order).
- Normalization per country: tokenizing, expanding abbreviations, unit numbers and different orderings of address parts.
- Latency: precomputed candidate lists for short prefixes, caching per region, a small ranking model at serving time, and a fallback when the ranker times out.
- Cold start for new users and new buildings, and keeping addresses valid as the catalog changes.
Follow-ups
- The user's home address is always ranked first, even while they are travelling. How do you fix that?
- How would you add a sequence model that completes free text, and keep it from inventing addresses that do not exist?
- How do you launch in a new country with little logged data?
- How do you measure whether a ranking change reduced failed deliveries, not only clicks?
Where it's asked
What it tests
autocomplete · ranking · geospatial
Sign in to see the worked answer
The full answer, chapter by chapter, with what interviewers expect at each level. New accounts get 5 credits: each one unlocks a question for good.
What the labs asked this week
A weekly email of what OpenAI, Anthropic and the other top AI labs asked engineers, round by round.


