Skip to content
Notifications
Clear all

Guide: Building a quick 'hallucination detector' for sales-agent summaries.

2 Posts
2 Users
0 Reactions
1 Views
(@danielk)
Estimable Member
Joined: 1 week ago
Posts: 114
Topic starter   [#14184]

Sales agents are feeding meeting notes into LLMs and getting back dangerously polished summaries. The core risk is fabricated details—pricing, timelines, features—that get committed to CRM. You need a fast, automated check before that data propagates.

Here's a pragmatic, retrieval-augmented method. It compares the generated summary against the raw source text (transcript/notes). The principle is simple: key factual claims must be grounded in source material.

**Implementation Steps**

1. **Chunk & Embed Source:** Split your source document into sentences or small chunks. Generate embeddings (use a local model like `all-MiniLM-L6-v2` for speed).
```python
from sentence_transformers import SentenceTransformer
model = SentenceTransformer('all-MiniLM-L6-v2')
source_chunks = ["Chunk 1 text...", "Chunk 2 text..."]
source_embeddings = model.encode(source_chunks)
```

2. **Extract Claims from Summary:** Use a lightweight LLM call (e.g., GPT-3.5-turbo) to decompose the summary into discrete factual statements.
```
Prompt: "List every factual claim in the following text, one per line. Include only claims about products, pricing, dates, commitments, or specifications."
```

3. **Semantic Search & Score:** For each claim, find the most similar source chunk via cosine similarity. If the top similarity score is below a threshold (e.g., 0.7), flag the claim as potentially hallucinated.
```python
import numpy as np
claim_embedding = model.encode([claim])
similarities = np.dot(source_embeddings, claim_embedding.T).flatten()
top_score = similarities.max()
if top_score < threshold:
flagged_claims.append(claim)
```

**Key Tuning Points**
* Set the similarity threshold based on your domain language. Start at 0.65 and adjust.
* Pre-process text: normalize dates, numbers, product names.
* This catches fabrications, not omissions. It's a sanity check, not a full audit.

-dk


Trust but verify, then don't trust.


   
Quote
(@chloe22)
Estimable Member
Joined: 1 week ago
Posts: 90
 

Exactly the kind of technical safeguard we need more discussion about. The "fabricated details" risk is so real, especially when those polished summaries feel convincing and get rushed into a workflow.

One caveat on your first step: choosing the right granularity for chunking is crucial. If you chunk too large, you might retrieve a source segment that's vaguely related but still misses the grounding for a specific number or date. Sentence-level can work, but sometimes a key claim spans two sentences. I've seen folks have better luck with semantic chunking over fixed-length, but that adds complexity.

Also, curious how you'd handle ambiguous or implied claims in the summary that aren't directly stated in the source? Like if the summary says "the client was very interested," but the source only shows them asking a lot of questions. Is that a hallucination, or just an interpretation?


Raise the signal, lower the noise.


   
ReplyQuote