SourceMapR
See what your RAG system actually saw.
SourceMapR provides evidence observability for RAG pipelines. Trace every LLM answer back to the exact document evidence that produced it, with complete evidence lineage.
Why SourceMapR?
| Problem | SourceMapR Solution |
|---|---|
| "Which chunks did the retriever return?" | See every retrieved chunk with similarity scores |
| "What prompt was sent to the LLM?" | Full prompt/response capture with token counts |
| "Why did the model hallucinate?" | Click any chunk to view it in the original PDF |
| "Is my chunking strategy working?" | Compare experiments side by side |
Add RAG observability in two lines of code.
Document Support
| Format | Status | Notes |
|---|---|---|
| ✅ Supported | Full support with chunk highlighting and source viewing | |
| HTML | 🧪 Experimental | Basic rendering, chunk highlighting may not work |
| Other formats | 🧪 Experimental | Under development |
Current Focus: SourceMapR is optimized for PDF documents. Support for HTML and other file types is experimental and under active development.
Quick Start
pip install sourcemapr
sourcemapr server
LlamaIndex
from sourcemapr import init_tracing, stop_tracing
init_tracing(endpoint="http://localhost:5000")
# Your existing LlamaIndex code — unchanged
from llama_index.core import SimpleDirectoryReader, VectorStoreIndex
documents = SimpleDirectoryReader("./papers").load_data()
index = VectorStoreIndex.from_documents(documents)
response = index.as_query_engine().query("What is attention?")
print(response)
stop_tracing()
LangChain
from sourcemapr import init_tracing, stop_tracing
init_tracing(endpoint="http://localhost:5000")
# Your existing LangChain code — unchanged
from langchain_community.document_loaders import PyPDFLoader
from langchain_text_splitters import RecursiveCharacterTextSplitter
from langchain_community.vectorstores import FAISS
loader = PyPDFLoader("./papers/attention.pdf")
documents = loader.load()
splitter = RecursiveCharacterTextSplitter(chunk_size=512)
chunks = splitter.split_documents(documents)
vectorstore = FAISS.from_documents(chunks, embeddings)
results = vectorstore.similarity_search("What is attention?")
stop_tracing()
Open http://localhost:5000 to see the full evidence lineage.
Supported Frameworks
| Framework | Documents | Chunks | Retrieval | LLM Calls |
|---|---|---|---|---|
| LlamaIndex | ✅ | ✅ | ✅ | ✅ |
| LangChain | ✅ | ✅ | ✅ | ✅ |
| OpenAI | — | — | — | ✅ |
Pipeline Support
⚠️ Experimental: Pipeline tracing (e.g.,
langchain_pipeline_demo.py) is currently experimental and does not have stable support. Basic functionality works but may have limitations.
See Supported Features for details.
Features
- Trace LLM Answers to Sources — Trace responses to exact chunks with similarity scores and rankings
- PDF Chunk Viewer — Click any chunk to see it highlighted in the original PDF
- Full LLM Tracing — Prompts, responses, tokens, latency for every query
- Experiment Tracking — Organize runs and compare chunking strategies
- Evidence Lineage — Complete trace from document load → parse → chunk → embed → retrieve → answer
- Debug RAG Hallucinations — Verify grounding without guessing
CLI Commands
# Server management
sourcemapr server # Start server (foreground)
sourcemapr server -b # Start server in background
sourcemapr server -p 8080 # Start on custom port
sourcemapr stop # Stop running server
sourcemapr restart # Restart server
sourcemapr status # Check if server is running
# Data management
sourcemapr clear # Clear all trace data (with confirmation)
sourcemapr clear -y # Clear without confirmation
sourcemapr init # Initialize database
sourcemapr init --reset # Delete and recreate database
# Info
sourcemapr version # Show version
Examples
# LlamaIndex with PDFs
python examples/llamaindex_pdf_demo.py
# LangChain with PDFs
python examples/langchain_pdf_demo.py
See Examples for more.
Installation
From PyPI
pip install sourcemapr
From Source
git clone https://github.com/kamathhrishi/sourcemapr.git
cd sourcemapr && pip install -e .
Documentation
- Supported Features — Framework coverage
- Examples — Usage examples
- REST API — API endpoints
License
MIT
Built for developers who are tired of print-debugging RAG pipelines.
Release files for sourcemapr 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| sourcemapr-0.1.1.tar.gz | 701.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| sourcemapr-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size:1.4 MB
Release files / sourcemapr-0.1.1.tar.gz
| Download URL | sourcemapr-0.1.1.tar.gz |
|---|---|
| Size | 701.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9a71e217a3cf21f5449053f158a4c8f85b2023827b865f11c14d4e2eb816bb85
|
|
BLAKE2b-256 checksum How to use checksums |
e4ad759c9610cfa93373f484da5c5c2a516762c558a0ef0a4d624b6adb4bcfdf
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.1
|
Release files / sourcemapr-0.1.1-py3-none-any.whl
| Download URL | sourcemapr-0.1.1-py3-none-any.whl |
|---|---|
| Size | 710.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3ea5b069b769dc380f35c09c9e1fe63e542d5a298f5ea549477dc8beafb2a85e
|
|
BLAKE2b-256 checksum How to use checksums |
0a3ba6af808c6486dbe51f20c2896ca1d2d29f0cae5ceb94fbd2d3a180a863c2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.1
|