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)
Runs of EmbeddedLLM bge-reranker-base-onnx-o3-cpu on huggingface.co
26
Total runs
-2
24-hour runs
0
3-day runs
2
7-day runs
10
30-day runs
More Information About bge-reranker-base-onnx-o3-cpu huggingface.co Model
More bge-reranker-base-onnx-o3-cpu license Visit here:
bge-reranker-base-onnx-o3-cpu huggingface.co is an AI model on huggingface.co that provides bge-reranker-base-onnx-o3-cpu's model effect (), which can be used instantly with this EmbeddedLLM bge-reranker-base-onnx-o3-cpu model. huggingface.co supports a free trial of the bge-reranker-base-onnx-o3-cpu model, and also provides paid use of the bge-reranker-base-onnx-o3-cpu. Support call bge-reranker-base-onnx-o3-cpu model through api, including Node.js, Python, http.
bge-reranker-base-onnx-o3-cpu huggingface.co is an online trial and call api platform, which integrates bge-reranker-base-onnx-o3-cpu's modeling effects, including api services, and provides a free online trial of bge-reranker-base-onnx-o3-cpu, you can try bge-reranker-base-onnx-o3-cpu online for free by clicking the link below.
EmbeddedLLM bge-reranker-base-onnx-o3-cpu online free url in huggingface.co:
bge-reranker-base-onnx-o3-cpu is an open source model from GitHub that offers a free installation service, and any user can find bge-reranker-base-onnx-o3-cpu on GitHub to install. At the same time, huggingface.co provides the effect of bge-reranker-base-onnx-o3-cpu install, users can directly use bge-reranker-base-onnx-o3-cpu installed effect in huggingface.co for debugging and trial. It also supports api for free installation.
bge-reranker-base-onnx-o3-cpu install url in huggingface.co: