Skip to content

RAG Latency

Definition

RAG Latency is a metric measuring the total time from the receipt of a user request to the completion of the response generation in a system using retrieval-augmented generation. Unlike pure LLM inference latency, RAG latency includes the time taken for searching relevant fragments, processing them, and passing them to the model context.

Latency Components

graph LR
    A[Request] --> B[Query Embedding]
    B --> C[Vector Search]
    C --> D[Post-processing]
    D --> E[Context Formation]
    E --> F[LLM Inference]
    F --> G[Response]
Stage Typical Share Influencing Factors
Query Embedding 5–10% Embedding model size
Vector Search 10–20% Index, data volume
Post-processing 5% Re-ranking, filtering
Context Formation 5% Number of fragments
LLM Inference 50–70% Context length, model size

Latency Optimization

  • Caching search results for repeated queries.
  • Using faster embedding models.
  • Parallel execution of search and pre-generation.
  • Reducing the number of fragments passed to the context.

See also