Ruri v3
is a general-purpose Japanese text embedding model built on top of
ModernBERT-Ja
.
Ruri v3 offers several key technical advantages:
State-of-the-art performance
for Japanese text embedding tasks.
Supports sequence lengths up to 8192 tokens
Previous versions of Ruri (v1, v2) were limited to 512.
Expanded vocabulary of 100K tokens
, compared to 32K in v1 and v2
The larger vocabulary make input sequences shorter, improving efficiency.
Integrated FlashAttention
, following ModernBERT's architecture
Enables faster inference and fine-tuning.
Tokenizer based solely on SentencePiece
Unlike previous versions, which relied on Japanese-specific BERT tokenizers and required pre-tokenized input, Ruri v3 performs tokenization with SentencePiece only—no external word segmentation tool is required.
Model Series
We provide Ruri-v3 in several model sizes. Below is a summary of each model.
You can use our models directly with the transformers library v4.48.0 or higher:
pip install -U "transformers>=4.48.0"
Additionally, if your GPUs support Flash Attention 2, we recommend using our models with Flash Attention 2.
pip install flash-attn --no-build-isolation
Then you can load this model and run inference.
import torch.nn.functional as F
from sentence_transformers import SentenceTransformer
# Download from the 🤗 Hub
model = SentenceTransformer("cl-nagoya/ruri-v3-130m")
# Ruri v3 employs a 1+3 prefix scheme to distinguish between different types of text inputs:# "" (empty string) is used for encoding semantic meaning.# "トピック: " is used for classification, clustering, and encoding topical information.# "検索クエリ: " is used for queries in retrieval tasks.# "検索文書: " is used for documents to be retrieved.
sentences = [
"川べりでサーフボードを持った人たちがいます",
"サーファーたちが川べりに立っています",
"トピック: 瑠璃色のサーファー",
"検索クエリ: 瑠璃色はどんな色?",
"検索文書: 瑠璃色(るりいろ)は、紫みを帯びた濃い青。名は、半貴石の瑠璃(ラピスラズリ、英: lapis lazuli)による。JIS慣用色名では「こい紫みの青」(略号 dp-pB)と定義している[1][2]。",
]
embeddings = model.encode(sentences, convert_to_tensor=True)
print(embeddings.size())
# [5, 512]
similarities = F.cosine_similarity(embeddings.unsqueeze(0), embeddings.unsqueeze(1), dim=2)
print(similarities)
# [[1.0000, 0.9564, 0.8183, 0.7000, 0.7108],# [0.9564, 1.0000, 0.8112, 0.6994, 0.7117],# [0.8183, 0.8112, 1.0000, 0.8788, 0.8514],# [0.7000, 0.6994, 0.8788, 1.0000, 0.9448],# [0.7108, 0.7117, 0.8514, 0.9448, 1.0000]]
@misc{
Ruri,
title={{Ruri: Japanese General Text Embeddings}},
author={Hayato Tsukagoshi and Ryohei Sasano},
year={2024},
eprint={2409.07737},
archivePrefix={arXiv},
primaryClass={cs.CL},
url={https://arxiv.org/abs/2409.07737},
}
ruri-v3-130m huggingface.co is an AI model on huggingface.co that provides ruri-v3-130m's model effect (), which can be used instantly with this cl-nagoya ruri-v3-130m model. huggingface.co supports a free trial of the ruri-v3-130m model, and also provides paid use of the ruri-v3-130m. Support call ruri-v3-130m model through api, including Node.js, Python, http.
ruri-v3-130m huggingface.co is an online trial and call api platform, which integrates ruri-v3-130m's modeling effects, including api services, and provides a free online trial of ruri-v3-130m, you can try ruri-v3-130m online for free by clicking the link below.
cl-nagoya ruri-v3-130m online free url in huggingface.co:
ruri-v3-130m is an open source model from GitHub that offers a free installation service, and any user can find ruri-v3-130m on GitHub to install. At the same time, huggingface.co provides the effect of ruri-v3-130m install, users can directly use ruri-v3-130m installed effect in huggingface.co for debugging and trial. It also supports api for free installation.