cohere-wikipedia-en-100k
collection in the playground project. Each example showcases different approaches to finding the most relevant information from your data.
π Prerequisites
Before running these examples, ensure you have: Required credentials:- Cohere API key from cohere.com
- LambdaDB playground project API key
Fill out this form to obtain playground credentials.
βοΈ Initial setup
π― Example 1: Hybrid search with combined scoring
π‘ When to use: This is your go-to search method when you want the most comprehensive and accurate results. Perfect for general queries where you need both keyword relevance and semantic understanding. π§ How it works: Combines traditional full-text search with vector similarity using hybrid scoring strategies like Reciprocal Rank Fusion(rrf
), L2 distance(l2
), or Min-Max(mm
) normalizationβflexibly choosing the best fit for your use case.
Check out this page for more details about hybrid query and scoring.
π·οΈ Example 2: Hybrid search with keyword filtering
π‘ When to use: Perfect when you want to search within a specific category or document type. Use this when you know the general category but need semantic ranking within that subset. π§ How it works: First filters documents by specific keywords (like titles starting with βListβ), then applies semantic search within those filtered results.filter
parameter within the knn
query:
π― Example 3: Vector search with exact match filtering
π‘ When to use: Ideal when you know the exact document or URL and want to find the most relevant content within it. Perfect for document-specific Q&A scenarios. π§ How it works: Filters to an exact URL match, then uses vector similarity to rank the most relevant sections within that specific document.π§ Complete working example
Hereβs a complete script that runs all three examples with proper error handling:π Search method comparison
Method | Best For | Advantages | Use cases |
---|---|---|---|
Hybrid search | General queries | Best overall accuracy, combines keyword + semantic | User questions, general search |
Keyword filtering | Category-specific search | Fast filtering + semantic ranking | Document type filtering, topic-specific search |
Exact match | Document-specific queries | Precise targeting within known documents | Q&A on specific pages, document analysis |
π― Best practices
β Configuration tips
- Set
skipSyntax: true
for user inputs that may contain special characters. - Use appropriate
k
values (5-20 for most use cases). - Choose RRF for best overall search quality.
- Apply filters in
knn.filter
for semantic search within filtered results.
π Performance optimization
- Use smaller
k
values for faster vector search. - Combine multiple filters in boolean queries for precise targeting.
- Consider using
l2
ormm
(min-max) normalization for simpler score interpretation.
β‘οΈ Next step
- Apply for early access: https://lambdadb.ai/early-access
π€ Support
Need help with your implementation? Check out our:- API reference: Comprehensive documentation for developers
- Community forum: Get help from other developers