スコアリングアルゴリズム
KnowledgePulse スコアリングエンジンは、4つの独立した品質次元を組み合わせた複合式を使用して推論トレースを評価します。フェーズ 2 では、エンジンは異なるタスクドメインに対してスコアリングの重点を調整するドメイン固有の重みプロファイルを導入し、評価ごとに 100ms のパフォーマンスバジェットを適用します。
複合式
全体の品質スコアは4つの正規化された次元の加重和として計算されます:
score = C × wC + N × wN + D × wD + O × wO
各記号の意味:
| 記号 | 次元 | 範囲 |
|---|---|---|
| C | 複雑さ | 0.0 -- 1.0 |
| N | 新規性 | 0.0 -- 1.0 |
| D | ツール多様性 | 0.0 -- 1.0 |
| O | 結果信頼度 | 0.0 -- 1.0 |
重み(wC、wN、wD、wO)はドメインによって異なります。合計は常に 1.0 です。
ドメイン固有の重みプロファイル
異なるタスクドメインは異なる品質シグナルを優先します。財務トレースは高い結果信頼度から最も恩恵を受け、コーディングトレースは多様なツール使用から恩恵を受けます。スコアリングエンジンは metadata.task_domain に基づいて重みプロファイルを自動的に選択します。
利用可能なプロファイル
| ドメイン | wC (複雑さ) | wN (新規性) | wD (ツール多様性) | wO (結果) |
|---|---|---|---|---|
| default | 0.25 | 0.35 | 0.15 | 0.25 |
| finance | 0.20 | 0.25 | 0.10 | 0.45 |
| code | 0.20 | 0.30 | 0.30 | 0.20 |
| medical | 0.15 | 0.20 | 0.10 | 0.55 |
| customer_service | 0.20 | 0.30 | 0.20 | 0.30 |
設計根拠
- Finance は財務分析が正確で検証可能な結論を要求するため、結果信頼度を重く重み付けします。
- Code は効果的なコーディングエージェントが複数のツール(リンター、型チェッカー、テストランナー)を活用するため、ツール多様性を重く重み付けします。
- Medical は医療推論で正確性が重要であるため、最も高い結果信頼度の重み(0.55)を持ちます。
- Customer service は新規性と結果信頼度のバランスを取り、創造的かつ効果的な問題解決を報酬します。
ドメインプロファイルの使用
ドメイン選択はトレースメタデータを通じて自動的に行われます:
import { evaluateValue } from "@knowledgepulse/sdk";
import type { ReasoningTrace } from "@knowledgepulse/sdk";
const trace: ReasoningTrace = {
"@context": "https://openknowledgepulse.org/schema/v1",
"@type": "ReasoningTrace",
id: "kp:trace:finance-demo-001",
metadata: {
created_at: new Date().toISOString(),
task_domain: "finance", // ← finance 重みプロファイルを選択
success: true,
quality_score: 0,
visibility: "network",
privacy_level: "aggregated",
},
task: { objective: "Analyze TSMC Q4 earnings report" },
steps: [
{ step_id: 0, type: "thought", content: "Extracting revenue and margin data" },
{ step_id: 1, type: "tool_call", tool: { name: "financial_data_api" }, input: { ticker: "TSM" } },
{ step_id: 2, type: "observation", content: "Revenue: $26.3B, up 14.3% YoY" },
{ step_id: 3, type: "tool_call", tool: { name: "comparison_tool" }, input: { metric: "gross_margin" } },
{ step_id: 4, type: "observation", content: "Gross margin 57.9%, above industry average" },
],
outcome: {
result_summary: "Strong quarterly performance driven by AI chip demand",
confidence: 0.92,
},
};
const score = await evaluateValue(trace);
// finance の重みでは、高い結果信頼度(0.92)がより多く寄与
console.log(score); // 例: 0.78
ドメインが登録されたプロファイルと一致しない場合、default の重みが使用されます。未知のドメインはサイレントに処理され、エラーはスローされません。