EmbeddedLLM/bge-base-en-v1.5-onnx-o4-o2-gpu
By EmbeddedLLM · ↓ 3 · ♥ 0 · Updated 2024-02-19
What's in this repo
This page lists the files in EmbeddedLLM/bge-base-en-v1.5-onnx-o4-o2-gpu, including model.onnx.
- 1 ONNX models (.onnx files)
- 9 files, including 5 .json, 1 .md, 1 .onnx, 1 .txt
- Last updated 2024-02-19
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-base-en-v1.5
- ONNX model for GPU with O4-O2 optimisation
- We exported the model with
use_raw_attention_mask=Truedue to this issue
Usage
import torch.nn.functional as F
from optimum.onnxruntime import ORTModelForFeatureExtraction
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.",
]
model_name = "EmbeddedLLM/bge-base-en-v1.5-onnx-o4-o2-gpu"
device = "cuda"
provider = "CUDAExecutionProvider"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = ORTModelForFeatureExtraction.from_pretrained(
model_name, use_io_binding=True, provider=provider, device_map=device
)
inputs = tokenizer(
sentences,
padding=True,
truncation=True,
return_tensors="pt",
max_length=model.config.max_position_embeddings,
)
inputs = inputs.to(device)
embeddings = model(**inputs).last_hidden_state[:, 0]
embeddings = F.normalize(embeddings, p=2, dim=1)
print(embeddings.cpu().numpy().shape)
Model info
feature-extraction
transformers
transformers
onnx
bert
feature-extraction
sentence-similarity
en
license:mit
text-embeddings-inference
endpoints_compatible
region:us
↓ 3
♥ 0
Created: 2024-02-16
Updated: 2024-02-19
View on Hugging FaceFiles (9)
.gitattributes
README.md
config.json
model.onnx
ONNX
ort_config.json
special_tokens_map.json
tokenizer.json
tokenizer_config.json
vocab.txt