コンテンツにスキップ
Nibiru docsv0.9.2

トレーニング コーパス

ドキュメントがLoRAトレーニングセットとしてエクスポートされる方法と、それを再生成する方法。

Stable Reading time ~ 1 min Edit on GitHub

このドキュメンテーションのすべてのページはまた、トレーニングデータポイントです。Nibiruには、Llama、Mistral、Qwen、GemmaなどのオープンウェイトモデルをNibiru固有の知識でLoRA微調整に適したクリーンなJSONLコーパスを抽出するスクリプトが付属しています。

Terminal window
cd docs
npm run build:corpus

これは書きます。

docs/dist/corpus/
├── instructions.jsonl # instruction → response pairs
├── chat.jsonl # OpenAI/Anthropic chat-message format
├── completion.jsonl # plain prompt → completion (legacy)
└── chunks.jsonl # raw Markdown chunks (one per H2/H3 section)

LoRAに適した指示調整:

{
"instruction": "How do I scaffold a new module in Nibiru?",
"input": "",
"output": "Run `./nibiru -m <name>`, optionally with `-g` for Graylog hooks. This creates `application/module/<name>/` with traits/, plugins/, interfaces/, settings/<name>.ini and the main `<name>.php` class implementing `IModule`."
}

各エントリは、明確な質問(H2/H3タイトルから派生)とセクション本文を答えとして生成されます。

OpenAIチャット / Anthropicメッセージ形式:

{
"messages": [
{"role": "system", "content": "You are an expert on the Nibiru PHP framework."},
{"role": "user", "content": "How do I scaffold a new module?"},
{"role": "assistant", "content": "Run `./nibiru -m <name>`. …"}
]
}

OpenAIのfine-tune、AnthropicのAPI評価、ほとんどのLoRAツール(Axolotlのsharegptテンプレート、Unsloth、LLaMA-Factory)と互換性があります。

生のチャンクは、RAG検索データとして使用するために保存されます。

{
"id": "core/modules#observer-pattern",
"title": "The observer pattern",
"url": "/core/modules/#the-observer-pattern",
"section": "core/modules",
"language": "en",
"tokens": 412,
"content": "Modules implementing `SplSubject` can broadcast events…"
}

これはOracleが内部で使用している正確なファイルです。

コーパスビルダーは、src/content/docs/ ディレクトリ以下のすべての .md および .mdx ファイルを走査し、AST(抽象構文木)にパースし、H2/H3 の境界でチャンク分けします。以下を強制します:

  • 1つのセクションごとに1つのチャンク(またはH2が空の場合はH3)。
  • 各チャンクは約200〜800トークンで、長ければ分割し、短ければ結合します。
  • コードフェンスはそのまま保持されます — ブロックの途中で分割しません。
  • 各チャンクにはソースパス、アンカーURL、および言語コードが含まれます。

スクリプトは scripts/build-corpus.mjs にあり、完全に構成可能です。

シングル A100 / 4090 上での 8B パラメータベースモデルの実用的な基準:

axolotl.yaml
base_model: meta-llama/Llama-3.1-8B-Instruct
adapter: lora
lora_r: 16
lora_alpha: 32
lora_dropout: 0.05
lora_target_modules: [q_proj, k_proj, v_proj, o_proj]
datasets:
- path: docs/dist/corpus/chat.jsonl
type: sharegpt
sequence_len: 4096
sample_packing: true
gradient_accumulation_steps: 4
micro_batch_size: 2
num_epochs: 3
optimizer: adamw_bnb_8bit
learning_rate: 0.0002
warmup_ratio: 0.05
bf16: true

訓練を実行し、その後LoRAの重みをマージしてOllama、vLLM、またはtext-generation-inference経由で提供します。OracleのMODELをローカルエンドポイントを指すように変更すると、完全にNibiruネイティブなチャットユーザーインターフェースが得られます。

ドキュメントの変更時に毎回再実行する

Section titled “ドキュメントの変更時に毎回再実行する”

CIに組み込んでください。

- name: Build corpus
run: cd docs && npm run build:corpus
- name: Upload corpus artifact
uses: actions/upload-artifact@v4
with:
name: nibiru-corpus
path: docs/dist/corpus/

ドキュメントが変更されると、コーパスが再構築されます;消費者(トレーニングパイプライン、RAG インデックス)は常に最新のデータを持っています。

コーパスはロケールを尊重しています。en/ 以下のページは language: en、ドイツ語のページは language: de とタグ付けされています。JSONL を language フィールドでフィルタリングして、単語学的または多言語の LoRAs を訓練します。

ドキュメントは、フレームワーク自体と同じBSD-4-Clauseライセンスで許可されています。エクスポートされたコーパスもそのライセンスを受け継ぎます — あなたは、それに基づいてモデルを商業的に微調整することができますが、著作権表示が必要です。