Suppose you want to find an image like one you have, but you do not know its ID or the right keywords. A vector database lets you search for nearby representations instead. It stores vectors, such as embeddings, alongside metadata; its distinguishing strength is similarity search, not storage alone. Searches can use Euclidean distance, cosine similarity, or dot product similarity. section 3.4.5
Choose how to use one based on the retrieval job:
- Use vector search when a similar item is easier to specify than an exact ID or keyword. Traditional database indexes and text search remain useful when you know what to look for. section 3.4.5
- Consider a feature store alongside the vector database, not necessarily instead of it: a feature store can be an abstraction built on top. Multiple data sources, embedding models, and frequent updates make management harder. section 3.4.5
- For a small dataset, consider in-memory similarity search with Faiss or USearch. Milvus offers a locally run, Docker-based database, managed clusters, and a GPU-enabled option. section 10.2.1
Retrieving Python coding examples
A coding copilot can use retrieval-augmented generation (RAG) to add relevant coding context without fine-tuning its model. One implementation loads 18.6K Python instruction-and-code examples into Milvus, chunks and embeds them in batches, and stores IDs, embeddings, and JSON metadata in a collection. An IVF_FLAT index groups embeddings into clusters to accelerate similarity search. A query about classifying MNIST is embedded and searched for nearby instructions; the returned examples include handwritten-digit classification tasks. Using an organization’s changing codebase instead would require a pipeline to ingest and update that code. section 10.2 section 10.2.2
collection.load() #1
query = ( #2
"Construct a neural network model in Python to classify "
"the MNIST data set correctly."
)
search_embedding = python_code_ingestion.embedder.encode(query)
search_params = {
"metric_type": "L2",
"params": {"nprobe": 10}, #3
}
results = collection.search(
[search_embedding],
"embeddings",
search_params,
limit=3,
output_fields=["metadata"],
)
for hits in results:
for hit in hits:
print(hit.distance)
print(hit.entity.metadata["instruction"])
The Milvus search listing shows the query-to-embedding step, L2 search parameters, a three-result limit, and retrieval of instruction metadata. section 10.2.2

























