Datasets:
The dataset viewer is not available for this dataset.
Need help to make the dataset viewer work? Make sure to review how to configure the dataset viewer, and open a discussion for direct support.
MIRACL Retrieval (Pairs / Triplets / N-tuples + distillation)
sbintuitions/JMTEB の miracl-retrieval-query / miracl-retrieval-corpus の train split を元に、日本語 retrieval 学習用の (query, positive) ペア、Hard Negative Mining を施した triplet / n-tuple、および Cross-Encoder 蒸留スコアで validated 判定された行のみを抽出した n-tuples-filtered を提供するデータセット。
pairs に加え、cl-nagoya/ruri-v3-310m での kNN 検索と cl-nagoya/ruri-v3-reranker-310m での再スコアリングを通じて Hard Negative を 1 件 / 5 件付与した triplets / n-tuples、ならびに quality_score で validated 判定された行のみを残した n-tuples-filtered を提供する。Dense Retriever / Cross-Encoder の日本語検索モデル学習および KL Divergence 蒸留に利用できる。
元データセット
ベースは sbintuitions/JMTEB の Retrieval タスク MIRACL-ja で、本データセットは miracl-retrieval-query の train split (2,433 クエリ) のみを使用する。validation / test split は本リポジトリには含めず、評価には元データセットを直接利用することを想定している。
MIRACL (Multilingual Information Retrieval Across a Continuum of Languages) の日本語サブセットを、JMTEB が retrieval タスクとして整備したもの。corpus は Wikipedia 由来のパッセージ 6,953,614 件で構成される。
Configs
| config | rows | columns | 説明 |
|---|---|---|---|
| pairs | 4,932 | query, positive | miracl-retrieval-query train から作った (query, positive) ペア |
| triplets | 4,603 | query, positive, negative | クエリごとに 1 件の hard negative を付けた triplet (negative は n-tuples の negative_1 と同一) |
| n-tuples | 4,603 | query, positive, negative_1〜negative_5, label | クエリごとに 5 件の hard negative + Cross-Encoder の生 logit を label に付与 |
| n-tuples-filtered | 4,603 | 同上 | quality_score の valid_mask を通過した行のみ、quality_score 降順で並ぶ |
split は train のみ。triplets / n-tuples / n-tuples-filtered の行数は Hard Negative Mining 時の positive スコア下限フィルタにより pairs (4,932 行) から減っており、pos スコア 2.0 未満の 329 行 (6.7%) を除外している。今回の構築では HNM の margin >= 4.0 フィルタが quality_score の borderline / weak positive / false negative を全て吸収するため、n-tuples-filtered の行数は n-tuples と完全に一致する (全 4,603 行が validated)。
label カラムの形式
List[float] 長さ 6 で [score(query, positive), score(query, neg_1), …, score(query, neg_5)]。label[0] が positive、label[1:] が negative_1〜negative_5 に 1:1 で順序通り対応する。スコアは Cross-Encoder の 生 logit (sigmoid 適用前)。
データセットの構築手順
pairs
- JMTEB の miracl-retrieval-query (train, 2,433 行) と miracl-retrieval-corpus (corpus, 6,953,614 行) を取得する。
- 各クエリの relevant_docs フィールドに含まれる docid を集合化する (4,589 件のユニーク docid)。
- corpus から該当 docid の text を取り出し、(query, docid) を (query, positive) ペアに展開する。
- 1 クエリに対し relevant_docs が複数ある場合は、複数行に展開する。
構築結果:
| 項目 | 件数 |
|---|---|
| 元クエリ数 (train) | 2,433 |
| ユニーク docid 数 | 4,589 |
| 生成された pairs | 4,932 |
| 展開倍率 (pairs / queries) | 約 2.03 |
triplets / n-tuples (Hard Negative Mining)
- 候補プール構築 — pairs の全ユニーク positive (4,589 件) と、miracl-retrieval-corpus からランダムサンプリングした 2,000,000 件のテキスト (seed=42) を結合し、重複除去後の 2,000,605 件を候補プールとする。
- 埋め込み生成 — 候補プールおよびユニーククエリ (2,433 件) を cl-nagoya/ruri-v3-310m (768 次元、ModernBERT-Ja-310m ベース) でエンコード。検索クエリには "検索クエリ: "、文書側には "検索文書: " の prefix を付与した上で、L2 正規化された fp16 埋め込みを得る。
- kNN 検索 — GPU matmul + chunked topk によりクエリ × 候補プールの cosine 類似度を計算、各クエリの top-100 を取得する (top-15 の運用に加え、後段の margin filter で不足する場合の拡張余地を確保。実測では top-up 不要だった)。
- リランクスコア計算 — cl-nagoya/ruri-v3-reranker-310m (Cross-Encoder) で、各ユニーク (query, positive) と (query, kNN top-50 候補) の組について 生 logit (sigmoid 適用前) を計算する (合計 121,714 ペア)。
- Hard Negative 選定 — 行ごとに以下のステップで 5 件を選ぶ。
- 各 pair の positive スコアが 2.0 未満なら、その行を丸ごと除外する (σ(2.0) ≈ 0.88 未満の弱い positive は学習雑音になりやすい)。
- kNN top 候補から、同一クエリの他の positive と一致する pool_id を除外する (false negative 防止)。
- positive スコアとの差が 4.0 未満 (pos - neg < 4.0) の候補を Hard Negative 候補から外す。
- 残った候補のリランクスコア降順で上位 5 件を採用する。
- 候補が 5 件に満たない場合は、kNN を top-100 まで拡張した中で margin filter を通過した候補から補い、それでも不足する場合のみ margin filter 落ち候補のうち最もスコアの高いものを補充する (今回のデータでは全行 margin filter のみで 5 件を満たし、top-up は発生しなかった)。
- triplets と n-tuples 出力 — n-tuples は (query, positive, negative_1〜5, label)、triplets は同じ negative_1 を 1 件 negative とした (query, positive, negative)。
統計 (HNM 結果)
| 指標 | 値 |
|---|---|
| 入力ペア数 | 4,932 |
| positive スコア < 2.0 で除外 | 329 (6.7%) |
| 候補不足で除外 | 0 |
| margin filter のみで 5 件確保 | 4,603 (100%) |
| top-up 使用行 | 0 |
| 累計 negative (margin filter 通過) | 23,015 |
| 累計 negative (top-up) | 0 |
| 出力 triplets / n-tuples 行数 | 4,603 |
label カラム統計 (n-tuples)
| 項目 | min | median | mean | max |
|---|---|---|---|---|
| positive logit | 2.00 | 7.93 | 7.87 | 13.25 |
| max(neg) logit | -7.62 | 0.99 | 1.21 | 8.75 |
| mean(neg) logit | -8.29 | -0.62 | -0.42 | 7.72 |
| margin (= pos - max_neg) | 4.00 | 5.51 | 6.66 | 19.16 |
positive は σ ≈ 0.88〜0.99999 に集中しており、教師が確信を持って relevant と判定した行のみが残っている。max(neg) は σ ≈ 0.5 付近 (mean 1.21、σ(1.21) ≈ 0.77) で「relevant 寄りだが positive より弱い」典型的な Hard Negative の位置にある。margin は最小 4.0 (フィルタどおり) で、Goldilocks ゾーン (+3〜+8) に中央値が収まっている。
n-tuples-filtered (quality_score validated 行のみ)
Cross-Encoder 蒸留スコア付与ガイドの quality_score 定義に従い、n-tuples の label から行ごとに 3 つの mask を計算する。
import numpy as np
POS_MIN = 2.0 # σ(2.0) ≈ 0.88: 確信のある positive のみ採用
MARGIN_MIN = 0.5 # 誤差レベルの分離は雑音と見なす
MARGIN_PENALTY = 0.1 # 易しすぎる行を弱く後回しにする係数
def quality_score_vec(labels: np.ndarray) -> np.ndarray:
p = labels[:, 0]
neg = labels[:, 1:]
max_n = neg.max(axis=1)
mean_n = neg.mean(axis=1)
margin = p - max_n
fn_mask = margin <= 0
weak_mask = (~fn_mask) & (p < POS_MIN)
border_mask = (~fn_mask) & (~weak_mask) & (margin < MARGIN_MIN)
valid_mask = (~fn_mask) & (~weak_mask) & (~border_mask)
raw = mean_n - MARGIN_PENALTY * margin
return np.where(valid_mask, raw, -np.inf)
n-tuples-filtered は valid_mask が True の行のみを残し、quality_score 降順 で並べたもの。今回の HNM 設計では margin >= 4.0 のフィルタが quality_score の各 mask を全て吸収するため、n-tuples の全 4,603 行が validated 判定となり、行集合としては n-tuples と一致する (順序は quality_score 降順)。フィルタの内訳:
| フィルタ | 条件 | 意味 |
|---|---|---|
| 偽 negative | max(neg) >= positive | negative 群に実は relevant な passage が混入 |
| weak positive | positive < 2.0 | 教師が positive を「弱く relevant」としか見ていない |
| borderline | 0 < margin < 0.5 | positive と最強 negative の差が誤差程度 |
蒸留スコア付けの設定
| 項目 | 値 |
|---|---|
| Teacher | cl-nagoya/ruri-v3-reranker-310m |
| Max length | 512 |
| 推論精度 | FP16 |
| Batch size | 128 |
| 入力フォーマット | 単一文ペア (query, document) |
| 出力 | 生 logit (sigmoid 適用前) |
| 観測 logit レンジ | min -10.94, max 13.26 (mean -4.62 / median -5.65 across 121,714 pairs) |
KL 蒸留損失 (SparseDistillKLDivLoss / DistillKLDivLoss 等) は softmax(label / T) を target distribution として使うため、sigmoid 後の [0, 1] 値だと softmax target が一様分布に潰れて ranking 情報が失われる。これを防ぐため、教師の最終活性化を明示的に Identity に置き換えてスコアを出力した。
import torch.nn as nn
from sentence_transformers import CrossEncoder
teacher = CrossEncoder("cl-nagoya/ruri-v3-reranker-310m", max_length=512, device="cuda")
teacher.model.eval()
teacher.default_activation_function = nn.Identity()
scores = teacher.predict(
[("query A", "passage A"), ("query A", "passage B")],
batch_size=128,
convert_to_numpy=True,
activation_fct=nn.Identity(),
)
assert abs(scores).max() > 1.0
logit のスケール感:
| logit | sigmoid(logit) | 解釈 |
|---|---|---|
| +8 | 0.9997 | 確信度高く relevant |
| +5 | 0.993 | 強く relevant |
| +2 | 0.881 | relevant 寄り |
| 0 | 0.5 | 不確か |
| -2 | 0.119 | irrelevant 寄り |
| -5 | 0.007 | 強く irrelevant |
| -8 | 0.0003 | 確信度高く irrelevant |
KL 蒸留損失への組み込み
import torch.nn.functional as F
def kl_distill_loss(student_logits, teacher_label, T=2.0):
log_p_student = F.log_softmax(student_logits / T, dim=-1)
p_teacher = F.softmax(teacher_label / T, dim=-1)
return F.kl_div(log_p_student, p_teacher, reduction="batchmean") * (T * T)
sentence-transformers の SparseDistillKLDivLoss / DistillKLDivLoss を使う場合は、label カラムをそのまま teacher score として渡せばよい。
License
CC BY-SA 4.0
直接のソースである sbintuitions/JMTEB が CC BY-SA 4.0 で配布されているため、本データセットも CC BY-SA 4.0 を継承する。元の MIRACL は Apache-2.0、corpus の Wikipedia 由来テキストは CC BY-SA に従う。
Citation
@misc{sbintuitions_jmteb,
author = {SB Intuitions},
title = {JMTEB: Japanese Massive Text Embedding Benchmark},
year = {2024},
url = {https://huggingface.co/datasets/sbintuitions/JMTEB},
}
@article{miracl,
author = {Xinyu Zhang and Nandan Thakur and Odunayo Ogundepo and Ehsan Kamalloo and David Alfonso-Hermelo and Xiaoguang Li and Qun Liu and Mehdi Rezagholizadeh and Jimmy Lin},
title = {{MIRACL}: A Multilingual Retrieval Dataset Covering 18 Diverse Languages},
journal = {Transactions of the Association for Computational Linguistics},
year = {2023},
}
Acknowledgements
- 元データ: sbintuitions/JMTEB
- 元タスク: MIRACL
- HNM 用 retriever: cl-nagoya/ruri-v3-310m
- 蒸留教師: cl-nagoya/ruri-v3-reranker-310m
- Downloads last month
- 53