Independent Project Not affiliated with, sponsored by, or endorsed by the Watch Tower Bible and Tract Society or Jehovah's Witnesses.
jw-agent-toolkit
ES

Guide

Verificador de citas en imágenes (Fase 70)

Defensa contra desinformación visual. Toma una imagen (screenshot, meme, foto de publicación) y emite uno de 4 veredictos: SUPPORTED, DISTORTED, FABRICATED, UNVERIFIABLE. Pipeline 100% local-first con OCR + heurísticas visuales + RAG/NLI inyectables.

Quick start

# Verificar imagen (requiere Tesseract si no usas --ocr-text)
jw verify-image check meme.jpg

# Bypass de Tesseract: OCR override manual
jw verify-image check meme.jpg --ocr-text "Texto pegado de la imagen..."

# Pasar descripción visual (de un VLM externo)
jw verify-image check meme.jpg --vlm-description "Cover with font mismatch"

# Modo breve
jw verify-image check meme.jpg --ocr-text "..." --brief

# Listar los 4 veredictos y acciones sugeridas
jw verify-image verdicts

CLI

ComandoDescripción
jw verify-image checkVerifica una imagen y emite JSON
jw verify-image verdictsLista los 4 veredictos posibles

Flags de check

FlagDefaultEfecto
--language / -lesIdioma del OCR (es / en / pt)
--ocr-textBypass Tesseract: provee texto directo
--vlm-descriptionHint visual desde un VLM externo
--briefFalseSolo verdict + confidence + suggested_action

MCP

ToolDescripción
verify_image_quote_toolDevuelve ImageQuoteVerdict dict

Los 4 veredictos

VerdictSignificadoAcción sugerida
SUPPORTEDCita real, presentación sin anomalías visualesshare_with_correct_link
DISTORTEDCita real pero contexto/visual alterado, o contradiceshare_corrected_version
FABRICATEDSin coincidencia + anomalías visualesdo_not_share
UNVERIFIABLESeñal insuficiente para decidirdiscuss_with_elders

Arquitectura

   meme.jpg


 ┌─────────────────────┐
 │ load_image (PIL)    │
 │  - EXIF rotation    │
 │  - pHash 8x8        │
 └──────────┬──────────┘

   ┌────────┴────────┐
   ▼                 ▼
 OCR              VLM description
 (Tesseract       (opcional)
  opt-guarded)
   │                 │
   ▼                 ▼
 cleanup_ocr     fingerprint
 extract_quote   - apparent_era
                 - apparent_publication
                 - visual_anomalies
                 - layout_consistency


   ┌────────────────────┐
   │ RAG retriever      │ (inyectable)
   │ -> [RAGHit, ...]   │
   └──────────┬─────────┘

   ┌────────────────────┐
   │ NLI F39 verify     │ (inyectable)
   │ entails/contradicts│
   └──────────┬─────────┘

   ┌────────────────────┐
   │ synthesize_verdict │
   │ -> SUPPORTED       │
   │    DISTORTED       │
   │    FABRICATED      │
   │    UNVERIFIABLE    │
   └────────────────────┘

Detección de framing visual

fingerprint.py aplica heurísticas conservadoras (regex sobre VLM caption + OCR text):

  • apparent_era: extrae año de copyright o marcadores estilísticos (primary colors bold → 1980s, pixelated logo → 1990s, etc.).
  • apparent_publication: detecta títulos Atalaya, Watchtower, Despertad, Awake!, Sentinela.
  • visual_anomalies: font_mismatch, logo_modified, layout_inconsistent, color_off, edited_composition, etc.
  • layout_consistency: consistent / inconsistent / unknown.

Extracción de cita

extractor.py parsea:

  • cleaned_quote: bloque más largo no-atribución.
  • language_detected: sniffer barato sobre hint words es/en/pt.
  • has_attribution + attribution_text: detecta URLs wol, pub codes (w23.04, g23, etc.), títulos de revista.

Reglas de síntesis de veredicto

no matches + short quote (<20 chars)        -> UNVERIFIABLE (0.3)
no matches + anomalías visuales              -> FABRICATED (0.7)
no matches + sin anomalías                   -> UNVERIFIABLE (0.4)
top match entails + score ≥0.85 + anomalías  -> DISTORTED (0.8)
top match entails + score ≥0.85 + clean      -> SUPPORTED (≤0.95)
top match contradicts                        -> DISTORTED (0.85)
otros (neutral, entails low score)           -> UNVERIFIABLE (0.35)

Integración en F65 meta-orchestrator

Registrada como tool verification.image_quote. El planner F65 puede componer:

{"steps": [
  {"id": "s1", "tool": "verification.image_quote",
   "args": {"image_path": "/tmp/meme.jpg",
            "ocr_text_override": "<texto pegado>"}}
]}

Dependencias opcionales

FeatureDepFallback
OCRpytesseract + tesseract--ocr-text manual
Imagen + pHashPillowrequerido
RAG retrievalF33 RAG storesin RAG → UNVERIFIABLE
NLI verifyF39 providersin NLI → neutral en matches

Estado actual

  • 8 tasks TDD. 51 tests passing (5 models + 6 preprocess + 12 fingerprint + 9 extractor + 8 verdict + 6 engine + 3 CLI + 1 MCP + 2 meta + 1 protocol delta).
  • Pipeline end-to-end con verify_image_quote() async.
  • 4 veredictos discretos con confidence + suggested_action.
  • CLI jw verify-image {check,verdicts} + MCP tool.
  • Meta tool verification.image_quote en F65.
  • RAG retriever + NLI inyectables (Protocol-shaped).

Pendiente (futuro)

  • Wire-up con RAG real F33 (from jw_rag.store import default_store).
  • Wire-up con NLI real via F65 nli_factory.
  • VLM provider real Florence-2 (via Plugin SDK F41) para fingerprint.
  • F48 browser extension: context menu “Verificar imagen” que llama verify_image_quote_tool con la imagen seleccionada.
  • Golden dataset de 50 imágenes (25 reales + 15 distorsionadas + 10 fabricadas) como tests de regresión.

Edit this page on docs/guias/image-quote-verifier.md