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.
from sentence_transformers import CrossEncoder
model = CrossEncoder("cross-encoder/monoelectra-base", 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)
# [ 8.122868 -4.292924]
Usage with Transformers
from transformers import AutoTokenizer, AutoModelForSequenceClassification
import torch
model = AutoModelForSequenceClassification.from_pretrained("cross-encoder/monoelectra-base", trust_remote_code=True)
tokenizer = AutoTokenizer.from_pretrained("cross-encoder/monoelectra-base")
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([ 8.1229, -4.2929])
Runs of cross-encoder monoelectra-base on huggingface.co
122
Total runs
0
24-hour runs
8
3-day runs
13
7-day runs
91
30-day runs
More Information About monoelectra-base huggingface.co Model
monoelectra-base huggingface.co is an AI model on huggingface.co that provides monoelectra-base's model effect (), which can be used instantly with this cross-encoder monoelectra-base model. huggingface.co supports a free trial of the monoelectra-base model, and also provides paid use of the monoelectra-base. Support call monoelectra-base model through api, including Node.js, Python, http.
monoelectra-base huggingface.co is an online trial and call api platform, which integrates monoelectra-base's modeling effects, including api services, and provides a free online trial of monoelectra-base, you can try monoelectra-base online for free by clicking the link below.
cross-encoder monoelectra-base online free url in huggingface.co:
monoelectra-base is an open source model from GitHub that offers a free installation service, and any user can find monoelectra-base on GitHub to install. At the same time, huggingface.co provides the effect of monoelectra-base install, users can directly use monoelectra-base installed effect in huggingface.co for debugging and trial. It also supports api for free installation.