U
niversal
S
entence
E
ncoder for
R
ussian (USER) is a
sentence-transformer
model for extracting embeddings exclusively for Russian language.
It maps sentences & paragraphs to a 1024 dimensional dense vector space and can be used for tasks like clustering or semantic search.
This model is initialized from
TatonkaHF/bge-m3_en_ru
which is shrinked version of
baai/bge-m3
model and trained to work mainly with the Russian language. Its quality on other languages was not evaluated.
from sentence_transformers import SentenceTransformer
input_texts = [
"Когда был спущен на воду первый миноносец «Спокойный»?",
"Есть ли нефть в Удмуртии?",
"Спокойный (эсминец)\nЗачислен в списки ВМФ СССР 19 августа 1952 года.",
"Нефтепоисковые работы в Удмуртии были начаты сразу после Второй мировой войны в 1945 году и продолжаются по сей день. Добыча нефти началась в 1967 году."
]
model = SentenceTransformer("deepvk/USER-bge-m3")
embeddings = model.encode(input_texts, normalize_embeddings=True)
import torch.nn.functional as F
from torch import Tensor, inference_mode
from transformers import AutoTokenizer, AutoModel
input_texts = [
"Когда был спущен на воду первый миноносец «Спокойный»?",
"Есть ли нефть в Удмуртии?",
"Спокойный (эсминец)\nЗачислен в списки ВМФ СССР 19 августа 1952 года.",
"Нефтепоисковые работы в Удмуртии были начаты сразу после Второй мировой войны в 1945 году и продолжаются по сей день. Добыча нефти началась в 1967 году."
]
tokenizer = AutoTokenizer.from_pretrained("deepvk/USER-bge-m3")
model = AutoModel.from_pretrained("deepvk/USER-bge-m3")
model.eval()
encoded_input = tokenizer(sentences, padding=True, truncation=True, return_tensors='pt')
with torch.no_grad():
model_output = model(**encoded_input)
# Perform pooling. In this case, cls pooling.
sentence_embeddings = model_output[0][:, 0]
# normalize embeddings
sentence_embeddings = torch.nn.functional.normalize(sentence_embeddings, p=2, dim=1)
# [[0.5567, 0.3014],# [0.1701, 0.7122]]
scores = (sentence_embeddings[:2] @ sentence_embeddings[2:].T)
Fine-tuning:
Supervised fine-tuning two different models based on data symmetry and then merging via
LM-Cocktail
:
Since we split the data, we could additionally apply the
AnglE loss
to the symmetric model, which enhances performance on symmetric tasks.
Finally, we added the original
bge-m3
model to the two obtained models to prevent catastrophic forgetting, tuning the weights for the merger using
LM-Cocktail
to produce the final model,
USER-bge-m3
.
Total positive pairs:
2,240,961
Total negative pairs:
792,644 (negative pairs from AIINLI, MIRACL, deepvk/ru-WANLI, deepvk/ru-HNP)
For all labeled datasets, we only use its training set for fine-tuning.
For datasets Gazeta, Mlsum, Xlsum: pairs (title/text) and (title/summary) are combined and used as asymmetric data.
AllNLI
is an translated to Russian combination of SNLI, MNLI and ANLI.
Experiments
We compare our mode with the basic
baai/bge-m3
on the
encodechka
benchmark.
In addition, we evaluate model on the russian subset of
MTEB
on Classification, Reranking, Multilabel Classification, STS, Retrieval, and PairClassification tasks.
We use validation scripts from the official repositories for each of the tasks.
We did not thoroughly evaluate the model's ability for sparse and multi-vec encoding.
Citations
@misc{deepvk2024user,
title={USER: Universal Sentence Encoder for Russian},
author={Malashenko, Boris and Zemerov, Anton and Spirin, Egor},
url={https://huggingface.co/datasets/deepvk/USER-base},
publisher={Hugging Face}
year={2024},
}
Runs of deepvk USER-bge-m3 on huggingface.co
361.3K
Total runs
-2.9K
24-hour runs
-8.1K
3-day runs
-4.9K
7-day runs
55.9K
30-day runs
More Information About USER-bge-m3 huggingface.co Model
USER-bge-m3 huggingface.co is an AI model on huggingface.co that provides USER-bge-m3's model effect (), which can be used instantly with this deepvk USER-bge-m3 model. huggingface.co supports a free trial of the USER-bge-m3 model, and also provides paid use of the USER-bge-m3. Support call USER-bge-m3 model through api, including Node.js, Python, http.
USER-bge-m3 huggingface.co is an online trial and call api platform, which integrates USER-bge-m3's modeling effects, including api services, and provides a free online trial of USER-bge-m3, you can try USER-bge-m3 online for free by clicking the link below.
deepvk USER-bge-m3 online free url in huggingface.co:
USER-bge-m3 is an open source model from GitHub that offers a free installation service, and any user can find USER-bge-m3 on GitHub to install. At the same time, huggingface.co provides the effect of USER-bge-m3 install, users can directly use USER-bge-m3 installed effect in huggingface.co for debugging and trial. It also supports api for free installation.