ONNX Model Zoo

rokeya71/granite-embedding-125m-english-onnx

By rokeya71 · ↓ 2 · ♥ 1 · Updated 2024-12-27

What's in this repo

This page lists the files in rokeya71/granite-embedding-125m-english-onnx, including model.onnx, model_uint8.onnx.

  • 2 ONNX models (.onnx files)
  • 10 files, including 5 .json, 2 .onnx, 1 .md, 1 .txt
  • Last updated 2024-12-27

ONNX files

File Size Download
model.onnx — Download
model_uint8.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 Converted Version of IBM Granite Embedding Model

This repository contains the ONNX converted version of the Hugging Face model IBM Granite Embedding 125M English.

Running the Model

You can run the ONNX model using the following code:

import onnxruntime as ort
from transformers import AutoTokenizer
import numpy as np

# Define paths
model_path = "./model_uint8.onnx"  # Path to ONNX model file
tokenizer_path = "./"  # Path to folder containing tokenizer.json and tokenizer_config.json

# Load tokenizer
tokenizer = AutoTokenizer.from_pretrained(tokenizer_path)

# Load ONNX model using ONNX Runtime
onnx_session = ort.InferenceSession(model_path)

# Example text input
text = "hi."

# Tokenize input
inputs = tokenizer(text, return_tensors="np", truncation=True, padding=True)

# Prepare input for ONNX model
onnx_inputs = {key: inputs[key].astype(np.int64) for key in inputs.keys()}

# Run inference
outputs = onnx_session.run(None, onnx_inputs)

# Extract embeddings (e.g., using mean pooling)
last_hidden_state = outputs[0]  # Assuming the first output is the last hidden state
pooled_embedding = last_hidden_state.mean(axis=1)  # Mean pooling over the sequence dimension

print(f"Embedding: {pooled_embedding}")

Model info

onnx roberta rag embedding feature-extraction base_model:ibm-granite/granite-embedding-125m-english base_model:quantized:ibm-granite/granite-embedding-125m-english license:mit region:us
↓ 2 ♥ 1

Created: 2024-12-27

Updated: 2024-12-27

View on Hugging Face

Files (10)

.gitattributes
README.md
config.json
merges.txt
model.onnx ONNX
model_uint8.onnx ONNX
special_tokens_map.json
tokenizer.json
tokenizer_config.json
vocab.json

Related models