← Harvey Interview Insights

Harvey·Software Engineer·Onsite - System Design / Architecture·Senior

SeniorPrefer not to say
Jul 2026

Summary

System design interview at Harvey for a software engineer role, centered entirely on building a RAG pipeline for legal research. The problem was meaty and touched basically every layer of the stack, from crawling to eval. Felt like a real product they're thinking about.

Questions Asked (8)

Q1

Design a retrieval-augmented generation system that answers legal questions by grounding responses in publicly published memos and client alerts from large law firms, with citations back to source documents.

System DesignTechnical Trade-offs
Author's notes

This is the main question and it's a beast.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements and constraints, then walk through the end-to-end architecture: ingestion, indexing, retrieval, generation, and citation. Emphasize how you ensure grounding and verifiable citations, and discuss trade-offs in retrieval methods, model choice, and evaluation.

Pro tip: Focus on the citation mechanism as a first-class design concern—legal users need to trust and verify every claim, so design retrieval and generation to produce precise, traceable citations. Also, mention the importance of handling legal-specific challenges like long documents, domain jargon, and evolving content.

1. Clarify Requirements and Constraints

Ask about scale (number of documents, queries per second), latency, accuracy needs, and whether the system must handle updates. Clarify that sources are public memos and client alerts, so no confidential data.

2. Design Ingestion and Indexing Pipeline

Describe how to collect, parse, and chunk documents, extract metadata (firm, date, practice area), and create embeddings. Consider hybrid indexing (dense + sparse) for robust retrieval.

3. Design Retrieval and Ranking

Explain retrieval strategies: dense retrieval with embeddings, sparse retrieval (BM25), or hybrid. Discuss re-ranking with cross-encoders to improve precision, and filtering by metadata.

4. Design Generation with Citations

Describe how to generate answers grounded in retrieved passages, with inline citations. Use a large language model with a prompt that instructs it to cite sources, and post-process to verify citations.

5. Discuss Evaluation and Trade-offs

Cover metrics (citation accuracy, answer correctness, latency), and trade-offs (e.g., retrieval depth vs. latency, model size vs. cost). Mention continuous evaluation and user feedback.

Key Points to Mention

  • Hybrid retrieval combining dense and sparse methods for better recall and precision.
  • Chunking strategies for long legal documents, preserving context and enabling precise citations.
  • Use of metadata filters (e.g., jurisdiction, date) to narrow down relevant sources.
  • Citation generation and verification: ensuring each claim maps to a specific source passage.
  • Handling updates and freshness: incremental indexing and versioning of documents.
  • Evaluation metrics: citation precision/recall, answer faithfulness, and latency.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q2

How do you design the crawling and ingestion pipeline to keep the corpus fresh across roughly 500 heterogeneous law firm websites without re-crawling everything constantly?

System DesignTechnical Trade-offs
Author's notes

I went straight to sitemaps and RSS feeds for discovery, which was right.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by framing the problem as a change-detection and prioritization challenge, not a crawling challenge. Propose a tiered architecture where cheap signals (sitemaps, RSS, HTTP headers) drive selective re-crawls, and only high-value or high-change-rate sites get deeper attention. Emphasize that freshness is a product decision—define what 'fresh' means per content type and design the pipeline to meet those SLAs efficiently.

Pro tip: Mention that you'd measure the marginal value of freshness (e.g., how often does new content actually appear?) and use that to set crawl frequency, rather than assuming every site needs daily updates. This shows you think about cost-benefit and avoid over-engineering.

1. Define freshness requirements and content value

Clarify what 'fresh' means for different content types (e.g., attorney bios vs. blog posts) and prioritize based on user impact. This prevents uniform crawling and sets the stage for tiered scheduling.

2. Implement lightweight change detection

Use sitemaps, RSS feeds, HTTP caching headers (ETag, Last-Modified), and content hashing to detect changes without full re-crawls. This reduces load on both your system and the target sites.

3. Design a tiered crawl scheduler

Assign each site to a tier based on historical change frequency, site importance, and technical constraints. High-change sites get frequent checks; static sites get infrequent ones, with adaptive adjustment over time.

4. Build a scalable ingestion pipeline

Decouple crawling from processing using a queue-based system (e.g., Kafka, SQS) to handle bursts and ensure fault tolerance. Normalize heterogeneous content into a unified schema for downstream use.

5. Monitor and adapt

Track metrics like crawl success rate, change detection accuracy, and freshness lag. Use feedback loops to adjust crawl frequency and detect anomalies (e.g., sites that suddenly change often).

Key Points to Mention

  • Politeness and rate limiting: respect robots.txt, use backoff, and avoid overloading small firm sites.
  • Incremental crawling: leverage sitemaps, RSS, and conditional GETs to avoid full re-crawls.
  • Prioritization: rank sites by change frequency, business value, and user demand.
  • Scalability: use distributed queues, worker pools, and horizontal scaling to handle 500+ sites.
  • Data normalization: handle heterogeneous formats (HTML, PDFs, etc.) and extract structured data.
  • Cost efficiency: balance freshness with compute and bandwidth costs, and measure ROI of crawl frequency.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q3

Walk through your chunking strategy and how you'd structure the retrieval index to maximize both recall and precision for legal queries.

System DesignTechnical Trade-offs
Author's notes

Chunking on semantic boundaries rather than fixed token windows is pretty standard advice but I actually had to think through why it matters more in legal text specifically.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by framing the unique challenges of legal text (long documents, precise terminology, hierarchical structure) and how they affect chunking and indexing. Then walk through a concrete pipeline: chunking strategy, embedding model choice, index structure (e.g., hybrid search with metadata filters), and retrieval/reranking to balance recall and precision. Emphasize trade-offs and how you'd evaluate and iterate.

Pro tip: Mention that legal queries often require exact citation matching, so you'd combine dense retrieval with sparse methods like BM25 and use metadata filters (e.g., jurisdiction, date) to boost precision without sacrificing recall.

1. Understand legal text characteristics

Explain that legal documents are long, structured (sections, clauses), and contain domain-specific jargon, which demands chunking that preserves context and hierarchy.

2. Design chunking strategy

Propose a hybrid approach: use semantic chunking (e.g., by section or paragraph) with overlap, and consider smaller chunks for precision or larger for recall; optionally add metadata like section titles.

3. Choose embedding and indexing approach

Select a domain-adapted embedding model (e.g., legal-BERT) and build a hybrid index combining dense vectors and sparse representations (e.g., BM25) to leverage both semantic and keyword matching.

4. Implement retrieval and reranking

Use a two-stage retrieval: first retrieve a broad set of candidates with high recall (e.g., via hybrid search), then rerank with a cross-encoder or LLM for precision, applying metadata filters as needed.

5. Evaluate and iterate

Define metrics (recall@k, precision@k, MRR) and set up an evaluation pipeline with legal queries; continuously tune chunk size, overlap, and model choice based on results.

Key Points to Mention

  • Hybrid search combining dense and sparse retrieval (e.g., embeddings + BM25)
  • Metadata filtering (jurisdiction, date, document type) to improve precision
  • Chunk overlap and hierarchical chunking to preserve context
  • Domain-specific embeddings (e.g., Legal-BERT) and fine-tuning
  • Two-stage retrieval with reranking (e.g., cross-encoder)
  • Evaluation metrics and iterative tuning for recall/precision trade-off

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q4

How do you constrain the LLM to only answer from retrieved evidence, and how do you verify that citations in the generated answer actually support the claims being made?

System DesignTechnical Trade-offs
Author's notes

Numbered passage IDs in the prompt, instruct the model to cite inline, then do a post-hoc check that each cited passage actually entails the claim.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by explaining that constraining an LLM to retrieved evidence involves both prompt engineering and system-level guardrails, such as instructing the model to only use provided context and using techniques like retrieval-augmented generation (RAG) with strict filtering. Then, describe verification methods like automatic citation checking, entailment models, and human-in-the-loop evaluation to ensure citations support claims.

Pro tip: Emphasize that you would measure citation precision and recall, and set up a feedback loop where incorrect citations are used to fine-tune the retrieval or generation components, showing a proactive approach to quality.

1. Constrain via Prompting and Decoding

Use system prompts that explicitly instruct the model to answer only from the provided evidence and to cite sources. Optionally, use constrained decoding to limit outputs to extracted spans or to enforce citation formats.

2. Retrieve and Filter Evidence

Implement a robust retrieval system that fetches relevant passages and applies relevance filtering (e.g., by score threshold) to ensure only high-quality evidence is passed to the LLM.

3. Generate with Citations

Have the LLM generate an answer that includes inline citations referencing specific evidence passages. Use few-shot examples to demonstrate the desired citation behavior.

4. Verify Citations Automatically

Employ automatic verification methods such as entailment models (e.g., NLI) to check if each cited passage supports the associated claim. Also, use rule-based checks for citation format and existence.

5. Iterate with Human Feedback

Set up a human-in-the-loop evaluation to sample and review generated answers and citations. Use discrepancies to improve prompts, retrieval, or fine-tune the model.

Key Points to Mention

  • Retrieval-Augmented Generation (RAG) architecture
  • Prompt engineering with explicit instructions and few-shot examples
  • Constrained decoding or logit bias to enforce citation formats
  • Automatic citation verification using entailment models (e.g., NLI)
  • Metrics for citation quality: precision, recall, and F1
  • Human-in-the-loop evaluation and feedback loops for continuous improvement

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q5

How do you evaluate this system offline and online, and how do you isolate whether a bad answer is a retrieval failure or a generation failure?

Product Analytics & MetricsRoot Cause Analysis
Author's notes

Evaluate retrieval and generation separately.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by outlining a layered evaluation strategy: offline benchmarks with labeled data to measure retrieval and generation separately, and online A/B tests with user feedback and implicit signals. Then describe a diagnostic process to isolate failures: first check retrieval quality (e.g., recall@k, precision) and then generation quality (e.g., faithfulness, relevance) using controlled experiments and error analysis.

Pro tip: Emphasize the importance of building a golden dataset with annotated retrieval and generation errors, and using counterfactual analysis: swap in perfect retrieval to see if generation improves, or swap in perfect generation to see if retrieval was the bottleneck.

1. Define offline metrics for retrieval and generation

Use labeled datasets to compute retrieval metrics (recall@k, MRR, nDCG) and generation metrics (BLEU, ROUGE, faithfulness, answer relevance). Ensure metrics are computed independently to avoid confounding.

2. Set up online evaluation with A/B testing

Deploy the system to a subset of users and track implicit signals (click-through, dwell time, user edits) and explicit feedback (thumbs up/down, ratings). Compare against a baseline to measure overall impact.

3. Isolate retrieval vs. generation failures via controlled experiments

For a sample of queries, manually inspect retrieved documents and generated answers. Use counterfactuals: replace retrieved documents with ground-truth passages to test generation, and replace generated answers with ground-truth to test retrieval.

4. Perform error analysis and root cause categorization

Categorize failures into retrieval errors (missing relevant docs, ranking issues) and generation errors (hallucination, irrelevance, incompleteness). Quantify the proportion of each to prioritize fixes.

5. Iterate and monitor with continuous evaluation

Implement a feedback loop where offline metrics and online signals inform model improvements. Use canary deployments and monitor for regressions in both retrieval and generation.

Key Points to Mention

  • Offline evaluation: retrieval metrics (recall@k, precision@k, MRR) and generation metrics (faithfulness, answer relevance, BLEU/ROUGE).
  • Online evaluation: A/B testing with user engagement metrics (CTR, dwell time) and explicit feedback (thumbs up/down, ratings).
  • Counterfactual analysis: swapping retrieved documents or generated answers to isolate failure source.
  • Error analysis: manual annotation of failures to categorize retrieval vs. generation issues.
  • Golden dataset: a curated set of queries with ground-truth relevant documents and ideal answers for benchmarking.
  • Continuous monitoring: tracking metrics over time and using canary releases to detect regressions.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q6

A memo gets corrected or retracted after you've already indexed it. How do you detect this and make sure users aren't getting answers backed by stale or withdrawn guidance?

System DesignAdaptability & Ambiguity
Author's notes

Honestly caught me a bit flat-footed.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Frame the problem as a data freshness and consistency challenge: detect source changes via versioning or change data capture, then propagate updates to the index with clear user-facing signals. Emphasize a layered approach combining automated detection, re-indexing pipelines, and query-time safeguards to prevent stale answers.

Pro tip: Mention that you would treat the source memo as the single source of truth and store its version/hash with each indexed chunk, so you can detect drift and even serve 'last known good' with a warning if re-indexing lags. This shows you balance correctness with availability.

1. Detect source changes

Implement change detection via webhooks, polling with checksums, or a version control system that emits events when a memo is corrected or retracted. Store the memo's version identifier and content hash at index time.

2. Propagate updates to the index

On change events, trigger a re-indexing pipeline that updates or removes affected chunks. Use idempotent operations and maintain a mapping from source memo to indexed chunks to ensure precise updates.

3. Handle retractions and deletions

For retracted memos, mark them as invalid in the index and exclude them from retrieval. Consider soft-deletes with a grace period to allow for rollback if the retraction is reversed.

4. Guard at query time

At retrieval, check the freshness of each chunk against the source version; if stale, either filter it out or attach a warning. Optionally, fall back to the latest source content if available.

5. Monitor and alert

Track metrics like index lag, stale chunk count, and failed re-indexing attempts. Alert on anomalies and provide dashboards to ensure the system remains healthy.

Key Points to Mention

  • Versioning or content hashing to detect changes
  • Change data capture (CDC) or event-driven re-indexing
  • Idempotent and incremental indexing to avoid full rebuilds
  • Query-time freshness checks and user-facing warnings
  • Soft deletes and retraction handling with audit trails
  • Monitoring and alerting for index staleness

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q7

Your retrieval recall looks good in offline eval but users are still reporting wrong answers. How do you figure out where the failure is happening?

Root Cause AnalysisA/B Testing & Experimentation
Author's notes

Classic debugging question.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by acknowledging the gap between offline metrics and online user experience, then propose a systematic investigation that traces the retrieval pipeline from query to answer. Focus on identifying where the failure occurs: query understanding, retrieval, ranking, or generation, and use both qualitative and quantitative methods to pinpoint the issue.

Pro tip: Instrument the entire pipeline with detailed logging and user feedback to catch discrepancies early. Remember that offline recall may not reflect real-world query distribution or user intent, so always validate with online metrics and user studies.

1. Reproduce and Characterize the Failure

Collect specific user queries and wrong answers to understand the failure patterns. Categorize errors by type (e.g., missing relevant documents, irrelevant documents, or generation errors).

2. Audit the Retrieval Pipeline

Trace each query through the retrieval stages: query parsing, embedding, ANN search, and re-ranking. Check if relevant documents are retrieved but not used, or if they are missing entirely.

3. Compare Offline and Online Metrics

Analyze differences between offline recall and online user feedback. Look for distribution shifts, such as queries with different characteristics or new intents not covered in the offline eval set.

4. Isolate the Component

Use ablation tests or A/B experiments to isolate whether the issue is in retrieval, ranking, or generation. For example, swap in a perfect retriever to see if the answer improves.

5. Validate and Iterate

Once the root cause is identified, propose a fix and validate it with both offline and online experiments. Monitor user feedback to ensure the issue is resolved.

Key Points to Mention

  • Offline recall may not capture real-world query distribution or user intent
  • Importance of logging and tracing the full pipeline from query to answer
  • Categorizing failure modes: retrieval vs. ranking vs. generation
  • Using A/B testing to isolate the problematic component
  • Analyzing user feedback and click-through data to identify patterns
  • Considering query understanding and embedding quality as potential failure points

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.

Q8

How would you extend this system to support comparative queries, like asking how different firms differ in their guidance on a specific topic?

System DesignProduct Sense & Ideation
Author's notes

This one's genuinely hard.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the current system's architecture and data model, then propose extensions such as a comparative query layer that can align and contrast firm-specific guidance on a given topic. Focus on how you would handle data ingestion, indexing, and query execution to support side-by-side analysis, while considering scalability and user experience.

Pro tip: Emphasize the importance of a unified schema or ontology for topics to enable accurate comparisons, and suggest a phased rollout starting with a limited set of firms and topics to validate the approach before scaling.

1. Clarify Requirements and Current System

Ask questions to understand the existing system's capabilities, data sources, and how guidance is currently stored and queried. Identify what 'comparative queries' mean in this context (e.g., side-by-side text, aggregated differences, or trend analysis).

2. Design Data Model and Indexing Strategy

Propose a data model that normalizes topics across firms, possibly using a topic ontology or embeddings for semantic matching. Outline an indexing strategy that supports efficient retrieval of firm-specific guidance for a given topic.

3. Extend Query Processing and API

Describe how to modify the query layer to accept comparative queries, such as a new API endpoint that takes a topic and a list of firms, then returns aligned guidance. Discuss how to handle ranking, summarization, and presentation of differences.

4. Address Scalability and Performance

Consider how the extension impacts system scalability, including data volume, query latency, and caching. Suggest optimizations like pre-computed comparisons or materialized views for frequent queries.

5. Plan for Evaluation and Iteration

Outline metrics to evaluate the feature's success (e.g., user engagement, accuracy of comparisons) and propose an iterative rollout plan with feedback loops.

Key Points to Mention

  • Use of a shared taxonomy or embeddings to align topics across firms for accurate comparison.
  • Design of a comparative query API that supports filtering by topic and firm, and returns structured differences.
  • Consideration of data freshness and versioning to handle updates in guidance over time.
  • Scalability strategies such as pre-computation, caching, and distributed indexing.
  • User experience aspects: how to present comparisons clearly (e.g., side-by-side view, highlighted differences).
  • Potential integration with existing search or RAG pipelines to leverage semantic understanding.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.