Model reference · open weights
stella_en is an open-weight embedding model from billatsectorflow. AxForge deploys and operates it for you on dedicated EU-owned hardware — with the licence handled where one is required.
Available as managed deployment — configured and operated for you on dedicated EU hardware, quoted per deployment.
What it is
| Released by | billatsectorflow |
|---|---|
| Type | Embedding models |
| Task | Embeddings |
| Parameters (lead) | 435M |
| Context | 8k tokens |
| Runs with | sentence-transformers |
| Released | 2025-01-22 |
| Popularity | 83k downloads / month |
| Licence | Open weights |
About
Hi, everyone, thanks for using stella models. After six months of work, I trained the jasper model on top of the stella model, which is a multimodal model, and it can be ranked 2 in mteb (submitted the results on 2024-12-11, which may need official review https://github.com/embeddings-benchmark/results/pull/68).
Model link: https://huggingface.co/infgrad/jasper_en_vision_language_v1
I'll focus on the technical report, training data and related code, hopefully the tricks I've used will be of some help to you guys!
The core training code will be integrated into the rag-retrieval library(https://github.com/NLPJCL/RAG-Retrieval) in the near future. (Welcome to star)
This work was accomplished during my free time, it's a personal hobby. One person's time and energy is limited, and you are welcome to make any contributions!
You can also find these models on my homepage.
The models are trained based on Alibaba-NLP/gte-large-en-v1.5 and Alibaba-NLP/gte-Qwen2-1.5B-instruct. Thanks for
their contributions!
We simplify usage of prompts, providing two prompts for most general tasks, one is for s2p, another one is for s2s.
Prompt of s2p task(e.g. retrieve task):
Instruct: Given a web search query, retrieve relevant passages that answer the query.\nQuery: {query}
Prompt of s2s task(e.g. semantic textual similarity task):
Instruct: Retrieve semantically similar text.\nQuery: {query}
The models are finally trained by MRL, so they have multiple dimensions: 512, 768, 1024, 2048, 4096, 6144 and 8192.
The higher the dimension, the better the performance. Generally speaking, 1024d is good enough. The MTEB score of 1024d is only 0.001 lower than 8192d.
The model directory structure is very simple, it is a standard SentenceTransformer directory with a series
of 2_Dense_{dims}
folders, where dims represents the final vector dimension.
For example, the 2_Dense_256 folder stores Linear weights that convert vector dimensions to 256 dimensions.
Please refer to the following chapters for specific instructions on how to use them.
You can use SentenceTransformers or transformers library to encode text.
from sentence_transformers import SentenceTransformer
# This model supports two prompts: "s2p_query" and "s2s_query" for sentence-to-passage and sentence-to-sentence tasks, respectively.
# They are defined in `config_sentence_transformers.json`
query_prompt_name = "s2p_query"
queries = [
"What are some ways to reduce stress?",
"What are the benefits of drinking green tea?",
]
# docs do not need any prompts
docs = [
"There are many effective ways to reduce stress. Some common techniques include deep breathing, meditation, and physical activity. Engaging in hobbies, spending time in nature, and connecting with loved ones can also help alleviate stress. Additionally, setting boundaries, practicing self-care, and learning to say no can prevent stress from building up.",
"Green tea has been consumed for centuries and is known for its potential health benefits. It contains antioxidants that may help protect the body against damage caused by free radicals. Regular consumption of green tea has been associated with improved heart health, enhanced cognitive function, and a reduced risk of certain types of cancer. The polyphenols in green tea may also have anti-inflammatory and weight loss properties.",
]
# !The default dimension is 1024, if you need other dimensions, please clone the model and modify `modules.json` to replace `2_Dense_1024` with another dimension, e.g. `2_Dense_256` or `2_Dense_8192` !
# on gpu
model = SentenceTransformer("dunzhang/stella_en_400M_v5", trust_remote_code=True).cuda()
# you can also use this model without the features of `use_memory_efficient_attention` and `unpad_inputs`. It can be worked in CPU.
# model = SentenceTransformer(
# "dunzhang/stella_en_400M_v5",
# trust_remote_code=True,
# device="cpu",
# config_kwargs={"use_memory_efficient_attention": False, "unpad_inputs": False}
# )
query_embeddings = model.encode(queries, prompt_name=query_prompt_name)
doc_embeddings = model.encode(docs)
print(query_embeddings.shape, doc_embeddings.shape)
# (2, 1024) (2, 1024)
similarities = model.similarity(query_embeddings, doc_embeddings)
print(similarities)
# tensor([[0.8398, 0.2990],
# [0.3282, 0.8095]])
import os
import torch
from transformers import AutoModel, AutoTokenizer
from sklearn.preprocessing import normalize
query_prompt = "Instruct: Given a web search query, retrieve relevant passages that answer the query.\nQuery: "
queries = [
"What are some ways to reduce stress?",
"What are the benefits of drinking green tea?",
]
queries = [query_prompt + query for query in queries]
# docs do not need any prompts
docs = [
"There are many effective ways to reduce stress. Some common techniques include deep breathing, meditation, and physical activity. Engaging in hobbies, spending time in nature, and connecting with loved ones can also help alleviate stress. Additionally, setting boundaries, practicing self-care, and learning to say no can prevent stress from building up.",
"Green tea has been consumed for centuries and is known for its potential health benefits. It contains antioxidants that may help protect the body against damage caused by free radicals. Regular consumption of green tea has been associated with improved heart health, enhanced cognitive function, and a reduced risk of certain types of cancer. The polyphenols in green tea may also have anti-inflammatory and weight loss properties.",
]
# The path of your model after cloning it
model_dir = "{Your MODEL_PATH}"
vector_dim = 1024
vector_linear_directory = f"2_Dense_{vector_dim}"
model = AutoModel.from_pretrained(model_dir, trust_remoFrom the published model card. Full card on the HuggingFace links in the sidebar.
Benchmarks
As published on the model card — the maker's own numbers, not measured by AxForge.
| Task | Dataset | Metric | Score |
|---|---|---|---|
| Classification | MTEB AmazonCounterfactualClassification (en) | accuracy | 92.358 |
| Classification | MTEB AmazonCounterfactualClassification (en) | ap | 70.813 |
| Classification | MTEB AmazonCounterfactualClassification (en) | ap_weighted | 70.813 |
| Classification | MTEB AmazonCounterfactualClassification (en) | f1 | 88.951 |
| Classification | MTEB AmazonCounterfactualClassification (en) | f1_weighted | 92.686 |
| Classification | MTEB AmazonCounterfactualClassification (en) | main_score | 92.358 |
| Classification | MTEB AmazonPolarityClassification | accuracy | 97.195 |
| Classification | MTEB AmazonPolarityClassification | ap | 96.082 |
| Classification | MTEB AmazonPolarityClassification | ap_weighted | 96.082 |
| Classification | MTEB AmazonPolarityClassification | f1 | 97.194 |
| Classification | MTEB AmazonPolarityClassification | f1_weighted | 97.194 |
| Classification | MTEB AmazonPolarityClassification | main_score | 97.195 |
| Classification | MTEB AmazonReviewsClassification (en) | accuracy | 59.528 |
| Classification | MTEB AmazonReviewsClassification (en) | f1 | 59.210 |
| Classification | MTEB AmazonReviewsClassification (en) | f1_weighted | 59.210 |
| Classification | MTEB AmazonReviewsClassification (en) | main_score | 59.528 |
| Retrieval | MTEB ArguAna | main_score | 64.240 |
| Retrieval | MTEB ArguAna | map_at_1 | 40.398 |
| Retrieval | MTEB ArguAna | map_at_10 | 56.215 |
| Retrieval | MTEB ArguAna | map_at_100 | 56.834 |
| Retrieval | MTEB ArguAna | map_at_1000 | 56.835 |
| Retrieval | MTEB ArguAna | map_at_20 | 56.747 |
| Retrieval | MTEB ArguAna | map_at_3 | 52.181 |
| Retrieval | MTEB ArguAna | map_at_5 | 54.628 |
Using it via the API
Once AxForge deploys billatsectorflow-stella-en for you, it answers on the OpenAI-compatible API — the same base URL and keys as every other model. (billatsectorflow-stella-en below is illustrative; you get the exact model name on deployment.)
$ curl -sS https://api.axforge.ai/v1/embeddings \
-H "Authorization: Bearer $AXFORGE_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"billatsectorflow-stella-en","input":"text to embed"}'
Create an account — your API key is available in the console. 3M free tokens every 30 days with every new account.