This is a
sentence-transformers model fine-tuned with
Matryoshka Representation Learning (MRL)
on top of
klue/roberta-base. The model produces 768-dim embeddings, but the first
m dims for
m ∈ {768, 512, 256, 128, 64, 32} are themselves valid
sentence representations — you can slice the embedding to trade accuracy for
storage/latency without retraining.
All values are reported as percentages (×100).
1from sentence_transformers import SentenceTransformer
2
3model = SentenceTransformer("jhgan/ko-sroberta-sts-mrl")
4embeddings = model.encode(["안녕하세요", "반갑습니다"])
5print(embeddings.shape) # (2, 768)
1import torch.nn.functional as F
2from sentence_transformers import SentenceTransformer
3
4model = SentenceTransformer("jhgan/ko-sroberta-sts-mrl")
5emb = model.encode(["안녕하세요", "반갑습니다"], convert_to_tensor=True)
6
7# Slice to the first 64 dims and re-normalise for cosine similarity
8emb_64 = F.normalize(emb[:, :64], p=2, dim=1)
1@inproceedings{kusupati2022matryoshka,
2 title = {Matryoshka Representation Learning},
3 author = {Kusupati, Aditya and Bhatt, Gantavya and Rege, Aniket and
4 Wallingford, Matthew and Sinha, Aditya and Ramanujan, Vivek and
5 Howard-Snyder, William and Chen, Kaifeng and Kakade, Sham and
6 Jain, Prateek and Farhadi, Ali},
7 booktitle = {Advances in Neural Information Processing Systems},
8 year = {2022},
9 url = {https://arxiv.org/abs/2205.13147}
10}
This model is part of the
ko-sentence-transformers
project; see the repository for training scripts and the non-MRL baselines
(
jhgan/ko-sroberta-sts,
jhgan/ko-sroberta-nli,
jhgan/ko-sroberta-multitask).