stella is a general-purpose text encoder, which mainly includes the following models:
Model Name
Model Size (GB)
Dimension
Sequence Length
Language
Need instruction for retrieval?
stella-base-en-v2
0.2
768
512
English
No
stella-large-zh-v2
0.65
1024
1024
Chinese
No
stella-base-zh-v2
0.2
768
1024
Chinese
No
stella-large-zh
0.65
1024
1024
Chinese
Yes
stella-base-zh
0.2
768
1024
Chinese
Yes
The training data mainly includes:
Open-source training data (wudao_base_200GB, m3e, and simclue), with a focus on selecting texts with lengths greater
than 512.
A batch of (question, paragraph) and (sentence, paragraph) data constructed on a general corpus using LLM.
The loss functions mainly include:
Contrastive learning loss function
Contrastive learning loss function with hard negative examples (based on bm25 and vector hard negatives)
EWC (Elastic Weights Consolidation)
cosent loss
Model weight initialization:
stella-base-zh and stella-large-zh use piccolo-base-zh and piccolo-large-zh as the base models, respectively, and the
512-1024 position embedding uses the initialization strategy of hierarchical decomposed position encoding.
Training strategy:
One iterator for each type of data, separately calculating the loss.
Based on stella models, stella-v2 use more training data and remove instruction by Knowledge Distillation.
Metric
C-MTEB leaderboard (Chinese)
Model Name
Model Size (GB)
Dimension
Sequence Length
Average (35)
Classification (9)
Clustering (4)
Pair Classification (2)
Reranking (4)
Retrieval (8)
STS (8)
stella-large-zh-v2
0.65
1024
1024
65.13
69.05
49.16
82.68
66.41
70.14
58.66
stella-base-zh-v2
0.2
768
1024
64.36
68.29
49.4
79.95
66.1
70.08
56.92
stella-large-zh
0.65
1024
1024
64.54
67.62
48.65
78.72
65.98
71.02
58.3
stella-base-zh
0.2
768
1024
64.16
67.77
48.7
76.09
66.95
71.07
56.54
MTEB leaderboard (English)
Model Name
Model Size (GB)
Dimension
Sequence Length
Average (56)
Classification (12)
Clustering (11)
Pair Classification (3)
Reranking (4)
Retrieval (15)
STS (10)
Summarization (1)
stella-base-en-v2
0.2
768
512
62.61
75.28
44.9
86.45
58.77
50.1
83.02
32.52
Reproduce our results
C-MTEB:
python
1import torch
2import numpy as np
3from typing import List
4from mteb import MTEB
5from sentence_transformers import SentenceTransformer
678classFastTextEncoder():9def__init__(self, model_name):10 self.model = SentenceTransformer(model_name).cuda().half().eval()11 self.model.max_seq_length =5121213defencode(14 self,15 input_texts: List[str],16*args,17**kwargs
18):19 new_sens =list(set(input_texts))20 new_sens.sort(key=lambda x:len(x), reverse=True)21 vecs = self.model.encode(22 new_sens, normalize_embeddings=True, convert_to_numpy=True, batch_size=25623).astype(np.float32)24 sen2arrid ={sen: idx for idx, sen inenumerate(new_sens)}25 vecs = vecs[[sen2arrid[sen]for sen in input_texts]]26 torch.cuda.empty_cache()27return vecs
282930if __name__ =='__main__':31 model_name ="infgrad/stella-base-zh-v2"32 output_folder ="zh_mteb_results/stella-base-zh-v2"33 task_names =[t.description["name"]for t in MTEB(task_langs=['zh','zh-CN']).tasks]34 model = FastTextEncoder(model_name)35for task in task_names:36 MTEB(tasks=[task], task_langs=['zh','zh-CN']).run(model, output_folder=output_folder)37