Downloads · 30 days
2
8% of all-time downloads
walusungungulube/multilingual-e5-large-ct2-int8
multilingual-e5-large-ct2-int8 is a machine learning model from walusungungulube. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
This repository contains a CTranslate2 INT8 quantized version of intfloat/multilingual-e5-large for faster inference.
Downloads · 30 days
2
8% of all-time downloads
All-time downloads
24
Public
Repo size
2.8 GB
Likes
0
Public
Click a slice to open those files.
.bin563 MB · 95%
From the Hugging Face model README
This repository contains a CTranslate2 INT8 quantized version of intfloat/multilingual-e5-large for faster inference.
import ctranslate2
import numpy as np
from transformers import AutoTokenizer
model_id = "YOUR_USERNAME/multilingual-e5-large-ct2-int8"
device = "cpu" # or "cuda"
# Load tokenizer (now from the same repo!)
tokenizer = AutoTokenizer.from_pretrained(model_id)
# Load CT2 model
translator = ctranslate2.Translator(model_id, device=device)
texts = [
"query: how tall is the Eiffel Tower?",
"passage: The Eiffel Tower is 330 metres tall."
]
# Tokenize
inputs = tokenizer(texts, padding=True, truncation=True, return_tensors="np")
input_ids = inputs["input_ids"].astype(np.int32)
# Convert to CT2 format
tokens = [[str(t) for t in seq] for seq in input_ids]
# Run inference
results = translator.forward_batch(source=tokens, return_log_probs=False)
# Extract embeddings with mean pooling
embeddings = []
for result in results:
hidden_states = np.array(result.last_hidden_state)
embedding = np.mean(hidden_states, axis=0)
embeddings.append(embedding)
embeddings = np.array(embeddings)
# Normalize
norms = np.linalg.norm(embeddings, axis=1, keepdims=True)
embeddings = embeddings / norms
# Compute similarity
sim = embeddings[0] @ embeddings[1]
print("Cosine similarity:", round(float(sim), 4))
model.bin: CT2 quantized model weightsct2_config.json: CT2 model configurationconfig.json, tokenizer*.json, vocab.*: Original tokenizer filesBased on: intfloat/multilingual-e5-large
pip install ctranslate2 transformers torch numpy