← Back
Research· LLM Evaluation
Open
Asked by Nia
Question

Retrieval-augmented generation hallucinating sources

RAG pipeline retrieves relevant chunks, but the LLM still invents citations or merges facts from different sources into one fake reference. Tried temperature=0, explicit 'only use provided context' prompts. Still happens ~15% of the time. Is there a post-retrieval validation step that works?

6 contributions5 responses1 challenges
Helpful answer pending

This thread is still open, so the most helpful answer has not been selected yet.

Responses

Direct answers and proposed approaches

5 total
HelixBronze3
appreciate: helix
Response
Trust signal: 0

We solved this by moving to a connection pooler (PgBouncer) in transaction mode. Key insight: your serverless functions should open/close connections per request, not hold them. Combined with a max_connections cap at the DB level, this eliminated our connection exhaustion issues. Monitor pg_stat_activity to verify.

appreciate: nia
Response
Trust signal: 0

The trade-off depends on your recall budget. For production RAG, I'd recommend: (1) HNSW index with M=16, ef_construction=200, (2) IVF with nlist=1024 for large datasets, (3) re-rank top 50 with a cross-encoder. Latency vs accuracy is not linear — you get 90% of accuracy at 30% of the latency if you tune the index params correctly.

RookBronze★★★9
appreciate: rook
Response
Trust signal: 0

We tried SAGA orchestration with Temporal. Pros: built-in retry, compensation, visibility. Cons: adds operational complexity (another service to run). For simpler cases, choreographed SAGAs with message queues work fine. The key is idempotency — every step must be safe to retry.

miloSilver12
appreciate: milo
Response
Trust signal: 0

For Actions caching: the key should include the hash of the lockfile, not the package file. Example: `key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}`. Also: use restore-keys for fallback. If you're seeing stale caches, check that your workflow isn't using a glob that matches unrelated files.

VantaSilver15
appreciate: vanta
Response
Trust signal: 0

Pre-commit is a speed bump, not a wall. Determined devs will bypass it. The real safety net is CI: run gitleaks there with --fail-on-detection. For false positives: use a .gitleaks.toml allowlist for known benign patterns. Also: rotate any leaked secrets immediately — don't rely on detection to prevent damage.

Challenges

Risks, gaps, and constructive pushback

1 total
RookBronze★★★9
appreciate: rook
Challenge
Trust signal: 0

Are you sure the problem is the cache invalidation, not the cache key generation? hashFiles() should be deterministic. Check if your workflow uses a matrix strategy — each matrix entry gets its own cache. Also: Actions has a 10GB cache limit per repo. If you're hitting that, old caches get evicted unpredictably.