Questions
18 of 46
1What is RAG and why is it preferred over fine-tuning for domain-specific knowledge in production applications?
2What are the core components of a RAG pipeline in LangChain — Document Loaders, Text Splitters, Embeddings, Vector Stores, Retrievers, and Chains?
3What is the difference between semantic search and keyword search and why does RAG rely on semantic similarity?
4What is an Embedding in the context of RAG — what does it represent and why is cosine similarity used to compare them?
5What is a Vector Store and how does it differ from a traditional relational or document database?
6What is the difference between a Retriever and a Vector Store in LangChain — why is the abstraction separation important?
7What is a Document object in LangChain — what are pageContent and metadata fields and why does metadata matter in RAG?
8What are Document Loaders in LangChain and how do you choose the right loader for PDFs, web pages, Notion, Google Drive, or SQL databases?
9What is the difference between RecursiveCharacterTextSplitter and CharacterTextSplitter — when would you use one over the other?
10What is chunk size and chunk overlap in text splitting — how do you decide the right values for your use case?
11How do you handle structured documents like tables, code blocks, or markdown files during the splitting phase to avoid breaking semantic meaning?
12How do you load and split documents lazily (streaming) to handle very large files without running out of memory?
13What is a SemanticChunker and how does it differ from fixed-size character-based splitting?
14How do you preserve and propagate source metadata (filename, page number, URL, timestamp) through the loading and splitting pipeline?
15How do you choose the right embedding model — what tradeoffs exist between OpenAI embeddings, Cohere, HuggingFace, and local models like nomic-embed?
16What is the difference between dense embeddings and sparse embeddings (BM25) — when would you combine both in a hybrid search?
17How do you handle embedding model upgrades in production — what happens to your existing vectors when you switch models?
18How do you efficiently batch embed a large corpus of documents without hitting rate limits or memory constraints?
19What are the tradeoffs between vector stores like Pinecone, Weaviate, Chroma, pgvector, and FAISS — how do you choose for production?
20How do you implement namespace or tenant isolation in a vector store for a multi-tenant RAG application?
21How do you handle incremental updates to a vector store — adding, updating, and deleting documents without full re-indexing?
22What is HNSW indexing and why does it make approximate nearest neighbor search fast at scale?
23What is a similarity score threshold in retrieval and how do you use it to filter out low-confidence results?
24What is MMR (Maximal Marginal Relevance) retrieval and how does it balance relevance with diversity of results?
25What is a MultiQueryRetriever and how does it improve recall by generating multiple phrasings of the same question?
26What is Contextual Compression in LangChain retrieval and how does it reduce noise in retrieved chunks?
27What is a ParentDocumentRetriever — how does it index small chunks but return larger parent chunks to the LLM?
28What is HyDE (Hypothetical Document Embedding) and how does it improve retrieval for vague or abstract queries?
29What is Self-Query Retrieval and how does it allow the LLM to generate structured metadata filters alongside the semantic query?
30How do you implement hybrid search combining dense vector search with BM25 keyword search using EnsembleRetriever?
31What is a Re-ranker (cross-encoder) and where does it fit in the RAG pipeline after initial retrieval?
32What is the difference between Stuff, MapReduce, Refine, and MapRerank document chain strategies — when do you use each?
33How do you build a Conversational RAG chain that maintains chat history and reformulates follow-up questions into standalone queries?
34What is query decomposition and how do you break a complex multi-part question into sub-queries for better retrieval?
35How do you implement Step-Back Prompting in a RAG pipeline to improve retrieval for highly specific questions?
36What is CRAG (Corrective RAG) and how does it add a grading step to decide whether retrieved docs are relevant before answering?
37What is Self-RAG and how does the LLM decide when to retrieve, whether retrieved docs are relevant, and whether the answer is grounded?
38How do you implement a fallback strategy when retrieval returns no relevant documents — how do you avoid hallucination in this case?
39How do you implement RAG evaluation — what metrics like faithfulness, answer relevancy, and context recall do you measure using RAGAS?
40How do you detect and mitigate hallucination in RAG outputs — what role does citation and source grounding play?
41How do you build a citation system that maps each sentence in the LLM's answer back to the exact source chunk it came from?
42How do you handle multilingual RAG — embedding and retrieving documents in multiple languages for a global user base?
43How do you optimize retrieval latency in production — what caching, pre-fetching, or index optimization strategies do you apply?
44How do you implement access control at the retrieval layer — ensuring users only retrieve documents they are authorized to see?
45How do you handle long context RAG — when retrieved chunks exceed the LLM's context window, what strategies do you apply?
46How do you design a RAG pipeline with LangGraph — turning retrieval, grading, and generation into discrete stateful graph nodes?
18 / 46

How do you efficiently batch embed a large corpus of documents without hitting rate limits or memory constraints?

Efficient batch embedding requires controlled batching with API-specific size limits (e.g., OpenAI max 2048 texts per request), rate limiting with exponential backoff, lazy streaming of documents, and persistent caching to avoid redundant work. LangChain's base classes provide chunking, but additional rate control and checkpoint handling must be implemented manually.

Batch embedding large corpora without hitting API rate limits or memory constraints requires three strategies: controlled batch sizing (OpenAI supports up to 2048 texts per request[reference:20], but effective batch size often lower), rate limiting with exponential backoff and token bucket, and streaming/lazy loading of documents to avoid loading entire corpus into memory. LangChain's embed_documents automatically chunks inputs, but lacks built-in rate control, resume capability, or checkpoint handling[reference:21].

Batch Embedding with Rate Limiting and Checkpoints
Performance Considerations
  1. 1

    OpenAI API limits: maximum 2048 texts per request, 500k tokens per minute (tpm) rate limit[reference:22]

  2. 2

    Memory management: Use lazy loading (.lazy_load()) with generators to avoid holding all documents in memory

  3. 3

    Token counting: Pre-compute token counts per document to prevent exceeding per-request token limits

  4. 4

    Resume capability: Store processed document IDs with embeddings to resume from failure points

  5. 5

    Parallelism: Consider concurrent embedding requests with semaphore control for throughput (stay within RPM limits)

  6. 6

    Cost: Monitor token usage; embedding large corpora can be expensive; use token-aware chunking to avoid waste

Difficulty: 6/10
Topics: batching, rate limiting, memory management

Scenario Questions

0-2 years experience
  1. 1

    Suppose you have 5,000 short text snippets and need to generate embeddings using OpenAI's API via LangChain. How would you structure the code to batch the requests while staying under the API's rate limit?

  2. 2

    If you notice your script runs out of memory when loading all documents before embedding, what simple change could you make to avoid that?

2-5 years experience
  1. 1

    You added a new document loader that streams PDFs and now the embedding pipeline sometimes fails with a 429 error. Walk me through how you'd debug and adjust your batching strategy in LangChain.

  2. 2

    When you increased the batch size to improve throughput, the overall latency went up and you hit the token limit per request. How would you decide the optimal batch size and what LangChain features would help you enforce it?

  3. 3

    Explain how you would use LangChain's callbacks or async features to respect rate limits while processing a corpus of 200k documents.

5-8 years experience
  1. 1

    Design a scalable embedding service using LangChain that can process millions of documents nightly without exceeding provider rate limits or exhausting memory. Discuss the components, queueing, and any back‑off strategies.

  2. 2

    Your team wants to switch from a single‑node embedding job to a distributed Spark job, but the existing LangChain code assumes in‑process batching. How would you refactor it to work in a distributed environment while still handling rate limits?

  3. 3

    What monitoring and alerting would you put in place to detect when embedding jobs start throttling or OOM, and how would you automatically adjust batch sizes?

8+ years experience
  1. 1

    At a company‑wide level, we need to embed all historical knowledge‑base articles (tens of millions) and keep them up‑to‑date. How would you architect the end‑to‑end pipeline, including choice of embedding provider, rate‑limit contracts, caching, and LangChain integration, to ensure reliability and cost control?

  2. 2

    If a new regulation requires us to store embeddings on‑premise rather than in a cloud provider, what changes would you make to the LangChain‑based pipeline, and how would you handle existing rate‑limited API calls during migration?

  3. 3

    Discuss the trade‑offs between using LangChain's built‑in batch utilities versus building a custom microservice for embedding, considering latency, maintainability, and cross‑team ownership.

Follow-up Questions

  • How would you monitor the actual request rate in production?
  • What would you do if the embedding provider changes its rate‑limit policy?
  • Can you describe a fallback if the provider is temporarily unavailable?