翻篇收录说明
翻篇网页快照

Self-consistency: choices - TypeSafe

https://docs.typesafe.ai/cookbooks/consistency_choice_cookbook

最近抓取:2026-12-03 20:34:35(北京时间)

最近内容变化:2026-12-03 20:34:35(北京时间)

这是最近一次有效抓取的文本快照,不含网页脚本、图片和动态交互内容。实际网页可能已更新。

访问原网页

页面简介

Ask a model the same moderation question twice: how often does the decision change? A test of reliability that needs no answer key, comparing LLMs and Jev on borderline posts.

正文摘录

A pipeline that hands decisions to a model needs the same post to get the same decision every time. We send one post again and again, unchanged, and count how often a decision changes: remove or leave up, escalate or auto-resolve, which queue owns it. That says nothing about whether the decision is right; it comes before that. If the decision moves when the post hasn’t, an appeal can’t be reproduced and identical posts get different treatment. It needs no answer key, only repeats, so every model is measured on the same footing. Each of the 8 Choice questions comes back as a probability on each of its options, 37 options in all, such as 0.62 that the right action is Strike. A pipeline turns one of those into a decision with a cutoff: strike when P(Strike) is above 0.6. If the next request returns 0.55, the same post is no longer struck. Whether a wobble like that changes the decision depends on where the cutoff sits, and we don’t know where yours is, so we count every cutoff from 0 to 1 equally. Two answers 0.10 apart disagree at 10% of cutoffs. Averaging that over every pair of repeats gives one number per option: the chance that asking again changes the decision. Clear-cut posts are easy for every model, so the test uses borderline ones: 40 versions of a post, each a different mix of facts a moderation model has to weigh. A pipeline is only as dependable as its shakiest decision, so each post is scored by its least stable option. The conditions, each one model plus one setting: Claude models claude-fable-5-1, claude-opus-5-5, claude-sonnet-5-5 and claude-haiku-5-5, and GPT models gpt-6-astra, gpt-6.1-sol, gpt-6.1-terra and gpt-6-luna, each reasoning at high effort. gpt-6.1-terra and gpt-6-luna with reasoning off, at temperature 0 and the API default. They are the only models here that take a temperature. Jev 1.14 (jev-1.14.0): one system_one call over the 8 Choice questions. For Jev, a post’s least stable decision changes 4.0% of the time on average, about 1 time in 25, and never more than 6.7%. Every LLM condition has a post where a decision changes more than 10% of the time, and depending on the condition, between 2 and 36 of the 40 posts have a decision that changes more than 1 time in 10. Temperature 0 narrows the gap but doesn’t close it. Luck alone would produce a gap as large as Jev’s lead over any LLM condition less than once in a thousand runs. Setup Run in ColabRuns as published without an API key.Python fileThis page as one .py file, to run locally.Open in playgroundEdit one request and run it live. Needs a TypeSafe account. To run it on your own machine instead: pip install anthropic openai matplotlib ipython 'cooksafe>=0.3.0,<0.4.0' With uv, uv run consistency_choice_cookbook.py installs the dependencies for you. The code replays saved answers, so it runs as published without an API key. To change a request, set TYPESAFE_API_KEY, ANTHROPIC_API_KEY and OPENAI_API_KEY; in Colab, add them in the Secrets panel. Numbers below came from jev-1.14.0 on 2026-11-02. The LLM answers for the 40 versions were sampled from 2026-11-07 to 2026-11-09, and for the example post on 2026-11-10. import copy import itertools import json import os import random import textwrap import urllib.request from concurrent.futures import ThreadPoolExecutor from pathlib import Path from secrets import token_hex from statistics import mean from time import perf_counter import anthropic import matplotlib.pyplot as plt import numpy as np from cooksafe import JsonCache, make_playground_link from IPython.display import Markdown, display from matplotlib.colors import ListedColormap from matplotlib.ticker import PercentFormatter from openai import OpenAI from typesafe_sdk import Choice, TypeSafeClient LLM_MODELS = { # every one reasons at high effort "claude-fable-5-1": "Claude Fable 5.1", "claude-opus-5-5": "Claude Opus 5.5", "claude-sonnet-5-5": "Claude Sonnet 5.5", "claude-haiku-5-5": "Claude Haiku 5.5", "gpt-6-astra": "GPT-6 Astra", "gpt-6.1-sol": "GPT-6.1 Sol", "gpt-6.1-terra": "GPT-6.1 Terra", "gpt-6-luna": "GPT-6 Luna", } TEMPERATURE_MODELS = ["gpt-6.1-terra", "gpt-6-luna"] # also reasoning off: temperature 0 + default TYPESAFE_MODEL = "jev-1.14.0" # the page's model; "jev-latest" runs the newest, live NUM_SAMPLES = 15 # repeated post+rubric calls per condition NUM_POSTS = 40 # versions of the post, drawn from the combinations of the borderline facts LLM_PRICES = { # $ per 1M tokens (input, output), list prices as of 2026-11 "claude-fable-5-1": (10.00, 50.00), "claude-opus-5-5": (4.00, 20.00), "claude-sonnet-5-5": (2.00, 10.00), "claude-haiku-5-5": (0.10, 0.50), "gpt-6-astra": (10.00, 50.00), "gpt-6.1-sol": (2.00, 10.00), "gpt-6.1-terra": (1.00, 5.00), "gpt-6-luna": (0.10, 0.50), } TYPESAFE_PRICE = (0.042, 0.00) # $ per 1M tokens (input, output), as of 2026-08 # The keys this cookbook uses. In Colab, keys saved in the Secrets panel are copied in here. KEYS = ["TYPESAFE_API_KEY", "ANTHROPIC_API_KEY", "OPENAI_API_KEY"] try: from google.colab import userdata except ImportError: # not in Colab userdata = None for key in KEYS: if userdata is not None and key not in os.environ: try: os.environ[key] = userdata.get(key) except (userdata.SecretNotFoundError, userdata.NotebookAccessError): pass # not saved, or this notebook may not read it anthropic_client = anthropic.Anthropic( api_key=os.environ.get("ANTHROPIC_API_KEY", "cache-only") ) openai_client = OpenAI(api_key=os.environ.get("OPENAI_API_KEY", "cache-only")) typesafe_client = TypeSafeClient( api_key=os.environ.get("TYPESAFE_API_KEY", "cache-only"), base_url="https://api.typesafe.ai", timeout=30.0, ) See all 72 lines The state: a borderline user post, as JSON The post below is built to sit on the fence. The language is heated and insulting, aimed partly at one person and partly at the argument and the community. It includes an off-platform invite (a link pulling people to another site) and wording that sounds like a threat without stating one. The account has one prior strike, and four users have reported the post. This is the example post. The LLMs get json.dumps(post) in the prompt. Jev gets the structure directly. POST = { "post_id": "P-88213", "author": { "user_id": "user_4471", "account_age_days": 38, "prior_strikes": 1, "followers": 210, }, "context": { "surface": "public reply", "in_reply_to": "another user defending a game patch", "community": "example-game-debates", }, "content": { "text": ( "Are you seriously this dense? Anyone who defends that patch is a complete clown and " "should be embarrassed to even post here. People like you are what's ruining this " "community and honestly you need to be dealt with. Come say it to my face, invite's " "right here. Keep it up and I'll end your whole channel." ), "has_link": True, "link_domain": "chat.example", "language": "en", }, "reports": {"user_reports": 4, "report_reasons": ["harassment", "spam", "threat"]}, } The rubric: 8 Choice questions Each question has a key, a line of instructions, and a fixed set of options. The options within a question are mutually exclusive (exactly one applies), and each carries a short description. Jev returns a picked choice plus a probabilities distribution over the options. The LLMs are asked to use the same options, which makes the LLM and Jev answers comparable. QUESTIONS = { "category": ( "What is the single most applicable content-policy category for this post?", { "None": "No policy violation of any kind.", "Harass": "Insults or demeans a person, with no threat of harm and no protected-class attack.", "Hate": "Attacks a person or group over a protected characteristic (race, religion, gender, ...).", "Violence": "Makes a credible threat of harm or incites violence against someone.", "Spam": "Unsolicited promotion or link spam, with no personal attack.", "Sexual": "Sexual or adult content.", }, ), "primary_risk": ( "What is the primary moderation risk that should drive triage for this post?", { "Harassment": "Personal attack or targeted abuse is the main risk.", "Violence": "A threat of harm or intimidation is the main risk.", "LinkAbuse": "External-link or off-platform coordination risk is the main risk.", "AccountHistory": "Prior account history or repeat behavior is the main risk.", "LowRisk": "No meaningful moderation risk is present.", }, ), "target": ( "Who or what is the content primarily directed at?", { "None": "Not directed at anyone in particular.", "Person": "Directed at one specific individual.", "Group": "Directed at a protected group or class.", "Platform": "Directed at the community or platform itself, not a person.", }, ), "action": ( "What enforcement action should be taken on this post?", { "Allow": "Leave the post up with no action.", "Warn": "Leave the post up but attach a warning label.", "Remove": "Remove the post, but do not penalize the account.", "Strike": "Remove the post and add a strike to the account.", "Escalate": "Take no automated action; hold for a human decision.", }, ), "queue": ( "Which single moderation queue should own this post?", { "Auto": "Auto-resolve; no human queue needed.", "General": "General moderation queue.", "Threat": "Threat / violence response queue.", "Spam": "Spam and platform-abuse queue.", "TSLead": "Trust-and-safety lead / senior queue.", }, ), "link_handling": ( "How should any external link or off-platform invite in the post be handled?", { "Allow": "Leave the link in place.", "RmLink": "Strip or disable the link but keep the post.", "Brigade": "Treat the link as coordinated brigading and action it as abuse.", "Escalate": "Send the link to a specialist to assess before acting.", }, ), "review_path": ( "Who should make the final call on this post?", { "Auto": "Automated action; no human review.", "Human": "A frontline human moderator makes the call.", "Senior": "A senior or specialist reviewer is required.", "Legal": "Route to legal or law-enforcement escalation.", }, ), "severity": ( "What is the overall severity of this post?", { "N