Design Enterprise Search with AI-Generated Answers
Serve permission-aware ranked results across several workplace apps within a tight latency budget, and add a cited AI-generated answer that never delays the results or cites anything the reader cannot open.
Problem statement
Design a large-scale search system for workplace content that returns traditional ranked results and can also show an AI-generated answer.
For this exercise, assume a workplace software provider offers one search box across several of its apps: wiki-style pages, issue tickets, chat messages and shared files. Many customer organizations use it, and an employee only ever searches inside their own organization.
When an employee submits a query, the page shows a ranked list of items the employee is allowed to read. For queries that read like a question, the page may also show a short AI-generated answer that cites the items it relies on.
For this exercise, also assume: - Each app sends the search system its items and every change to them: new items, edits, deletions and permission changes. Each item comes with the users and groups allowed to read it. Group membership comes from the organization's directory, and a user belongs to at most 500 groups.
- Content a user cannot read must never appear in their results, snippets or answers, and must never be used to write an answer for them. If the system cannot confirm access, it leaves the item out. - Every citation in an answer must point to a result shown on the same page.
When the results do not support an answer, the page shows no answer rather than a guess. - The answer is optional. The ranked results must never wait for it. - Employees can narrow results by source app and by last-updated date. - A hosted language model is available.
It starts returning text about 1 second after it receives a prompt of about 3,000 tokens, then writes about 50 tokens a second.
Conversational follow-up questions, actions inside the apps, public web search, training the language model, and the internals of each app's connector are out of scope.
What to build
- An employee submits a query, optionally filtered by source app and last-updated date, and receives a ranked page of items from the connected apps that they are allowed to read, each with title, source app, snippet and link.
- For question-like queries, the page can also show a short generated answer whose every citation opens a result shown on the same page, or it shows no answer when the results do not support one.
- New items, edits, deletions and permission changes in the connected apps are reflected in results and answers within the stated freshness targets.
- Record what was shown, what was clicked and how answers were rated, so result relevance and answer quality can be measured and the ranking improved.
At scale
- For this exercise, assume about 50,000 customer organizations with about 2 billion items in total, split into about 8 billion passages for retrieval; the largest organization has about 100 million items.
- For this exercise, assume peaks of about 20,000 searches a second across all organizations, and that about one search in five reads like a question an answer could help with.
- For this exercise, assume ranked results must return within 300 milliseconds at p95, and an answer, when shown, should start appearing within 2 seconds at p95.
- For this exercise, assume about 20 million item changes a day. An edit should be searchable within 5 minutes, and a removed permission must stop the item from appearing in new results or answers for that user within 30 seconds.