Module 1: Vector Search¶
Without grounding in real data, LLMs hallucinate confidently. Vector search lets your agent retrieve actual policy documents from Redis by meaning, not just keywords, so every answer is backed by source material.
Exercise¶
Open exercises/digital-native/vector_search.py. You will write ~5 lines in SimpleRAGService .
create_vector_query(embedding, rag_config)¶
This method builds a VectorQuery — the object that tells Redis how to search your document vectors and what to send back.
| Parameter | What it means | What to pass |
|---|---|---|
vector |
The user's question as an embedding. Redis compares this against all stored document vectors using cosine similarity. | embedding |
vector_field_name |
Which field in your documents contains the embedding vectors. | rag_config.vector_field |
return_fields |
Which fields to return from matching documents (title, content, etc.). | rag_config.return_fields |
num_results |
How many documents to retrieve. More results = more context but weaker matches. | rag_config.num_results |
Return a VectorQuery(...) instance.
Show solution
Verify¶
Stop the running server (Ctrl+C in the terminal), then restart with make dev. Open localhost:3040.
- Ask: "Why is my order running late?"
- View the Activity Panel — you see RAG retrieval results with document titles
Try this¶
- Change
num_resultsto1, refresh, and ask the same question. Notice how the response changes with less information.