-
Notifications
You must be signed in to change notification settings - Fork 652
model: add nemotron rerank #3750
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
Changes from 7 commits
8648438
711ccaa
4a2bd2c
01e6334
9626efd
ba013ef
f3d00e1
00f1132
edf3362
c105e3c
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 |
|---|---|---|
|
|
@@ -9,8 +9,9 @@ | |
| from transformers import AutoModel, AutoTokenizer | ||
| from transformers import __version__ as transformers_version | ||
|
|
||
| from mteb import TaskMetadata | ||
| from mteb._requires_package import requires_package | ||
| from mteb.abstasks.task_metadata import TaskMetadata | ||
| from mteb.models import CrossEncoderWrapper | ||
| from mteb.models.abs_encoder import AbsEncoder | ||
| from mteb.models.instruct_wrapper import InstructSentenceTransformerModel | ||
| from mteb.models.model_meta import ModelMeta, ScoringFunction | ||
|
|
@@ -550,3 +551,55 @@ def _extract_embeddings( | |
| contacts=["ybabakhin"], | ||
| citation=NV_RETRIEVER_CITATION, | ||
| ) | ||
|
|
||
|
|
||
| def _nemotron_rerank_model(model: str, revision: str, **kwargs) -> CrossEncoderWrapper: | ||
| required_transformers_version = "4.47.1" | ||
|
|
||
| if Version(transformers_version) != Version(required_transformers_version): | ||
| raise RuntimeError( | ||
| f"transformers version {transformers_version} is not match with required " | ||
| f"install version {required_transformers_version} to run `nvidia/NV-Embed-v2`" | ||
|
Samoed marked this conversation as resolved.
Outdated
|
||
| ) | ||
|
|
||
| return CrossEncoderWrapper( | ||
| model=model, | ||
| revision=revision, | ||
| **kwargs, | ||
| ) | ||
|
|
||
|
|
||
| nemotron_rerank_1b_v2 = ModelMeta( | ||
| loader=_nemotron_rerank_model, | ||
| loader_kwargs=dict( | ||
| trust_remote_code=True, | ||
| query_prefix="question:", | ||
| passage_prefix=" \n \n passage:", | ||
| model_kwargs={"torch_dtype": torch.bfloat16}, | ||
|
Contributor
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. I would either change dtype to cc: @tomaarsen I did a run on FIQA, here are the metrics and one sample result for each setup:
Member
Author
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. Changed to fp32. I just not sure that passing
Member
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. Perhaps the model config could also be updated if you prefer Identity? Then it'll always be loaded with that. I'm also open to changing the default activation function on Sentence Transformers, as that
Contributor
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.
Will look into this |
||
| ), | ||
| name="nvidia/llama-nemotron-rerank-1b-v2", | ||
| revision="78efcfdc23b53a753f6c73f2d78b18132a34ac4d", | ||
| release_date="2025-10-16", | ||
| languages=["eng-Latn"], | ||
| n_parameters=1235816448, | ||
| memory_usage_mb=2357.0, | ||
| max_tokens=4096, | ||
| embed_dim=2048, | ||
| license="https://www.nvidia.com/en-us/agreements/enterprise-software/nvidia-open-model-license/", | ||
| open_weights=True, | ||
| public_training_code=None, | ||
| public_training_data=None, | ||
| framework=["PyTorch", "Sentence Transformers"], | ||
| reference="https://huggingface.co/nvidia/llama-nemotron-rerank-1b-v2", | ||
| similarity_fn_name=ScoringFunction.COSINE, | ||
| use_instructions=None, | ||
| training_datasets=set( | ||
| # private | ||
| ), | ||
| adapted_from="meta-llama/Llama-3.2-1B", | ||
| superseded_by=None, | ||
| modalities=["text"], | ||
| is_cross_encoder=True, | ||
| citation=None, | ||
| contacts=None, | ||
| ) | ||
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.
Where is this function used?
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 is loader function for
nvidia/llama-nemotron-rerank-1b-v2mteb/mteb/models/model_implementations/nvidia_models.py
Lines 569 to 571 in 01e6334