Skip to main content

RAGScope

RAGScope — Monitoring Machines Lab

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:

  1. Extract the leading topic words from each document collection.
  2. Detect mismatching topic words.
  3. 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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ragscope_sdk-0.1.0.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ragscope_sdk-0.1.0-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file ragscope_sdk-0.1.0.tar.gz.

File metadata

  • Download URL: ragscope_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.3

File hashes

Hashes for ragscope_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 34140a1755657c4b224d8075cb94dd6d1638af8ff5bc834bae38729cb60a7deb
MD5 4a085c8996bd1ce0021fe8f77acd5dc3
BLAKE2b-256 6f0bb7b14573cf37eded4c31c2c03fcb43acd659fa8d071f4665eee4d3cf1be2

See more details on using hashes here.

File details

Details for the file ragscope_sdk-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: ragscope_sdk-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.3

File hashes

Hashes for ragscope_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4abcf03623742c019722ba975a46aa4b67f054f31e9f3afdf6e3f00c80f9f909
MD5 6dae4a47452bce0e12e4d8253d59613d
BLAKE2b-256 7dc3d9905eabf367086ba6b8bb9a539daf5d7642fc7393d2d4a55f47c2cf761e

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page