KatInterview

Build a Machine Learning Document Search Engine

Machine LearningModel answer
HardModel answerMachine Learningml-systemsinformation-retrievalranking

Last updated

Design a production search system that combines keyword and semantic retrieval, enforces tenant-level access control, and ranks results with learned models.

You're building a search engine for a SaaS product that indexes workplace documents—files from cloud storage, project management tools, internal wikis, and communication platforms. Users type queries in natural language or keywords and expect relevant results from only the documents they're permitted to see.

Your system must handle multiple organizations (tenants), each with its own corpus and permission rules. A typical deployment serves thousands of tenants; the largest tenant may have tens of millions of documents.

Design the end-to-end system. Cover:

  • Requirements and scale assumptions: query volume, corpus size, latency targets, privacy and compliance constraints, and cost considerations.
  • Indexing pipeline: how documents are ingested, parsed, chunked, and prepared for search.
  • Retrieval architecture: how you find candidate results quickly—both exact keyword matches and semantically similar content.
  • Ranking: how you order candidates by relevance, using features and learned models.
  • Access control enforcement: how you guarantee users never see documents they lack permission to access, even under caching or partial failures.
  • Evaluation and monitoring: how you measure search quality when click data is sparse and you cannot manually inspect tenant data.
  • Scalability and operational concerns: caching, freshness, multilingual support, and cost trade-offs.

Be concrete: state numbers, name algorithms and data structures, explain trade-offs, and identify the failure modes that matter most in production.

Hints

Hint 1

Start with requirements—especially the difference between content freshness SLA and permission revocation SLA, and why one must be stricter.

Hint 2

Access control is the hardest part: decide whether to filter during retrieval (early binding) or after (late binding), and explain how each affects recall and security.

Hint 3

Hybrid retrieval means running keyword (BM25) and semantic (vector) search in parallel, then merging results; explain how to combine scores from different retrieval methods.