Sentence Similarity
Transformers
ONNX
English
xlm-roberta
text-classification
text-embeddings-inference
Run this model with HF Jobs
Run EmbeddedLLM/bge-reranker-base-onnx-o3-cpu on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/EmbeddedLLM/bge-reranker-base-onnx-o3-cpu. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/EmbeddedLLM/bge-reranker-base-onnx-o3-cpu on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use EmbeddedLLM/bge-reranker-base-onnx-o3-cpu with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use EmbeddedLLM/bge-reranker-base-onnx-o3-cpu with Transformers:
# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("EmbeddedLLM/bge-reranker-base-onnx-o3-cpu") model = AutoModelForSequenceClassification.from_pretrained("EmbeddedLLM/bge-reranker-base-onnx-o3-cpu", device_map="auto") - Notebooks
- Google Colab
- Kaggle
ONNX Conversion of BAAI/bge-reranker-base
- ONNX model for CPU with O3 optimisation
Usage
from itertools import product
import torch.nn.functional as F
from optimum.onnxruntime import ORTModelForSequenceClassification
from transformers import AutoTokenizer
sentences = [
"The llama (/ˈlɑːmə/) (Lama glama) is a domesticated South American camelid.",
"The alpaca (Lama pacos) is a species of South American camelid mammal.",
"The vicuña (Lama vicugna) (/vɪˈkuːnjə/) is one of the two wild South American camelids.",
]
queries = ["What is a llama?", "What is a harimau?", "How to fly a kite?"]
pairs = list(product(queries, sentences))
model_name = "EmbeddedLLM/bge-reranker-base-onnx-o3-cpu"
device = "cpu"
provider = "CPUExecutionProvider"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = ORTModelForSequenceClassification.from_pretrained(
model_name, use_io_binding=True, provider=provider, device_map=device
)
inputs = tokenizer(
pairs,
padding=True,
truncation=True,
return_tensors="pt",
max_length=model.config.max_position_embeddings,
)
inputs = inputs.to(device)
scores = model(**inputs).logits.view(-1).cpu().numpy()
# Sort most similar to least
pairs = sorted(zip(pairs, scores), key=lambda x: x[1], reverse=True)
for ps in pairs:
print(ps)
- Downloads last month
- 16