LIBRAAITECH/gte-multilingual-base-onnx
By LIBRAAITECH · ↓ 1 · ♥ 0 · Updated 2025-10-21
What's in this repo
This page lists the files in LIBRAAITECH/gte-multilingual-base-onnx, including model.onnx.
- 1 ONNX models (.onnx files)
- 7 files, including 4 .json, 1 .md, 1 .onnx
- Last updated 2025-10-21
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
This is the ONNX version of the gte-multilingual-base model.
This example is adapted from the original model repository for the ONNX version.
# Requires transformers>=4.36.0
import onnxruntime as ort
import numpy as np
from transformers import AutoTokenizer
input_texts = [
"what is the capital of China?",
"how to implement quick sort in python?",
"北京",
"快排算法介绍"
]
# Load the tokenizer (using the original model for tokenizer)
tokenizer = AutoTokenizer.from_pretrained('Alibaba-NLP/gte-multilingual-base')
# Load the ONNX model
session = ort.InferenceSession("model.onnx")
# Tokenize the input texts
batch_dict = tokenizer(input_texts, max_length=8192, padding=True, truncation=True, return_tensors='np')
# Run inference
outputs = session.run(None, {
"input_ids": batch_dict["input_ids"],
"attention_mask": batch_dict["attention_mask"]
})
# Get embeddings from the second output (last hidden states)
# Extract the [CLS] token embedding (first token) for each sequence
last_hidden_states = outputs[1] # Shape: (batch_size, seq_len, hidden_size)
dimension = 768 # The output dimension of the output embedding, should be in [128, 768]
embeddings = last_hidden_states[:, 0, :dimension] # Shape: (batch_size, dimension)
# Debug: Check embeddings
print(f"Embeddings shape: {embeddings.shape}")
print(f"First few values of first embedding: {embeddings[0][:5]}")
print(f"First few values of second embedding: {embeddings[1][:5]}")
# Normalize embeddings
embeddings = embeddings / np.linalg.norm(embeddings, axis=1, keepdims=True)
# Calculate similarity scores
scores = (embeddings[:1] @ embeddings[1:].T) * 100
print(scores.tolist())
# [[0.3016996383666992, 0.7503870129585266, 0.3203084468841553]]
Model info
onnx
new
text-generation
custom_code
base_model:Alibaba-NLP/gte-multilingual-base
base_model:quantized:Alibaba-NLP/gte-multilingual-base
license:apache-2.0
region:us
↓ 1
♥ 0
Created: 2025-06-30
Updated: 2025-10-21
View on Hugging FaceFiles (7)
.gitattributes
README.md
config.json
model.onnx
ONNX
special_tokens_map.json
tokenizer.json
tokenizer_config.json
Related models
More from LIBRAAITECH
No other models by this author.