ONNX Model Zoo

EmbeddedLLM/bge-reranker-base-onnx-o4-o2-gpu

By EmbeddedLLM · ↓ 7 · ♥ 1 · Updated 2024-02-18

What's in this repo

This page lists the files in EmbeddedLLM/bge-reranker-base-onnx-o4-o2-gpu, including model.onnx.

  • 1 ONNX models (.onnx files)
  • 9 files, including 5 .json, 1 .md, 1 .onnx, 1 .model
  • Last updated 2024-02-18

ONNX files

File Size Download
model.onnx — Download

How to use

These ONNX files can be loaded with ONNX Runtime. To inspect a model graph, upload the file to the Netron viewer. Download links point to the original files on Hugging Face.

README

ONNX Conversion of BAAI/bge-reranker-base

  • ONNX model for GPU with O4-O2 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-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)

Model info

sentence-similarity transformers
transformers onnx xlm-roberta text-classification sentence-similarity en license:mit text-embeddings-inference endpoints_compatible region:us
↓ 7 ♥ 1

Created: 2024-02-16

Updated: 2024-02-18

View on Hugging Face

Files (9)

.gitattributes
README.md
config.json
model.onnx ONNX
ort_config.json
sentencepiece.bpe.model
special_tokens_map.json
tokenizer.json
tokenizer_config.json

Related models