cross-encoder/monoelectra-large

🤗 Hugging Face 来源text-rankingapache-2.0334M 参数1.3 GBsafetensors✓ 12 个校验和今天更新
一条命令提交

在你的模型文件夹旁边运行它。它会制作种子、将文件与 Hugging Face 比对,然后提交。你只需开始做种,并粘贴你账户中的密钥。它只读取你的文件,绝不修改。如果愿意,可以先阅读脚本。

curl -fsSL https://pirateface.co/package.sh | bash -s -- --repo cross-encoder/monoelectra-large ./model-folder
需要做种者 →

Cross-Encoder for Text Ranking

This model is a port of the webis/monoelectra-large model from lightning-ir to Sentence Transformers and Transformers.

The original model was introduced in the paper A Systematic Investigation of Distilling Large Language Models into Cross-Encoders for Passage Re-ranking. See https://github.com/webis-de/rank-distillm for code used to train the original model.

The model can be used as a reranker in a 2-stage "retrieve-rerank" pipeline, where it reorders passages returned by a retriever model (e.g. an embedding model or BM25) given some query. See SBERT.net Retrieve & Re-rank for more details.

Usage with Sentence Transformers

The usage is easy when you have SentenceTransformers installed.

pip install sentence-transformers

Then you can use the pre-trained model like this:

from sentence_transformers import CrossEncoder

model = CrossEncoder("cross-encoder/monoelectra-large", trust_remote_code=True)
scores = model.predict([
    ("How many people live in Berlin?", "Berlin had a population of 3,520,031 registered inhabitants in an area of 891.82 square kilometers."),
    ("How many people live in Berlin?", "Berlin is well known for its museums."),
])
print(scores)
# [ 6.016401  -3.6922567]

Usage with Transformers

from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch

model = AutoModelForSequenceClassification.from_pretrained("cross-encoder/monoelectra-large", trust_remote_code=True)
tokenizer = AutoTokenizer.from_pretrained("cross-encoder/monoelectra-large")

features = tokenizer(
    [
        ("How many people live in Berlin?", "Berlin had a population of 3,520,031 registered inhabitants in an area of 891.82 square kilometers."),
        ("How many people live in Berlin?", "Berlin is well known for its museums."),
    ],
    padding=True,
    truncation=True,
    return_tensors="pt",
)

model.eval()
with torch.no_grad():
    scores = model(**features).logits.view(-1)
print(scores)
# tensor([ 6.0164, -3.6923])