How vaisax/refrag works
REFRAG is a compact RAG context-compression implementation. Its main workflow accepts retrieved passages, chunks them, encodes chunks, selects chunks for expansion, and returns compressed representations with statistics. The README also documents decoder-space projection and decoder use, plus a three-stage training simulation; these capabilities are represented at the level supported by documentation. The source excerpt omits parts of refrag.py, so uncertain internal wiring and any generated-response path are not detailed.
Main entry points: refrag.py SimpleREFRAG
Components 11
Context Compression
- SimpleREFRAG
refrag.py - Passage Chunking
refrag.py - Expansion Policy
refrag.py - Compressed Result
refrag.py - Performance Estimates
refrag.py
Model Components
- Chunk Encoding
refrag.py - Decoder Projection
refrag.py - Decoder Model
refrag.py
Training Simulation
- Training Simulation
refrag.py
Other components
- RAG caller
- Pretrained Models
Connections 12
- RAG caller → SimpleREFRAG: submits passages
- SimpleREFRAG → Passage Chunking: chunks passages
- SimpleREFRAG → Chunk Encoding: encodes chunks
- SimpleREFRAG → Expansion Policy: selects expansion
- SimpleREFRAG → Decoder Projection: projects embeddings
- SimpleREFRAG → Compressed Result: assembles result
- SimpleREFRAG → Performance Estimates: estimates metrics
- SimpleREFRAG → Decoder Model: uses compressed context
- Chunk Encoding → Pretrained Models: loads encoder
- SimpleREFRAG → Pretrained Models: loads tokenizer
- RAG caller → Training Simulation: runs simulation
- SimpleREFRAG → Training Simulation: provides model