KatInterview

Enterprise Data Asset Retrieval for Autonomous Coding Agents

Machine LearningModel answer
MediumModel answerMachine LearningInformation RetrievalRAGSystem Design

Last updated

Design a multi-stage retrieval system that surfaces the right database tables and analytical notebooks for an internal AI coding assistant answering data queries.

An enterprise is building an internal LLM-powered coding agent capable of answering data-oriented questions (e.g., "Why did user retention dip in Q3?" or "How do we calculate net ARR?") and writing execution-ready SQL or Python scripts.

To answer these queries accurately, the agent needs to retrieve the relevant technical context from the organization's data platform—specifically database tables and jupyter/analytical notebooks.

Design an enterprise retrieval and reranking system that surfaces the most relevant data assets to the downstream coding agent.

Your design should address the following four key components:

  1. Asset Indexing & Representation: How to represent, enrich, and chunk tables and notebooks (combining structured metadata, schemas, execution logs, and textual documentation) to bridge the semantic gap between non-technical user queries and technical asset identifiers.
  2. Multi-Stage Retrieval & Reranking Architecture: How to implement a hybrid candidate generation layer (sparse + dense) combined with a cross-encoder reranker, including training label strategy and latency constraints.
  3. Quality Filtering, Freshness, & Permissioning: Mechanisms to handle low-quality artifacts (e.g., ad-hoc scratchpad notebooks, duplicate tables, stale schemas, or deprecated data assets) and strict security/permission filtering.
  4. Evaluation & Metrics Framework: Metrics for evaluation across the entire lifecycle, from stage-specific retrieval metrics (Recall@K, MRR) to downstream LLM code-generation accuracy and online performance monitoring.

Hints

Hint 1

Bridge the vocabulary gap between business concepts and technical schema names by synthesizing descriptions using an LLM or mining query logs.

Hint 2

Use a two-stage retrieval pipeline: lightweight hybrid search (BM25 + Dense vector embeddings) for broad candidate generation, followed by a heavier cross-encoder reranker.

Hint 3

Apply quality scores (e.g., query volume, upstream pipeline health, explicit deprecation flags) as hard pre-filters or soft rank modifiers to handle scratchpads and stale assets.

Hint 4

Ensure strict security compliance by applying permission-based access control filters directly during candidate retrieval or pre-filtering.