/ Модель

Характеристики

Размер весов
15,7 ГБ
Лицензия
CC BY-NC 4.0
Архитектура
nvembed · dense
Библиотека
transformers
Опубликована
29 авг 2024

NV-Embed-v2

ЭмбеддингиТекст → embedding10 профессий

NV-Embed-v2 — текстовая модель NVIDIA, создающая эмбеддинги для семантического поиска, сравнения текстов и RAG.

142 тыс.скачиваний за 30 дней521лайквеса обновлены21 июл 2025

Бенчмарки

Как модель справилась с задачами пользователей ailist и что о ней публикуют открытые лидерборды

Тесты пользователейпока нет

Никто ещё не опубликовал тест этой модели. Соберите бенчмарк из своих задач — результат появится здесь.

  1. Добавьте модель в бенчмарк

    Вместе с другими моделями категории «Эмбеддинги» — сравнение идёт внутри одной категории.

  2. Опишите свои задачи

    Напишите запросы, при необходимости приложите файлы и эталонные ответы.

  3. Запустите и опубликуйте

    Модели ответят на каждую задачу, судья оценит ответы. Опубликованный результат появится на этой странице.

Публичные оценки32

Из открытых лидербордов. Сравнивайте результаты одного теста при одинаковых условиях — отсутствие оценки не значит, что модель хуже.

  • SwahiliNewsClassification

    main_score

    Результат

    0,5855

    MTEB

    Публичная таблицадругая ревизия

  • MassiveIntentClassification

    main_score

    Результат

    0,6109

    Общий результат 0,5309
    MTEB

    Публичная таблицадругая ревизия

  • XQuADRetrieval

    main_score

    Результат

    0,972

    Общий результат 0,8715
    MTEB

    Публичная таблицадругая ревизия

  • PawsXPairClassification

    main_score

    Результат

    0,4766

    MTEB

    Публичная таблицадругая ревизия

  • STSBenchmarkMultilingualSTS

    main_score

    Результат

    0,8554

    Общий результат 0,8343Общий результат 0,8214
    MTEB

    Публичная таблицадругая ревизия

  • MasakhaNEWSClusteringS2S

    main_score

    Результат

    0,4965

    Общий результат 0,1577
    MTEB

    Публичная таблицадругая ревизия

  • MIRACLRetrievalHardNegatives

    main_score

    Результат

    0,5361

    MTEB

    Публичная таблицадругая ревизия

  • EPBench

    main_score

    Результат

    1

    MTEB

    Публичная таблицадругая ревизия

  • MLQARetrieval

    main_score

    Результат

    0,4665

    Общий результат 0,8583Общий результат 0,5384Общий результат 0,4442
    MTEB

    Публичная таблицадругая ревизия

  • AllegroReviews

    main_score

    Результат

    0,4079

    MTEB

    Публичная таблицадругая ревизия

  • MemBench

    main_score

    Результат

    0,4386

    Общий результат 0,8359
    MTEB

    Публичная таблицадругая ревизия

  • CUREv1

    main_score

    Результат

    0,6707

    MTEB

    Публичная таблицадругая ревизия

  • CyrillicTurkicLangClassification

    main_score

    Результат

    0,7022

    MTEB

    Публичная таблицадругая ревизия

  • Tatoeba

    main_score

    Результат

    0,8883

    Общий результат 0,7376Общий результат 0,3111
    MTEB

    Публичная таблицадругая ревизия

  • IndicGenBenchFloresBitextMining

    main_score

    Результат

    0,8829

    Общий результат 0,9492Общий результат 0,8512Общий результат 0,5597
    MTEB

    Публичная таблицадругая ревизия

  • IndicCrosslingualSTS

    main_score

    Результат

    0,0796

    MTEB

    Публичная таблицадругая ревизия

  • SemRel24STS

    main_score

    Результат

    0,7073

    MTEB

    Публичная таблицадругая ревизия

  • WebLINXCandidatesReranking

    main_score

    Результат

    0,0896

    MTEB

    Публичная таблицадругая ревизия

  • MemGovern

    main_score

    Результат

    0,8595

    Общий результат 0,9845Общий результат 0,9177
    MTEB

    Публичная таблицадругая ревизия

  • REALTALK

    main_score

    Результат

    0,3777

    MTEB

    Публичная таблицадругая ревизия

  • JapaneseCode1Retrieval

    main_score

    Результат

    0,7982

    MTEB

    Публичная таблицадругая ревизия

  • MultiEURLEXMultilabelClassification

    main_score

    Результат

    0,0191

    MTEB

    Публичная таблицадругая ревизия

  • HotpotQAHardNegatives

    main_score

    Результат

    0,8383

    MTEB

    Публичная таблицадругая ревизия

  • WikiClusteringP2P.v2

    main_score

    Результат

    0,3758

    MTEB

    Публичная таблицадругая ревизия

  • ReMe

    main_score

    Результат

    0,5856

    MTEB

    Публичная таблицадругая ревизия

  • ArXivHierarchicalClusteringS2S

    main_score

    Результат

    0,5924

    MTEB

    Публичная таблицадругая ревизия

  • CDSC-R

    main_score

    Результат

    0,9112

    MTEB

    Публичная таблицадругая ревизия

  • MassiveScenarioClassification

    main_score

    Результат

    0,7697

    Общий результат 0,5658
    MTEB

    Публичная таблицадругая ревизия

  • StatcanDialogueDatasetRetrieval

    main_score

    Результат

    0,3033

    MTEB

    Публичная таблицадругая ревизия

  • HC3FinanceRetrieval

    main_score

    Результат

    0,8242

    MTEB

    Публичная таблицадругая ревизия

  • KnowMeBench

    main_score

    Результат

    0,6912

    MTEB

    Публичная таблицадругая ревизия

  • MTOPDomainClassification

    main_score

    Результат

    0,9095

    MTEB

    Публичная таблицадругая ревизия

Что умеет модель

Описание составлено по карточке модели и метаданным Hugging Face

NV-Embed-v2 — модель эмбеддингов общего назначения, разработанная NVIDIA на основе Mistral-7B-v0.1. Она преобразует текстовые запросы и документы в векторы размерностью 4096 для поиска, сравнения смысловой близости и других задач работы с текстовыми представлениями.

Модель использует decoder-only архитектуру и pooling на основе latent attention. По данным авторов, она заняла первое место в MTEB на момент публикации карточки, включая подкатегорию поиска; разработчики также описывают двухэтапную настройку по инструкциям и подбор сложных негативных примеров. Для бенчмарков и сходных задач важно применять рекомендованные авторами инструкции-префиксы.

NV-Embed-v2 предназначена для текстовых сценариев, включая семантический поиск и подбор контекста для RAG. Карточка указывает лицензию CC BY-NC 4.0, которая ограничивает коммерческое использование без отдельного разрешения.

Сценарии применения

  • семантический поиск по коллекции документов
  • подбор контекста для RAG-системы
  • поиск релевантных фрагментов по запросу
  • сравнение смысловой близости текстов
  • кластеризация текстов по смыслу
  • классификация текстов по эмбеддингам

Ограничения

Для воспроизводимых результатов на задачах бенчмарка нужно соблюдать рекомендованные инструкции-префиксы; реализация Sentence Transformers может давать небольшое расхождение результатов. Лицензия CC BY-NC 4.0 ограничивает коммерческое использование без отдельного разрешения.

Для каких профессий подходит10

Разделы каталога профессий, в задачах которых используется эта модель

Все профессии

Также подходит для

Карточка модели

README от автора на Hugging Face, как он его опубликовал

Открыть на Hugging Face

Introduction

We present NV-Embed-v2, a generalist embedding model that ranks No. 1 on the Massive Text Embedding Benchmark (MTEB benchmark)(as of Aug 30, 2024) with a score of 72.31 across 56 text embedding tasks. It also holds the No. 1 in the retrieval sub-category (a score of 62.65 across 15 tasks) in the leaderboard, which is essential to the development of RAG technology.

NV-Embed-v2 presents several new designs, including having the LLM attend to latent vectors for better pooled embedding output, and demonstrating a two-staged instruction tuning method to enhance the accuracy of both retrieval and non-retrieval tasks. Additionally, NV-Embed-v2 incorporates a novel hard-negative mining methods that take into account the positive relevance score for better false negatives removal.

For more technical details, refer to our paper: NV-Embed: Improved Techniques for Training LLMs as Generalist Embedding Models.

Model Details

  • Base Decoder-only LLM: Mistral-7B-v0.1
  • Pooling Type: Latent-Attention
  • Embedding Dimension: 4096

How to use

Here is an example of how to encode queries and passages using Huggingface-transformer and Sentence-transformer. Please find the required package version here.

Usage (HuggingFace Transformers)

import torch
import torch.nn.functional as F
from transformers import AutoTokenizer, AutoModel

# Each query needs to be accompanied by an corresponding instruction describing the task.
task_name_to_instruct = {"example": "Given a question, retrieve passages that answer the question",}

query_prefix = "Instruct: "+task_name_to_instruct["example"]+"\nQuery: "
queries = [
    'are judo throws allowed in wrestling?', 
    'how to become a radiology technician in michigan?'
    ]

# No instruction needed for retrieval passages
passage_prefix = ""
passages = [
    "Since you're reading this, you are probably someone from a judo background or someone who is just wondering how judo techniques can be applied under wrestling rules. So without further ado, let's get to the question. Are Judo throws allowed in wrestling? Yes, judo throws are allowed in freestyle and folkstyle wrestling. You only need to be careful to follow the slam rules when executing judo throws. In wrestling, a slam is lifting and returning an opponent to the mat with unnecessary force.",
    "Below are the basic steps to becoming a radiologic technologist in Michigan:Earn a high school diploma. As with most careers in health care, a high school education is the first step to finding entry-level employment. Taking classes in math and science, such as anatomy, biology, chemistry, physiology, and physics, can help prepare students for their college studies and future careers.Earn an associate degree. Entry-level radiologic positions typically require at least an Associate of Applied Science. Before enrolling in one of these degree programs, students should make sure it has been properly accredited by the Joint Review Committee on Education in Radiologic Technology (JRCERT).Get licensed or certified in the state of Michigan."
]

# load model with tokenizer
model = AutoModel.from_pretrained('nvidia/NV-Embed-v2', trust_remote_code=True)

# get the embeddings
max_length = 32768
query_embeddings = model.encode(queries, instruction=query_prefix, max_length=max_length)
passage_embeddings = model.encode(passages, instruction=passage_prefix, max_length=max_length)

# normalize embeddings
query_embeddings = F.normalize(query_embeddings, p=2, dim=1)
passage_embeddings = F.normalize(passage_embeddings, p=2, dim=1)

# get the embeddings with DataLoader (spliting the datasets into multiple mini-batches)
# batch_size=2
# query_embeddings = model._do_encode(queries, batch_size=batch_size, instruction=query_prefix, max_length=max_length, num_workers=32, return_numpy=True)
# passage_embeddings = model._do_encode(passages, batch_size=batch_size, instruction=passage_prefix, max_length=max_length, num_workers=32, return_numpy=True)

scores = (query_embeddings @ passage_embeddings.T) * 100
print(scores.tolist())
# [[87.42693328857422, 0.46283677220344543], [0.965264618396759, 86.03721618652344]]

Usage (Sentence-Transformers)

import torch
from sentence_transformers import SentenceTransformer

# Each query needs to be accompanied by an corresponding instruction describing the task.
task_name_to_instruct = {"example": "Given a question, retrieve passages that answer the question",}

query_prefix = "Instruct: "+task_name_to_instruct["example"]+"\nQuery: "
queries = [
    'are judo throws allowed in wrestling?', 
    'how to become a radiology technician in michigan?'
    ]

# No instruction needed for retrieval passages
passages = [
    "Since you're reading this, you are probably someone from a judo background or someone who is just wondering how judo techniques can be applied under wrestling rules. So without further ado, let's get to the question. Are Judo throws allowed in wrestling? Yes, judo throws are allowed in freestyle and folkstyle wrestling. You only need to be careful to follow the slam rules when executing judo throws. In wrestling, a slam is lifting and returning an opponent to the mat with unnecessary force.",
    "Below are the basic steps to becoming a radiologic technologist in Michigan:Earn a high school diploma. As with most careers in health care, a high school education is the first step to finding entry-level employment. Taking classes in math and science, such as anatomy, biology, chemistry, physiology, and physics, can help prepare students for their college studies and future careers.Earn an associate degree. Entry-level radiologic positions typically require at least an Associate of Applied Science. Before enrolling in one of these degree programs, students should make sure it has been properly accredited by the Joint Review Committee on Education in Radiologic Technology (JRCERT).Get licensed or certified in the state of Michigan."
]

# load model with tokenizer
model = SentenceTransformer('nvidia/NV-Embed-v2', trust_remote_code=True)
model.max_seq_length = 32768
model.tokenizer.padding_side="right"

def add_eos(input_examples):
  input_examples = [input_example + model.tokenizer.eos_token for input_example in input_examples]
  return input_examples

# get the embeddings
batch_size = 2
query_embeddings = model.encode(add_eos(queries), batch_size=batch_size, prompt=query_prefix, normalize_embeddings=True)
passage_embeddings = model.encode(add_eos(passages), batch_size=batch_size, normalize_embeddings=True)

scores = (query_embeddings @ passage_embeddings.T) * 100
print(scores.tolist())

License

This model should not be used for any commercial purpose. Refer the license for the detailed terms.

For commercial purpose, we recommend you to use the models of NeMo Retriever Microservices (NIMs).

Correspondence to

Chankyu Lee (chankyul@nvidia.com), Rajarshi Roy (rajarshir@nvidia.com), Wei Ping (wping@nvidia.com)

Citation

If you find this code useful in your research, please consider citing:

@article{lee2024nv,
  title={NV-Embed: Improved Techniques for Training LLMs as Generalist Embedding Models},
  author={Lee, Chankyu and Roy, Rajarshi and Xu, Mengyao and Raiman, Jonathan and Shoeybi, Mohammad and Catanzaro, Bryan and Ping, Wei},
  journal={arXiv preprint arXiv:2405.17428},
  year={2024}
}
@article{moreira2024nv,
  title={NV-Retriever: Improving text embedding models with effective hard-negative mining},
  author={Moreira, Gabriel de Souza P and Osmulski, Radek and Xu, Mengyao and Ak, Ronay and Schifferer, Benedikt and Oldridge, Even},
  journal={arXiv preprint arXiv:2407.15831},
  year={2024}
}

Troubleshooting

1. Instruction template for MTEB benchmarks

For MTEB sub-tasks for retrieval, STS, summarization, please use the instruction prefix template in instructions.json. For classification, clustering and reranking, please use the instructions provided in Table. 7 in NV-Embed paper.

2. Required Packages

If you have trouble, try installing the python packages as below

pip uninstall -y transformer-engine
pip install torch==2.2.0
pip install transformers==4.42.4
pip install flash-attn==2.2.0
pip install sentence-transformers==2.7.0

3. How to enable Multi-GPU (Note, this is the case for HuggingFace Transformers)

from transformers import AutoModel
from torch.nn import DataParallel

embedding_model = AutoModel.from_pretrained("nvidia/NV-Embed-v2")
for module_key, module in embedding_model._modules.items():
    embedding_model._modules[module_key] = DataParallel(module)

4. Fixing "nvidia/NV-Embed-v2 is not the path to a directory containing a file named config.json"

Switch to your local model path,and open config.json and change the value of "_name_or_path" and replace it with your local model path.

5. Access to model nvidia/NV-Embed-v2 is restricted. You must be authenticated to access it

Use your huggingface access token to execute "huggingface-cli login".

6. How to resolve slight mismatch in Sentence transformer results.

A slight mismatch in the Sentence Transformer implementation is caused by a discrepancy in the calculation of the instruction prefix length within the Sentence Transformer package.

To fix this issue, you need to build the Sentence Transformer package from source, making the necessary modification in this line as below.

git clone https://github.com/UKPLab/sentence-transformers.git
cd sentence-transformers
git checkout v2.7-release
# Modify L353 in SentenceTransformer.py to **'extra_features["prompt_length"] = tokenized_prompt["input_ids"].shape[-1]'**.
pip install -e .

Как запустить

На своей GPU в ailist. Цена — по текущим предложениям провайдеров

GPU в ailist

Универсальный рантайм · transformers

Можно запустить

Подбираем GPU…

Класс архитектуры
NVEmbedModel
Ревизия весов
3fa5965

0 моделей