learning-it by example

Back to the video

HyDE and Query Rewriting: 7 of 12 vs 10 of 12

My search put the right page first 7 times out of 12. A pretend answer did it 10 times.

Video #45 ยท RAG and vector search

Steps in the video

  1. 0:00 Search for an answer that does not exist
  2. 0:32 The idea
  3. 1:08 Setup
  4. 1:30 The index and ranking
  5. 1:50 Two helpers
  6. 2:14 Twelve vague questions
  7. 3:10 What this does not show
  8. 3:40 Mistakes to avoid
  9. 4:04 My take and next steps
  10. 4:27 Recap

Files

  • compare.py (26 lines)
  • handbook.md (28 lines)
  • rewrite.py (19 lines)
  • search.py (28 lines)

Download the code (zip)

Tested with

Python 3.12.15 | ollama==0.6.3

What this does not show

A made-up handbook with nine sections and twelve vague questions that I wrote, made vaguer after a first easier set showed almost no difference. One small model, one embedder, one run, prompts not tuned. A difference of one or two questions is small. Clear questions were not tested.

Sources

Learning IT by Example.