RAGScope
Topic-drift observability for retrieval-augmented generation systems.
RAG systems can appear healthy while their knowledge base, retrieved context, or user questions gradually move in different directions. RAGScope helps make that shift visible. It compares the principal topic words in document collections so you can monitor whether the context your system relies on remains aligned with the questions it receives and the content it produces.
RAGScope currently focuses on one essential observability capability: Topic Drift.
Why RAGScope?
- Catch misalignment early. Identify when incoming queries no longer match the topics covered by your knowledge base.
- Monitor changing content. Compare new or generated content to a trusted reference corpus before the shift becomes a quality issue.
- Use interpretable similarity scores. Evaluate topic alignment with Dice, Braun, Jaccard, overlap, and Tanimoto coefficients.
- Start small and integrate easily. Supply document collections and an embedding model; RAGScope handles topic extraction and comparison.
Installation
Clone the repository, then install the project dependencies and RAGScope:
pip install -r requirements.txt
pip install -e .
Topic Drift
RAGScope exposes two monitors in ragscope.topic_drift:
| Monitor | Use it when you want to compare |
|---|---|
TopicContentQueryDrift |
knowledge-base content with user queries |
TopicSemanticContentDrift |
trusted reference content with new analysis content |
Both monitors provide the same topic-drift workflow:
- Extract the leading topic words from each document collection.
- Detect mismatching topic words.
- Calculate an alignment score with Dice, Braun, Jaccard, overlap, or Tanimoto similarity.
Example: Are user questions covered by the knowledge base?
The following example compares a small knowledge base with incoming questions.
BERTopic accepts an embedding-model identifier, such as
"all-MiniLM-L6-v2", or a compatible embedding model object.
from ragscope.topic_drift import TopicContentQueryDrift
knowledge_base = [
"RAG systems retrieve relevant documents before generating an answer.",
"Embedding models represent text as vectors for semantic search.",
"Topic drift monitoring identifies changes in document collections.",
]
user_queries = [
"How can I monitor topic drift in a retrieval pipeline?",
"Which embedding model should I use for semantic search?",
]
monitor = TopicContentQueryDrift(
content_docs=knowledge_base,
query_docs=user_queries,
embedding_model="all-MiniLM-L6-v2",
)
# Surface the topic words that do not align between content and queries.
monitor.detect_mismatching_topics()
# Retrieve the comparison object and calculate Jaccard topic alignment.
drift = monitor.topic_word_drift()
jaccard_alignment = drift.jaccard_coeff("words")
print(f"Topic alignment: {jaccard_alignment:.2%}")
A Jaccard score closer to 1.0 indicates stronger overlap between the leading
topics of your knowledge base and incoming queries. A low score is a useful
signal to review your content, query routing, or retrieval strategy.
Where to go next
Read the Topic Drift documentation for the
complete API reference, including TopicSemanticContentDrift and the available
similarity methods.
Conclusion
Reliable RAG systems need more than retrieval metrics—they need visibility into whether the system is still operating in the right semantic territory. RAGScope gives you a focused starting point: monitor topic alignment, investigate drift, and keep your RAG experience grounded in the knowledge your users expect.
Metadata
Release files for ragscope-sdk 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ragscope_sdk-0.1.0.tar.gz | 9.1 kB | Without provenance | Details for ragscope_sdk-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ragscope_sdk-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for ragscope_sdk-0.1.0-py3-none-any.whl |
Total release size: 18.4 kB
Release files / ragscope_sdk-0.1.0.tar.gz
| Download URL | ragscope_sdk-0.1.0.tar.gz |
|---|---|
| Size | 9.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
34140a1755657c4b224d8075cb94dd6d1638af8ff5bc834bae38729cb60a7deb
|
|
BLAKE2b-256 checksum How to use checksums |
6f0bb7b14573cf37eded4c31c2c03fcb43acd659fa8d071f4665eee4d3cf1be2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / ragscope_sdk-0.1.0-py3-none-any.whl
| Download URL | ragscope_sdk-0.1.0-py3-none-any.whl |
|---|---|
| Size | 9.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4abcf03623742c019722ba975a46aa4b67f054f31e9f3afdf6e3f00c80f9f909
|
|
BLAKE2b-256 checksum How to use checksums |
7dc3d9905eabf367086ba6b8bb9a539daf5d7642fc7393d2d4a55f47c2cf761e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Security for ragscope-sdk 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.