Logo von Cost Performance Scorer

Cost Performance Scorer

Community
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).

Übersicht

HerausgeberAnthonyAlcaraz
Repositoryagentic-graph-rag-skills
Skill-Namecost-performance-scorer
Sterne
29
Forks
9
Mitgelieferte Dateien
3
LizenzMIT
Links
  • Anweisungen in Markdown

    Eine SKILL.md-Datei, die das Modell bei Bedarf lädt. So werden nur dann Token verbraucht, wenn eine Anfrage tatsächlich dazu passt.

  • Funktioniert mit jedem LLM

    KI-Skills bestehen aus reinem Markdown, nicht aus anbieterspezifischem Code. Daher funktionieren sie mit GPT, Claude, Gemini, Grok oder einem lokalen Modell.

  • Mitgelieferte Dateien: 3

    Skripte, Vorlagen und Referenzmaterial, die das Modell bei der Arbeit lesen kann. Die Dateien sind schreibgeschützt und werden niemals ausgeführt.

  • Open Source

    Von AnthonyAlcaraz auf GitHub veröffentlicht. Prüfen Sie vor der Installation die Quelldateien.

Installation

Installieren Sie den KI-Skill Cost Performance Scorer in TypingMind, um ihn mit jedem LLM zu nutzen, oder fügen Sie ihn einem anderen Agenten hinzu, der SKILL.md lesen kann.

1

In TypingMind installieren

TypingMind installiert einen Skill direkt aus seinem GitHub-Ordner. Dabei liest die App SKILL.md, bündelt die Ressourcendateien und speichert das Ergebnis lokal.

  1. Öffnen Sie die App und gehen Sie zu Plugins → Skills.
  2. Wählen Sie „Von GitHub installieren“.
  3. Fügen Sie die unten angegebene URL des Skill-Ordners ein und bestätigen Sie.
    https://github.com/AnthonyAlcaraz/agentic-graph-rag-skills/tree/main/skills/optimization/cost-performance-scorer
  4. Aktivieren Sie den Skill in jedem Chat, in dem er verfügbar sein soll.
Plugins → Skills → Skill hinzufügen → Über GitHub-URL. Fügen Sie dann die Ordner-URL ein und klicken Sie auf „Weiter“.
2

In einem anderen Agenten installieren

Jeder Agent, der das Agent-Skills-Format unterstützt, kann diesen Skill nutzen. Kopieren Sie den Ordner in das Skill-Verzeichnis des jeweiligen Agenten.

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
Starten Sie Claude Code nach dem Kopieren neu, damit der neue Skill erkannt wird.

In TypingMind verwenden

Aktivieren Sie Cost Performance Scorer in einem beliebigen Chat in TypingMind. Den Rest übernimmt das Modell. Name und Beschreibung des Skills stehen im System-Prompt. Sobald eine Anfrage passt, lädt das Modell selbstständig die vollständigen Anweisungen — Sie müssen den Skill nie manuell aufrufen, und er verbraucht erst Token, wenn er tatsächlich genutzt wird.

Das Modell lädt Cost Performance Scorer automatisch, sobald eine passende Anfrage gestellt wird.

Funktioniert mit jedem KI-Modell

KI-Skills bestehen aus reinen Markdown-Anweisungen statt aus anbieterspezifischem Code. Daher ist Cost Performance Scorer nicht an das Modell gebunden, für das der Skill geschrieben wurde. Installieren Sie ihn einmal in TypingMind und nutzen Sie ihn mit GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama oder einem selbst betriebenen lokalen Modell — alles mit Ihren eigenen API-Schlüsseln.

  • Wird nur bei Bedarf geladen

    Der System-Prompt enthält nur den Namen und die Beschreibung. Die Anweisungen werden bei der ersten passenden Anfrage geladen. Ein ungenutzter Skill verursacht daher keine Kosten.

  • Modell im laufenden Chat wechseln

    Da der Skill aus Anweisungen statt aus Code besteht, funktioniert er auch nach einem Modellwechsel — das nächste Modell liest dieselbe SKILL.md-Datei.

Skill-Anweisungen

Dies ist der Inhalt von SKILL.md, den das Modell lädt. Lesen Sie ihn vor der Installation — ein Skill besteht aus Anweisungen, denen Ihr Modell folgt.

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)

Mitgelieferte Dateien

Das Modell liest diese Dateien bei Bedarf, während der Skill geladen ist. Sie werden als lesbare Dateien bereitgestellt und niemals ausgeführt.

Häufig gestellte Fragen

Was macht der KI-Skill 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 benchma...

Warum Cost Performance Scorer in TypingMind nutzen?

Weil Sie den Skill einmal installieren und mit jedem Modell verwenden können. Cost Performance Scorer besteht aus reinem Markdown statt aus anbieterspezifischem Code. So funktioniert derselbe Skill mit GPT-5, Claude, Gemini, Grok oder einem lokalen Modell – und Sie können das Modell mitten im Chat wechseln, ohne dass der Skill seine Funktion verliert. TypingMind verwendet Ihre eigenen API-Schlüssel. Sie bezahlen die Anbieter daher direkt statt über ein Abonnement pro Nutzerplatz, und Ihre Skills und Chats bleiben in Ihrem eigenen Speicher.

Wie installiere ich Cost Performance Scorer in TypingMind?

Öffnen Sie in TypingMind Plugins → Skills → Von GitHub installieren und fügen Sie https://github.com/AnthonyAlcaraz/agentic-graph-rag-skills/tree/main/skills/optimization/cost-performance-scorer ein. TypingMind liest die Datei SKILL.md, bündelt die zugehörigen Dateien und installiert alles als Skill, den Sie für jeden Chat einzeln aktivieren können.

Welche KI-Modelle können Cost Performance Scorer nutzen?

Jedes Modell, das Sie mit TypingMind verbinden. KI-Skills bestehen aus reinen Markdown-Anweisungen statt aus anbieterspezifischem Code. Daher können GPT, Claude, Gemini, Grok und lokale Modelle diesen Skill laden, wenn eine Anfrage dazu passt.

Wie viele KI-Modelle kann ich mit Cost Performance Scorer verwenden?

So viele Sie möchten. In TypingMind können Sie Cost Performance Scorer mit jedem Modell verwenden, das Skills unterstützt, etwa mit GPT, Claude, Gemini, Grok, DeepSeek, Mistral oder Llama. Dabei nutzen Sie Ihre eigenen API-Schlüssel.

Ist der KI-Skill Cost Performance Scorer kostenlos?

Ja. Der Skill wird von AnthonyAlcaraz auf GitHub unter der Lizenz MIT veröffentlicht. Sie bezahlen nur Ihren eigenen KI-Anbieter für die verwendeten Token.

Was sind KI-Skills?

Ein KI-Skill ist ein wiederverwendbares Anweisungspaket, das einem KI-Modell vermittelt, wie es eine bestimmte Aufgabe erledigt. Es folgt dem offenen Format Agent Skills: Die Datei SKILL.md enthält den Namen und die Beschreibung des Skills. Hinzu kommen bei Bedarf Skripte, Vorlagen oder Referenzdateien für das Modell. Das Modell liest die Anweisungen nur, wenn Ihre Anfrage zum Skill passt. Ein installierter Skill verursacht daher erst Kosten, wenn er verwendet wird.

Wie unterscheiden sich KI-Skills von Plugins oder MCP-Servern?

Ein Plugin oder MCP-Server stellt einem Modell neue aufrufbare Tools bereit – Code, der auf einem System ausgeführt wird und ein Ergebnis zurückgibt. Ein KI-Skill vermittelt dem Modell stattdessen Wissen und Vorgehensweisen: wie es eine Aufgabe angeht, welche Schritte es befolgt und wie eine gute Ausgabe aussieht. Skills bestehen aus reinem Markdown und kommen daher ohne Server, API-Schlüssel und Laufzeitumgebung aus. Sie funktionieren mit jedem Modell.

Alle anzeigen

Jetzt eigenen KI-Arbeitsbereich einrichten

Abonnieren Sie unseren Newsletter und erfahren Sie mehr über neue Funktionen und kommende Gewinnspiele 👇