Katkat

Build a Mistral-powered RAG agent

MetaSoftware Engineer · Onsite

Last updated

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.

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.