Build a Mistral-powered RAG agent

Quick Overview

This question evaluates a candidate's ability to design and implement a retrieval-augmented generation (RAG) system using a large language model API, including document ingestion, chunking, vector indexing and retrieval, streaming completions, service interfaces (CLI and HTTP), and resilience features like retries, persistence, and structured error handling. Commonly asked in the ML System Design domain to assess practical engineering and architectural reasoning, it tests API integration, production-readiness (configuration, error handling, persistence, and testing) and emphasizes practical application with conceptual understanding of retrieval trade-offs.

Build a Mistral-powered RAG agent

Company: Meta

Role: Software Engineer

Category: ML System Design

Difficulty: hard

Interview Round: Onsite

You are given an API token. Build a small retrieval-augmented generation (RAG) tool that can answer questions over a local folder of Markdown/PDF files using the Mistral API. Requirements: ( 1) Implement document ingestion, chunking, and an in-memory vector index for retrieval; ( 2) Provide a CLI with commands: index <path>, ask <question>, and serve an HTTP /chat endpoint; ( 3) Call chat/completions with streaming, include top-k retrieved chunks and return source citations; ( 4) Add exponential backoff/retries for 429/timeouts and structured error handling; ( 5) Configure via environment variables (e.g., pyenv) for API key, model, and ports; ( 6) Include a README with setup steps and minimal tests; ( 7) Briefly explain your retrieval algorithm choices and a quick method to evaluate answer quality.

Quick Answer: This question evaluates a candidate's ability to design and implement a retrieval-augmented generation (RAG) system using a large language model API, including document ingestion, chunking, vector indexing and retrieval, streaming completions, service interfaces (CLI and HTTP), and resilience features like retries, persistence, and structured error handling. Commonly asked in the ML System Design domain to assess practical engineering and architectural reasoning, it tests API integration, production-readiness (configuration, error handling, persistence, and testing) and emphasizes practical application with conceptual understanding of retrieval trade-offs.

|Home/ML System Design/Meta
Meta logo
Meta
Sep 6, 2025, 12:00 AM
hardSoftware EngineerOnsiteML System Design
8
0

Build a Minimal RAG Tool Using the Mistral API

Context

You have an API token and need to implement a small retrieval-augmented generation (RAG) tool in Python that can answer questions over a local folder of Markdown and PDF files using the Mistral API. The tool should support both a CLI and an HTTP server.

Requirements

  1. Implement document ingestion, chunking, and an in-memory vector index for retrieval.
  2. Provide a CLI with commands:
    • index <path>
    • ask <question>
    • serve (HTTP server exposing a /chat endpoint)
  3. Call chat/completions with streaming; include the top-k retrieved chunks in the prompt and return source citations.
  4. Add exponential backoff/retries for 429 and timeouts, plus structured error handling.
  5. Configure via environment variables for API key, model names, and ports.
  6. Include a README with setup steps and minimal tests.
  7. Briefly explain your retrieval algorithm choices and a quick way to evaluate answer quality.

Assumptions

  • Language: Python 3.10+.
  • Use the Mistral HTTP API directly to avoid client-library version mismatch.
  • You may persist the built index to disk so that ask and serve can reuse it across processes, while the core index data structure remains in-memory when serving queries.
  • Supported file types: .md and .pdf.

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...