Model reference · open weights
marqo-gcl-e5-large-130 is an open-weight embedding model from Marqo. 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
| Maker | Marqo |
|---|---|
| Type | Embedding models |
| Task | Embeddings |
| Parameters (lead) | 335M |
| Context | 512 tokens |
| Runs with | transformers |
| Released | 2024-04-10 |
| Popularity | 8 downloads / month |
| Licence | Open weights |
About
This work aims to improve and measure the ranking performance of information retrieval models, especially for retrieving relevant products given a search query.
Blog post: https://www.marqo.ai/blog/generalized-contrastive-learning-for-multi-modal-retrieval-and-ranking
Paper: https://arxiv.org/pdf/2404.08535.pdf
| Methods | Models | nDCG | ERR | RBP |
|---|---|---|---|---|
| BM25 | - | 0.071 | 0.028 | 0.052 |
| E5 | e5-large-v2 | 0.335 | 0.095 | 0.289 |
| E5 (GCL) | e5-large-v2 | 0.470 | 0.457 | 0.374 |
import torch.nn.functional as F
from torch import Tensor
from transformers import AutoTokenizer, AutoModel
def average_pool(last_hidden_states: Tensor,
attention_mask: Tensor) -> Tensor:
last_hidden = last_hidden_states.masked_fill(~attention_mask[..., None].bool(), 0.0)
return last_hidden.sum(dim=1) / attention_mask.sum(dim=1)[..., None]
# Each input text should start with "query: " or "passage: ".
# For tasks other than retrieval, you can simply use the "query: " prefix.
input_texts = ['query: Espresso Pitcher with Handle',
'query: Women’s designer handbag sale',
"passage: Dianoo Espresso Steaming Pitcher, Espresso Milk Frothing Pitcher Stainless Steel",
"passage: Coach Outlet Eliza Shoulder Bag - Black - One Size"]
tokenizer = AutoTokenizer.from_pretrained('Marqo/marqo-gcl-e5-large-v2-130')
model_new = AutoModel.from_pretrained('Marqo/marqo-gcl-e5-large-v2-130')
# Tokenize the input texts
batch_dict = tokenizer(input_texts, max_length=77, padding=True, truncation=True, return_tensors='pt')
outputs = model_new(**batch_dict)
embeddings = average_pool(outputs.last_hidden_state, batch_dict['attention_mask'])
# normalize embeddings
embeddings = F.normalize(embeddings, p=2, dim=1)
scores = (embeddings[:2] @ embeddings[2:].T) * 100
print(scores.tolist())
From the published model card. Full card on the HuggingFace links in the sidebar.
Using it via the API
Once AxForge deploys marqo-gcl-e5-large-130 for you, it answers on the OpenAI-compatible API — the same base URL and keys as every other model. (marqo-gcl-e5-large-130 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":"marqo-gcl-e5-large-130","input":"text to embed"}'
Create an account — your API key is available in the console. 5M tokens/month currently included with every new account at launch.