Logo Cost Performance Scorer

Cost Performance Scorer

Cộng đồng
AnthonyAlcaraz
cost-performance-scorer

Score a multi-model routing policy on cost versus quality using the two metrics that actually decide selective intelligence: cost per successful completion (not cost per token) and a per-node quality parity threshold with domain-specific failure weights. Wraps a NodeInvocation log, computes cost-per-success and p95 latency per node, and evaluates a candidate model against a per-node evaluation set drawn from production data. Use to justify or recalibrate a routing decision AFTER you have run traffic. NOT for deciding routing a priori (that is model-routing-selector), NOT for generic benchmarks (MMLU/HumanEval do not capture your alert taxonomy), NOT for latency/KV budgeting (that is kv-cache-latency-budgeter).

Tổng quan

Nhà phát hànhAnthonyAlcaraz
Kho mãagentic-graph-rag-skills
Tên kỹ năngcost-performance-scorer
Sao
29
Bản fork
9
Tệp đi kèm
3
Giấy phépMIT
Liên kết
  • Hướng dẫn bằng Markdown

    Tệp SKILL.md được mô hình tải khi cần, nên chỉ tốn token khi có yêu cầu thực sự phù hợp.

  • Dùng được với mọi LLM

    Kỹ năng AI dùng hướng dẫn viết bằng Markdown thay vì mã dành riêng cho một nhà cung cấp, nên dùng được với GPT, Claude, Gemini, Grok hoặc mô hình cục bộ.

  • 3 tệp đi kèm

    Các tập lệnh, mẫu và tài liệu tham khảo mà mô hình có thể đọc khi làm việc. Các tệp chỉ cho phép đọc và không bao giờ được thực thi.

  • Mã nguồn mở

    Được AnthonyAlcaraz công bố trên GitHub. Hãy đọc các tệp nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Cost Performance Scorer trong TypingMind để dùng với bất kỳ LLM nào, hoặc thêm vào một tác nhân AI khác có thể đọc SKILL.md.

1

Cài đặt trong TypingMind

TypingMind cài đặt kỹ năng trực tiếp từ thư mục GitHub — đọc SKILL.md, đóng gói các tệp tài nguyên và lưu kết quả trên máy.

  1. Mở ứng dụng và vào Plugin → Kỹ năng.
  2. Chọn "Cài đặt từ GitHub".
  3. Dán URL của thư mục kỹ năng được hiển thị bên dưới rồi xác nhận.
    https://github.com/AnthonyAlcaraz/agentic-graph-rag-skills/tree/main/skills/optimization/cost-performance-scorer
  4. Bật kỹ năng trong từng cuộc trò chuyện mà bạn muốn sử dụng kỹ năng đó.
Plugin → Kỹ năng → Thêm kỹ năng → Từ URL GitHub, sau đó dán URL thư mục và nhấn Tiếp tục.
2

Cài đặt trong tác nhân AI khác

Bất kỳ tác nhân AI nào đọc được định dạng Agent Skills đều có thể dùng kỹ năng này — hãy sao chép thư mục vào thư mục kỹ năng của tác nhân AI đó.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/AnthonyAlcaraz/agentic-graph-rag-skills.git /tmp/agentic-graph-rag-skills
mkdir -p .claude/skills
cp -r /tmp/agentic-graph-rag-skills/skills/optimization/cost-performance-scorer .claude/skills/cost-performance-scorer
Khởi động lại Claude Code sau khi sao chép để ứng dụng nhận kỹ năng mới.

Sử dụng trong TypingMind

Bật Cost Performance Scorer trong bất kỳ cuộc trò chuyện nào trên TypingMind, mô hình sẽ tự xử lý phần còn lại. Tên và mô tả của kỹ năng nằm trong prompt hệ thống. Ngay khi có yêu cầu phù hợp, mô hình tự tải toàn bộ hướng dẫn — bạn không cần gọi thủ công và kỹ năng không tốn token cho đến khi thực sự được dùng.

Mô hình tự nạp Cost Performance Scorer ngay khi có yêu cầu phù hợp.

Dùng được với mọi mô hình AI

Kỹ năng AI là các hướng dẫn Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên bạn có thể dùng Cost Performance Scorer với cả những mô hình khác ngoài mô hình ban đầu. Chỉ cần cài đặt một lần trong TypingMind rồi dùng với GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama hoặc mô hình cục bộ do bạn tự chạy — tất cả đều dùng khóa API của riêng bạn.

  • Chỉ tải khi cần

    Prompt hệ thống chỉ chứa tên và mô tả. Hướng dẫn được tải khi có yêu cầu phù hợp đầu tiên, nên khi kỹ năng chưa được dùng, bạn không tốn token cho phần hướng dẫn.

  • Đổi mô hình ngay trong cuộc trò chuyện

    Vì kỹ năng là hướng dẫn chứ không phải mã, việc đổi mô hình không làm kỹ năng ngừng hoạt động — mô hình tiếp theo vẫn đọc cùng tệp SKILL.md.

Hướng dẫn của kỹ năng

Đây là nội dung SKILL.md mà mô hình tải. Hãy đọc trước khi cài đặt — kỹ năng là những hướng dẫn mà mô hình của bạn sẽ làm theo.

Cost-Performance Scorer

Overview

Routing strategies are only as good as the data that informs them. Selective intelligence works only if you can measure it, and the book names two metrics that matter:

  • Cost per successful completion. Cost per task completed correctly, not cost per token. A cheap model that fails 40% of the time is not cheaper than an expensive model that succeeds on the first attempt — the wasted spend on failures is amortized over the successes.
  • Quality parity threshold. The minimum acceptable quality per node type. The AlertClassifier may need 0.99 (a wrong validation is worse than none); the QueryAnalyst may tolerate 0.90 because downstream nodes recover from misclassification.

The book's harness wraps every node and logs a NodeInvocation per call (Example 8-3). Success is judged per node — matching a human-labeled severity for the AlertClassifier, an SRE accepting the recommendation for PredictionSynthesis. Each candidate model is scored against a per-node evaluation set with domain failure weights (Example 8-4): a P1 alert misclassified as P3 is 10x worse than the reverse, an asymmetry a generic accuracy metric cannot express. Kakao's AI Shopping Mate is the worked anchor: restructuring GPT-4o-everywhere into a workflow graph of fine-tuned 27-32B models moved format adherence from 0.655 to 0.987 and accuracy from 0.578 to 0.890, with the smaller models preferred over GPT-4o in 63% of 2,100 turns.

When to Use

  • You have run production traffic through a routed pipeline and need to know which node is over- or under-provisioned.
  • You are choosing a specialist SLM and must evaluate it on your data, not MMLU.
  • A cheap node looks cheap per token but you suspect its failure rate erases the savings.
  • You need a per-node quality gate before promoting a routing change.

Phrases that should invoke this skill: "cost per successful completion", "is this model actually cheaper", "per-node evaluation set", "quality parity threshold", "score the routing policy", "weighted error rate".

When NOT to Use

  • Deciding routing before you run — that is model-routing-selector (Ch8). This skill measures what happened; that one decides what should happen.
  • Generic capability benchmarking — MMLU/HumanEval scores do not predict performance on your alert taxonomy (Ch8 Common Pitfalls: "benchmarking models on the wrong evaluation set").
  • Latency / KV-cache budgeting — that is kv-cache-latency-budgeter.
  • When you have no ground-truth success signal. Cost-per-success requires a per-node evaluator (gold labels or downstream acceptance). Without it, you can only report cost per call, which is the metric this skill exists to replace.

Process

StepInputActionOutputVerification
1Invocation log JSON_load_tracker(path)CostTracker of NodeInvocationsEach row has node_name, cost_usd, success
2Node nametracker.cost_per_success(node)$/successful completionFinite, > 0; higher than $/call by the failure ratio
3Node nametracker.node_report(node)success_rate + p95 latency + $/successsuccess_rate in [0,1]
4(gold, pred) pairs + eval setlib.evaluate_candidate(preds, set)accuracy + meets_threshold + weighted_error_rateweighted_error applies the domain failure weights
5Full trackerlib.score_policy(tracker)Pipeline total + blended $/successSums per-node; blended ≥ max single-node $/success/pipeline-len
6Two model profileslib.compare_cost_per_success(...)Which is cheaper per call vs per successCheaper-per-call and cheaper-per-success can disagree

Rationalizations

Agent rationalizationDocumented rebuttal
"This model is 10x cheaper per token, ship it."Cost per token is not cost per success. If it fails 40% of the time and each failure triggers a retry or a downstream error, the true cost per completed task can exceed the reliable model (Ch8). Measure cost-per-success.
"It scores 85% on MMLU, that's good enough."MMLU does not contain your alert-classification taxonomy. The book's pitfall is exactly this: build a per-node eval set from production data and re-evaluate when the task distribution shifts.
"Accuracy is 0.985, close enough to the 0.99 bar."For the AlertClassifier a missed P1 is catastrophic; the bar is 0.99 and 0.985 fails it. The weighted_error_rate exists to price that asymmetry (P1_as_P3 = 10x).
"One eval set for the whole pipeline is simpler."Nodes have different stakes: 0.99 for the AlertClassifier, 0.90 for the QueryAnalyst. A shared set over- or under-gates half the pipeline (Example 8-4).
"Smaller models always cost quality."Kakao's fine-tuned 27-32B models beat GPT-4o on their task (0.987 vs 0.655 format adherence) and were preferred in 63% of 2,100 turns. Specialization can improve quality because the training signal is focused.

Red Flags

  • Cost per success reported as cost per call. If success is not evaluated, the headline metric is missing; wire a per-node evaluator first.
  • A node's success_rate is 1.0 across thousands of calls. Either the evaluator is a no-op or the eval set is trivial — real production nodes fail.
  • weighted_error_rate equals the raw error rate. The failure weights are not being applied; check the <gold>_as_<pred> keys.
  • Blended $/success unchanged after a routing change. The change moved cost between nodes without improving completions; re-inspect per-node reports.
  • CLI --help exits non-zero. SKILL.md / CLI mismatch.

Non-Negotiable Verification

Before trusting a policy score:

  1. Run the benchmark battery.

    python cli.py benchmark

    Confirms cost-per-success is computed, the domain failure weights apply (P1_as_P3 = 10.0), the 0.99 threshold gate is honoured, and the cost-per-success inversion holds (cheaper-per-call ≠ cheaper-per-success).

  2. Score the sample policy and read the per-node table.

    python cli.py score

    Confirm the SLM nodes are far cheaper per success than the frontier synthesis node, and that a node with seeded failures shows success_rate < 1.0.

  3. Evaluate a candidate against a real per-node set.

    python cli.py evaluate AlertClassifier

    Confirm a single P1-as-P3 miss produces a weighted_error_rate of 10.0, not 1.0.

  4. Domain test in the notebook. Run notebooks/ch8-optimization.ipynb; confirm the cost-performance section reads moto-mocked CloudWatch cost and latency signals into the tracker and computes cost-per-success per node.

Security Posture

  • Read-only over the invocation log. lib.py makes no network calls and writes nothing; it consumes a log the caller supplies.
  • Cost figures are inputs, not authority. The log's cost_usd values come from the caller's pricing; verify them against live pricing before acting.
  • Untrusted logs. If the invocation log is machine-generated from an external system, validate the schema (numeric costs, boolean success) before scoring — a poisoned log could hide a failing node behind fabricated successes.

Composition

  • Closes the loop with model-routing-selector (Ch8): the cost-per-success numbers here recalibrate the cascade thresholds and per-node bars there.
  • Feeds the Ch7 self-evolution loop: cost-per-success and weighted-error are evaluation signals the diagnostic engine can act on.
  • Pairs with kv-cache-latency-budgeter (Ch8): this scores cost/quality; that scores latency/concurrency. Both gate a production routing change.

Source Attribution

Distilled from Agentic GraphRAG (O'Reilly, by Anthony Alcaraz and Sam Julien), Chapter 8 — Optimization, "Measuring Cost-Performance Tradeoffs". Key references:

  • Example 8-3 CostTracker / NodeInvocation (cost per successful completion)
  • Example 8-4 per-node evaluation sets with domain failure weights
  • Kakao AI Shopping Mate (0.655 -> 0.987 format adherence, 0.578 -> 0.890 accuracy, 63% preference over GPT-4o across 2,100 turns)

Tệp đi kèm

Khi kỹ năng đã được tải, mô hình có thể đọc các tệp này nếu cần. Các tệp này chỉ dùng để đọc và không bao giờ được thực thi.

Câu hỏi thường gặp

Kỹ năng AI Cost Performance Scorer làm được gì?

Score a multi-model routing policy on cost versus quality using the two metrics that actually decide selective intelligence: cost per successful completion (not cost per token) and a per-node quality parity threshold with domain-specific failure weights. Wraps a NodeInvocation log, computes cost-per-success and p95 latency per node, and evaluates a candidate model against a per-node evaluation set drawn from production data. Use to justify or recalibrate a routing decision AFTER you have run traffic. NOT for deciding routing a priori (that is model-routing-selector), NOT for generic benchma...

Vì sao nên dùng Cost Performance Scorer trên TypingMind?

Vì bạn chỉ cần cài một lần rồi dùng với bất kỳ mô hình nào. Cost Performance Scorer là nội dung Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên cùng một kỹ năng có thể chạy trên GPT-5, Claude, Gemini, Grok hoặc mô hình trên thiết bị — và bạn có thể đổi mô hình ngay trong cuộc trò chuyện mà kỹ năng vẫn hoạt động. TypingMind dùng khóa API riêng của bạn, nên bạn thanh toán trực tiếp cho nhà cung cấp thay vì trả phí thuê bao theo suất người dùng, đồng thời kỹ năng và các cuộc trò chuyện vẫn nằm trong bộ lưu trữ của bạn.

Làm thế nào để cài Cost Performance Scorer trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/AnthonyAlcaraz/agentic-graph-rag-skills/tree/main/skills/optimization/cost-performance-scorer. TypingMind đọc tệp SKILL.md, đóng gói các tệp đi kèm rồi cài đặt cả gói dưới dạng một kỹ năng mà bạn có thể bật cho từng cuộc trò chuyện.

Những mô hình AI nào có thể dùng Cost Performance Scorer?

Bất kỳ mô hình nào bạn kết nối trong TypingMind. Kỹ năng AI là các hướng dẫn bằng Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên GPT, Claude, Gemini, Grok và các mô hình chạy trên thiết bị đều có thể tải kỹ năng này khi có yêu cầu phù hợp.

Có thể dùng Cost Performance Scorer với bao nhiêu mô hình AI?

Bao nhiêu cũng được. Miễn là mô hình hỗ trợ kỹ năng, bạn có thể dùng Cost Performance Scorer với mô hình đó — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama và nhiều mô hình khác — tất cả đều trên TypingMind với khóa API riêng của bạn.

Kỹ năng AI Cost Performance Scorer có miễn phí không?

Có. Kỹ năng này được AnthonyAlcaraz phát hành trên GitHub theo giấy phép MIT. Bạn chỉ trả tiền cho nhà cung cấp AI của mình theo số token đã dùng.

Kỹ năng AI là gì?

Kỹ năng AI là một gói hướng dẫn có thể tái sử dụng, chỉ cho mô hình AI cách thực hiện một tác vụ cụ thể. Kỹ năng tuân theo định dạng mở Agent Skills: một tệp SKILL.md chứa tên và mô tả, cùng các tập lệnh, mẫu hoặc tệp tham khảo mà mô hình có thể cần. Mô hình chỉ đọc hướng dẫn khi yêu cầu của bạn phù hợp với kỹ năng, nên kỹ năng đã cài đặt không phát sinh chi phí cho đến khi được sử dụng.

Kỹ năng AI khác gì với plugin hoặc máy chủ MCP?

Plugin hoặc máy chủ MCP cung cấp các công cụ mới mà mô hình có thể gọi. Khi mô hình gọi một công cụ, mã của công cụ đó chạy ở đâu đó và trả về kết quả. Còn kỹ năng AI cung cấp kiến thức và quy trình: cách tiếp cận tác vụ, các bước cần thực hiện và những tiêu chí mà kết quả cần đáp ứng. Kỹ năng chỉ là nội dung Markdown, nên không cần máy chủ, khóa API hay môi trường thực thi và hoạt động với mọi mô hình.

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇