-
Notifications
You must be signed in to change notification settings - Fork 6
adding rerank #34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
adding rerank #34
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| --- | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. style: This appears to be a duplicate file - the filename includes 'copy' which suggests it may be unintentional. Consider removing this file if documentation/hql/rerankers/overview.mdx contains the same content. Prompt To Fix With AIThis is a comment left during a code review.
Path: documentation/hql/rerankers/overview copy.mdx
Line: 1:1
Comment:
**style:** This appears to be a duplicate file - the filename includes 'copy' which suggests it may be unintentional. Consider removing this file if documentation/hql/rerankers/overview.mdx contains the same content.
How can I resolve this? If you propose a fix, please make it concise. |
||
| title: "Rerankers Overview" | ||
| description: "Improve search result quality by reordering results after initial retrieval." | ||
| icon: "arrows-up-down" | ||
| --- | ||
|
|
||
| ## What are Rerankers? | ||
|
|
||
| Rerankers are powerful post-processing operations that improve the quality and diversity of search results by reordering them after the initial retrieval phase. They enable you to: | ||
|
|
||
| - Combine results from multiple search strategies (hybrid search) | ||
| - Reduce redundancy by diversifying results | ||
| - Optimize the relevance-diversity trade-off | ||
| - Improve the overall user experience of your search application | ||
|
|
||
| ## When to Use Rerankers | ||
|
|
||
| Apply rerankers in your query pipeline when you need to: | ||
|
|
||
| - **Merge multiple search methods**: Combine vector search with BM25 keyword search, or merge results from multiple vector searches | ||
| - **Diversify results**: Eliminate near-duplicate content and show varied perspectives | ||
| - **Optimize ranking**: Fine-tune the balance between relevance and variety based on your use case | ||
| - **Improve search quality**: Leverage sophisticated ranking algorithms without changing your underlying search infrastructure | ||
|
|
||
| ## Available Rerankers | ||
|
|
||
| HelixQL provides two powerful reranking strategies: | ||
|
|
||
| ### RerankRRF (Reciprocal Rank Fusion) | ||
|
|
||
| A technique for combining multiple ranked lists without requiring score calibration. Perfect for hybrid search scenarios where you want to merge results from different search methods. | ||
|
|
||
| ```rust | ||
| ::RerankRRF() // Uses default k=60 | ||
| ::RerankRRF(k: 30.0) // Custom k parameter | ||
| ``` | ||
|
|
||
| [Learn more about RerankRRF →](/documentation/hql/rerankers/rerank-rrf) | ||
|
|
||
| ### RerankMMR (Maximal Marginal Relevance) | ||
|
|
||
| A diversification technique that balances relevance with diversity to reduce redundancy. Ideal when you want to show varied results instead of similar or duplicate content. | ||
|
|
||
| ```rust | ||
| ::RerankMMR(lambda: 0.7) // Default cosine distance | ||
| ::RerankMMR(lambda: 0.5, distance: "euclidean") // Custom distance metric | ||
| ``` | ||
|
|
||
| [Learn more about RerankMMR →](/documentation/hql/rerankers/rerank-mmr) | ||
|
|
||
| ## Basic Usage Pattern | ||
|
|
||
| RRF Usage: | ||
| ```rust focus=3 | ||
| QUERY SearchDocuments(query_vec: [F64]) => | ||
| results <- SearchV<Document>(query_vec, 100) | ||
| ::RerankRRF() // Apply reranking | ||
| ::RANGE(0, 10) // Get top 10 results | ||
| RETURN results | ||
| ``` | ||
|
|
||
| MMR Usage: | ||
|
|
||
| ```rust focus=3 | ||
| QUERY SearchDocuments(query_vec: [F64]) => | ||
| results <- SearchV<Document>(query_vec, 100) | ||
| ::RerankMMR(lambda: 0.7) // Apply reranking | ||
| ::RANGE(0, 10) // Get top 10 results | ||
| RETURN results | ||
| ``` | ||
|
|
||
| ## Chaining Rerankers | ||
|
|
||
| You can chain multiple rerankers together for complex result optimization: | ||
|
|
||
| ```rust focus={3-4} | ||
| QUERY AdvancedSearch(query_vec: [F64]) => | ||
| results <- SearchV<Document>(query_vec, 150) | ||
| ::RerankRRF(k: 60) // First: combine multiple rankings | ||
| ::RerankMMR(lambda: 0.6) // Then: diversify results | ||
| ::RANGE(0, 10) | ||
| RETURN results | ||
| ``` | ||
|
|
||
| ## Best Practices | ||
|
|
||
| 1. **Retrieve more results initially**: Fetch 100-200 candidates to give rerankers sufficient options to work with | ||
| 2. **Apply rerankers before RANGE**: Rerank first, then limit the number of results returned | ||
|
Check warning on line 88 in documentation/hql/rerankers/overview copy.mdx
|
||
| 3. **Choose the right reranker**: Use RRF for combining searches, MMR for diversification | ||
| 4. **Test with your data**: Experiment with different parameters to find what works best for your use case | ||
|
|
||
| ## Common Patterns | ||
|
|
||
| ```rust | ||
| // Pattern 1: Simple diversification | ||
| SearchV<Document>(vec, 100)::RerankMMR(lambda: 0.7)::RANGE(0, 10) | ||
|
|
||
| // Pattern 2: Hybrid search fusion | ||
| SearchV<Document>(vec, 100)::RerankRRF()::RANGE(0, 10) | ||
|
|
||
| // Pattern 3: Fusion + diversification | ||
| SearchV<Document>(vec, 150)::RerankRRF()::RerankMMR(lambda: 0.6)::RANGE(0, 10) | ||
| ``` | ||
|
|
||
| ## Next Steps | ||
|
|
||
| Explore the detailed documentation for each reranker: | ||
|
|
||
| - [RerankRRF (Reciprocal Rank Fusion)](/documentation/hql/rerankers/rerank-rrf) | ||
| - [RerankMMR (Maximal Marginal Relevance)](/documentation/hql/rerankers/rerank-mmr) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,99 @@ | ||
| --- | ||
| title: "Rerankers Overview" | ||
| description: "Improve search result quality by reordering results after initial retrieval." | ||
| icon: "arrows-up-down" | ||
| --- | ||
|
|
||
| ## What are Rerankers? | ||
|
|
||
| Rerankers are powerful post-processing operations that improve the quality and diversity of search results by reordering them after the initial retrieval phase. They enable you to: | ||
|
|
||
| - Combine results from multiple search strategies (hybrid search) | ||
| - Reduce redundancy by diversifying results | ||
| - Optimize the relevance-diversity trade-off | ||
| - Improve the overall user experience of your search application | ||
|
|
||
| ## When to Use Rerankers | ||
|
|
||
| Apply rerankers in your query pipeline when you need to: | ||
|
|
||
| - **Merge multiple search methods**: Combine vector search with BM25 keyword search, or merge results from multiple vector searches | ||
| - **Diversify results**: Eliminate near-duplicate content and show varied perspectives | ||
| - **Optimize ranking**: Fine-tune the balance between relevance and variety based on your use case | ||
| - **Improve search quality**: Leverage sophisticated ranking algorithms without changing your underlying search infrastructure | ||
|
|
||
| ## Available Rerankers | ||
|
|
||
| HelixQL provides two powerful reranking strategies: | ||
|
|
||
| ### RerankRRF (Reciprocal Rank Fusion) | ||
|
|
||
| A technique for combining multiple ranked lists without requiring score calibration. Perfect for hybrid search scenarios where you want to merge results from different search methods. | ||
|
|
||
| ```rust | ||
| ::RerankRRF // Uses default k=60 | ||
| ::RerankRRF(k: 30.0) // Custom k parameter | ||
| ``` | ||
|
|
||
| ### RerankMMR (Maximal Marginal Relevance) | ||
|
|
||
| A diversification technique that balances relevance with diversity to reduce redundancy. Ideal when you want to show varied results instead of similar or duplicate content. | ||
|
|
||
| ```rust | ||
| ::RerankMMR(lambda: 0.7) | ||
| ``` | ||
|
|
||
|
|
||
| ## Basic Usage Pattern | ||
|
|
||
| RRF Usage: | ||
| ```rust focus=3 | ||
| QUERY SearchDocuments(query_vec: [F64]) => | ||
| results <- SearchV<Document>(query_vec, 100) | ||
| ::RerankRRF // Apply reranking | ||
| ::RANGE(0, 10) // Get top 10 results | ||
| RETURN results | ||
| ``` | ||
|
|
||
| MMR Usage: | ||
|
|
||
| ```rust focus=3 | ||
| QUERY SearchDocuments(query_vec: [F64]) => | ||
| results <- SearchV<Document>(query_vec, 100) | ||
| ::RerankMMR(lambda: 0.7) // Apply reranking | ||
| ::RANGE(0, 10) // Get top 10 results | ||
| RETURN results | ||
| ``` | ||
|
|
||
| ## Chaining Rerankers | ||
|
|
||
| You can chain multiple rerankers together for complex result optimization: | ||
|
|
||
| ```rust focus={3-4} | ||
| QUERY AdvancedSearch(query_vec: [F64]) => | ||
| results <- SearchV<Document>(query_vec, 150) | ||
| ::RerankRRF(k: 60) // First: combine multiple rankings | ||
| ::RerankMMR(lambda: 0.6) // Then: diversify results | ||
| ::RANGE(0, 10) | ||
| RETURN results | ||
| ``` | ||
|
|
||
| ## Best Practices | ||
|
|
||
| 1. **Retrieve more results initially**: Fetch 100-200 candidates to give rerankers sufficient options to work with | ||
| 2. **Apply rerankers before RANGE**: Rerank first, then limit the number of results returned | ||
|
Check warning on line 84 in documentation/hql/rerankers/overview.mdx
|
||
| 3. **Choose the right reranker**: Use RRF for combining searches, MMR for diversification | ||
| 4. **Test with your data**: Experiment with different parameters to find what works best for your use case | ||
|
|
||
| ## Common Patterns | ||
|
|
||
| ```rust | ||
| // Pattern 1: Simple diversification | ||
| SearchV<Document>(vec, 100)::RerankMMR(lambda: 0.7)::RANGE(0, 10) | ||
|
|
||
| // Pattern 2: Hybrid search fusion | ||
| SearchV<Document>(vec, 100)::RerankRRF::RANGE(0, 10) | ||
|
|
||
| // Pattern 3: Fusion + diversification | ||
| SearchV<Document>(vec, 150)::RerankRRF::RerankMMR(lambda: 0.6)::RANGE(0, 10) | ||
| ``` | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Only includes overview page but PR contains rerank-mmr.mdx and rerank-rrf.mdx files that aren't referenced here
Prompt To Fix With AI