Skip to content

Conversation

@ljt019
Copy link
Owner

@ljt019 ljt019 commented Jul 7, 2025

Summary

  • add RerankResult type and make pipeline methods async
  • support batch reranking in the RerankModel trait
  • update Qwen3RerankModel implementation for new API
  • update example usage and README with reranking docs

Testing

  • cargo check
  • cargo test --lib

https://chatgpt.com/codex/tasks/task_e_686b721f9b248330ae075fe11fbfee2c

Summary by CodeRabbit

  • New Features

    • Introduced a structured result type for reranking outputs, providing clearer document index and relevance score information.
    • Added asynchronous support to reranking pipeline methods for improved performance and flexibility.
    • Added a new Rust example demonstrating a two-stage retrieval pipeline combining embedding recall and reranking.
    • Updated documentation with a new section and Rust code example for the reranking pipeline, including available model sizes and usage guidance.
  • Documentation

    • Expanded README with a detailed description and example of the reranking pipeline, including links to relevant models.
    • Added multiple new example documents covering diverse topics for use with the reranking pipeline.
  • Refactor

    • Replaced tuple-based reranking results with a dedicated struct for improved clarity and usability.
    • Unified and streamlined method signatures to use the new result structure and async operations.
    • Introduced a dedicated embedding size enum for Qwen3 embeddings and added support for optional instruction text in embedding generation.
  • Chores

    • Updated dependency on hf-hub crate to a newer version with added features.
    • Removed obsolete reranker test file to streamline the codebase.
    • Extended public API to expose embedding size types for Qwen3 models.

@coderabbitai
Copy link

coderabbitai bot commented Jul 7, 2025

Walkthrough

The changes introduce a structured RerankResult type to replace tuple-based reranking results throughout the reranker pipeline. All relevant methods are updated for asynchronous execution, and the public API is adjusted accordingly. Documentation is expanded with a new pipeline description and Rust usage example. No core scoring logic is altered.

Changes

File(s) Change Summary
README.md Added "Reranking Pipeline" section, listed model sizes, HuggingFace link, and a Rust usage example.
examples/reranker/main.rs Added new example demonstrating two-stage retrieval with embedding recall and async reranking.
examples/reranker.rs Removed old synchronous reranker example.
examples/reranker/corpus/*.txt Added new corpus documents on machine learning, math, physics, and miscellaneous topics.
src/models/implementations/qwen3_reranker.rs Renamed rerank to rerank_documents, changed return types to RerankResult, updated trait implementations with batch rerank.
src/models/implementations/qwen3_embeddings.rs Introduced Qwen3EmbeddingSize enum, refactored embedding methods to use it, added optional instruction support.
src/models/implementations/mod.rs Added Qwen3EmbeddingSize to public exports.
src/models/mod.rs Added Qwen3EmbeddingSize to public exports.
src/lib.rs Added Qwen3EmbeddingSize to public exports.
src/pipelines/reranker_pipeline/mod.rs Re-exported RerankResult for external use.
src/pipelines/reranker_pipeline/reranker_model.rs Changed trait method to return RerankResult; added default async batch_rerank method.
src/pipelines/reranker_pipeline/reranker_pipeline.rs Introduced RerankResult struct; updated all methods to use it and made them async; simplified batch rerank.
src/pipelines/embedding_pipeline/builder.rs Changed qwen3 builder method parameter type to Qwen3EmbeddingSize.
src/pipelines/embedding_pipeline/mod.rs Updated imports to use Qwen3EmbeddingSize instead of Qwen3Size.
tests/embedding_pipeline_tests/basic_embedding.rs Updated test to use Qwen3EmbeddingSize for embedding pipeline construction.
Cargo.toml Upgraded hf-hub dependency to 0.4.3 with "tokio" feature enabled.
test_reranker.rs Removed entire test file containing async main test for Qwen3 reranker model sizes.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant RerankPipeline
    participant RerankModel
    participant ModelImpl

    User->>RerankPipeline: rerank(query, documents)
    activate RerankPipeline
    RerankPipeline->>RerankModel: rerank(tokenizer, query, documents)
    activate RerankModel
    RerankModel->>ModelImpl: rerank_documents(tokenizer, query, documents)
    activate ModelImpl
    ModelImpl-->>RerankModel: Vec<RerankResult>
    deactivate ModelImpl
    RerankModel-->>RerankPipeline: Vec<RerankResult>
    deactivate RerankModel
    RerankPipeline-->>User: Vec<RerankResult>
    deactivate RerankPipeline
Loading

Possibly related PRs

  • Reranker pipeling using qwen3 reranker #63: Introduced the initial reranker pipeline and Qwen3 reranker model with synchronous rerank methods and a basic example; this PR builds upon and modifies that core reranker pipeline and model with async support and structured results.

Poem

In the garden of code, a new sprout appears,
RerankResult hops in, with structure and cheers!
Async calls now twinkle, like stars in the night,
No more tuples to juggle—just fields clear and bright.
Rusty paws tap the docs, with a pipeline anew,
This bunny’s reranking, just for you!
🥕✨

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Clippy (1.86.0)
Updating crates.io index
Updating git repository `https://github.com/huggingface/candle.git`

error: failed to get candle-core as a dependency of package transformers v0.0.12 ()

Caused by:
failed to load source for dependency candle-core

Caused by:
Unable to update https://github.com/huggingface/candle.git#d0a3b33e

Caused by:
failed to create directory /usr/local/git/db/candle-5b4d092929d18d36

Caused by:
Permission denied (os error 13)


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ba1fdb5 and d4d132a.

📒 Files selected for processing (1)
  • src/models/implementations/qwen3_reranker.rs (6 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/models/implementations/qwen3_reranker.rs
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Run Tests Development
✨ Finishing Touches
  • 📝 Generate Docstrings

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (1)
README.md (1)

96-107: Fix heading format per static analysis.

The content looks great, but line 97 should use a proper heading format instead of emphasis.

-#### **Reranking Pipeline**
+#### Reranking Pipeline
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3419ffa and 4292569.

📒 Files selected for processing (6)
  • README.md (2 hunks)
  • examples/reranker.rs (1 hunks)
  • src/models/implementations/qwen3_reranker.rs (4 hunks)
  • src/pipelines/reranker_pipeline/mod.rs (1 hunks)
  • src/pipelines/reranker_pipeline/reranker_model.rs (2 hunks)
  • src/pipelines/reranker_pipeline/reranker_pipeline.rs (2 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
src/pipelines/reranker_pipeline/reranker_model.rs (2)
src/pipelines/reranker_pipeline/reranker_pipeline.rs (1)
  • batch_rerank (26-28)
src/models/implementations/qwen3_reranker.rs (3)
  • batch_rerank (169-183)
  • batch_rerank (215-222)
  • new (197-199)
src/pipelines/reranker_pipeline/reranker_pipeline.rs (2)
src/pipelines/reranker_pipeline/reranker_model.rs (2)
  • rerank (13-18)
  • batch_rerank (20-32)
src/models/implementations/qwen3_reranker.rs (3)
  • rerank (201-208)
  • batch_rerank (169-183)
  • batch_rerank (215-222)
🪛 markdownlint-cli2 (0.17.2)
README.md

97-97: Emphasis used instead of a heading

(MD036, no-emphasis-as-heading)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Run Tests Development
🔇 Additional comments (18)
src/pipelines/reranker_pipeline/mod.rs (1)

7-7: LGTM! Clean export addition.

The addition of RerankResult to the public exports is necessary for external users to access the new structured result type.

examples/reranker.rs (4)

24-24: LGTM! Correct async API usage.

The addition of .await properly handles the asynchronous reranking call.


28-29: LGTM! Proper RerankResult field access.

The update from tuple destructuring to accessing result.index and result.score correctly uses the new structured result type.


33-33: LGTM! Consistent async usage.

Correct use of .await for the rerank_top_k method.


35-36: LGTM! Consistent field access pattern.

The iteration and field access pattern matches the previous update and correctly uses the new API.

README.md (1)

410-428: LGTM! Clear usage example.

The example correctly demonstrates the async API usage and shows proper error handling with the Result type.

src/pipelines/reranker_pipeline/reranker_model.rs (3)

3-3: LGTM! Necessary import for the new result type.

The import of RerankResult is required for the trait method signatures.


18-18: LGTM! Improved type safety.

The change from tuple (usize, f32) to RerankResult provides better type safety and clarity.


20-32: LGTM! Well-designed batch method with sensible default.

The batch_rerank method provides a clean API for processing multiple queries, and the default implementation correctly iterates over queries and collects results.

src/pipelines/reranker_pipeline/reranker_pipeline.rs (3)

4-11: LGTM! Well-designed result struct.

The RerankResult struct provides excellent type safety and clarity over the previous tuple approach. The documentation is clear and the fields are appropriately named.


31-35: Async usage is correct here.

This method properly uses .await when calling the async rerank method, which is correct if rerank remains async.


41-42: LGTM! Correct RerankResult field access.

The iteration and field access correctly use the new structured result type.

src/models/implementations/qwen3_reranker.rs (6)

82-87: LGTM! Method signature improvement enhances type safety.

The renaming from rerank to rerank_documents provides better clarity about the method's purpose, and the return type change from Vec<(usize, f32)> to Vec<RerankResult> improves type safety by replacing tuple-based results with a structured type.


92-92: LGTM! Correct adaptation to structured result type.

The change from tuple construction to RerankResult struct construction is consistent with the new return type and maintains the same semantics with clearer field names.


96-96: LGTM! Sorting logic correctly adapted to structured type.

The change from tuple field access (b.1) to struct field access (b.score) maintains the same sorting behavior while working with the new RerankResult type.


174-178: LGTM! Batch reranking method correctly updated for new API.

The method correctly updates both the return type to use Vec<Vec<RerankResult>> and the internal method call to use the renamed rerank_documents method, maintaining consistency with the API improvements.


192-192: LGTM! Import correctly added for new structured type.

The import for RerankResult is correctly added to support the new structured return type throughout the implementation.


206-223: LGTM! Trait implementation correctly updated for new API.

The trait implementation correctly:

  1. Updates the rerank method to delegate to rerank_documents and return Vec<RerankResult>
  2. Adds the batch_rerank method that properly forwards to the model's batch reranking functionality
  3. Maintains consistent return types with the new structured API

The implementation follows proper delegation patterns and maintains the expected interface.

Comment on lines +26 to 28
pub async fn batch_rerank(&self, queries: &[&str], documents: &[&str]) -> anyhow::Result<Vec<Vec<RerankResult>>> {
self.model.batch_rerank(&self.tokenizer, queries, documents)
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Same async consistency issue.

The method is marked as async but calls a synchronous trait method without .await.

Apply the same fix as the rerank method above.

🤖 Prompt for AI Agents
In src/pipelines/reranker_pipeline/reranker_pipeline.rs around lines 26 to 28,
the batch_rerank method is marked async but calls a synchronous trait method
without awaiting. To fix this, remove the async keyword from the method
signature and return the synchronous call result directly, matching the approach
used in the rerank method above for consistency.

Comment on lines +38 to 45
pub async fn get_scores(&self, query: &str, documents: &[&str]) -> anyhow::Result<Vec<f32>> {
let ranked = self.model.rerank(&self.tokenizer, query, documents)?;
let mut scores = vec![0.0f32; documents.len()];

for (idx, score) in ranked {
scores[idx] = score;
for r in ranked {
scores[r.index] = r.score;
}

Ok(scores)
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Another async consistency issue.

The method is marked as async but calls a synchronous trait method without .await and doesn't use any async operations.

-    pub async fn get_scores(&self, query: &str, documents: &[&str]) -> anyhow::Result<Vec<f32>> {
+    pub fn get_scores(&self, query: &str, documents: &[&str]) -> anyhow::Result<Vec<f32>> {
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
pub async fn get_scores(&self, query: &str, documents: &[&str]) -> anyhow::Result<Vec<f32>> {
let ranked = self.model.rerank(&self.tokenizer, query, documents)?;
let mut scores = vec![0.0f32; documents.len()];
for (idx, score) in ranked {
scores[idx] = score;
for r in ranked {
scores[r.index] = r.score;
}
Ok(scores)
}
pub fn get_scores(&self, query: &str, documents: &[&str]) -> anyhow::Result<Vec<f32>> {
let ranked = self.model.rerank(&self.tokenizer, query, documents)?;
let mut scores = vec![0.0f32; documents.len()];
for r in ranked {
scores[r.index] = r.score;
}
Ok(scores)
}
🤖 Prompt for AI Agents
In src/pipelines/reranker_pipeline/reranker_pipeline.rs around lines 38 to 45,
the get_scores method is marked async but calls a synchronous rerank method
without awaiting and performs no async operations. To fix this, remove the async
keyword from the get_scores method signature and adjust its return type to a
synchronous Result, since no asynchronous code is used inside the method.

Comment on lines +21 to 23
pub async fn rerank(&self, query: &str, documents: &[&str]) -> anyhow::Result<Vec<RerankResult>> {
self.model.rerank(&self.tokenizer, query, documents)
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix async consistency issue.

The method is marked as async but calls a synchronous trait method without .await. This creates unnecessary overhead and is misleading to users.

Either make the trait method async or remove the async from the pipeline method:

-    pub async fn rerank(&self, query: &str, documents: &[&str]) -> anyhow::Result<Vec<RerankResult>> {
+    pub fn rerank(&self, query: &str, documents: &[&str]) -> anyhow::Result<Vec<RerankResult>> {

If you choose to keep async, ensure the trait method is also async and add .await.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
pub async fn rerank(&self, query: &str, documents: &[&str]) -> anyhow::Result<Vec<RerankResult>> {
self.model.rerank(&self.tokenizer, query, documents)
}
pub fn rerank(&self, query: &str, documents: &[&str]) -> anyhow::Result<Vec<RerankResult>> {
self.model.rerank(&self.tokenizer, query, documents)
}
🤖 Prompt for AI Agents
In src/pipelines/reranker_pipeline/reranker_pipeline.rs around lines 21 to 23,
the rerank method is marked async but calls a synchronous trait method without
awaiting, causing misleading async usage. To fix this, either remove the async
keyword from the rerank method if the trait method is synchronous, or update the
trait method to be async and add .await to the call inside rerank to maintain
async consistency.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
examples/reranker.rs (1)

36-43: LGTM: Embedding generation is correct for the example.

The sequential processing is appropriate for a small corpus. The mixed error handling (expect() vs ?) is acceptable for an example but could be made consistent.

Consider using consistent error handling:

-        .map(|doc| embed_pipe.embed(doc).expect("embedding failed"))
+        .map(|doc| embed_pipe.embed(doc))
+        .collect::<Result<Vec<_>, _>>()?;
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4292569 and c18a0d3.

📒 Files selected for processing (3)
  • Cargo.toml (1 hunks)
  • examples/reranker.rs (2 hunks)
  • test_reranker.rs (0 hunks)
💤 Files with no reviewable changes (1)
  • test_reranker.rs
🧰 Additional context used
🧬 Code Graph Analysis (1)
examples/reranker.rs (1)
src/pipelines/reranker_pipeline/builder.rs (1)
  • qwen3 (50-52)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Run Tests Development
🔇 Additional comments (7)
Cargo.toml (1)

30-30: LGTM: Dependency update supports async refactoring.

The version bump and tokio feature addition are appropriate for the async pipeline refactoring described in the PR objectives.

examples/reranker.rs (6)

2-4: LGTM: Import additions support the two-stage retrieval approach.

The new imports for Qwen3Size, EmbeddingPipelineBuilder, and RerankPipelineBuilder are appropriate for the enhanced example that demonstrates both embedding and reranking pipelines.


6-11: LGTM: Cosine similarity implementation is mathematically correct.

The implementation follows the standard cosine similarity formula. Note that zero vectors would cause division by zero, but this is acceptable for an example with real embeddings.


15-24: LGTM: Pipeline building demonstrates the new async API correctly.

The async pipeline building with proper error handling and consistent model sizing (0.6B for both embedding and reranking) follows good practices.


45-63: LGTM: ANN recall stage implements proper similarity-based candidate selection.

The cosine similarity computation, sorting (descending), and top-k selection correctly implement the first stage of the two-stage retrieval pipeline.


65-76: LGTM: Reranking stage correctly uses the new async API.

The async rerank call and result handling demonstrate proper usage of the updated RerankResult structure. The index referencing of candidate documents is correct.


1-79: Excellent example enhancement demonstrating production-ready patterns.

The refactoring from direct reranking to a two-stage approach (embedding recall + reranking) is a significant improvement that:

  1. Demonstrates realistic usage: ANN recall followed by precise reranking is a common production pattern
  2. Shows API evolution: Proper usage of the new async pipeline APIs and RerankResult structure
  3. Provides educational value: Clear separation of concerns and informative output

This example effectively showcases the enhanced reranker API capabilities.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
examples/reranker/main.rs (1)

78-81: Consider adding error handling for individual embedding failures.

The current implementation uses expect() which will panic if any single document fails to embed. Consider using proper error handling to make the example more robust.

-    let doc_embeddings: Vec<Vec<f32>> = documents
-        .iter()
-        .map(|doc| embed_pipe.embed(doc).expect("embedding failed"))
-        .collect();
+    let doc_embeddings: Result<Vec<Vec<f32>>> = documents
+        .iter()
+        .map(|doc| embed_pipe.embed(doc))
+        .collect();
+    let doc_embeddings = doc_embeddings?;
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d67d639 and ba1fdb5.

📒 Files selected for processing (7)
  • examples/reranker.rs (0 hunks)
  • examples/reranker/corpus/machine_learning_doc.txt (1 hunks)
  • examples/reranker/corpus/math_doc.txt (1 hunks)
  • examples/reranker/corpus/misc_doc.txt (1 hunks)
  • examples/reranker/corpus/physics_doc.txt (1 hunks)
  • examples/reranker/main.rs (1 hunks)
  • src/models/implementations/qwen3_embeddings.rs (5 hunks)
💤 Files with no reviewable changes (1)
  • examples/reranker.rs
✅ Files skipped from review due to trivial changes (1)
  • examples/reranker/corpus/machine_learning_doc.txt
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/models/implementations/qwen3_embeddings.rs
🧰 Additional context used
🪛 LanguageTool
examples/reranker/corpus/math_doc.txt

[uncategorized] ~1-~1: A comma might be missing here.
Context: ...nships and solving problems across many fields including science, engineering, economi...

(AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)

examples/reranker/corpus/misc_doc.txt

[uncategorized] ~3-~3: Possible missing comma found.
Context: ...aking requires precise measurements and timing since it relies on chemical reactions b...

(AI_HYDRA_LEO_MISSING_COMMA)


[uncategorized] ~5-~5: You might be missing the article “the” here.
Context: ...ns are driven by the unequal heating of Earth's surface by the sun. Air masses with d...

(AI_EN_LECTOR_MISSING_DETERMINER_THE)


[uncategorized] ~5-~5: If this is a compound adjective that modifies the following noun, use a hyphen.
Context: ...ate various weather phenomena. High and low pressure systems move across the globe, bringing...

(EN_COMPOUND_ADJECTIVE_INTERNAL)


[style] ~11-~11: This phrase is redundant. Consider writing “moments” or “times”.
Context: ...ture generations. Photography captures moments in time and allows creative expression through ...

(MOMENT_IN_TIME)

examples/reranker/corpus/physics_doc.txt

[uncategorized] ~3-~3: Possible missing comma found.
Context: ...erything from car engines to spacecraft trajectories and remain accurate for everyday-scale ...

(AI_HYDRA_LEO_MISSING_COMMA)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Run Tests Development
🔇 Additional comments (8)
examples/reranker/corpus/math_doc.txt (1)

1-14: Well-structured educational content for reranking corpus.

The mathematics document provides comprehensive coverage of key mathematical disciplines with clear, accurate descriptions. The content is well-suited for use as corpus material in the reranking pipeline example.

examples/reranker/corpus/physics_doc.txt (1)

1-14: Comprehensive physics overview suitable for corpus use.

The physics document covers fundamental concepts from classical mechanics to modern physics with accurate descriptions. The content provides good diversity for testing reranking capabilities across different physics topics.

examples/reranker/corpus/misc_doc.txt (1)

1-14: Diverse topic coverage enhances corpus variety.

The miscellaneous document provides excellent topical diversity covering cooking, weather, gardening, travel, photography, and music theory. This variety will help test the reranking pipeline's ability to handle different domains effectively.

examples/reranker/main.rs (5)

9-14: Cosine similarity implementation is correct.

The cosine similarity function properly computes dot product and norms, handling the mathematical formula correctly for vector similarity comparison.


21-29: Pipeline building demonstrates the new async API well.

The builder pattern usage for both embedding and reranking pipelines is clean and follows the expected async initialization pattern. The CPU configuration is appropriate for the example.


40-71: Robust corpus loading with appropriate fallback.

The corpus loading logic handles both file-based and fallback scenarios well. The error handling for directory reading and file operations is appropriate, and the fallback to hardcoded examples ensures the demo works even without corpus files.


130-130: Async reranking usage follows the new API correctly.

The reranking call properly uses the async interface and demonstrates the expected usage pattern with the new RerankResult type.


133-141: Result display properly uses the new RerankResult structure.

The display logic correctly accesses the score and index fields from the RerankResult struct, demonstrating proper usage of the new API.

@ljt019 ljt019 merged commit 6573036 into dev Jul 7, 2025
1 of 2 checks passed
@ljt019 ljt019 deleted the analyze-reranking-pipeline-api-for-improvements branch July 7, 2025 19:53
@coderabbitai coderabbitai bot mentioned this pull request Jul 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants