This model has been trained on an extensive corpus of text pairs that encompass a broad spectrum of domains, including finance, science, medicine, law, and various others. During the training process, we incorporated techniques derived from the
RetroMAE and
SetFit research papers.
We are pleased to offer this model as an API service through our platform,
LLMRails. If you are interested, please don't hesitate to sign up.
1curl --location 'https://api.llmrails.com/v1/embeddings' \
2--header 'X-API-KEY: {token}' \
3--header 'Content-Type: application/json' \
4--data '{
5 "input": ["This is an example sentence"],
6 "model":"embedding-english-v1" # equals to ember-v1
7}'
1import torch.nn.functional as F
2from torch import Tensor
3from transformers import AutoTokenizer, AutoModel
4
5def average_pool(last_hidden_states: Tensor,
6 attention_mask: Tensor) -> Tensor:
7 last_hidden = last_hidden_states.masked_fill(~attention_mask[..., None].bool(), 0.0)
8 return last_hidden.sum(dim=1) / attention_mask.sum(dim=1)[..., None]
9
10input_texts = [
11 "This is an example sentence",
12 "Each sentence is converted"
13]
14
15tokenizer = AutoTokenizer.from_pretrained("llmrails/ember-v1")
16model = AutoModel.from_pretrained("llmrails/ember-v1")
17
18# Tokenize the input texts
19batch_dict = tokenizer(input_texts, max_length=512, padding=True, truncation=True, return_tensors='pt')
20
21outputs = model(**batch_dict)
22embeddings = average_pool(outputs.last_hidden_state, batch_dict['attention_mask'])
23
24# (Optionally) normalize embeddings
25embeddings = F.normalize(embeddings, p=2, dim=1)
26scores = (embeddings[:1] @ embeddings[1:].T) * 100
27print(scores.tolist())
1from sentence_transformers import SentenceTransformer
2from sentence_transformers.util import cos_sim
3
4sentences = [
5 "This is an example sentence",
6 "Each sentence is converted"
7]
8
9model = SentenceTransformer('llmrails/ember-v1')
10embeddings = model.encode(sentences)
11print(cos_sim(embeddings[0], embeddings[1]))
Our model achieve state-of-the-art performance on
MTEB leaderboard
This model exclusively caters to English texts, and any lengthy texts will be truncated to a maximum of 512 tokens.