Text Ranking
sentence-transformers
Safetensors
Japanese
modernbert
feature-extraction
hpprc's picture
Update README.md
bb46934 verified
---
language:
- ja
library_name: sentence-transformers
tags:
- sentence-transformers
- feature-extraction
base_model: cl-nagoya/ruri-v3-pt-310m
widget: []
pipeline_tag: text-ranking
license: apache-2.0
datasets:
- cl-nagoya/ruri-v3-dataset-reranker
---
# Ruri-Reranker: Japanese General Reranker
**Ruri-v3 Reranker** is a general-purpose Japanese reranker model built on top of [**ModernBERT-Ja**](https://huggingface.co/collections/sbintuitions/modernbert-ja-67b68fe891132877cf67aa0a).
Ruri v3 offers several key technical advantages:
- **State-of-the-art performance** with good robustness for vaious domains
- **Supports sequence lengths up to 8192 tokens**
- **Expanded vocabulary of 100K tokens**, compared to 32K in v1 and v2
- **Integrated FlashAttention**, following ModernBERT's architecture
- **Tokenizer based solely on SentencePiece**
## How to Use
You can use our models directly with the transformers library v4.48.0 or higher:
```bash
pip install -U "transformers>=4.48.0" sentence-transformers
```
Additionally, if your GPUs support Flash Attention 2, we recommend using our models with Flash Attention 2.
```
pip install flash-attn --no-build-isolation
```
### Example Usage (Sentence Transformers)
```python
from sentence_transformers import CrossEncoder
# Download from the 🤗 Hub
model = CrossEncoder("cl-nagoya/ruri-v3-reranker-310m")
inputs = [
[
"瑠璃色はどんな色?",
"瑠璃色(るりいろ)は、紫みを帯びた濃い青。名は、半貴石の瑠璃(ラピスラズリ、英: lapis lazuli)による。JIS慣用色名では「こい紫みの青」(略号 dp-pB)と定義している[1][2]。",
],
[
"瑠璃色 なに",
"瑠璃色(るりいろ)は、紫みを帯びた濃い青。名は、半貴石の瑠璃(ラピスラズリ、英: lapis lazuli)による。JIS慣用色名では「こい紫みの青」(略号 dp-pB)と定義している[1][2]。",
],
[
"瑠璃色はどんな色?",
"ワシ、タカ、ハゲワシ、ハヤブサ、コンドル、フクロウが代表的である。これらの猛禽類はリンネ前後の時代(17~18世紀)には鷲類・鷹類・隼類及び梟類に分類された。ちなみにリンネは狩りをする鳥を単一の目(もく)にまとめ、vultur(コンドル、ハゲワシ)、falco(ワシ、タカ、ハヤブサなど)、strix(フクロウ)、lanius(モズ)の4属を含めている。",
],
[
"ワシやタカのように、鋭いくちばしと爪を持った大型の鳥類を総称して「何類」というでしょう?",
"ワシ、タカ、ハゲワシ、ハヤブサ、コンドル、フクロウが代表的である。これらの猛禽類はリンネ前後の時代(17~18世紀)には鷲類・鷹類・隼類及び梟類に分類された。ちなみにリンネは狩りをする鳥を単一の目(もく)にまとめ、vultur(コンドル、ハゲワシ)、falco(ワシ、タカ、ハヤブサなど)、strix(フクロウ)、lanius(モズ)の4属を含めている。",
],
[
"ワシやタカのように、鋭いくちばしと爪を持った大型の鳥類を総称して「何類」というでしょう?",
"瑠璃色(るりいろ)は、紫みを帯びた濃い青。名は、半貴石の瑠璃(ラピスラズリ、英: lapis lazuli)による。JIS慣用色名では「こい紫みの青」(略号 dp-pB)と定義している[1][2]。",
],
]
scores = model.predict(inputs)
print(scores)
# [
# 0.9999963,
# 0.9996056,
# 0.00035428265,
# 0.9672038,
# 0.00002276988,
# ]
result = model.rank(
query="瑠璃色はどんな色?",
documents=[
"ワシ、タカ、ハゲワシ、ハヤブサ、コンドル、フクロウが代表的である。これらの猛禽類はリンネ前後の時代(17~18世紀)には鷲類・鷹類・隼類及び梟類に分類された。ちなみにリンネは狩りをする鳥を単一の目(もく)にまとめ、vultur(コンドル、ハゲワシ)、falco(ワシ、タカ、ハヤブサなど)、strix(フクロウ)、lanius(モズ)の4属を含めている。",
"瑠璃、または琉璃(るり)は、仏教の七宝の一つ。サンスクリットの vaiḍūrya またはそのプラークリット形の音訳である。金緑石のこととも、ラピスラズリであるともいう[1]。",
"瑠璃色(るりいろ)は、紫みを帯びた濃い青。名は、半貴石の瑠璃(ラピスラズリ、英: lapis lazuli)による。JIS慣用色名では「こい紫みの青」(略号 dp-pB)と定義している[1][2]。",
],
)
print(result)
# [
# {'corpus_id': 2, 'score': 0.9999963},
# {'corpus_id': 1, 'score': 0.07984412},
# {'corpus_id': 0, 'score': 0.00035577847},
# ]
```
## Benchmarks
|Model|#Param.(w/o Emb.)|JQaRA<br/>nDCG@10|JaCWIR<br/>MAP@10|MIRACL<br/>Recall@30|
|:-|:-:|:-:|:-:|:-:|
||||||
|[Ruri-v3-reranker-310m](https://huggingface.co/cl-nagoya/ruri-v3-reranker-310m) |315M (236M)|**86.9**|**95.4**|**97.3**|
||||||
|[hotchpotch/japanese-reranker-cross-encoder-xsmall-v1](https://huggingface.co/hotchpotch/japanese-reranker-cross-encoder-xsmall-v1)|107M (11M)|61.4|93.8|90.6|
|[hotchpotch/japanese-reranker-cross-encoder-small-v1](https://huggingface.co/hotchpotch/japanese-reranker-cross-encoder-small-v1)|118M (21M)|62.5|93.9|92.2|
|[hotchpotch/japanese-reranker-cross-encoder-base-v1](https://huggingface.co/hotchpotch/japanese-reranker-cross-encoder-base-v1)|111M (86M)|67.1|93.4|93.3|
|[hotchpotch/japanese-reranker-cross-encoder-large-v1](https://huggingface.co/hotchpotch/japanese-reranker-cross-encoder-large-v1)|337M (303M)|71.0|93.6|91.5|
|[hotchpotch/japanese-bge-reranker-v2-m3-v1](https://huggingface.co/hotchpotch/japanese-bge-reranker-v2-m3-v1)|568M (303M)|69.2|93.7|94.7|
|[BAAI/bge-reranker-v2-m3](https://huggingface.co/BAAI/bge-reranker-v2-m3)|568M (303M)|67.3|93.4|94.9|
||||||
|[Ruri-Reranker-Small](https://huggingface.co/cl-nagoya/ruri-reranker-small)|68M (43M)|64.5|92.6|92.3|
|[Ruri-Reranker-Base](https://huggingface.co/cl-nagoya/ruri-reranker-base)|111M (86M)|74.3|93.5|95.6|
|[Ruri-Reranker-Large](https://huggingface.co/cl-nagoya/ruri-reranker-large) |337M (303M)|77.1|94.1|96.1|
## Model Details
### Model Description
- **Model Type:** Sentence Transformer
- **Base model:** [cl-nagoya/ruri-v3-pt-310m](https://huggingface.co/cl-nagoya/ruri-v3-pt-310m)
- **Maximum Sequence Length:** 8192 tokens
- **Language:** Japanese
- **License:** Apache 2.0
- **Paper:** https://arxiv.org/abs/2409.07737
## Citation
```bibtex
@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},
}
```
## License
This model is published under the [Apache License, Version 2.0](https://www.apache.org/licenses/LICENSE-2.0).