Skip to main content
Version: 0.7.x

Recipe: vector RAG pipeline

Goal. Build the two halves of a retrieval-augmented pipeline: ingest documents into a vector store, then answer questions by retrieving the nearest passages and generating over them with an LLM.

Prerequisites.

  • An OpenAI-compatible embeddings endpoint (api_base, e.g. a local vLLM, Ollama, or OpenAI) and an API key via ${env:EMBEDDING_API_KEY}.
  • One vector store, running and reachable:
  • The collection/table must exist with the same vector dimension as the embedding model (e.g. 1536 for text-embedding-3-small).

Half 1: ingestion (documents → vectors)​

Embed a text column and upsert vectors plus payload into Qdrant:

- type: json_to_arrow
- type: embedding
api_base: "http://localhost:9997/v1"
model: "text-embedding-3-small"
api_key: "${env:EMBEDDING_API_KEY:-}"
field: "text"
batch_size: 32
output:
type: qdrant
url: "http://localhost:6333"
collection: documents
vector_field: embedding
id_field: doc_id

Point semantics:

  • With id_field, re-delivery overwrites the same point — the at-least-once pipeline is idempotent on re-runs.
  • Without id_field, each row gets a fresh UUID; every redelivery inserts a duplicate. Always set an id column for streaming ingestion.
  • One batch slice is at most 1,000 points per PUT; larger batches split sequentially.
  • The vector dimension must match the collection; mismatches fail the batch to error_output.

For pgvector, the pgvector output writes (id, embedding vector(n), payload jsonb) — the same table shape the pgvector_search processor reads, so ingestion and retrieval share one table. For Milvus, use the Milvus output.

The complete runnable ingestion config is examples/embedding_qdrant_pipeline.yaml (registered as embedding-qdrant-pipeline; pgvector and Milvus variants are registered alongside it).

Half 2: query (question → retrieval → answer)​

Embed the question, retrieve top-k, compose a prompt, and generate:

- type: json_to_arrow
- type: embedding
api_base: "http://localhost:9997/v1"
model: "text-embedding-3-small"
api_key: "${env:EMBEDDING_API_KEY:-}"
field: "text"
- type: vector_search
url: "http://localhost:6333"
collection: documents
vector_field: embedding
top_k: 5
target_field: matches
- type: sql
query: "SELECT *, concat('Question: ', text, ' | Passages: ', matches) AS rag_prompt FROM flow"
- type: llm
api_base: "http://localhost:9997/v1"
model: "gpt-4o-mini"
api_key: "${env:OPENAI_API_KEY:-}"
field: "rag_prompt"
system_prompt: "Answer the user's question using only the provided passages."
target_field: "answer"
- type: arrow_to_json

Expected result: each input row gains matches (a JSON array of {id, score, payload}, nearest first) and answer (the generated text). The complete runnable query config is examples/rag_query_pipeline.yaml (registered as rag-query-pipeline).

Verify​

  1. Start Qdrant and the embeddings endpoint; create the collection with the right dimension.
  2. Run the ingestion config against a small document set, then check GET /collections/documents point count.
  3. Run the query config with a question; confirm the stdout batch carries non-empty matches with sensible scores and an answer grounded in them.

Failure modes​

SymptomCauseFix
Dimension mismatch 4xxModel and collection dims differRecreate the collection or change the model.
Empty matchesCollection empty or wrong vector_fieldRun ingestion first; check column names.
llm/embedding 429Rate limitsRaise retry_count, lower batch_size, or set concurrency on the search processor.
Batch routed to error_outputExhausted retries / null input textInspect the DLQ; see dead letter queues.