/ Модель

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

Контекст
1 024 000 токенов
Параметры
6,4 млрд
Размер весов
14,9 ГБ
Лицензия
CC BY-NC-SA 4.0
Архитектура
mistral · dense
Библиотека
transformers
Опубликована
19 авг 2025

ctxl-rerank-v2-instruct-multilingual-6b

Генерация текстаТекст → текст8 профессий

Многоязычный инструкционный реранкер Contextual AI оценивает и упорядочивает документы по релевантности запросу с учётом заданных критериев.

439скачиваний за 30 дней19лайковвеса обновлены24 апр 2026

Бенчмарки

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

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

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

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

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

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

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

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

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

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

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

В подключённых источниках результатов для этой модели пока нет.

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

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

Contextual AI разработала ctxl-rerank-v2-instruct-multilingual-6b — плотную модель на архитектуре Mistral с 6,4 млрд параметров для ранжирования текстов. Она оценивает релевантность документов запросу и умеет учитывать пользовательские инструкции, например отдавать приоритет более свежим сведениям или разрешать противоречия между результатами поиска. Модель рассчитана на мультиязычный поиск более чем на 100 языках и сценарии поиска товаров и рекомендаций.

Модель принимает запрос, документ и, при необходимости, инструкцию; выдаёт оценку релевантности, где более высокий балл означает более подходящий документ. README указывает контекст до 32 тысяч токенов, тогда как метаданные Hugging Face заявляют нативный контекст в 1 024 000 токенов; фактический поддерживаемый размер зависит от реализации и конфигурации. В карточке также описаны применение для ответов на вопросы и результаты на BEIR, однако это остаётся моделью ранжирования, а не генератором ответов. Лицензия CC BY-NC-SA 4.0 допускает использование на её условиях, включая ограничения на коммерческое применение.

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

  • переранжирование результатов поиска по пользовательскому запросу
  • приоритизация свежих документов в поисковой выдаче
  • ранжирование документов с противоречащими сведениями
  • многоязычный поиск по коллекции документов
  • ранжирование товаров и рекомендаций

Ограничения

README указывает контекст до 32 тысяч токенов, а метаданные — 1 024 000; это расхождение требует проверки для конкретной реализации. Лицензия CC BY-NC-SA 4.0 ограничивает коммерческое использование.

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

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

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

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

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

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

Открыть на Hugging Face

Contextual AI Reranker v2 6B

Blog Post Hugging Face Collection

Highlights

Contextual AI's reranker is the first instruction-following reranker capable of handling retrieval conflicts and ranking with custom instructions (e.g., prioritizing recent information). It achieves state-of-the-art performance on BEIR and sits on the cost/performance Pareto frontier across:

  • Instruction following
  • Question answering
  • Multilinguality (100+ languages)
  • Product search & recommendation
  • Real-world use cases

For detailed benchmarks, see our blog post.

Overview

  • Model Type: Text Reranking
  • Supported Languages: 100+
  • Parameters: 6B
  • Context Length: up to 32K

When to Use This Model

Use this reranker when you need to:

  • Re-rank retrieved documents with custom instructions
  • Handle conflicting information in retrieval results
  • Prioritize documents by recency or other criteria
  • Support multilingual search (100+ languages)
  • Process long contexts (up to 32K tokens)

Quickstart

Each path below uses the same example inputs:

Query: What are the health benefits of exercise?
Instruction: Prioritize recent medical research
Documents:
  - Regular exercise reduces risk of heart disease and improves mental health.
  - A 2024 study shows exercise enhances cognitive function in older adults.
  - Ancient Greeks valued physical fitness for military training.

Expected Output:

Score: -2.2969 | Doc: A 2024 study shows exercise enhances cognitive function in older adults.
Score: -4.6875 | Doc: Regular exercise reduces risk of heart disease and improves mental health.
Score: -12.3750 | Doc: Ancient Greeks valued physical fitness for military training.

Using Sentence Transformers

Install Sentence Transformers:

pip install sentence_transformers
import torch
from sentence_transformers import CrossEncoder

model = CrossEncoder("ContextualAI/ctxl-rerank-v2-instruct-multilingual-6b", model_kwargs={"dtype": torch.bfloat16})

query = "What are the health benefits of exercise?"
instruction = "Prioritize recent medical research"
documents = [
    "Regular exercise reduces risk of heart disease and improves mental health.",
    "A 2024 study shows exercise enhances cognitive function in older adults.",
    "Ancient Greeks valued physical fitness for military training.",
]

pairs = [(query, doc) for doc in documents]
scores = model.predict(pairs, prompt=instruction)
print(scores)
# [ -4.6875   -2.171875 -12.4375  ]

rankings = model.rank(query, documents, prompt=instruction)
print(rankings)
# [{'corpus_id': 1, 'score': np.float32(-2.171875)}, {'corpus_id': 0, 'score': np.float32(-4.6875)}, {'corpus_id': 2, 'score': np.float32(-12.4375)}]

The prompt argument is optional, you can omit it to score pairs without any custom instruction. Scores are the raw bfloat16 logits at token id 0 at the final position (matching the Transformers path below), so higher means more relevant.

vLLM Usage (Recommended for Production)

Requires vllm==0.10.0 for NVFP4 or vllm>=0.8.5 for BF16.

import os
os.environ['VLLM_USE_V1'] = '0'  # v1 engine doesn't support logits processor yet

import torch
from vllm import LLM, SamplingParams


def logits_processor(_, scores):
    """Custom logits processor for vLLM reranking."""
    index = scores[0].view(torch.uint16)
    scores = torch.full_like(scores, float("-inf"))
    scores[index] = 1
    return scores


def format_prompts(query: str, instruction: str, documents: list[str]) -> list[str]:
    """Format query and documents into prompts for reranking."""
    if instruction:
        instruction = f" {instruction}"
    prompts = []
    for doc in documents:
        prompt = f"Check whether a given document contains information helpful to answer the query.\n<Document> {doc}\n<Query> {query}{instruction} ??"
        prompts.append(prompt)
    return prompts


def infer_w_vllm(model_path: str, query: str, instruction: str, documents: list[str]):
    model = LLM(
        model=model_path,
        gpu_memory_utilization=0.85,
        max_model_len=8192,
        dtype="bfloat16",
        max_logprobs=2,
        max_num_batched_tokens=262144,
    )
    sampling_params = SamplingParams(
        temperature=0,
        max_tokens=1,
        logits_processors=[logits_processor]
    )
    prompts = format_prompts(query, instruction, documents)

    outputs = model.generate(prompts, sampling_params, use_tqdm=False)

    # Extract scores and create results
    results = []
    for i, output in enumerate(outputs):
        score = (
            torch.tensor([output.outputs[0].token_ids[0]], dtype=torch.uint16)
            .view(torch.bfloat16)
            .item()
        )    
        results.append((score, i, documents[i]))

    # Sort by score (descending)
    results = sorted(results, key=lambda x: x[0], reverse=True)

    print(f"Query: {query}")
    print(f"Instruction: {instruction}")
    for score, doc_id, doc in results:
        print(f"Score: {score:.4f} | Doc: {doc}")


# Example usage
if __name__ == "__main__":
    model_path = "ContextualAI/reranker_v2_6b"
    query = "What are the health benefits of exercise?"
    instruction = "Prioritize recent medical research"
    documents = [
        "Regular exercise reduces risk of heart disease and improves mental health.",
        "A 2024 study shows exercise enhances cognitive function in older adults.",
        "Ancient Greeks valued physical fitness for military training."
    ]
    
    infer_w_vllm(model_path, query, instruction, documents)

Transformers Usage (Simpler Setup)

Requires transformers>=4.51.0 for BF16. Not supported for NVFP4.

import torch
from transformers import AutoTokenizer, AutoModelForCausalLM


def format_prompts(query: str, instruction: str, documents: list[str]) -> list[str]:
    """Format query and documents into prompts for reranking."""
    if instruction:
        instruction = f" {instruction}"
    prompts = []
    for doc in documents:
        prompt = f"Check whether a given document contains information helpful to answer the query.\n<Document> {doc}\n<Query> {query}{instruction} ??"
        prompts.append(prompt)
    return prompts


def infer_w_hf(model_path: str, query: str, instruction: str, documents: list[str]):
    device = "cuda" if torch.cuda.is_available() else "cpu"
    dtype = torch.bfloat16 if torch.cuda.is_available() else torch.float32

    tokenizer = AutoTokenizer.from_pretrained(model_path, use_fast=True)
    if tokenizer.pad_token is None:
        tokenizer.pad_token = tokenizer.eos_token
    tokenizer.padding_side = "left"  # so -1 is the real last token for all prompts

    model = AutoModelForCausalLM.from_pretrained(model_path, torch_dtype=dtype).to(device)
    model.eval()

    prompts = format_prompts(query, instruction, documents)
    enc = tokenizer(
        prompts,
        return_tensors="pt",
        padding=True,
        truncation=True,
    )
    input_ids = enc["input_ids"].to(device)
    attention_mask = enc["attention_mask"].to(device)

    with torch.no_grad():
        out = model(input_ids=input_ids, attention_mask=attention_mask)

    next_logits = out.logits[:, -1, :]  # [batch, vocab]

    scores_bf16 = next_logits[:, 0].to(torch.bfloat16)
    scores = scores_bf16.float().tolist()

    # Sort by score (descending)
    results = sorted([(s, i, documents[i]) for i, s in enumerate(scores)], key=lambda x: x[0], reverse=True)

    print(f"Query: {query}")
    print(f"Instruction: {instruction}")
    for score, doc_id, doc in results:
        print(f"Score: {score:.4f} | Doc: {doc}")
    """
    Query: What are the health benefits of exercise?
    Instruction: Prioritize recent medical research
    Score: -2.1719 | Doc: A 2024 study shows exercise enhances cognitive function in older adults.
    Score: -4.6875 | Doc: Regular exercise reduces risk of heart disease and improves mental health.
    Score: -12.4375 | Doc: Ancient Greeks valued physical fitness for military training.
    """

Citation

If you use this model, please cite:

@misc{ctxl_rerank_v2_instruct_multilingual,
      title={Contextual AI Reranker v2}, 
      author={Halal, George and Agrawal, Sheshansh},
      year={2025},
      url={https://contextual.ai/blog/rerank-v2}, 
}

License

Creative Commons Attribution Non Commercial Share Alike 4.0 (cc-by-nc-sa-4.0)

Contact

For questions or issues, please open an issue on the model repository.

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

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

GPU в ailist

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

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

Подбираем GPU…

Класс архитектуры
MistralForCausalLM
Ревизия весов
f14ca1a

0 моделей