-
-
Notifications
You must be signed in to change notification settings - Fork 7
Fix issue 371 in AiDotNet #457
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
base: master
Are you sure you want to change the base?
Conversation
This commit addresses issue #371 by implementing comprehensive unit tests for all RAG retrieval strategies in src/RetrievalAugmentedGeneration/Retrievers/. Test Coverage Includes: - RetrieverBase (via VectorRetriever tests) - DenseRetriever: Constructor validation, basic retrieval, semantic search - VectorRetriever: Full coverage including query/topK validation, metadata filtering - BM25Retriever: Keyword matching, BM25 scoring, parameter validation - TFIDFRetriever: TF-IDF scoring, caching behavior, term frequency analysis - HybridRetriever: Score fusion, weight balancing, dual strategy combination - MultiQueryRetriever: Query expansion, score aggregation, multi-query logic - MultiVectorRetriever: Vector aggregation methods (max/mean/weighted) - ParentDocumentRetriever: Chunk/parent relationship, hierarchical retrieval - ColBERTRetriever: Token-level interaction, parameter validation - GraphRetriever: Entity extraction, relationship scoring, graph-based retrieval Test Infrastructure: - Created InMemoryDocumentStore for isolated testing - Created StubEmbeddingModel for deterministic embeddings - Test helpers for creating sample documents and data All tests follow xUnit patterns and include: - Constructor validation with null/invalid parameters - Basic retrieval functionality - TopK parameter enforcement - Metadata filtering integration - Empty query/document store handling - Relevance score assignment and sorting - Strategy-specific scoring behavior - Edge cases and error conditions Target: 80%+ code coverage for all retriever implementations
|
Warning Rate limit exceeded@ooples has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 13 minutes and 25 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (8)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Pull Request Overview
This PR adds comprehensive unit tests for the Retrieval-Augmented Generation (RAG) retriever components in the AiDotNet library. The tests cover various retriever implementations including vector-based, keyword-based, hybrid, and advanced retrieval strategies.
- Introduces a shared TestHelpers utility with in-memory document store and stub embedding model for consistent test setup
- Provides exhaustive test coverage for 9 different retriever types with constructor validation, retrieval logic, metadata filtering, and edge cases
- Ensures all retrievers properly handle null/empty inputs, maintain sorted results, and respect topK limits
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| TestHelpers.cs | Provides shared test infrastructure including InMemoryDocumentStore and StubEmbeddingModel for deterministic test execution |
| VectorRetrieverTests.cs | Tests semantic vector-based retrieval with embedding models, including relevance scoring and metadata filtering |
| TFIDFRetrieverTests.cs | Tests TF-IDF keyword-based retrieval with scoring validation, cache behavior, and term frequency analysis |
| MultiQueryRetrieverTests.cs | Tests multi-query expansion retrieval strategy with score aggregation across multiple query variations |
| HybridRetrieverTests.cs | Tests hybrid retrieval combining dense and sparse strategies with weighted fusion and different weight configurations |
| DenseRetrieverTests.cs | Tests dense vector retrieval functionality with semantic search capabilities |
| BM25RetrieverTests.cs | Tests BM25 keyword-based retrieval with parameter tuning (k1, b), term frequency scoring, and case handling |
| AdvancedRetrieverTests.cs | Tests advanced retriever implementations including MultiVector, ParentDocument, ColBERT, and Graph retrievers with specialized functionality |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
| // Act | ||
| var hybridResults = retriever.Retrieve("machine learning", topK: 5).ToList(); | ||
| var denseResults = denseRetriever.Retrieve("machine learning", topK: 5).ToList(); |
Copilot
AI
Nov 8, 2025
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.
This assignment to denseResults is useless, since its value is never read.
| var denseResults = denseRetriever.Retrieve("machine learning", topK: 5).ToList(); |
| // Act | ||
| var hybridResults = retriever.Retrieve("machine learning", topK: 5).ToList(); | ||
| var denseResults = denseRetriever.Retrieve("machine learning", topK: 5).ToList(); | ||
| var sparseResults = sparseRetriever.Retrieve("machine learning", topK: 5).ToList(); |
Copilot
AI
Nov 8, 2025
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.
This assignment to sparseResults is useless, since its value is never read.
| var sparseResults = sparseRetriever.Retrieve("machine learning", topK: 5).ToList(); |
|
|
||
| // Act - First retrieval builds cache | ||
| var results1 = retriever.Retrieve("machine learning", topK: 5).ToList(); | ||
| var count1 = results1.Count; |
Copilot
AI
Nov 8, 2025
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.
This assignment to count1 is useless, since its value is never read.
| var count1 = results1.Count; |
This commit addresses issue #371 by implementing comprehensive unit tests for all RAG retrieval strategies in src/RetrievalAugmentedGeneration/Retrievers/.
Test Coverage Includes:
Test Infrastructure:
All tests follow xUnit patterns and include:
Target: 80%+ code coverage for all retriever implementations
User Story / Context
merge-dev2-to-masterSummary
Verification
Copilot Review Loop (Outcome-Based)
Record counts before/after your last push:
Files Modified
Notes