mahiyama commited on
Commit
e7d9ef0
·
verified ·
1 Parent(s): fa8ac51

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +91 -95
README.md CHANGED
@@ -27,31 +27,27 @@ datasets:
27
  - mahiyama/mldr-retrieval
28
  ---
29
 
30
- <p align="left">
31
- English&nbsp;|&nbsp;<a href="README_JA.md">日本語</a>
32
- </p>
33
-
34
  # splade-ja-310m-v2
35
 
36
- A Japanese SPLADE (Learned Sparse Retrieval) model based on `sbintuitions/modernbert-ja-310m`. Starting from a general-purpose base model trained on a large multi-source corpus, it is further fine-tuned for a short period on domain-specific data (government FAQs, quizzes, academic papers, and long documents) to improve retrieval accuracy.
37
 
38
- ## Model Overview
39
 
40
- | Item | Details |
41
  |---|---|
42
- | Base model | [sbintuitions/modernbert-ja-310m](https://huggingface.co/sbintuitions/modernbert-ja-310m) |
43
- | Architecture | Transformer (fill-mask) + SpladePooling (max) |
44
- | Parameters | approx. 315M |
45
- | Max input length | 8,192 tokens (this model was trained at 1,024 tokens) |
46
- | Vocabulary size (= output dimensions) | 102,400 |
47
- | Tokenizer | SentencePiece (uses the ModernBERT-Ja vocabulary as-is) |
48
- | Main framework | sentence-transformers >= 5.4 (SparseEncoder) |
49
- | Loss function | reranker distillation via CachedSpladeLoss(SparseDistillKLDivLoss) |
50
- | Mixed precision | bf16 |
51
 
52
- SPLADE produces sparse embeddings by max-pooling the MLM head logits per vocabulary dimension, resulting in only a few dozen to a few hundred non-zero dimensions per text. Because retrieval can be scored with a dot product, it integrates well with inverted indexes (Elasticsearch, OpenSearch, Vespa, Qdrant, etc.). Since each dimension corresponds to a vocabulary token, it also offers high interpretability: you can directly inspect which words act as retrieval signals.
53
 
54
- ## Usage
55
 
56
  ```python
57
  from sentence_transformers import SparseEncoder
@@ -71,57 +67,57 @@ documents = [
71
  q_emb = model.encode_query(queries)
72
  d_emb = model.encode_document(documents)
73
 
74
- # Compute similarity scores with the dot product
75
  scores = model.similarity(q_emb, d_emb)
76
  print(scores)
77
 
78
- # Inspect expansion tokens (top_k=15 vocabulary terms and their weights)
79
  for token, weight in model.decode(q_emb[0], top_k=15):
80
  print(f" {token:>20} {weight:.3f}")
81
  ```
82
 
83
- The same encoder is used for both queries and documents (symmetric, not asymmetric). Scores should be computed with the dot product (dot, not cosine).
84
 
85
- ## Training Method
86
 
87
- ### Base Model
88
 
89
- The model is built on `sbintuitions/modernbert-ja-310m`. Its MLM head is used as the projection to the vocabulary dimensions for SPLADE, combined with SpladePooling (max) to obtain sparse embeddings.
90
 
91
- ### Training Data
92
 
93
- All training data is in the n-tuples format (query / positive / negative_1 to negative_5), with teacher scores attached as the label. Each dataset is built with the following pipeline.
94
 
95
- | # | Step | Details |
96
  |---|---|---|
97
- | 1 | Hard Negative Mining | Hard negatives that are easily confused with the correct answer are mined via kNN search using the text embedding model [cl-nagoya/ruri-v3-310m](https://huggingface.co/cl-nagoya/ruri-v3-310m). Specifically, the top 15 documents by cosine similarity to the query are retrieved from the corpus, the correct answer (positive) is excluded, the remaining candidates are re-scored with the reranker below, and only candidates whose score is sufficiently separated from the positive score are adopted as negatives in descending order of score. |
98
- | 2 | Distillation Scoring | The reranker [cl-nagoya/ruri-v3-reranker-310m](https://huggingface.co/cl-nagoya/ruri-v3-reranker-310m) scores each (query, positive) and (query, negative_1 to negative_5) pair, and its raw logit is attached as the label. This label is used as the teacher signal for KLDiv distillation (SparseDistillKLDivLoss wrapped in CachedSpladeLoss). |
99
- | 3 | Quality Score Filter | Using the quality_score computed from the labels, only rows with high training value are retained — the n-tuples-filtered config. It keeps only valid rows that satisfy the conditions: the positive is reliable (its positive score is sufficiently high), there are no false negatives (no negative score exceeds the positive), and the negative margin is not excessive. |
100
 
101
- The specific datasets and adopted row counts are listed in the staged training tables below.
102
 
103
- ### Staged Training
104
 
105
- To balance generality and domain adaptation, training is done in two stages. In Stage 1 a general-purpose SPLADE base is built from a large multi-source corpus, and in Stage 2 that model is used as the starting point for short fine-tuning on domain-specific data. This raises domain accuracy without significantly degrading the representations of the general-purpose base.
106
 
107
- ### Stage 1: Building the General-Purpose Base
108
 
109
- A general-purpose SPLADE base covering a wide range of domains was built via KLDiv distillation on a multi-source corpus of about 2.2M rows.
110
 
111
- #### Training Data
112
 
113
- | Dataset | Config | Adopted rows | Total tokens |
114
  |---|---|---:|---:|
115
  | [mahiyama/auto-wiki-qa](https://huggingface.co/datasets/mahiyama/auto-wiki-qa) | n-tuples-1m | 993,749 | 704.83M |
116
  | [mahiyama/mqa-ja](https://huggingface.co/datasets/mahiyama/mqa-ja) | n-tuples-1m | 994,263 | 389.89M |
117
  | [mahiyama/mmarco-ja](https://huggingface.co/datasets/mahiyama/mmarco-ja) | n-tuples | 186,747 | 77.86M |
118
  | [mahiyama/miracl-retrieval](https://huggingface.co/datasets/mahiyama/miracl-retrieval) | n-tuples-filtered | 4,431 | 3.60M |
119
  | [mahiyama/mrtydi](https://huggingface.co/datasets/mahiyama/mrtydi) | n-tuples-filtered | 3,083 | 3.51M |
120
- | Total | | 2,182,273 | 1,179.69M |
121
 
122
- #### Hyperparameters
123
 
124
- | Item | Value |
125
  |---|---|
126
  | learning_rate | 5e-6 |
127
  | query_regularizer_weight | 1e-5 |
@@ -134,33 +130,33 @@ A general-purpose SPLADE base covering a wide range of domains was built via KLD
134
  | mini_batch_size | 32 |
135
  | temperature (SparseDistillKLDivLoss) | 2.0 |
136
 
137
- #### Training Time
138
 
139
- About 32.5 hours on an RTX PRO 6000 Blackwell Workstation Edition (96GB) x 1.
140
 
141
- ### Stage 2: Short Fine-Tuning on Specific Domains
142
 
143
- Starting from the Stage 1 model, short fine-tuning was performed on data from the government FAQ, quiz, academic paper, and long-document domains. By keeping the learning rate and regularization low, domain accuracy is improved while retaining generality.
144
 
145
- #### Training Data
146
 
147
- | Dataset | Config | Adopted rows | Total tokens | Role |
148
  |---|---|---:|---:|---|
149
- | [mahiyama/JaGovFaqs-22k](https://huggingface.co/datasets/mahiyama/JaGovFaqs-22k) | n-tuples-filtered | 11,107 | 8.13M | Government FAQ |
150
- | [mahiyama/amagasaki-qna](https://huggingface.co/datasets/mahiyama/amagasaki-qna) | n-tuples-filtered | 11,069 | 5.51M | Municipal QA |
151
- | [mahiyama/quiz-works](https://huggingface.co/datasets/mahiyama/quiz-works) | n-tuples-filtered | 12,502 | 16.67M | Quiz (short text) |
152
- | [mahiyama/quiz-no-mori](https://huggingface.co/datasets/mahiyama/quiz-no-mori) | n-tuples-filtered | 13,422 | 20.37M | Quiz (short to medium text) |
153
- | [mahiyama/anlp-meeting-retrieval](https://huggingface.co/datasets/mahiyama/anlp-meeting-retrieval) | title-abs_n-tuples-filtered | 1,926 | 1.72M | Academic papers (title-abs) |
154
- | [mahiyama/anlp-meeting-retrieval](https://huggingface.co/datasets/mahiyama/anlp-meeting-retrieval) | abs-intro_n-tuples-filtered | 2,014 | 6.59M | Academic papers (abs-intro) |
155
- | [mahiyama/anlp-meeting-retrieval](https://huggingface.co/datasets/mahiyama/anlp-meeting-retrieval) | title-intro_n-tuples-filtered | 1,952 | 6.97M | Academic papers (title-intro) |
156
- | [mahiyama/mldr-retrieval](https://huggingface.co/datasets/mahiyama/mldr-retrieval) | n-tuples-filtered | 349 | 1.97M | Long-document retrieval |
157
- | Total | | 54,341 | 67.94M | |
158
 
159
- All of this training data is built only from the train split of each JMTEB v2 dataset. The dev / test splits used for evaluation are never included in training, so there is no test-data leakage into the evaluation results.
160
 
161
- #### Hyperparameters
162
 
163
- | Item | Value |
164
  |---|---|
165
  | learning_rate | 2e-6 |
166
  | query_regularizer_weight | 1.5e-5 |
@@ -173,40 +169,40 @@ All of this training data is built only from the train split of each JMTEB v2 da
173
  | mini_batch_size | 8 |
174
  | temperature (SparseDistillKLDivLoss) | 2.0 |
175
 
176
- #### Training Time
177
 
178
- About 5.0 hours on an RTX PRO 6000 Blackwell Workstation Edition (96GB) x 1.
179
 
180
- In both stages the regularizer weight is scheduled with a quadratic warmup, which prevents the embeddings from collapsing due to excessive regularization early in training.
181
 
182
- ### Noise Token Suppression
183
 
184
- To achieve natural vocabulary expansion, a mechanism is built in to suppress, during training, tokens that have no value as retrieval signals.
185
 
186
- Suppression targets include punctuation and symbols, the standalone SPM word-initial marker , byte fallbacks (<0xHH>), decorative placeholders (○○, ※, ■, →, etc.), special tokens ([CLS], [SEP], [PAD], [MASK]), and corpus-derived meta tokens. Specifically, tokens automatically detected over the entire vocabulary by the following rules, plus corpus-specific meta tokens added manually:
187
 
188
- - Tokens composed only of Unicode categories Punctuation / Symbol / Separator / Other / Mark
189
- - Byte fallbacks (in the <0xHH> form)
190
- - The standalone SPM word-initial marker
191
- - Repetitions of the same character (ーー, ・・, !!, etc.)
192
- - Tokens composed only of modifier letters (Unicode category Lm)
193
- - Single ASCII letters or digits
194
- - A literal list of decorative placeholders (○○, ××, △△, ■, ※, ▼, ◆, …, ★, ☆, ♪, →, ・, ー, etc.)
195
- - Special tokens (CLS / SEP / PAD / MASK / UNK / BOS / EOS)
196
 
197
- Suppression is made permanent in the following two stages.
198
 
199
- 1. Forward pre-hook during training: immediately before SpladePooling, -1e4 is added to the suppressed dimensions of the MLM logits, so that gradients barely flow. To avoid producing NaN under bf16, -1e4 is used instead of -inf (relu(log(1+exp(-1e4))) ≈ 0, effectively zero).
200
 
201
- 2. Bias baking after training: -1e4 is permanently written into the suppressed dimensions of the MLM head bias parameters. Even after the hook is removed, the noise dimensions do not reappear at inference time, and the saved model can be loaded with a plain `SparseEncoder.from_pretrained()` (no trust_remote_code or extra modules required).
202
 
203
- ## Evaluation Results (JMTEB v2)
204
 
205
- nDCG@10 was measured on the 11 JMTEB v2 retrieval tasks. Note that because [JMTEB v2](https://github.com/sbintuitions/JMTEB) does not support sparse models, the measurement was done with [jmteb-v2-sparse-eval](https://github.com/mahiya/jmteb-v2-sparse-eval), an evaluation harness for evaluating sparse embedding models on the JMTEB v2 retrieval tasks.
206
 
207
- Also, during evaluation model.max_seq_length was set per task as shown in the table below. Ideally we would set model.max_seq_length=8192 to handle the full input, but due to GPU resource constraints we evaluated with the minimum number of tokens required for each task. Note that when max_seq_length is small, input tokens beyond it are truncated, so scores tend to drop for tasks that contain long documents.
208
 
209
- | Task | max_seq_length | nDCG@10 | Recall@10 | MAP@10 |
210
  |---|---:|---:|---:|---:|
211
  | NLPJournalTitleAbsRetrieval.V2 | 512 | 0.9557 | 0.9882 | 0.9448 |
212
  | NLPJournalTitleIntroRetrieval.V2 | 2456 | 0.9251 | 0.9824 | 0.9059 |
@@ -219,37 +215,37 @@ Also, during evaluation model.max_seq_length was set per task as shown in the ta
219
  | MultiLongDocRetrieval | 8192 | 0.5291 | 0.6400 | 0.4941 |
220
  | MIRACLRetrieval | 512 | 0.7444 | 0.8599 | 0.6655 |
221
  | MrTidyRetrieval | 512 | 0.6340 | 0.7863 | 0.5706 |
222
- | Average | | 0.7501 | 0.8319 | 0.7187 |
223
 
224
  ## Lessons Learned
225
 
226
- ### 1. Large-scale scaling-up saturates when the teacher is fixed
227
 
228
- This project distills the teacher reranker's outputs (logits) into the student. Under this setup, increasing the training data roughly 7x from 300K to 2.2M and investing about 33 GPU hours kept the JMTEB v2 5-task average almost flat, from 0.8258 to 0.8262 (+0.0004). With a fixed teacher, the amount of information the student can learn is bounded by the teacher's knowledge capacity; beyond a certain point, adding data becomes "repeated learning of the same knowledge," and it appears to saturate at a certain scale (around 300K here).
229
 
230
- By contrast, stacking short fine-tuning (FT) on a few thousand rows of domain data onto the same 300K base lifted the average to 0.8652 (+0.039) in about an hour of training. That is an order of magnitude more efficient than the +0.0004 from a 7x data increase. Once scores plateau, it seems better to redirect investment from data volume to data quality (stricter top-K filtering, stronger hard negatives, teacher ensembles) or targeted short FT.
231
 
232
- ### 2. Data diversification has a higher ROI than increasing data volume
233
 
234
- With hyperparameters fixed, simply changing the training data from a single source (Wikipedia 250K) to a mix of 5 domains with different writing styles and query lengths (Wikipedia QA / community Q&A / passage retrieval / trivia quizzes; about 274K total, roughly the same row count) improved Jaqket Retrieval nDCG@10 (+0.018 with an 8K corpus, +0.019 in the full evaluation with a corpus of 65,802).
235
 
236
- Notably, the same +0.018 had previously required a 2.5x increase in data volume. Simply going from 1 to 5 sources, with almost no change in row count, yielded a gain equivalent to a 2.5x increase. Moreover, this 274K model outperformed a configuration that increased a single source up to 1M rows, using about 1/3.6 of the data. This is likely because diversification broadens query-side vocabulary expansion (the average number of active query dimensions rose from 15 to 19). The implementation simply aligns each source to a common schema and concatenates and shuffles them; no special normalization was needed.
237
 
238
- ### 3. "Small-fraction multi-source mixing" is effective against catastrophic forgetting
239
 
240
- When short FT is concentrated on a single specific domain, the targeted task improves while unrelated tasks regress substantially — a "seesaw" phenomenon. In fact, when fine-tuning on a single academic-paper source, long-document tasks improved but the short-text quiz-style Jaqket dropped sharply by -0.169. Mixing in the domains that are easily lost (here, the short-query quiz-style data) protects them; in the mixed configuration, Jaqket not only recovered from the regression but also exceeded its original score.
241
 
242
- That said, "how much to mix" matters. Thinly mixing in general web text at only 3-4% of the total (about 2,000 rows) did not recover it; recovery only occurred when injected at a ratio of 10-20% or more. Domains you want to protect need to be added "thickly up to a certain ratio," not "in small amounts."
243
 
244
- ### 4. Input sequence length is the biggest lever for retrieval tasks with long documents
245
 
246
- For retrieval tasks where the document side contains long text such as papers, whether the document can be read in full greatly affects the score. Raising model.max_seq_length (the number of tokens the model can read at once) produced larger improvements on such tasks than any hyperparameter or data-composition change. For example, on MultiLongDocRetrieval (median document length about 6,700 tokens), simply extending from 1024 to 4096 improved nDCG@10 by 0.22.
247
 
248
- However, the longer the sequence length, the more time and memory training, evaluation, and inference require (going from 512 to 1024 roughly 1.8x'd the per-step training time). In this project, large-scale general-purpose base training prioritized throughput at 512, the published model with short FT stacked on top used 1024 for long-document support, and 4096 was confirmed effective in diagnostic experiments but kept as an option for long-document specialization rather than routine use.
249
 
250
 
251
- ## License
252
 
253
- The model weights are provided under the MIT License. The base model, [sbintuitions/modernbert-ja-310m](https://huggingface.co/sbintuitions/modernbert-ja-310m), is also under the MIT License.
254
 
255
- However, please note that part of the training data uses mmarco-ja, a Japanese translation of MS MARCO. MS MARCO is released on the premise of non-commercial research use, and its licensing for commercial use is not clear. Therefore, if you use this model for commercial purposes, please review the MS MARCO terms of use and make your own judgment at your own responsibility.
 
27
  - mahiyama/mldr-retrieval
28
  ---
29
 
 
 
 
 
30
  # splade-ja-310m-v2
31
 
32
+ `sbintuitions/modernbert-ja-310m` をベースとした日本語 SPLADE (Learned Sparse Retrieval) モデルです。大規模な汎用コーパスで学習した汎用ベースモデルを起点に、行政 FAQ・クイズ・学術論文・長文といった特定ドメインのデータで短期ファインチューニングを行い、検索精度を高めています。
33
 
34
+ ## モデルの概要
35
 
36
+ | 項目 | 内容 |
37
  |---|---|
38
+ | ベースモデル | [sbintuitions/modernbert-ja-310m](https://huggingface.co/sbintuitions/modernbert-ja-310m) |
39
+ | アーキテクチャ | Transformer (fill-mask) + SpladePooling (max) |
40
+ | パラメータ数 | 315M |
41
+ | 最大入力長 | 8,192 tokens (本モデルの訓練は 1,024 tokens で実施) |
42
+ | 語彙サイズ (= 出力次元数) | 102,400 |
43
+ | トークナイザ | SentencePiece (ModernBERT-Ja の語彙をそのまま使用) |
44
+ | 主要フレームワーク | sentence-transformers >= 5.4 (SparseEncoder) |
45
+ | 損失関数 | CachedSpladeLoss(SparseDistillKLDivLoss) による reranker 蒸留 |
46
+ | 混合精度 | bf16 |
47
 
48
+ SPLADE MLM head logits を語彙次元ごとに max pooling して得られる、文ごとに非ゼロ次元が数十から数百しかないスパース埋め込みです。検索時は内積でスコアリングできるので、転置インデックス (Elasticsearch, OpenSearch, Vespa, Qdrant ) との親和性が高いのが特徴です。各次元が語彙トークンに対応するため、どの語が検索シグナルとして効いているかを直接確認できる解釈性の高さも利点です。
49
 
50
+ ## 使い方
51
 
52
  ```python
53
  from sentence_transformers import SparseEncoder
 
67
  q_emb = model.encode_query(queries)
68
  d_emb = model.encode_document(documents)
69
 
70
+ # 内積で類似度スコアを計算
71
  scores = model.similarity(q_emb, d_emb)
72
  print(scores)
73
 
74
+ # 拡張トークンを覗く (top_k=15 の語彙とその重み)
75
  for token, weight in model.decode(q_emb[0], top_k=15):
76
  print(f" {token:>20} {weight:.3f}")
77
  ```
78
 
79
+ クエリと文書で同じ encoder を使う設計です (asymmetric ではなく symmetric)。スコアは内積で計算してください (cosine ではなく dot)
80
 
81
+ ## トレーニング方法
82
 
83
+ ### ベースモデル
84
 
85
+ `sbintuitions/modernbert-ja-310m` を基盤としています。このモデルの MLM head SPLADE の語彙次元射影として利用し、SpladePooling (max) を組み合わせてスパース埋め込みを得ます。
86
 
87
+ ### 学習データ
88
 
89
+ 学習には、いずれも query / positive / negative_1〜5 n-tuples 形式に、教師スコアを label として付与したデータセットを使用しています。各データセットは次のパ��プラインで構築されています。
90
 
91
+ | # | 工程 | 内容 |
92
  |---|---|---|
93
+ | 1 | Hard Negative Mining | テキスト埋め込みモデルである [cl-nagoya/ruri-v3-310m](https://huggingface.co/cl-nagoya/ruri-v3-310m) による kNN 検索で、正解に紛らわしい Hard Negatives を採掘しています。具体的には、query とコーパス全文書のコサイン類似度が最も高いトップ 15 件を取得し、正解 (positive) を除いた候補に対して下記のリランカーでスコアを再計算したうえで、positive スコアとの差が一定以上 (確実に分離できる) 候補のみをスコア降順で negative として採用しています。 |
94
+ | 2 | 蒸留スコアリング | リランカーである [cl-nagoya/ruri-v3-reranker-310m](https://huggingface.co/cl-nagoya/ruri-v3-reranker-310m) (query, positive) (query, negative_1〜5) の各ペアを採点し、その raw logit label として付与しています。この label を教師信号として KLDiv 蒸留 (SparseDistillKLDivLoss CachedSpladeLoss でラップ) を行っています。 |
95
+ | 3 | 品質スコアフィルタ | label から算出した quality_score を基準に、学習価値が高い行のみを残した n-tuples-filtered config を使用しています。positive が信頼できる (positive スコアが十分高い)、偽 negative が混入していない (negative スコアが positive を超えない)、negative マージンが過度でない、という条件を満たす valid 行のみを残しています。 |
96
 
97
+ 具体的なデータセットと採用件数は、後述の段階的トレーニングの各テーブルに記載しています。
98
 
99
+ ### 段階的トレーニング
100
 
101
+ 汎用性とドメイン適合を両立させるため、2 段階で学習しています。第 1 段階で大規模マルチソースコーパスから汎用 SPLADE ベースを構築し、第 2 段階でそのモデルを起点に特定ドメインデータで短期ファインチューニングを行うことで、汎用ベースの表現を大きく崩さずにドメイン精度を引き上げています。
102
 
103
+ ### 1 段階: 汎用ベースの構築
104
 
105
+ 2.2M 行のマルチソースコーパスで KLDiv 蒸留を行い、幅広いドメインに対応する汎用 SPLADE ベースを構築しました。
106
 
107
+ #### 学習データ
108
 
109
+ | データセット | Config | 採用件数 | 合計トークン数 |
110
  |---|---|---:|---:|
111
  | [mahiyama/auto-wiki-qa](https://huggingface.co/datasets/mahiyama/auto-wiki-qa) | n-tuples-1m | 993,749 | 704.83M |
112
  | [mahiyama/mqa-ja](https://huggingface.co/datasets/mahiyama/mqa-ja) | n-tuples-1m | 994,263 | 389.89M |
113
  | [mahiyama/mmarco-ja](https://huggingface.co/datasets/mahiyama/mmarco-ja) | n-tuples | 186,747 | 77.86M |
114
  | [mahiyama/miracl-retrieval](https://huggingface.co/datasets/mahiyama/miracl-retrieval) | n-tuples-filtered | 4,431 | 3.60M |
115
  | [mahiyama/mrtydi](https://huggingface.co/datasets/mahiyama/mrtydi) | n-tuples-filtered | 3,083 | 3.51M |
116
+ | 合計 | | 2,182,273 | 1,179.69M |
117
 
118
+ #### ハイパーパラメータ
119
 
120
+ | 項目 | |
121
  |---|---|
122
  | learning_rate | 5e-6 |
123
  | query_regularizer_weight | 1e-5 |
 
130
  | mini_batch_size | 32 |
131
  | temperature (SparseDistillKLDivLoss) | 2.0 |
132
 
133
+ #### 訓練時間
134
 
135
+ RTX PRO 6000 Blackwell Workstation Edition (96GB) x 1 で約 32.5 時間。
136
 
137
+ ### 2 段階: 特定ドメイン短期ファインチューニング
138
 
139
+ 1 段階のモデルを起点に、行政 FAQ・クイズ・学術論文・長文の各ドメインデータで短期 FT を行いました。学習率と正則化を抑えることで、汎用性を保ったままドメイン精度を引き上げています。
140
 
141
+ #### 学習データ
142
 
143
+ | データセット | Config | 採用件数 | 合計トークン数 | 役割 |
144
  |---|---|---:|---:|---|
145
+ | [mahiyama/JaGovFaqs-22k](https://huggingface.co/datasets/mahiyama/JaGovFaqs-22k) | n-tuples-filtered | 11,107 | 8.13M | 行政 FAQ |
146
+ | [mahiyama/amagasaki-qna](https://huggingface.co/datasets/mahiyama/amagasaki-qna) | n-tuples-filtered | 11,069 | 5.51M | 自治体 QA |
147
+ | [mahiyama/quiz-works](https://huggingface.co/datasets/mahiyama/quiz-works) | n-tuples-filtered | 12,502 | 16.67M | クイズ (短文) |
148
+ | [mahiyama/quiz-no-mori](https://huggingface.co/datasets/mahiyama/quiz-no-mori) | n-tuples-filtered | 13,422 | 20.37M | クイズ (短〜中文) |
149
+ | [mahiyama/anlp-meeting-retrieval](https://huggingface.co/datasets/mahiyama/anlp-meeting-retrieval) | title-abs_n-tuples-filtered | 1,926 | 1.72M | 学術論文 (title-abs) |
150
+ | [mahiyama/anlp-meeting-retrieval](https://huggingface.co/datasets/mahiyama/anlp-meeting-retrieval) | abs-intro_n-tuples-filtered | 2,014 | 6.59M | 学術論文 (abs-intro) |
151
+ | [mahiyama/anlp-meeting-retrieval](https://huggingface.co/datasets/mahiyama/anlp-meeting-retrieval) | title-intro_n-tuples-filtered | 1,952 | 6.97M | 学術論文 (title-intro) |
152
+ | [mahiyama/mldr-retrieval](https://huggingface.co/datasets/mahiyama/mldr-retrieval) | n-tuples-filtered | 349 | 1.97M | 長文ドキュメント検索 |
153
+ | 合計 | | 54,341 | 67.94M | |
154
 
155
+ これらの学習データは、いずれも JMTEB v2 の各データセットの train split のみから構築しています。評価に用いる dev / test split は学習には一切含めていないため、評価結果へのテストデータの混入 (リーク) はありません。
156
 
157
+ #### ハイパーパラメータ
158
 
159
+ | 項目 | |
160
  |---|---|
161
  | learning_rate | 2e-6 |
162
  | query_regularizer_weight | 1.5e-5 |
 
169
  | mini_batch_size | 8 |
170
  | temperature (SparseDistillKLDivLoss) | 2.0 |
171
 
172
+ #### 訓練時間
173
 
174
+ RTX PRO 6000 Blackwell Workstation Edition (96GB) x 1 で約 5.0 時間。
175
 
176
+ 正則化重みはいずれの段階でも quadratic warmup でスケジューリングし、訓練序盤に正則化が過剰に効いて埋め込みが潰れるのを防いでいます。
177
 
178
+ ### ノイズトークンの抑止
179
 
180
+ 自然な語彙拡張を実現するため、検索シグナルとして無価値なトークンを訓練段階で抑止する仕組みを組み込んでいます。
181
 
182
+ 抑止対象は、句読点や記号、SPM の語頭マーカ単独、バイトフォールバック (<0xHH>)、装飾プレースホルダ (○○, ※, ■, → )、特殊トークン ([CLS], [SEP], [PAD], [MASK])、コーパス由来のメタトークンなどです。具体的には、語彙全体に対して以下のルールで自動判定したものに、コーパス固有のメタトークンを加えています。
183
 
184
+ - Unicode カテゴリが Punctuation / Symbol / Separator / Other / Mark のみで構成されるトークン
185
+ - バイトフォールバック (<0xHH> 形式)
186
+ - SPM 語頭マーカ 単独
187
+ - 同一文字の繰り返し (ーー, ・・, !! など)
188
+ - modifier letter (Unicode カテゴリ Lm) のみで構成されるトークン
189
+ - ASCII 1 文字の英字・数字
190
+ - 装飾プレースホルダのリテラルリスト (○○, ××, △△, ■, ※, ▼, ◆, …, ★, ☆, ♪, →, ・, ー など)
191
+ - 特殊トークン (CLS / SEP / PAD / MASK / UNK / BOS / EOS)
192
 
193
+ 抑止は次の 2 段階で恒久化しています。
194
 
195
+ 1. 訓練時の forward pre-hook: SpladePooling の直前で MLM logits の抑止対象次元へ -1e4 を加算し、勾配がほぼ立たないようにします。bf16 環境で NaN を生まないよう -inf ではなく -1e4 を使用しています (relu(log(1+exp(-1e4))) ≈ 0 で実効ゼロ)
196
 
197
+ 2. 訓練後の bias 焼込: MLM head bias パラメータの抑止対象次元へ -1e4 を恒久的に書き込みます。hook を外したあとも推論時にノイズ次元が復活せず、保存モデルは素の `SparseEncoder.from_pretrained()` で読み込めます (trust_remote_code や追加モジュール不要)
198
 
199
+ ## 評価結果 (JMTEB v2)
200
 
201
+ JMTEB v2 retrieval 11 タスクで nDCG@10 を測定しました。なお、[JMTEB v2](https://github.com/sbintuitions/JMTEB) Sparse Model をサポートしていないため、測定には JMTEB v2 Retrieval タスクで Sparse Embedding モデルを評価するための評価ハーネスである [jmteb-v2-sparse-eval](https://github.com/mahiya/jmteb-v2-sparse-eval) を使用しています。
202
 
203
+ また、評価時には model.max_seq_length をタスクごとに下表の通り設定しています。本来は model.max_seq_length=8192 として全入力を扱いたいところですが、GPU リソースの制約から、各タスクで必要となる最低限のトークン数に抑えて評価しています。max_seq_length を小さくするとそれを超える入力トークンは切り捨てられるため、長文を含むタスクでは評価スコアが下がりやすい点に注意してください。
204
 
205
+ | タスク | max_seq_length | nDCG@10 | Recall@10 | MAP@10 |
206
  |---|---:|---:|---:|---:|
207
  | NLPJournalTitleAbsRetrieval.V2 | 512 | 0.9557 | 0.9882 | 0.9448 |
208
  | NLPJournalTitleIntroRetrieval.V2 | 2456 | 0.9251 | 0.9824 | 0.9059 |
 
215
  | MultiLongDocRetrieval | 8192 | 0.5291 | 0.6400 | 0.4941 |
216
  | MIRACLRetrieval | 512 | 0.7444 | 0.8599 | 0.6655 |
217
  | MrTidyRetrieval | 512 | 0.6340 | 0.7863 | 0.5706 |
218
+ | 平均 | | 0.7501 | 0.8319 | 0.7187 |
219
 
220
  ## Lessons Learned
221
 
222
+ ### 1. 大規模スケールアップは教師が固定なら飽和する
223
 
224
+ 本プロジェクトは教師リランカーの出力 (logits) を生徒に蒸留する構成です。この構成で訓練データを 300K から 2.2M へ約 7 倍に増やし約 33 GPU 時間を投じても、JMTEB v2 5 タスク平均は 0.8258 から 0.8262 (+0.0004) とほぼ横ばいでした。教師が固定だと生徒が学べる情報量は教師の知識容量に律速され、データを増やしても途中から「同じ知識の反復学習」になり、ある規模 (本件では 300K 前後) で飽和するように見えました。
225
 
226
+ 対照的に、同じ 300K ベースに数千行のドメインデータで短期 Fine-Tuning (FT) を重ねると、1 時間ほどの訓練で平均が 0.8652 (+0.039) へ跳ね上がりました。7 倍のデータ増が +0.0004 だったのと比べ桁違いの効率です。スコアが頭打ちになったら、投資先をデータ量ではなくデータ質 (top-K フィルタ厳格化、ハードネガティブ強化、教師アンサンブル) や的を絞った短期 FT に振り替えるのが良いと感じました。
227
 
228
+ ### 2. データ多様化はデータ量の増加よりも ROI が高い
229
 
230
+ ハイパーパラメータを固定したまま、訓練データを単一ソース (Wikipedia 250K) から、文体もクエリ長も異なる 5 ドメイン (Wikipedia QA / コミュニティ Q&A / パッセージ検索 / 雑学クイズ) のミックス (合計 274K、件数はほぼ同じ) に変えるだけで、Jaqket Retrieval nDCG@10 が改善しました (corpus 8K +0.018、corpus 65,802 のフル評価で +0.019)。
231
 
232
+ 注目すべきは、同じ +0.018 が前段ではデータ量を 2.5 倍にして得られていた点です。件数をほぼ変えずソース数を 1 から 5 にするだけで、2.5 倍増と同等の伸びが出たことになります。さらにこの 274K モデルは、単一ソースを 1M 行まで増やした構成を約 1/3.6 のデータ量で上回りました。多様化でクエリ側の語彙拡張が広がる (query の平均アクティブ次元数が 15 から 19 に上昇) ためと見られます。実装は各ソースを共通スキーマに揃えて連結・シャッフルするだけで、特別な正規化は不要でした。
233
 
234
+ ### 3. Catastrophic Forgetting 対策は「Multi-source の少量混合」が有効
235
 
236
+ 特定ドメインだけで集中的に短期 FT をすると、狙ったタスクは伸びる一方、無関係なタスクが大きく退行する「シーソー現象」が起きます。実際、論文ドメインの単一ソースで FT した際は長文タスクが伸びた反面、短文クイズ系の Jaqket -0.169 と急落しました。失われやすいドメイン (ここでは短文クエリのクイズ系) を訓練データに混ぜると保護でき、混合構成では Jaqket が退行を解消したうえ元を上回りました。
237
 
238
+ ただし「混ぜる量」が重要だと感じました。Web 一般文章を全体の 34% ( 2,000 ) だけ薄く混ぜても回復せず、1020% 以上の比率で投入して初めて回復しました。保護したいドメインは「少量入れる」のではなく「一定比率まで厚く入れる」必要があると考えました。
239
 
240
+ ### 4. 入力系列長は長文を扱う検索タスクで最大のレバーになる
241
 
242
+ 論文など長文を文書側に持つ検索タスクでは、文書を読み切れるかがスコアを大きく左右します。model.max_seq_length (モデルが一度に読み込めるトークン数) を引き上げると、こうしたタスクでハイパーパラメータやデータ構成のどの変更よりも大きな改善が出ました。たとえば MultiLongDocRetrieval (文書長の中央値が約 6,700 トークン) では、1024 から 4096 に伸ばすだけで nDCG@10 0.22 向上しました。
243
 
244
+ ただし系列長を伸ばすほど訓練・評価・推論の時間とメモリは増えます (512→1024 1 ステップの訓練時間が約 1.8 )。本プロジェクトでは大規模な汎用ベース学習はスループット優先で 512、その上に短期 FT を重ねた公開モデルは長文対応で 1024 とし、4096 は診断実験で効果を確認しつつ常用はせず長文特化用の選択肢としました。
245
 
246
 
247
+ ## ライセンス
248
 
249
+ 本モデルの重みは MIT License で提供します。ベースモデルである [sbintuitions/modernbert-ja-310m](https://huggingface.co/sbintuitions/modernbert-ja-310m) MIT License です。
250
 
251
+ ただし、学習データの一部に MS MARCO の日本語訳である mmarco-ja を使用している点に注意してください。MS MARCO は非商用の研究目的での利用を前提に公開されており、商用利用に関するライセンスは明確ではありません。そのため、本モデルを商用目的で利用する場合は、利用者ご自身の責任で MS MARCO の利用規約を確認したうえでご判断ください。