Skip to content

Conversation

@joein
Copy link
Member

@joein joein commented Feb 25, 2025

No description provided.

@coderabbitai
Copy link

coderabbitai bot commented Feb 25, 2025

📝 Walkthrough

Walkthrough

This pull request introduces the ability to extend dense text embeddings with custom models and support for late interaction multimodal tasks. The TextEmbedding class now includes an add_custom_model method for registering custom models, and a new LateInteractionMultimodalEmbedding class has been added. In addition, updates to the late interaction multimodal pipeline modify how ONNX inputs are prepared—using pixel_values rather than text-based placeholders—with a repositioned tokenizer assertion and the removal of an auxiliary input-building method. Documentation and code examples have been updated accordingly.

Changes

File(s) Change Summary
README.md, fastembed.py Added add_custom_model method in TextEmbedding and new LateInteractionMultimodalEmbedding class. Documentation now includes examples for custom model registration and multimodal embedding.
fastembed/.../colpali.py Modified _preprocess_onnx_image_input to replace input_ids/attention_mask with pixel_values for placeholder generation based on pixel length.
fastembed/.../onnx_multimodal_model.py Repositioned the tokenizer assertion after loading, removed _build_onnx_image_input, and now directly constructs the ONNX input dictionary using pixel_values.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant TE as TextEmbedding
    participant LI as LateInteractionMultimodalEmbedding
    participant ONNX as OnnxMultimodalModel

    U->>TE: Call add_custom_model(custom_model, pooling, normalization, sources, dim, model_file)
    U->>LI: Request multimodal embedding (text & image)
    LI->>TE: Process text embedding
    LI->>ONNX: Prepare image input using pixel_values
    ONNX->>ONNX: Assert tokenizer and create onnx_input
    LI->>U: Return combined embedding result
Loading
✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

🪧 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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. (Beta)
  • @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.

@joein joein requested review from I8dNLo and generall February 25, 2025 00:03
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)
README.md (1)

157-176: Consider clarifying example image paths.

The example effectively demonstrates the usage of late interaction multimodal models. However, the image paths used in the example (./path/to/qdrant_pdf_doc_1_screenshot.jpg) might be confusing.

Consider using more realistic example paths or adding a comment to clarify that these are placeholder paths:

 doc_images = [
-    "./path/to/qdrant_pdf_doc_1_screenshot.jpg",
-    "./path/to/colpali_pdf_doc_2_screenshot.jpg",
+    # Replace with actual image paths
+    "./examples/qdrant_doc.jpg",
+    "./examples/colpali_doc.jpg",
 ]
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 58ee7cc and b8eb703.

📒 Files selected for processing (3)
  • README.md (2 hunks)
  • fastembed/late_interaction_multimodal/colpali.py (1 hunks)
  • fastembed/late_interaction_multimodal/onnx_multimodal_model.py (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (16)
  • GitHub Check: Python 3.13.x on windows-latest test
  • GitHub Check: Python 3.13.x on macos-latest test
  • GitHub Check: Python 3.13.x on ubuntu-latest test
  • GitHub Check: Python 3.12.x on windows-latest test
  • GitHub Check: Python 3.12.x on macos-latest test
  • GitHub Check: Python 3.12.x on ubuntu-latest test
  • GitHub Check: Python 3.11.x on windows-latest test
  • GitHub Check: Python 3.11.x on macos-latest test
  • GitHub Check: Python 3.11.x on ubuntu-latest test
  • GitHub Check: Python 3.10.x on windows-latest test
  • GitHub Check: Python 3.10.x on macos-latest test
  • GitHub Check: Python 3.10.x on ubuntu-latest test
  • GitHub Check: Python 3.9.x on windows-latest test
  • GitHub Check: Python 3.9.x on macos-latest test
  • GitHub Check: Python 3.9.x on ubuntu-latest test
  • GitHub Check: Python 3.13 test
🔇 Additional comments (4)
fastembed/late_interaction_multimodal/colpali.py (1)

200-205: LGTM! Fixed placeholder generation based on pixel values.

The changes correctly modify the placeholder generation to use pixel_values instead of input_ids, which aligns with the expected input structure for image processing.

fastembed/late_interaction_multimodal/onnx_multimodal_model.py (2)

77-77: LGTM! Added early validation for tokenizer initialization.

The assertion ensures that the tokenizer is properly initialized before it's used, preventing potential null pointer issues.


170-170: LGTM! Simplified image input handling.

The code now directly uses pixel_values as the key for encoded image data, making the input structure clearer and more consistent.

README.md (1)

66-82: LGTM! Clear example for extending dense text embeddings.

The example clearly demonstrates how to add custom models with specific parameters.

@joein joein merged commit 5bd5c0a into main Feb 26, 2025
23 checks passed
@joein joein deleted the readme-examples-0.6.0 branch February 26, 2025 11:51
@coderabbitai coderabbitai bot mentioned this pull request Mar 16, 2025
@coderabbitai coderabbitai bot mentioned this pull request Jan 2, 2026
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants