Downloads · 30 days
21
0% of all-time downloads
alikia2x/jina-embedding-v3-m2v-1024
jina-embedding-v3-m2v-1024 is a machine learning model from alikia2x. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for model2vec. The card lists the license as mit.
This Model2Vec model is a distilled version of the jinaai/jina-embeddings-v3 Sentence Transformer. It uses static embeddings, allowing text embeddings to be computed orders of magnitude faster on both GPU and CPU. It…
Downloads · 30 days
21
0% of all-time downloads
All-time downloads
23.5K
Public
Parameters
256M
3.3 GB on disk
Likes
5
Public
Click a slice to open those files.
.onnx1.3 GB · 55%
From the Hugging Face model README
This Model2Vec model is a distilled version of the jinaai/jina-embeddings-v3 Sentence Transformer. It uses static embeddings, allowing text embeddings to be computed orders of magnitude faster on both GPU and CPU. It is designed for applications where computational resources are limited or where real-time performance is critical.
Install model2vec using pip:
pip install model2vec
model2vecLoad this model using the from_pretrained method:
from model2vec import StaticModel
# Load a pretrained Model2Vec model
model = StaticModel.from_pretrained("alikia2x/jina-embedding-v3-m2v-1024")
# Compute text embeddings
embeddings = model.encode(["Hello"])
sentence-transformerspip install sentence-transformers
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("alikia2x/jina-embedding-v3-m2v-1024")
# embedding:
# array([[ 1.1825741e-01, -1.2899181e-02, -1.0492010e-01, ...,
# 1.1131058e-03, 8.2779792e-04, -7.6874542e-08]],
# shape=(1, 1024), dtype=float32)
embeddings = model.encode(["Hello"])
pip install onnxruntime transformers
You need to download onnx/model.onnx in this repository first.
import onnxruntime
from transformers import AutoTokenizer
import numpy as np
tokenizer_model = "alikia2x/jina-embedding-v3-m2v-1024"
onnx_embedding_path = "path/to/your/model.onnx"
texts = ["Hello"]
tokenizer = AutoTokenizer.from_pretrained(tokenizer_model)
session = onnxruntime.InferenceSession(onnx_embedding_path)
inputs = tokenizer(texts, add_special_tokens=False, return_tensors="np")
input_ids = inputs["input_ids"]
lengths = [len(seq) for seq in input_ids[:-1]]
offsets = [0] + np.cumsum(lengths).tolist()
flattened_input_ids = input_ids.flatten().astype(np.int64)
inputs = {
"input_ids": flattened_input_ids,
"offsets": np.array(offsets, dtype=np.int64),
}
outputs = session.run(None, inputs)
embeddings = outputs[0]
embeddings = embeddings.flatten()
# [ 1.1825741e-01 -1.2899181e-02 -1.0492010e-01 ... 1.1131058e-03
# 8.2779792e-04 -7.6874542e-08]
print(embeddings)
Note: A quantized (INT8) version of this model is also available, offering reduced memory usage with minimal performance impact.
Simply replace onnx/model.onnx with the onnx/model_INT8.onnx file.
Our testing shows less than a 1% drop in the F1 score on a real down-stream task.
Model2vec creates a small, fast, and powerful model that outperforms other static embedding models by a large margin on all tasks we could find, while being much faster to create than traditional static embedding models such as GloVe. Best of all, you don't need any data to distill a model using Model2Vec.
It works by passing a vocabulary through a sentence transformer model, then reducing the dimensionality of the resulting embeddings using PCA, and finally weighting the embeddings using zipf weighting. During inference, we simply take the mean of all token embeddings occurring in a sentence.
Model2Vec was developed by the Minish Lab team consisting of Stephan Tulkens and Thomas van Dongen.
Please cite the Model2Vec repository if you use this model in your work.
@software{minishlab2024model2vec,
authors = {Stephan Tulkens, Thomas van Dongen},
title = {Model2Vec: Turn any Sentence Transformer into a Small Fast Model},
year = {2024},
url = {https://github.com/MinishLab/model2vec},
}