Model reference · open weights
NoInstruct-small-Embedding is an open-weight embedding model from avsolatorio. NoInstruct-small-Embedding-v0 (FP32) weighs 67 MB; the smallest configuration that runs it is RTX 3060 12 GB.
What it is
| Released by | avsolatorio |
|---|---|
| Type | Embedding models |
| Task | Embeddings |
| Parameters (lead) | 33M |
| Context | 512 tokens |
| Runs with | sentence-transformers |
| Released | 2024-05-01 |
| Popularity | 1k downloads / month |
| Weights | 67 MB (NoInstruct-small-Embedding-v0 (FP32), file size) |
| Licence | Open weights |
What it runs on
Weights 67 MB (file size) · overhead about 1.1 GB.
| Card | Runs | Counted memory |
|---|---|---|
| RTX 3060 12 GB | fits | 11.6 GB |
| RTX 4060 Ti 16 GB | fits | 15.4 GB |
| RTX 3090 24 GB | fits | 23.4 GB |
| RTX 4090 24 GB | fits | 23.4 GB |
| RTX 5090 32 GB | fits | 31.0 GB |
| L40S 48 GB | fits | 44.0 GB |
| A100 80 GB | fits | 78.2 GB |
| H100 80 GB | fits | 78.1 GB |
| RTX PRO 6000 Blackwell 96 GB | fits | 93.8 GB |
| DGX Spark (GB10) 128 GB unified | fits | 107 GB |
| H200 141 GB | fits | 138 GB |
| B200 180 GB | fits | 176 GB |
Estimates, not measurements: the weights are the build's file size. No cache grows with use; a batch of inputs needs working memory of its own. Counted memory is 92 % of what CUDA reports for the card.
From the model card
NoInstruct Embedding: Asymmetric Pooling is All You Need
This model has improved retrieval performance compared to the avsolatorio/GIST-small-Embedding-v0 model.
One of the things that the GIST family of models fell short on is the performance on retrieval tasks. We propose a method that produces improved retrieval performance while maintaining independence on crafting arbitrary instructions, a trending paradigm in embedding models for retrieval tasks, when encoding a query.
Technical details of the model will be published shortly.
from typing import Union
import torch
import torch.nn.functional as F
from transformers import AutoModel, AutoTokenizer
model = AutoModel.from_pretrained("avsolatorio/NoInstruct-small-Embedding-v0")
tokenizer = AutoTokenizer.from_pretrained("avsolatorio/NoInstruct-small-Embedding-v0")
def get_embedding(text: Union[str, list[str]], mode: str = "sentence"):
model.eval()
assert mode in ("query", "sentence"), f"mode={mode} was passed but only `query` and `sentence` are the supported modes."
if isinstance(text, str):
text = [text]
inp = tokenizer(text, return_tensors="pt", padding=True, truncation=True)
with torch.no_grad():
output = model(**inp)
# The model is optimized to use the mean pooling for queries,
# while the sentence / document embedding uses the [CLS] representation.
if mode == "query":
vectors = output.last_hidden_state * inp["attention_mask"].unsqueeze(2)
vectors = vectors.sum(dim=1) / inp["attention_mask"].sum(dim=-1).view(-1, 1)
else:
vectors = output.last_hidden_state[:, 0, :]
return vectors
texts = [
"Illustration of the REaLTabFormer model. The left block shows the non-relational tabular data model using GPT-2 with a causal LM head. In contrast, the right block shows how a relational dataset's child table is modeled using a sequence-to-sequence (Seq2Seq) model. The Seq2Seq model uses the observations in the parent table to condition the generation of the observations in the child table. The trained GPT-2 model on the parent table, with weights frozen, is also used as the encoder in the Seq2Seq model.",
"Predicting human mobility holds significant practical value, with applications ranging from enhancing disaster risk planning to simulating epidemic spread. In this paper, we present the GeoFormer, a decoder-only transformer model adapted from the GPT architecture to forecast human mobility.",
"As the economies of Southeast Asia continue adopting digital technologies, policy makers increasingly ask how to prepare the workforce for emerging labor demands. However, little is known about the skills that workers need to adapt to these changes"
]
# Compute embeddings
embeddings = get_embedding(texts, mode="sentence")
# Compute cosine-similarity for each pair of sentences
scores = F.cosine_similarity(embeddings.unsqueeze(1), embeddings.unsqueeze(0), dim=-1)
print(scores.cpu().numpy())
# Test the retrieval performance.
query = get_embedding("Which sentence talks about concept on jobs?", mode="query")
scores = F.cosine_similarity(query, embeddings, dim=-1)
print(scores.cpu().numpy())
Support for the Sentence Transformers library will follow soon.
Quoted from the model card on Hugging Face — the full card is behind the Hugging Face link above.
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 | 75.761 |
| Classification | MTEB AmazonCounterfactualClassification (en) | ap | 39.036 |
| Classification | MTEB AmazonCounterfactualClassification (en) | f1 | 69.859 |
| Classification | MTEB AmazonPolarityClassification | accuracy | 93.299 |
| Classification | MTEB AmazonPolarityClassification | ap | 90.035 |
| Classification | MTEB AmazonPolarityClassification | f1 | 93.286 |
| Classification | MTEB AmazonReviewsClassification (en) | accuracy | 49.988 |
| Classification | MTEB AmazonReviewsClassification (en) | f1 | 49.462 |
| Retrieval | MTEB ArguAna | map_at_1 | 31.935 |
| Retrieval | MTEB ArguAna | map_at_10 | 48.791 |
| Retrieval | MTEB ArguAna | map_at_100 | 49.619 |
| Retrieval | MTEB ArguAna | map_at_1000 | 49.623 |
| Retrieval | MTEB ArguAna | map_at_3 | 44.334 |
| Retrieval | MTEB ArguAna | map_at_5 | 46.908 |
| Retrieval | MTEB ArguAna | mrr_at_1 | 32.930 |
| Retrieval | MTEB ArguAna | mrr_at_10 | 49.158 |
| Retrieval | MTEB ArguAna | mrr_at_100 | 50.006 |
| Retrieval | MTEB ArguAna | mrr_at_1000 | 50.010 |
| Retrieval | MTEB ArguAna | mrr_at_3 | 44.618 |
| Retrieval | MTEB ArguAna | mrr_at_5 | 47.325 |
| Retrieval | MTEB ArguAna | ndcg_at_1 | 31.935 |
| Retrieval | MTEB ArguAna | ndcg_at_10 | 57.593 |
| Retrieval | MTEB ArguAna | ndcg_at_100 | 60.841 |
| Retrieval | MTEB ArguAna | ndcg_at_1000 | 60.924 |