Spaces:
Runtime error
Runtime error
File size: 6,936 Bytes
26e2bed 16f7cf4 ca4ed58 bbb543e 16f7cf4 ca4ed58 45c5f7e ca4ed58 45c5f7e ca4ed58 16f7cf4 ca4ed58 26e2bed ca4ed58 26e2bed ca4ed58 26e2bed ca4ed58 26e2bed ca4ed58 26e2bed ca4ed58 26e2bed ca4ed58 3da97ef ca4ed58 26e2bed ca4ed58 26e2bed ca4ed58 26e2bed ca4ed58 26e2bed 948d6ef ca4ed58 26e2bed ca4ed58 26e2bed ca4ed58 26e2bed ca4ed58 16f7cf4 ca4ed58 948d6ef 26e2bed 948d6ef ca4ed58 26e2bed | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 | ---
title: ClaimCheck.AI - Agentic Fact Verification
emoji: π
colorFrom: blue
colorTo: green
sdk: docker
sdk_version: "4.36.0"
app_file: app/main.py
pinned: false
license: mit
python_version: 3.9
suggested_hardware: cpu-basic
---
# ClaimCheck.AI β Agentic Fact Verification for Calls
**ClaimCheck.AI** is an multi-agent AI platform that turns meeting audio (Zoom/phone) into an evidence-backed report:
1) **ASR Agent** β transcript + timestamps
2) **Claim Extraction (watsonx.ai LLM)** β JSON claims
3) **Evidence Retrieval (watsonx.ai Embeddings + FAISS + optional Rerank)** β KB hits
4) **Verification (watsonx.ai LLM)** β supported/refuted/insufficient + citations
5) **Summarizer (watsonx.ai LLM)** β executive summary + action items
## β¨ Why it matters
High-stakes calls contain promises and metrics (SLA, compliance, finance). ClaimCheck.AI verifies statements against your **trusted KB** so decisions are grounded in factsβnot memory.
---
## π§ Project structure
```
claim-check/
ββ app/
β ββ agents/
β β ββ claims.py # Claim extractor (watsonx.ai Prompt Lab / LLM)
β β ββ retriever.py # IBM embeddings + FAISS + optional rerank
β β ββ verifier.py # LLM verdicts (supported/refuted/insufficient)
β β ββ summarizer.py # LLM executive summary + action items
β ββ core/
β β ββ config.py # env wiring (IBM base url, project, keys)
β β ββ json_utils.py # robust JSON extraction from LLM outputs
β ββ schemas/ # pydantic models (Claim, Evidence, Verdict, CallReport)
β ββ services/
β β ββ asr.py # Speech to Text model
β ββ main.py # FastAPI: /health, /process-audio, /process-transcript
ββ kb/
β ββ snippets.jsonl # your knowledge base (facts; one JSON per line)
β ββ index/ # FAISS index (auto-built)
ββ data/audio/ # demo audio files
ββ .env # local secrets (NOT committed)
ββ .env.sample # template for env vars (safe to commit)
ββ requirements.txt
ββ README.md
```
---
## π Deploy on Hugging Face Spaces
This app is configured to run on Hugging Face Spaces. The configuration header at the top of this README handles the deployment settings.
### Environment Variables for Spaces
You'll need to set these secrets in your Hugging Face Space settings:
```bash
# IBM Core
WATSONX_BASE_URL=https://us-south.ml.cloud.ibm.com
WATSONX_PROJECT_ID=<your-watsonx-project-id>
WATSONX_API_KEY=<your-ibm-cloud-api-key>
IBM_API_VERSION=2023-05-29
# Models
IBM_EMBEDDINGS_MODEL_ID=ibm/granite-embedding-107m-multilingual
IBM_RERANK_MODEL_ID=ibm/slate-30m-english-rtrvr-v2
IBM_VERIFIER_MODEL_ID=ibm/granite-3-8b-instruct
IBM_SUMMARY_MODEL_ID=ibm/granite-3-8b-instruct
IBM_CLAIM_MODEL_ID=ibm/granite-3-8b-instruct
# Speech to Text (IBM)
IBM_STT_URL=<your-ibm-stt-instance-url>
IBM_STT_APIKEY=<your-ibm-stt-api-key>
# Whisper fallback (optional)
WHISPER_MODEL_SIZE=base
WHISPER_DEVICE=cpu
WHISPER_COMPUTE_TYPE=int8
```
---
## π§ͺ Quick start (Local Development)
### 1) Python env
```bash
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
```
### 2) Configure IBM (edit `.env`)
Copy the sample and fill in values from your IBM Cloud / watsonx project.
```bash
cp .env.sample .env
```
### 3) Seed the KB
Put your facts in `kb/snippets.jsonl` (one JSON per line). Example:
```jsonl
{"doc_id":"uptime_q2_report","source":"Global Uptime Dashboard","snippet":"Q2 2025 uptime was 99.982% globally; LATAM outage lowered regional uptime to 99.965%.","metadata":{"quarter":"Q2","year":2025}}
```
If you change the KB, rebuild the index by deleting the `kb/index/` folder.
### 4) Run the API
```bash
uvicorn app.main:app --reload --host 0.0.0.0 --port 7860
```
### 5) Run the UI (Local Only)
```bash
cd ui/claimcheck-ui
pnpm install
pnpm dev
```
- If you change the UI dev port/host, add it to `allow_origins` in `app/main.py`.
### 6) Try it
**Transcript path (no audio):**
```bash
curl -X POST http://127.0.0.1:7860/process-transcript \
-H "Content-Type: application/json" \
-d '{"text":"We achieved 99.99% uptime in Q2. P95 latency under 200 ms globally. Default retention is 30 days."}'
```
**Audio path (IBM STT):**
```bash
curl -X POST http://127.0.0.1:7860/process-audio \
-F "file=@data/audio/demo_call.wav"
```
**Health:**
```bash
curl http://127.0.0.1:7860/health/ibm
```
---
## π§ How it works (agentic)
## π§ Core Concepts and Models
ClaimCheck.AI combines modern **agentic AI** orchestration with core NLP, IR, and speech processing techniques. Each agent is powered by a specific model or algorithm:
| Agent | Function | Model/Tool Used | Concepts |
|---------------|--------------------------------------|-----------------------------------------------|----------|
| ASR Agent | Audio transcription + timestamps | `IBM Speech-to-Text` or `Whisper` | Automatic Speech Recognition (ASR), Diarization |
| Claim Extractor | Turns transcript β atomic claims | `watsonx.ai` Prompt Lab + `granite-3-8b-instruct` | Information Extraction, Prompt Engineering |
| Retriever | Find matching KB facts | `granite-embedding-107m-multilingual`, FAISS, optional `slate-30m-rtrvr` | Embedding-based Retrieval, Vector Search, Reranking |
| Verifier | Evaluate support/refute status | `granite-3-8b-instruct` | Fact Verification, Retrieval-Augmented Generation (RAG) |
| Summarizer | Generate exec summary + action items | `granite-3-8b-instruct` | Abstractive Summarization, Plan Extraction |
---
## π‘οΈ Notes on data & security
- Do **not** commit `.env` or audio with sensitive content.
- Use IBM Cloud secrets manager / vault in production.
- All third-party calls are behind explicit env flags; the pipeline fails safe (insufficient) if evidence is missing.
---
## π§° Troubleshooting
- **Embeddings 400** β ensure `version` query param, body includes `"inputs"` and `"model_id"`.
- **FAISS dim mismatch** β delete `kb/index/` after changing embedding model.
- **OpenMP error (macOS)** β set `KMP_DUPLICATE_LIB_OK=TRUE` and `OMP_NUM_THREADS=1`.
- **JSON parse errors** β we use a robust extractor; check server logs `[RAW OUTPUT]`.
- **Rebuild index** β Incorrect evidence showing up in the evidence drawer
```bash
rm -f kb/index/kb.index kb/index/kb_meta.json
python -c "from app.agents.retriever import _build_or_load; _build_or_load(); print('rebuild done')"
```
---
## π License
MIT License - see LICENSE file for details.
---
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference |