CoolFace
Modelpublic

cl-nagoya/ruri-v3-reranker-310m

sourceHugging Faceapache-2.0updated 1y agoView on Hugging Face
15likes299kdownloads
Model Card

Ruri-Reranker: Japanese General Reranker

Ruri-v3 Reranker is a general-purpose Japanese reranker model built on top of **ModernBERT-Ja**. 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@10JaCWIR<br/>MAP@10MIRACL<br/>Recall@30
Ruri-v3-reranker-310m315M (236M)86.995.497.3
hotchpotch/japanese-reranker-cross-encoder-xsmall-v1107M (11M)61.493.890.6
hotchpotch/japanese-reranker-cross-encoder-small-v1118M (21M)62.593.992.2
hotchpotch/japanese-reranker-cross-encoder-base-v1111M (86M)67.193.493.3
hotchpotch/japanese-reranker-cross-encoder-large-v1337M (303M)71.093.691.5
hotchpotch/japanese-bge-reranker-v2-m3-v1568M (303M)69.293.794.7
BAAI/bge-reranker-v2-m3568M (303M)67.393.494.9
Ruri-Reranker-Small68M (43M)64.592.692.3
Ruri-Reranker-Base111M (86M)74.393.595.6
Ruri-Reranker-Large337M (303M)77.194.196.1

Model Details

Model Description

  • —Model Type: Sentence Transformer
  • —Base model: 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.