How alebbboy/trustless-rag-di works
Trustless RAG-DI audits whether an owner’s canary document was ingested and influenced a third-party RAG answer, using black-box queries and commitments intended to prevent post-hoc selection. The main path runs from canary creation and document indexing, through RAG retrieval and generation, to detection and ranking; a separate chain path commits candidate sets and reveals the selected canary. README documents additional experiments and contract capabilities. Some subsystem links are based on those descriptions, since their source was not sampled.
Main entry points: bridge.py Web3 bridge · pipeline.py RAG pipeline · ranking_test.py Ranking test · build_index.py Index builder
Components 22
RAG system
- Index builder
scripts/build_index.py - FAISS index
rag_di/pipeline.py - RAG pipeline
rag_di/pipeline.py - Embedding model
- Generation model
Canary audit
- Semantic canary
rag_di/canaries/semantic_canary.py - Unicode canary
rag_di/canaries/unicode_canary.py - Ranking test
rag_di/ranking_test.py - Canary detection
rag_di/canaries
Commitment protocol
- Merkle proofs
rag_di/merkle.py - Beacon randomness
rag_di/vrf.py
Chain backends
- Mock chain
rag_di/mockchain.py - Web3 bridge
rag_di/bridge.py - Canary registry
contracts/src/CanaryRegistry.sol - Commit-reveal registry
contracts/src/CommitRevealCanaryRegistry.sol - Time-bound commitment
contracts/src/Commitment.sol - Random beacon
contracts/src/RandomBeacon.sol - Beacon-bound commitment
contracts/src/BeaconBoundCommitment.sol
Experiments
- Audit experiments
scripts
Other components
- Document owner
- Auditor
- Source documents
Connections 28
- Document owner → Semantic canary: creates candidates
- Document owner → Unicode canary: creates candidates
- Semantic canary → Index builder: embeds fact
- Unicode canary → Index builder: embeds reply
- Source documents → Index builder: supplies documents
- Index builder → FAISS index: writes index
- Auditor → RAG pipeline: asks question
- RAG pipeline → Embedding model: encodes query
- RAG pipeline → FAISS index: searches index
- RAG pipeline → Generation model: generates answer
- Auditor → Ranking test: starts audit
- Ranking test → RAG pipeline: queries black box
- Ranking test → Canary detection: scores responses
- Canary detection → Semantic canary: checks semantic cue
- Canary detection → Unicode canary: checks invisible reply
- Document owner → Merkle proofs: hashes candidates
- Merkle proofs → Mock chain: commits root
- Document owner → Beacon randomness: commits seed
- Beacon randomness → Beacon-bound commitment: selects candidate
- Web3 bridge → Mock chain: falls back to
- Web3 bridge → Canary registry: calls
- Web3 bridge → Commit-reveal registry: calls
- Web3 bridge → Time-bound commitment: assigns and reveals
- Web3 bridge → Random beacon: deploys and calls
- Web3 bridge → Beacon-bound commitment: deploys and calls
- Beacon-bound commitment → Random beacon: reads randomness
- Audit experiments → Ranking test: evaluates
- Audit experiments → Web3 bridge: exercises protocol