Logo de Llm Calibration Logprobs

Llm Calibration Logprobs

Comunidade
scdenney
llm-calibration-logprobs

Reads model uncertainty from token log-probabilities. Covers collecting logprobs and aggregating multi-token labels, confidence tiers and margins for triage, calibration assessment with ECE, Brier scores, and reliability diagrams against human labels, responsible downstream use of confidence, and reproducibility archives. Use when the user asks about classifier confidence by item, logprobs, top-k tokens, calibration, ECE, Brier, reliability diagrams, or routing low-confidence cases to human review. Codebook and validation design go to text-classification.

Visão geral

Publicado porscdenney
Repositórioopen-science-skills
Nome da habilidadellm-calibration-logprobs
Estrelas
69
Forks
3
Arquivos incluídos
Somente instruções
Links
  • Instruções em Markdown

    Um arquivo SKILL.md que o modelo carrega sob demanda, consumindo tokens apenas quando uma solicitação é realmente relevante para a habilidade.

  • Funciona com qualquer LLM

    As habilidades de IA são escritas em Markdown simples, não em código específico de um provedor. Por isso, funcionam com GPT, Claude, Gemini, Grok ou um modelo local.

  • Sem arquivos extras

    Tudo de que o modelo precisa está nas instruções — sem arquivos extras para sincronizar.

  • Código aberto

    Publicada por scdenney no GitHub. Leia os arquivos da habilidade antes de instalá-la.

Instalação

Instale a habilidade de IA Llm Calibration Logprobs no TypingMind para usá-la com qualquer LLM ou adicione-a a outro agente que leia SKILL.md.

1

Instalar no TypingMind

O TypingMind instala uma habilidade diretamente da pasta dela no GitHub — lê o arquivo SKILL.md, reúne os arquivos de recursos em um pacote e armazena o resultado localmente.

  1. Abra o app e vá para Plugins → Habilidades.
  2. Escolha "Instalar do GitHub".
  3. Cole a URL abaixo, que aponta para a pasta da habilidade, e confirme.
    https://github.com/scdenney/open-science-skills/tree/main/plugin/skills/llm-calibration-logprobs
  4. Ative a habilidade em cada chat em que quiser disponibilizá-la.
Plugins → Habilidades → Adicionar habilidade → Via URL do GitHub. Depois, cole a URL da pasta e pressione Continuar.
2

Instalar em outro agente

Qualquer agente que leia o formato Agent Skills pode usar esta habilidade — copie a pasta para o diretório de habilidades desse agente.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/scdenney/open-science-skills.git /tmp/open-science-skills
mkdir -p .claude/skills
cp -r /tmp/open-science-skills/plugin/skills/llm-calibration-logprobs .claude/skills/llm-calibration-logprobs
Reinicie Claude Code após copiar para que a nova habilidade seja reconhecida.

Use no TypingMind

Ative Llm Calibration Logprobs em qualquer chat do TypingMind e o modelo cuida do resto. O nome e a descrição da habilidade ficam no prompt do sistema e, assim que uma solicitação relevante aparece, o modelo carrega as instruções completas automaticamente — sem precisar de acionamento manual e sem consumir tokens até que ela seja realmente usada.

O modelo carrega Llm Calibration Logprobs automaticamente assim que uma solicitação é relevante para essa habilidade.

Funciona com qualquer modelo de IA

Habilidades de IA são instruções em Markdown simples, não código específico de um provedor. Por isso, Llm Calibration Logprobs não fica vinculada ao modelo para o qual foi criada. Instale-a uma vez no TypingMind e use-a com GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama ou um modelo local executado por conta própria — tudo com suas próprias chaves de API.

  • Carregada apenas quando necessário

    O prompt do sistema contém apenas o nome e a descrição. As instruções são buscadas na primeira solicitação relevante, então uma habilidade sem uso não gera custo.

  • Troque de modelo durante a conversa

    Como a habilidade é composta de instruções, não de código, trocar de modelo não afeta seu funcionamento — o próximo modelo lê o mesmo arquivo SKILL.md.

Instruções da habilidade

Este é o conteúdo de SKILL.md que o modelo carrega. Leia antes de instalar — uma habilidade é um conjunto de instruções que seu modelo seguirá.

Reading a Model's Own Uncertainty from Token Log-Probabilities

Instructions

This skill covers within-model confidence: how sure one model is about each decision, read from the token log-probabilities it emits, and whether that confidence is calibrated against ground truth. Agreement across several independent models is a different kind of evidence — when a pipeline uses both, report both. Codebook design and human-validation statistics (κ, F1) belong to text-classification; cross-reference rather than re-derive them.

1. What a Logprob Can and Cannot Tell You

  • Use logprobs when you need a per-item, continuous confidence signal. It comes free with the forward pass that produced the label and answers "how sure was the model about this classification?", which a hard 0/1 label cannot.
  • A logprob is the model's subjective probability under its own distribution, not a probability of correctness. A model can assign 0.95 to labels that are right 70% of the time. Treat it as a claim about confidence that calibration (§4) tests.
  • Applied social science usually takes the final label at face value and discards the distribution it came from; computational linguists treat token probabilities as the native uncertainty signal. Neither is enough alone — the logprob is informative but must be calibrated against external truth before it carries weight. State the choice in the methods section.
  • Prefer the emitted-token logprob over a prompted "rate your confidence HIGH/MEDIUM/LOW" string. Verbalized confidence is generated text subject to the same biases (Kadavath et al. 2022; Tian et al. 2023); it can be made roughly calibrated with effort (Tian et al. 2023), but treat it as a separate, weaker signal and cross-check it rather than substitute it. A long reasoning trace is not a confidence measure either.

2. Collecting Logprobs and Aggregating Multi-Token Labels

  • Check compatibility before choosing the model. Logprob support depends on model, endpoint, and reasoning setting; confirm with current documentation and a small test response before a batch. Astra does not support reasoning effort none, so a logprob example from a non-reasoning model may not transfer to it. Keep a validated compatible model for calibration, and mark missing logprobs as unavailable rather than filling them with verbal confidence.
  • Enable logprob return. OpenAI chat completions take logprobs=True and top_logprobs=K (K ≤ 20 at time of writing) and return per-token .token, .logprob, and .top_logprobs. vLLM's OpenAI-compatible server exposes the same fields (logprobs=K); Ollama returns per-token logprobs too. A typical script sets api_kwargs["logprobs"] = True and api_kwargs["top_logprobs"] = 5, then stores resp.choices[0].logprobs.content alongside the parsed label.
  • Fix decoding. Set temperature=0 and a fixed seed, and record both. Temperature 0 makes the label deterministic on most backends but does not make hosted-API logprob values bit-identical (§6).
  • Constrain the output so label tokens are findable. A rigid schema (JSON with a "code" field) lets you locate the label; free prose makes the span ambiguous.
  • Aggregate label tokens by character span. A label like civic_commitment spans several sub-word tokens. Reconstruct the output string, locate the label (e.g., the value after "code":), map each token to its character offsets, and select exactly the tokens overlapping the label span — never guessed token indices. Then choose an aggregation and state it; the three are not interchangeable:
    • Sum = log P(whole label), the joint probability. Principled, but length-confounded: longer labels score lower. Comparable only across labels of similar token length. (logprob_code_sum)
    • Mean per-token logprob (geometric-mean probability) removes most of the length confound; the better default when label lengths differ.
    • First-token logprob: cheap and length-invariant, informative only when the labels diverge at the first token. Check that before relying on it; shared prefixes make it useless. (logprob_first_token)
  • Store the top alternatives at the first label position (top_alternatives_json). The margin to the runner-up is a separate, often more discriminating signal (§3).

3. Confidence Tiers, Margins, and Triage

  • Map the chosen-label probability p = exp(logprob) onto action tiers. A starting scheme:
    • p ≥ 0.90 → auto-accept
    • 0.65 ≤ p < 0.90 → accept, flag for spot-check
    • p < 0.65 → human review
  • These cut points are house planning defaults, not values from a cited study, and mean nothing until calibration is checked (§4). If the model is overconfident, a 0.90 cut admits too many errors. Re-derive the cuts from your own reliability diagram at the bin where empirical accuracy crosses the tolerated error rate.
  • Use the margin as a second trigger. A small gap to the runner-up (e.g., p_top − p_second < 0.10) marks a coin-toss between two specific labels even when p is high. Flagging on either signal catches more errors than absolute confidence alone, and the runner-up label shows which codebook boundary is ambiguous.
  • Route low-confidence items to humans; the tiers allocate scarce review time to genuine coin-tosses rather than a random sample. This is the within-model counterpart of disagreement-based flagging in text-classification.
  • Plan for roughly 10-20% of items in the low tier (house default). A much larger share usually means overlapping labels or an under-specified prompt — return to the codebook before spending review hours.

4. Calibration Assessment

A model is calibrated if, among items labeled with confidence p, a fraction p are correct. Tiers are trustworthy only after this is measured against held-out ground truth.

  • Ground truth must be human-adjudicated labels (or another external standard), not the model's modal answer or other model runs. Checking logprobs against model output measures self-consistency, not correctness; within-model confidence and cross-model agreement can both look reassuring while the labels are jointly wrong, because model errors are correlated.
  • Reliability diagram. Bin by predicted confidence (e.g., 10 equal-width bins) and plot mean confidence against empirical accuracy. Below the diagonal is overconfidence, above is underconfidence. Modern deep networks, including large transformers, tend toward overconfidence (Guo et al. 2017).
  • Expected Calibration Error. ECE = Σ_b (n_b / N) · |acc(b) − conf(b)| (Guo et al. 2017). Report it with the bin count, since it is binning-sensitive, and always with the diagram — different curves can share an ECE.
  • Brier score. BS = (1/N) Σ (p_i − y_i)² (Brier 1950). A proper scoring rule that captures calibration and resolution together, so it penalizes hedging everything at 0.5. Report it alongside ECE.
  • Calibration is not accuracy. Triage depends on calibration: if the 0.90 bin is 70% accurate, the auto-accept tier leaks errors regardless of overall F1.
  • Temperature scaling fixes calibration without changing the argmax label: fit one scalar T on a calibration split and rescale before softmax; it often largely corrects ECE (Guo et al. 2017). Report ECE and Brier before and after, and never fit T on the evaluation data.

5. Using Uncertainty in the Pipeline

  • Route, don't discard. Dropping unsure items biases the remaining sample toward what the model finds easy, which is rarely random with respect to the construct.
  • Propagate uncertainty. When labels feed a regression or prevalence estimate, carry per-item confidence (observation weights, soft labels, or multiple-imputation draws over the label) instead of hard 0/1 labels. At minimum, rerun the downstream analysis without the low-confidence tier and report whether conclusions move. This connects to the measurement-error correction in text-classification.
  • Report the share of the corpus in each tier. It is a corpus-level quality signal and sizes the review budget.

6. Caveats

  • Hosted-API logprobs are unstable. Providers may restrict or change logprob support without notice, and values drift across snapshots and even identical calls; batching, kernel non-determinism, and silent updates perturb them at temperature 0. Pin the exact model version, record the run date, and re-measure calibration after any model update. Open-weight models served locally (vLLM, Ollama — e.g., Llama 3.1 8B or Qwen 2.5 3B) give stable, inspectable logprobs.
  • Closed-set tasks only, mostly. Logprob confidence is interpretable for a fixed label set. For open-ended generation, per-token logprobs measure local fluency, not global correctness.

7. Reproducibility and Reporting

  • Collection recipe: exact model version or snapshot, decoding settings (temperature, seed, top_logprobs K), the output schema used to locate labels, and the aggregation function with its rationale. Archive the raw per-token logprobs and top-K alternatives, not only the derived scalar.
  • Calibration: reliability diagram, ECE with bin count, and Brier score on a held-out human-labeled set; direction and size of miscalibration; whether temperature scaling was applied.
  • Triage: thresholds and how they were derived from the diagram, per-tier shares, and the human-review rate.
  • Ground-truth source for calibration, stated explicitly.
  • For the broader methods checklist (model disclosure, archived prompts, DA-RT/JARS), use methods-reporting; for codebook and human-validation metrics, text-classification.

Quality Checks

  • Logprobs enabled (logprobs=True, top_logprobs=K); temperature=0 and a fixed seed recorded
  • Label tokens located by character span; aggregation (first-token / sum / mean) stated, with the sum's length confound acknowledged
  • Top-K alternatives stored and margin to the runner-up computed
  • Logprob confidence not reported as probability of correctness without calibration against external ground truth
  • Reliability diagram against human-adjudicated labels; ECE (with bin count) and Brier reported (Guo et al. 2017; Brier 1950)
  • Direction of miscalibration stated; temperature scaling, if used, fit on a separate split
  • Triage thresholds derived from the reliability diagram, with house defaults re-justified on this corpus
  • Low-confidence items routed to review, not discarded; per-tier shares and review rate reported
  • Downstream analysis rerun without the low-confidence tier (or uncertainty propagated), with sensitivity reported
  • Verbalized confidence and reasoning text not substituted for the token logprob
  • Model snapshot pinned, run date recorded, calibration re-measured after model updates
  • Collection recipe and raw per-token logprobs archived; token-probability vs. face-value convention stated in the methods section

Perguntas frequentes

O que a habilidade de IA Llm Calibration Logprobs faz?

Reads model uncertainty from token log-probabilities. Covers collecting logprobs and aggregating multi-token labels, confidence tiers and margins for triage, calibration assessment with ECE, Brier scores, and reliability diagrams against human labels, responsible downstream use of confidence, and reproducibility archives. Use when the user asks about classifier confidence by item, logprobs, top-k tokens, calibration, ECE, Brier, reliability diagrams, or routing low-confidence cases to human review. Codebook and validation design go to text-classification.

Por que usar Llm Calibration Logprobs no TypingMind?

Porque basta instalar uma vez para usar com qualquer modelo. A habilidade Llm Calibration Logprobs é escrita em Markdown simples, e não em código específico de um provedor, então a mesma habilidade funciona com GPT-5, Claude, Gemini, Grok ou um modelo local — e é possível trocar de modelo no meio do chat sem que ela deixe de funcionar. No TypingMind, você usa suas próprias chaves de API e paga diretamente aos provedores, em vez de pagar uma assinatura por licença de usuário. Suas habilidades e chats permanecem no seu próprio armazenamento.

Como instalar Llm Calibration Logprobs no TypingMind?

Abra Plugins → Habilidades → Instalar do GitHub no TypingMind e cole https://github.com/scdenney/open-science-skills/tree/main/plugin/skills/llm-calibration-logprobs. O TypingMind lê o arquivo SKILL.md e instala a habilidade para que possa ser ativada em cada chat.

Quais modelos de IA podem usar Llm Calibration Logprobs?

Qualquer modelo conectado no TypingMind. As habilidades de IA são instruções em Markdown simples, e não código específico de um provedor. Assim, GPT, Claude, Gemini, Grok e modelos locais podem carregar esta habilidade quando uma solicitação corresponder a ela.

Quantos modelos de IA posso usar com Llm Calibration Logprobs?

Quantos quiser. Desde que o modelo ofereça suporte a habilidades, é possível usar Llm Calibration Logprobs com ele — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama e outros — tudo no TypingMind com suas próprias chaves de API.

A habilidade de IA Llm Calibration Logprobs é gratuita?

A habilidade é publicada no GitHub por scdenney. Consulte os termos de licenciamento no repositório. O pagamento é feito apenas ao seu provedor de IA pelos tokens usados.

O que são habilidades de IA?

Uma habilidade de IA é um conjunto reutilizável de instruções que ensina um modelo de IA a realizar uma tarefa específica. Ela segue o formato aberto Agent Skills: um arquivo SKILL.md com nome e descrição, além de scripts, templates ou arquivos de referência de que o modelo possa precisar. O modelo lê as instruções apenas quando sua solicitação corresponde à habilidade, então uma habilidade instalada não gera custos até ser usada.

Qual é a diferença entre habilidades de IA e plugins ou servidores MCP?

Um plugin ou servidor MCP oferece ao modelo novas ferramentas que ele pode acionar — código que é executado em algum lugar e retorna um resultado. Já uma habilidade de IA dá ao modelo o conhecimento e as orientações de que ele precisa: como abordar uma tarefa, quais etapas seguir e como deve ser um bom resultado. As habilidades são escritas em Markdown simples, por isso não precisam de servidor, chave de API nem ambiente de execução, e funcionam com qualquer modelo.

Ver lista completa

Crie seu próprio espaço de trabalho com IA agora

Inscreva-se na nossa newsletter para receber avisos sobre novos recursos e futuros sorteios 👇