#03 RAG and vector search 6.3 min
pgvector vs Chroma vs Qdrant: Same Data, Real Results
Same notes, same question, three vector databases on your laptop: pgvector, Chroma and Qdrant, with real output and three classic mistakes.
Ask a different question
Copy the code folder first. In compare.py change the question to ask when the shop is open on a Saturday. Before you run it, read notes.txt and predict which note each of the three stores will return, and whether the three will agree. Then start the containers as in the video, run python compare.py, and compare your prediction with what you see. This needs Docker and the Ollama embedding model, as in the video.
A hint
The note that answers an opening hours question starts with its title, so look for it in notes.txt.
Turn off cosine in Chroma
In compare.py remove the metadata argument that sets hnsw:space to cosine from the Chroma collection, and put the question back to the bike returns one. Predict the distance Chroma will print compared with pgvector. Then run it and write down the two numbers. Which distance is Chroma using now? Start the Docker containers as in the video first, and stop and remove them when you finish.
A hint
The video says that unless you ask for cosine, Chroma measures distance a different way, called L2.
Print Qdrant as a distance
Qdrant prints a score where higher is closer. Change the print line in with_qdrant so it prints 1 minus hit.score and says lower is closer, like the other two lines. Using the video's idea that similarity is one minus the distance, predict the number it will print before you run it. Start the Docker containers as in the video first, and stop and remove them when you finish.
A hint
Compare your prediction with the distance that pgvector and Chroma print for the same question.
Send the right sized vector
In gotchas.py the Qdrant collection is created with size 384, but the test sends a list of 768 numbers. Change 768 to 384 and predict what the Qdrant part of the output will look like. Think about which lines of the script print anything. Then run it and check. Start the Docker containers as in the video first, and stop and remove them when you finish.
A hint
The print about Qdrant refusing a vector sits inside the except branch.
These tasks are for you to try on your own machine. Nothing is checked or saved.
What this does not show
One question over seven made-up notes on one laptop; no test of speed or scale. The query-plan result is from 10,000 random vectors with an HNSW index. Behaviour is for the pinned versions. Which-to-pick advice is from blog posts, not a benchmark.
Up next in RAG and vector search
More in RAG and vector search
Related videos
- #50 pgvector Tuning: When Filtered Vector Search Returns Nothing RAG and vector search
- #246 Data Architecture for AI Agents: Tables, Vectors, Graphs Enterprise architecture and AI agents
- #69 Detect LLM Hallucinations: 5 Checks Scored on 16 Answers LLM engineering and evals
- #02 RAG From Scratch in Python: Chunk, Embed, Retrieve (Local) RAG and vector search
