Skip to content
Back to Portfolio
AI / Machine LearningIn Development

Kotoba — Japanese RAG Evaluation Harness

Kotoba — Japanese RAG Evaluation Harness

A reproducible RAG evaluation harness designed for Japanese-language documents. Combines Sudachi/MeCab morphological pre-processing, pgvector-based batch measurement of nDCG@10, MRR, and Recall@K, and automated comparisons across Japanese-tuned embeddings such as ruri-large. Internal R&D harness.

2026 Ongoing (internal validation) 2026-04
#RAG#評価#日本語NLP#pgvector#ベンチマーク

Live Demo

Preview the actual application interface

DEMO
app.kotoba.jp/dashboard
Recall@10
0.847
+4.2%
nDCG@10
0.792
+3.1%
MRR
0.681
+5.8%
Gold dataset
12,480
社内検証

Retriever 比較

live refresh 5s
BM25 (sudachi)R@10 72 · nDCG 68 · MRR 58
Dense (ruri-large)R@10 84 · nDCG 79 · MRR 66
Hybrid RRFR@10 91 · nDCG 86 · MRR 74

Embedding Leaderboard

internal benchmark
#ModelParamsR@10nDCG
1ruri-large-v2337M0.8470.792
2multilingual-e5-large560M0.8210.774
3cl-nagoya/sup-simcse-ja110M0.7890.751
4sudachi-bm25 (baseline)0.7240.683
5mE5-small118M0.7120.669

Query trace — sample #842

index: kotoba-legal-ja-v3

Query

医療機器の添付文書における使用期限の記載要件を教えて

#1
薬機法施行規則 第218条0.942

医療機器の添付文書には、使用の期限を記載しなければならない…

#2
PMDA ガイダンス 20230.887

使用期限の表示は、製造販売業者が設定する有効期間に基づき…

#3
JIS T 14971:20200.812

リスクマネジメントの観点から、使用期限の妥当性を検証する…

#4
社内SOP MED-0070.774

ラベル表示における日付フォーマットは YYYY.MM 形式とし…

retrieval 42ms · rerank 18ms · total 84msreranker: bge-reranker-v2-m3 · top-k 10

Challenge

Existing RAG evaluation tools assume English tokenization and similarity, mishandling Japanese phrase boundaries and orthographic variation, which underestimates retrieval-quality deltas. Public Japanese eval datasets are also scarce, making it hard to benchmark internal know-how reproducibly.

Solution

Pluggable tokenizer layer switches between Sudachi (modes A/B/C) and MeCab+IPAdic, while pgvector (HNSW/IVFFlat) runs ruri-large, multilingual-e5, and OpenAI text-embedding-3 in parallel. JSQuAD and MIRACL-ja are augmented with synthetic QA pairs generated by an LLM-as-Judge, and Ragas-compatible metrics are persisted to DuckDB.

Results

  • +18-point nDCG@10 lift on 1,200 internal synthetic QA pairs (internal benchmark)
  • Quantified Sudachi mode impact — Mode C shows -6% accuracy on long passages
  • Per-run wall-clock time cut from 42 min to 9 min via parallelization
  • Reproducible YAML configs now drive a nightly regression workflow on GitHub Actions
Key Metrics

Measured Impact

評価データセット件数

1,200 QA

+1,200 (内部合成)

nDCG@10改善幅

+18pt

社内ベースライン比

1ラン実行時間

9分

-33分

並列ワーカー数

8

+6

Features

What it does

評価機能

nDCG/MRR/Recall@K

主要IRメトリクスをDuckDBに永続化し差分可視化。

LLM-as-Judge

合成QAとRagas faithfulness/answer relevancy。

日本語対応

トークナイザ抽象

Sudachi A/B/CモードとMeCabをプラガブル切替。

表記ゆれ正規化

NFKC・全半角・カタカナ揺れの事前統一。

Architecture

System Layers

Layered architecture showing components, responsibilities, and data flow.

L1

Layer

前処理層

表記ゆれと分かち書き境界を揃える日本語前処理。モード別に分岐し結果をキャッシュ。

Sudachi.rsMeCabnormalize-jpUnicodeNFKC
L2

Layer

検索層

密ベクトルとBM25のハイブリッドで候補抽出、cross-encoderで再ランキング。

pgvector HNSWIVFFlatBM25 (PGroonga)ハイブリッドReranker
L3

Layer

評価層

実行ごとのメトリクスとプロンプトをDuckDBに蓄積し差分レポートを生成。

RagasカスタムnDCGDuckDBJupyter Reports
Development Process

How we built it

Step 1

データセット整備

JSQuAD・MIRACL-jaと社内合成QAを統一スキーマに変換。

Deliverables

  • データローダ
  • スキーマ定義
  • 品質レポート
Step 2

トークナイザ比較

Sudachi各モードとMeCabの精度・速度をマトリクス評価。

Deliverables

  • ベンチマーク表
  • ユニットテスト
  • 設定テンプレート
Step 3

埋め込みモデル評価

ruri-large等の日本語特化モデルを並列評価。

Deliverables

  • モデル比較レポート
  • 埋め込みキャッシュ
Step 4

CI統合

夜間回帰と差分アラートをGitHub Actionsに組み込み。

Deliverables

  • ワークフローYAML
  • 通知Bot
  • ダッシュボード
Roadmap

Delivery Timeline

  • Phase 1Done2026-04

    トークナイザ抽象層

    Sudachi/MeCabをPluginインターフェースで統一し単体テストを整備。

  • Phase 2In Progress2026-05

    評価メトリクス実装

    nDCG/MRR/Recallを再計算可能な形でDuckDBに永続化。

  • Phase 3Planned2026-06

    LLM-as-Judge合成QA

    社内文書からQAペアを自動生成し人手レビュー導線を追加。

  • Phase 4Planned2026-08

    OSS公開検討

    MITライセンスでの部分公開と社外ベンチマーク受け入れ。

Team

Who built it

2engineers

Roles

  • MLエンジニア (リード)
  • データエンジニア (パートタイム)
Tech Stack

Tools & Platforms

Backend

Python 3.12

Data

pgvectorPostgreSQL 16

Infrastructure

GitHub Actions

Other

Sudachi.rsMeCabruri-largemultilingual-e5RagasDuckDBLangChainPydantic v2pytestPoetry
Build with KGA

Considering a similar project?

We will propose the best solution for your business needs.

Discuss Your Project