Chroma DB and Gemini: semantic search tutorial
Learn to store Gemini embeddings in Chroma DB and query them by meaning, using 768-dimensional vectors and examples about programming and electronics.
Player not loading? Watch on YouTube
This tutorial walks through generating text embeddings with Gemini, storing them in Chroma DB, and retrieving related documents through semantic search. The demo requires a Google API key for the embedding client, so the workflow includes an external API even though the speaker configures a persistence directory on the machine.
The example calls client.models.embed_content with a list of texts and sets the output dimensionality to 768. The speaker describes 3072 as the default dimension and stresses that query embeddings must use the same model and dimensions as the stored vectors. The model named in the explanation is Gemini embedding 001.
After installing Chroma DB, the speaker creates a client and a collection called codedex_chromadb_demo. Each record includes an embedding, its original document text, and an ID. A separate embedding represents the search query, which the demo passes to collection.query with the desired result count.
The query "programming" returns documents about writing a Python function and creating a Java class, although neither contains that search word. A second query, "electronics", returns texts about an iPhone release and smartphone cameras. These examples illustrate retrieval by meaning within the small sample collection; the tutorial does not provide a broader accuracy benchmark.