Skip to main content
Glama

chunktuner

PyPI version Python versions License: MIT CI Docs

RAGパイプライン向けの自動チャンク分割チューナーおよびMCPサーバーです。

ドキュメントを渡すと、複数のチャンク分割戦略を試し、AIが最も正確に質問に回答できる戦略を測定して、最適なものを提示します。

chunktunerのプロジェクトフロー:ドキュメントが戦略、評価を経て推奨設定に至る様子


機能

RAGパイプラインを構築する際、ドキュメントをどのようにチャンクに分割するかは、検索品質に直接影響します。chunktunerは、特定のコーパス、埋め込みモデル、ユースケースに最適なチャンク分割戦略を見つけるプロセスを自動化します。

固定トークンウィンドウ、再帰的文字分割、セマンティック分割、PDF構造的チャンク分割、ASTベースのコードチャンク分割などの戦略をベンチマークし、実際の検索メトリクス(トークン再現率、MRR、NDCG)やオプションの生成メトリクス(RAGASの忠実度、回答の関連性)に基づいて各戦略をスコアリングします。


Related MCP server: golden-dataset-mcp

インターフェース

  • Pythonライブラリ — パイプラインへのプログラムによる統合

  • CLI (chunk-tune) — ターミナルからの人間によるチューニング

  • MCPサーバー — Claude Desktopや任意のMCPホストから直接利用可能


クイックスタート

# Install
uv tool install chunktuner

# Initialize workspace
chunk-tune init --provider openai

# See cost estimate before running anything
chunk-tune estimate ./my_docs --use-case rag_qa

# Get a recommendation
chunk-tune recommend ./my_docs --use-case rag_qa

Python API:

from pathlib import Path
from chunktuner import FileIngestor, LiteLLMEmbeddingFunction, AutoTuner
from chunktuner import default_registry, Evaluator, ScoreCalculator

docs = FileIngestor().ingest_dir(Path("./my_docs"))
embedding_fn = LiteLLMEmbeddingFunction("text-embedding-3-small")
tuner = AutoTuner(
    strategies=default_registry,
    evaluator=Evaluator(embedding_fn),
    scorer=ScoreCalculator(use_case="rag_qa"),
)
result = tuner.recommend(docs, use_case="rag_qa")
print(result.best.config)

サポートされている戦略

戦略

最適な用途

fixed_tokens

ベースライン、均一なトークンウィンドウ

recursive_character

一般的な文章やドキュメント

semantic

テーマ性の強い記事

markdown_semantic

構造化されたMarkdownドキュメント

pdf_structural

レイアウト領域や表を含むPDF

structural_semantic

レイアウトとテキストが混在するPDF/DOCX

late_chunking

密な相互参照を含む長いドキュメント

agentic

高価値な物語形式のドキュメント

code_ast

コードリポジトリ (Python, JavaScript)

code_window

コードのベースライン (スライディングウィンドウ)


MCPサーバー (Claude Desktop)

Python FastMCP (chunk-tune-mcp, stdio) を使用。Node.jsビルドは不要です。docs/mcp_setup.mdを参照してください。

.mcp.jsonに追加します:

{
  "mcpServers": {
    "chunktuner": {
      "command": "uvx",
      "args": ["--from", "chunktuner[mcp]", "chunk-tune-mcp"],
      "env": {
        "CHUNK_TUNER_BASE_DIR": "/path/to/your/corpus"
      }
    }
  }
}

利用可能なツール:list_strategies, preview_chunks, evaluate_chunking, recommend_config


CLIリファレンス

chunk-tune init       Bootstrap workspace config
chunk-tune analyze    Quick structural scan (no API cost)
chunk-tune estimate   Dry-run cost/token estimate
chunk-tune evaluate   Full evaluation across strategies
chunk-tune recommend  Evaluation + best config recommendation
chunk-tune compare    Side-by-side comparison of specific strategies
chunk-tune preview    Inspect how a strategy splits a document
chunk-tune cache      Manage embedding and chunk cache

インストールオプション

uv add chunktuner                    # library
uv tool install chunktuner           # global CLI
uvx chunktuner                       # ephemeral, no install

# With optional extras
uv add "chunktuner[docling]"         # PDF/DOCX support
uv add "chunktuner[ragas]"           # generation metrics
uv add "chunktuner[semantic]"        # semantic chunking
uv add "chunktuner[code]"            # AST code chunking
uv add "chunktuner[all]"             # everything

コントリビューション

CONTRIBUTING.mdを参照してください。


👨🏻💻 著者

Shantanu Deshmukh

E2E AIアプリケーション構築の経験を持つフルスタック開発者。

Linkedin / Twitter / AngelList

Install Server
A
license - permissive license
B
quality
B
maintenance

Maintenance

Maintainers
Response time
Release cycle
1Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • A
    license
    Not graded
    quality
    D
    maintenance
    Exposes queryable GPU inference benchmark data (quantization, throughput, VRAM, concurrent users) as tools for LLM clients.
    MIT
  • A
    license
    A
    quality
    B
    maintenance
    Enables version-controlled golden dataset management and semantic evaluation for RAG/LLM pipelines using TF-IDF cosine similarity, without requiring an LLM API key.
    9
    MIT
  • A
    license
    Not graded
    quality
    C
    maintenance
    Evaluates RAG outputs on faithfulness, answer relevancy, and context precision using an LLM-as-a-Judge backend. Exposes tools for running evaluations, scoring individual samples, and checking thresholds, enabling CI gating and on-demand assessment via MCP.
    MIT

View all related MCP servers

Related MCP Connectors

  • Multi-LLM entity enrichment: schemas, single/batch enrichment, fusion, model benchmarks.

  • Bounded tools for rendering, extraction, RAG, enrichment, local discovery and review analysis.

  • Machine-readable utilities and datasets for AI agents.

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/shantanu-deshmukh/chunktuner'

If you have feedback or need assistance with the MCP directory API, please join our Discord server