Views
No views yet
S+W score of encodechka benchmark.transformers. To load the model correctly, you must enable dowloading code from the model's repository: trust_remote_code=True, this will download the modeling_rope_bert.py script and load the weights into the correct architecture.
Otherwise, you can download this script manually and use classes from it directly to load the model.1model_name = 'Tochka-AI/ruRoPEBert-e5-base-512'
2tokenizer = AutoTokenizer.from_pretrained(model_name)
3model = AutoModel.from_pretrained(model_name, trust_remote_code=True, attn_implementation='eager')model = AutoModel.from_pretrained(model_name, trust_remote_code=True, attn_implementation='sdpa')mean) is already built into the model architecture, which averages embeddings based on the attention mask. You can also select the pooler type (first_token_transform), which performs a learnable linear transformation on the first token.pooler_type parameter in AutoModel.from_pretrained function1test_batch = tokenizer.batch_encode_plus(["Привет, чем занят?", "Здравствуйте, чем вы занимаетесь?"], return_tensors='pt', padding=True)
2with torch.inference_mode():
3 pooled_output = model(**test_batch).pooler_output 1import torch.nn.functional as F
2F.normalize(pooled_output, dim=1) @ F.normalize(pooled_output, dim=1).Tnum_labels parameter):model = AutoModelForSequenceClassification.from_pretrained(model_name, trust_remote_code=True, attn_implementation='sdpa', num_labels=4)linear and dynamic. To extend the model's context window you need to change tokenizer max length and add rope_scaling parameter.1tokenizer.model_max_length = 1024
2model = AutoModel.from_pretrained(model_name,
3 trust_remote_code=True,
4 attn_implementation='sdpa',
5 rope_scaling={'type': 'dynamic','factor': 2.0}
6 ) # 2.0 for x2 scaling, 4.0 for x4, etc..| Model name | STS | PI | NLI | SA | TI | IA | IC | ICX | NE1 | NE2 | Avg S (no NE) | Avg S+W (with NE) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| ruRoPEBert-e5-base-512 | 0.793 | 0.704 | 0.457 | 0.803 | 0.970 | 0.788 | 0.802 | 0.749 | 0.328 | 0.396 | 0.758 | 0.679 |
| intfloat/multilingual-e5-base | 0.834 | 0.704 | 0.458 | 0.795 | 0.964 | 0.782 | 0.803 | 0.740 | 0.234 | 0.373 | 0.76 | 0.668 |