Build and design a Mistral RAG agent

Quick Overview

This question evaluates a candidate's skills in building a retrieval-augmented generation (RAG) system, covering document ingestion, chunking, embedding generation, vector indexing, retrieval, LLM API-driven streaming completions, short-term conversation memory, and operational reliability features.

Build and design a Mistral RAG agent

Company: Mistral AI

Role: Software Engineer

Category: ML System Design

Difficulty: hard

Interview Round: Technical Screen

Build and discuss an LLM-powered retrieval-augmented agent that calls the Mistral API. Implement a minimal Python tool that: ( 1) ingests a small local corpus (e.g., Markdown/PDF), chunks text, generates embeddings, and indexes them; ( 2) retrieves top-k passages for a user query; ( 3) composes a prompt and invokes Mistral chat/completions with streaming; ( 4) keeps short-term conversation memory; ( 5) reads the API token from an environment variable; ( 6) handles errors, retries, and rate limits; and ( 7) includes a brief README and smoke tests. Then, explain your system design choices: chunking strategy, embedding model choice, vector index selection, latency and cost budgeting, caching, prompt templating, safety/PII handling, logging/monitoring, offline RAG evaluation, and fallbacks when retrieval fails.

Quick Answer: This question evaluates a candidate's skills in building a retrieval-augmented generation (RAG) system, covering document ingestion, chunking, embedding generation, vector indexing, retrieval, LLM API-driven streaming completions, short-term conversation memory, and operational reliability features.

|Home/ML System Design/Mistral AI
Mistral AI logo
Mistral AI
Sep 6, 2025, 12:00 AM
hardSoftware EngineerTechnical ScreenML System Design
66
0

Design and Implement a Minimal LLM-Powered RAG Agent (Python, Mistral API)

Context

You are asked to build a minimal, but production-minded, retrieval-augmented generation (RAG) agent in Python that uses the Mistral API for embeddings and chat completions. The agent should work over a small local corpus (e.g., Markdown and PDF files), support streaming responses, maintain a short conversation memory, and include basic reliability features.

Assume Python 3.10+ and that external dependencies can be installed. The Mistral API token is provided via an environment variable.

Deliverables

Implement a minimal Python tool that:

  1. Ingests a small local corpus (Markdown/PDF), chunks text, generates embeddings, and builds an index.
  2. Retrieves top-k passages for a user query.
  3. Composes a prompt and invokes Mistral chat/completions with streaming.
  4. Keeps short-term conversation memory.
  5. Reads the API token from an environment variable.
  6. Handles errors, retries, and rate limits.
  7. Includes a brief README and smoke tests.

Then, explain your system design choices, covering:

  • Chunking strategy
  • Embedding model choice
  • Vector index selection
  • Latency and cost budgeting
  • Caching
  • Prompt templating
  • Safety/PII handling
  • Logging/monitoring
  • Offline RAG evaluation
  • Fallbacks when retrieval fails

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...