YouTube debate fact-checking pipeline: claim extraction, speaker attribution, evidence-backed verification
  • Python 56.3%
  • HTML 43.3%
  • Shell 0.4%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-10-31 15:08:18 -04:00
docs Track OWID evidence snapshot; document queue resume on a new machine 2026-10-31 15:08:18 -04:00
examples Import fact-check pipeline with r1 resolution and r3/r4 queue findings 2026-10-31 15:02:58 -04:00
prompts Import fact-check pipeline with r1 resolution and r3/r4 queue findings 2026-10-31 15:02:58 -04:00
schema Import fact-check pipeline with r1 resolution and r3/r4 queue findings 2026-10-31 15:02:58 -04:00
scripts Import fact-check pipeline with r1 resolution and r3/r4 queue findings 2026-10-31 15:02:58 -04:00
template Import fact-check pipeline with r1 resolution and r3/r4 queue findings 2026-10-31 15:02:58 -04:00
tests Import fact-check pipeline with r1 resolution and r3/r4 queue findings 2026-10-31 15:02:58 -04:00
work Track OWID evidence snapshot; document queue resume on a new machine 2026-10-31 15:08:18 -04:00
.gitignore Track OWID evidence snapshot; document queue resume on a new machine 2026-10-31 15:08:18 -04:00
config.example.json Import fact-check pipeline with r1 resolution and r3/r4 queue findings 2026-10-31 15:02:58 -04:00
DECISIONS.md Import fact-check pipeline with r1 resolution and r3/r4 queue findings 2026-10-31 15:02:58 -04:00
lessons_learned.md Import fact-check pipeline with r1 resolution and r3/r4 queue findings 2026-10-31 15:02:58 -04:00
next_steps.md Import fact-check pipeline with r1 resolution and r3/r4 queue findings 2026-10-31 15:02:58 -04:00
PROGRESS.md Import fact-check pipeline with r1 resolution and r3/r4 queue findings 2026-10-31 15:02:58 -04:00
README.md Import fact-check pipeline with r1 resolution and r3/r4 queue findings 2026-10-31 15:02:58 -04:00
requirements-speakers.txt Import fact-check pipeline with r1 resolution and r3/r4 queue findings 2026-10-31 15:02:58 -04:00
requirements.txt Import fact-check pipeline with r1 resolution and r3/r4 queue findings 2026-10-31 15:02:58 -04:00
STATUS.md Import fact-check pipeline with r1 resolution and r3/r4 queue findings 2026-10-31 15:02:58 -04:00
work_log.md Import fact-check pipeline with r1 resolution and r3/r4 queue findings 2026-10-31 15:02:58 -04:00

debate-factcheck

YouTube debate video -> single-file, interactive HTML fact-check report (scorecard per round, claim-by-claim ratings with timestamps, fallacy notes, sources, searchable transcript).

Reverse-engineered from a public "Dr. Daf Debate Fact-Check" page. See docs/REVERSE_ENGINEERING.md for what was inferred and how confident that is.

Quick start

pip install -r requirements.txt
export ANTHROPIC_API_KEY=...            # needed for stages 3-5 (and 2 if chapters are missing)
cp config.example.json config.json      # name the two sides, add speaker hints

python scripts/run_pipeline.py "https://www.youtube.com/watch?v=VIDEO_ID" --config config.json --stages 1-2
# -> review work/segments.json, fix if needed, then:
python scripts/run_pipeline.py "https://www.youtube.com/watch?v=VIDEO_ID" --config config.json --stages 3-6
open output/index.html

Stage 1 must run on a machine that can reach YouTube.

Stages

# Script In -> Out Uses LLM
1 01_fetch.py URL -> work/meta.json, work/transcript.json (captions cleaned into ~120-char timestamped lines) no
2 02_segment.py chapters / config.rounds / LLM guess -> work/segments.json only as fallback
3 03_extract_claims.py round text -> work/rounds/rN.claims.json (checkable claims, timestamp, side) yes
4 04_factcheck.py claims -> rN.checked.json (rating, note, sources) using web search yes + search
5 05_analyze.py checked claims -> rN.analysis.json (lead, fallacies, verdict) + overall.json yes
6 06_build.py everything -> work/final.json -> output/index.html (validated first) no

All stages cache to work/. Edit any intermediate JSON by hand and rerun the later stages. To edit the final data directly: python scripts/06_build.py --data work/final.json --out output/index.html.

Rating scale

true, mtrue (mostly true), partly, contested, misleading, unsupported, mfalse (mostly false), false. Definitions live in prompts/factcheck.md. Opinions, predictions and personal testimony are not rated.

Sides

The template supports exactly two sides: L (first) and C (second). C can be a group; for a one-on-one round the analysis can set c_name so the heading reads "Eden's fallacies". vwho is l, c or split.

No API key? Run it in a chat

Stages 3-5 are just the markdown files in prompts/. Paste a prompt as the system/instructions and one round's text as the message, save the JSON reply under work/rounds/, and continue with stage 6. A chat with web search enabled can do stage 4.

Fact-checking without an API key or a long chat session

scripts/factcheck_queue.py hands each claim to its own fresh headless CLI session (4 concurrently by default) and saves each result as it lands. Interrupting it, or running out of quota, loses only claims in flight; re-running resumes. Each claim takes ~45–120 s with codex at its configured effort, so wall time is roughly claims × 80 s ÷ workers.

# per video, detached so it survives closing the terminal; --build merges into rounds/rN.checked.json at the end
nohup caffeinate -i python -u scripts/factcheck_queue.py --work work/VIDEO_ID --workers 6 --build \
  > work/VIDEO_ID/factcheck-rounds/queue/run.log 2>&1 &
python scripts/factcheck_queue.py --work work/VIDEO_ID --status            # progress per round, any time
python scripts/factcheck_queue.py --work work/VIDEO_ID --retry-failed      # retry claims that failed validation
python scripts/factcheck_queue.py --work work/VIDEO_ID --rounds r5 --backend claude --limit 10   # claude -p, sonnet

--effort low|medium|high overrides the CLI's reasoning effort (faster, possibly weaker); the effort is recorded in each finding's checked_by. --workers is bounded by the plan's rate limits; a run of rate-limit errors trips the stop below. Prompt: prompts/factcheck_queue.md; enforced output: schema/factcheck_finding.schema.json. Results are rejected (one repair attempt, then marked failed) if the status/rating rules are broken or a cited URL returns 404/410 or does not resolve. Per-claim results and raw replies live in factcheck-rounds/queue/rN/; collected findings are written to rN.auto.findings.json/rN.auto.sources.json. Hand-written findings for the same claim always win. The run stops after 3 consecutive CLI failures (quota, auth, outage). Automated findings are marked checked_by ... (automated, unreviewed).

Known limitations (read before publishing)

  • Speaker attribution is a guess. YouTube captions have no speaker labels; the model infers sides from turn-taking and your speaker_hints. Low-confidence attributions are flagged in stage 3's output. For serious use add diarization (e.g. WhisperX/pyannote on the audio) or review claims by hand. Claims by the host are dropped.
  • AI-generated ratings need spot-checking. The prompts enforce one standard for both sides and keep source URLs only if they were actually retrieved, but model judgment can still be wrong or one-sided. Treat "who argued better" verdicts as opinion, and read the claims you plan to rely on.
  • Not every claim is individually sourced. Sources are grouped per round at the bottom; the page says how many claims have none.
  • Live YouTube access is untested here. Stage 1's caption parser is tested on synthetic json3 data only, and the API stages are tested against a scripted fake model (tests/), not a real model run. The web-search tool type (web_search_20250305) and default model (claude-sonnet-5-5) are configurable via env vars WEB_SEARCH_TOOL_TYPE and FACTCHECK_MODEL - check the current Anthropic docs if a call is rejected.
  • Rights. The report embeds the full caption text and links to the video, as the original did. Check that you are comfortable republishing a creator's transcript before sharing the page publicly.
  • Cost/time scale with claims: stage 4 makes one search-enabled call per claim (the original had 91 claims).

Tests

python -m unittest discover -s tests -v     # offline; no network or API key
python scripts/validate.py examples/sample_data.json
python scripts/06_build.py --data examples/sample_data.json --out output/sample.html

examples/sample_data.json is synthetic illustrative data, not a real fact-check.

Layout

prompts/   segment.md, extract_claims.md, factcheck.md, round_analysis.md, overall.md
scripts/   01_fetch ... 06_build, validate, run_pipeline, common
template/  report.template.html   (CSS + renderers; data injected at __DATA_JSON__)
schema/    report.schema.json      (shape of work/final.json)
examples/  sample_data.json, sample_captions.json3
docs/      REVERSE_ENGINEERING.md
tests/     test_pipeline.py