← Harvey Interview Insights

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

SeniorPrefer not to say
Apr 2026

Summary

System design interview at Harvey for a software engineer role, focused entirely on building a RAG-based Q&A agent for a big law firm's memo corpus. It was a long open-ended design discussion with multiple layers, and the interviewer clearly wanted breadth across ingestion, retrieval, grounding, and evaluation rather than a deep dive into any single piece.

Questions Asked (5)

Q1

Design an AI system that lets attorneys ask natural-language questions and get answers grounded in a large corpus of legal memos, covering ingestion, retrieval, answer generation, and evaluation.

System DesignTechnical Trade-offs
Author's notes

This was the whole interview basically.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements and constraints, then walk through the system architecture end-to-end: ingestion, retrieval, generation, and evaluation. Emphasize trade-offs at each stage, especially around accuracy, latency, and cost, and how you would measure and iterate on quality.

Pro tip: Attorneys care most about trust and verifiability, so prioritize citation-backed answers and a human-in-the-loop review flow over raw model sophistication. Also, mention that legal language is nuanced and domain-specific, so fine-tuning or domain adaptation of embeddings and LLMs is often necessary.

1. Clarify Requirements and Constraints

Ask about corpus size, document types, update frequency, latency requirements, and compliance needs (e.g., data privacy, audit trails). This shapes the entire design.

2. Design Ingestion Pipeline

Outline how to parse, chunk, and index legal memos, including handling of citations, metadata, and versioning. Consider OCR for scanned documents and incremental updates.

3. Design Retrieval System

Propose a hybrid retrieval approach combining keyword search (e.g., BM25) and dense vector search, with re-ranking. Discuss embedding models, index types (e.g., HNSW), and filtering by metadata.

4. Design Answer Generation

Describe how to generate grounded answers using retrieved passages, with citations. Cover prompt engineering, LLM selection, and techniques to reduce hallucination (e.g., constrained decoding, self-consistency).

5. Design Evaluation and Monitoring

Define offline and online metrics (e.g., retrieval recall, answer faithfulness, citation accuracy) and a human-in-the-loop feedback loop. Discuss A/B testing and continuous improvement.

Key Points to Mention

  • Hybrid retrieval (sparse + dense) with re-ranking to balance precision and recall.
  • Chunking strategies for legal documents (e.g., by section, with overlap) and metadata enrichment.
  • Citation grounding: ensure every claim in the answer is traceable to a source passage.
  • Hallucination mitigation: use retrieval-augmented generation (RAG), prompt constraints, and post-hoc verification.
  • Evaluation metrics: retrieval recall@k, answer faithfulness, citation precision/recall, and user feedback.
  • Scalability and cost: index sharding, caching, and model selection (e.g., smaller models for retrieval, larger for generation).

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

Q2

Your crawled corpus has two memos from different firms that directly contradict each other on the same legal question. How should the agent respond, and how do you surface that conflict to the user?

System DesignAdaptability & Ambiguity
Author's notes

Didn't see this coming mid-session.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Acknowledge the conflict as a signal of legal ambiguity rather than a system failure, and design the agent to surface both memos with clear provenance instead of silently picking one. Then propose a user-facing mechanism that highlights the contradiction, explains the implications, and offers paths to resolution.

Pro tip: Frame the conflict as valuable information that prevents overconfident wrong answers, and suggest logging these conflicts to improve the corpus over time. This shows you think about the system's long-term health, not just the immediate query.

1. Detect and classify the conflict

Use retrieval and contradiction detection to identify that two memos from different firms directly oppose each other on the same legal question. Classify the conflict type (e.g., jurisdictional, temporal, or interpretive) to inform the response.

2. Decide the agent's response strategy

The agent should not arbitrarily choose one memo. Instead, it should present both positions neutrally, clearly attributing each to its source firm, and avoid synthesizing a false consensus.

3. Surface the conflict to the user

In the UI, display a prominent conflict alert that shows the two memos side-by-side with key excerpts, firm names, dates, and a concise explanation of the disagreement. Provide links to the full documents for context.

4. Offer resolution pathways

Suggest next steps such as consulting a senior attorney, checking for a controlling jurisdiction, or requesting an updated memo. Optionally, allow the user to flag the conflict for corpus curation.

5. Log and learn from the conflict

Record the conflict in a feedback loop to improve future retrieval and contradiction detection, and to inform knowledge base maintenance.

Key Points to Mention

  • Provenance and attribution: always show which firm authored each memo and when.
  • Neutral presentation: avoid taking sides or hallucinating a resolution.
  • User trust: transparency about uncertainty builds confidence in the system.
  • Actionable next steps: guide the user toward human expertise or further research.
  • Feedback loop: use conflicts to improve the corpus and detection algorithms.
  • Scalability: design the conflict detection to handle many such cases efficiently.

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

Q3

A regulator publishes a change that supersedes the conclusions in several memos already in your index. How does your pipeline prevent the agent from citing those stale memos as current authority?

System DesignRoot Cause Analysis
Author's notes

I talked about re-crawling and updating metadata with a 'superseded' flag, and linking newer memos to older ones they invalidate.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by framing the problem as a data freshness and authority management challenge in a RAG pipeline. Then walk through a layered defense: ingestion-time supersession detection, metadata-driven retrieval filtering, and runtime citation validation. Emphasize that the system must treat regulatory changes as first-class events that trigger re-indexing and invalidation of affected memos.

Pro tip: Mention that you would log every time a stale memo is retrieved but filtered out, and use that as a signal to improve supersession detection. This shows you think about observability and continuous improvement, not just a static fix.

1. Detect and Ingest Supersession Events

Build a watcher that monitors regulatory sources for new publications. When a change is detected, parse it to identify which memos it supersedes (e.g., by matching citations, topics, or explicit references).

2. Update Memo Metadata and Invalidate Stale Entries

For each affected memo, update its metadata to mark it as superseded, including the superseding regulation ID and effective date. Optionally, move it to a 'historical' index or add a tombstone flag.

3. Filter Retrieval by Authority and Freshness

At query time, apply filters to exclude memos marked as superseded unless the user explicitly asks for historical context. Use metadata such as 'status: current' or 'superseded_by: null' in the retrieval query.

4. Validate Citations at Generation Time

After the agent generates a response, run a post-hoc check that every cited memo is still current. If a stale memo is cited, either regenerate the answer or flag it for human review.

5. Monitor and Iterate

Log all instances where stale memos are retrieved or cited, and use this data to refine supersession detection rules and retrieval filters. Set up alerts for high rates of stale citations.

Key Points to Mention

  • Metadata enrichment: add fields like 'superseded_by', 'effective_date', and 'status' to each memo.
  • Retrieval filtering: use metadata filters in the vector database or search engine to exclude superseded memos by default.
  • Supersession graph: maintain a directed graph of regulations and memos to trace authority chains and propagate invalidation.
  • Runtime guardrails: implement a citation validator that cross-checks cited sources against the current index.
  • Observability: log and alert on stale retrievals to continuously improve the pipeline.
  • User intent: allow explicit queries for historical memos but clearly label them as superseded in the response.

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

Q4

Attorneys say the agent refuses too often on questions it could partially answer. How do you tune the refusal threshold without increasing hallucinations, and how do you measure that trade-off?

A/B Testing & ExperimentationTechnical Trade-offs
Author's notes

This one I actually liked.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Frame the problem as a precision-recall trade-off: lowering the refusal threshold increases coverage but risks hallucinations, so you need a principled way to tune it. Propose a data-driven approach using a labeled evaluation set to measure both refusal rate and hallucination rate, then optimize the threshold to maximize helpfulness while keeping hallucinations below an acceptable bound. Emphasize continuous monitoring and A/B testing to validate improvements in production.

Pro tip: Define a single north-star metric that combines helpfulness and hallucination cost (e.g., weighted F-beta score) so you can make objective threshold decisions and communicate trade-offs clearly to stakeholders.

1. Define metrics and constraints

Establish clear metrics: refusal rate (false refusals), hallucination rate (false answers), and coverage. Set a hard constraint on hallucination rate (e.g., <1%) based on business risk tolerance.

2. Build a labeled evaluation set

Create a diverse dataset of queries with ground-truth answers and labels for whether a partial answer is acceptable. Include edge cases where the model could partially answer without hallucinating.

3. Model the trade-off and tune threshold

Use the evaluation set to sweep refusal thresholds and plot the precision-recall curve. Select the threshold that maximizes coverage subject to the hallucination constraint, or optimize a weighted metric like F-beta.

4. Validate with A/B test in production

Deploy the new threshold to a small percentage of traffic and compare against control on key metrics: user satisfaction, task completion, and hallucination reports. Use statistical significance to confirm improvement.

5. Monitor and iterate

Continuously monitor refusal and hallucination rates in production, and retune as data distribution shifts. Implement guardrails to automatically revert if hallucination rate spikes.

Key Points to Mention

  • Precision-recall trade-off and the cost asymmetry between refusing and hallucinating
  • Use of a labeled evaluation set with ground-truth for both refusal and hallucination
  • Threshold tuning via ROC/PR curves or optimization of a weighted metric (e.g., F-beta)
  • A/B testing with proper statistical power to measure real-world impact
  • Guardrails and monitoring to detect and mitigate hallucination regressions
  • Business context: aligning threshold with user expectations and risk tolerance

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

Q5

How would your design change if query volume grew 100x, or if you needed to support multi-turn conversations where follow-up questions depend on prior context?

System DesignAdaptability & Ambiguity
Author's notes

Ran out of time here so this was more of a quick back-and-forth than a real design question.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Treat the two scenarios as separate but related scaling challenges: first, address the 100x query volume by identifying bottlenecks and proposing horizontal scaling, caching, and sharding; then, for multi-turn conversations, introduce a stateful session layer with context storage and retrieval. Show how the design evolves incrementally, balancing trade-offs between consistency, latency, and cost.

Pro tip: Anchor your answer in the specific domain of legal AI (Harvey's focus): emphasize that multi-turn context must handle long documents and precise citations, so context window management and retrieval-augmented generation (RAG) are critical. Also, mention that 100x volume may require a shift from synchronous to asynchronous processing for non-interactive queries.

1. Clarify requirements and constraints

Ask about query types (read vs. write, latency SLAs), data size, consistency needs, and whether multi-turn conversations require exact recall or can use summarization. This shows you avoid premature optimization.

2. Analyze current design and identify bottlenecks

Describe the baseline architecture (e.g., monolithic API, single database) and pinpoint components that would fail under 100x load or stateful conversations, such as database connections, compute, and session storage.

3. Propose scaling strategies for 100x volume

Outline horizontal scaling (stateless services, load balancers), caching (Redis for frequent queries), database sharding/replication, and asynchronous processing (queues) for non-urgent tasks. Mention auto-scaling and CDN for static assets.

4. Design for multi-turn conversations

Introduce a session service that stores conversation history and context, using a fast datastore (e.g., Redis) for active sessions and a persistent store (e.g., DynamoDB) for long-term. Use RAG to fetch relevant past turns or documents, and manage context window limits with summarization or vector search.

5. Discuss trade-offs and monitoring

Compare consistency vs. availability (CAP), cost implications of caching and storage, and latency impact of context retrieval. Emphasize observability (metrics, tracing) to detect bottlenecks and iterate.

Key Points to Mention

  • Horizontal scaling with stateless services and load balancing to handle 100x traffic.
  • Caching strategies (e.g., Redis) for frequent queries and session data to reduce database load.
  • Database sharding and replication for read-heavy workloads, with eventual consistency where acceptable.
  • Asynchronous processing via message queues for non-interactive or batch queries.
  • Session management for multi-turn conversations: storing context in a fast datastore and using RAG to retrieve relevant history.
  • Context window management: summarization, vector databases, and truncation strategies to fit LLM limits.

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