Prerequisites
Before you begin, ensure you have:- Cerebras API Key - Get a free API key here
- Milvus Instance - Either install Milvus locally or use Zilliz Cloud (managed Milvus)
- Python 3.8 or higher
- Basic understanding of vector databases and RAG concepts
Configure Milvus with Cerebras
Create a virtual environment
Install required dependencies
openai- For connecting to Cerebras API (OpenAI-compatible)pymilvus- Python SDK for Milvus vector database
Configure environment variables
.env file in your project directory to store your API credentials:http://localhost:19530. For Zilliz Cloud, you’ll receive a URI and token when you create your cluster.Initialize the Cerebras client
Connect to Milvus
Create a collection for your embeddings
Generate and store embeddings
Create an index for fast retrieval
nlist based on your data size: use higher values (1024-4096) for millions of vectors.Build a RAG query pipeline
Stream responses for better UX
Available Models
Milvus RAG pipelines work with all Cerebras models:model parameter in your RAG query function to switch between models.
Next Steps
- Migrate to GLM4.7: Ready to upgrade? Follow our migration guide to start using our latest model
- Explore Milvus documentation for advanced features like hybrid search and filtering
- Try different Cerebras models to optimize for your use case
- Learn about Milvus indexing strategies for better performance
- Check out Zilliz Cloud for a fully managed Milvus experience
- Experiment with different embedding models and dimensions for your specific domain
- Implement hybrid search combining vector and scalar filtering
Troubleshooting
Connection refused when connecting to Milvus
Connection refused when connecting to Milvus
.env file. The URI should look like: https://your-cluster.api.gcp-us-west1.zillizcloud.comDimension mismatch error when inserting embeddings
Dimension mismatch error when inserting embeddings
- The
dimparameter in your collection schema matches your embedding model’s output dimension - You’re using the correct embedding model consistently throughout your application
- If you need to change embedding models, create a new collection with the correct dimension
- OpenAI text-embedding-3-small: 1536
- OpenAI text-embedding-3-large: 3072 (or 1024 with dimension parameter)
- Cohere embed-english-v3.0: 1024
- Voyage AI voyage-2: 1024
Slow search performance
Slow search performance
-
Choose the right index: Use HNSW for best performance on large datasets:
-
Adjust search parameters: Increase
effor HNSW ornprobefor IVF indexes: -
Ensure collection is loaded: Always call
collection.load()before searching -
Use appropriate nlist: For IVF indexes, set
nlistto sqrt(num_entities) as a starting point - Consider GPU acceleration: Milvus supports GPU indexes for even faster search on large datasets
Out of memory errors
Out of memory errors
-
Batch your insertions: Insert documents in batches of 1000-10000 instead of all at once:
-
Use memory-efficient indexes: IVF_SQ8 uses less memory than IVF_FLAT:
- Adjust Docker memory limits: If running locally, increase Docker’s memory allocation in Docker Desktop settings
- Consider Zilliz Cloud: Managed service with automatic scaling and memory management
-
Release collections: Release collections from memory when not in use:
Why am I getting empty search results?
Why am I getting empty search results?
-
Collection not loaded: Ensure you call
collection.load()after creating the index -
Wrong metric type: If you used
IP(inner product) for indexing butL2for searching, results may be incorrect. Keep them consistent: - Embedding mismatch: Ensure you’re using the same embedding model for both indexing and querying
-
Collection is empty: Verify data was inserted successfully:
-
Search threshold too strict: Try increasing
limitparameter or adjusting distance thresholds

