Skip to main content
Limit stage showing result truncation to top-N documents
The Limit stage truncates the document set to a maximum number of results, optionally with an offset for pagination-style behavior. This is the retriever pipeline equivalent of SQL’s LIMIT/OFFSET clause.
Stage Category: REDUCE (Truncates documents)Transformation: N documents → min(N, limit) documents

When to Use

When NOT to Use

Parameters

Configuration Examples

Place the limit stage after sorting/reranking to ensure you’re keeping the highest-quality results. Limiting before reranking loses potentially relevant documents.

Performance

Common Pipeline Patterns

Rerank Then Limit

Cost-Controlled LLM Pipeline

Error Handling

  • Sample - Random or stratified sampling
  • Deduplicate - Remove duplicates before limiting
  • Rerank - Re-score before limiting to ensure best results