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