Metadata-Version: 2.4
Name: ragkit-local
Version: 0.1.0
Summary: A modular, fully local reliability layer for RAG pipelines.
Author: Sindhuja Ramaraj
License: MIT
Project-URL: Homepage, https://github.com/Sindhu06trs/ragkit
Project-URL: Repository, https://github.com/Sindhu06trs/ragkit
Keywords: rag,retrieval,llm,nlp,hallucination,local,offline
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: spacy>=3.0.0
Requires-Dist: sentence-transformers>=2.2.0
Requires-Dist: numpy
Provides-Extra: dev
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: tabulate>=0.9.0; extra == "dev"
Dynamic: license-file

# ragkit-local

A modular, pip-installable reliability layer for Retrieval-Augmented Generation (RAG) pipelines. 

## Why ragkit?
- **100% Fully Local**: Requires zero external API calls, zero hosted LLM inference, and runs completely offline.
- **Privacy-First**: No data leaves your machine; uses local NLP rules and lightweight, open-source sentence-transformers NLI models.
- **Framework-Agnostic**: Plugs directly into LangChain, LlamaIndex, or any custom pythonic RAG pipeline.
- **Import-Only-What-You-Need**: Extremely fast import times with lazy loading of all underlying model dependencies on first invocation.

---

## Installation

```bash
# Install the library in editable/dev mode or directly
pip install ragkit-local

# Download the required local English spaCy pipeline
python -m spacy download en_core_web_sm
```

---

## Quickstart Examples

### 1. Query Decomposition
Split compound queries into atomic questions before retrieval.
```python
from ragkit import QueryDecomposer

decomposer = QueryDecomposer()
sub_questions = decomposer.decompose("What is climate change and how does it affect oceans?")
print(sub_questions)
# Output: ['What is climate change?', 'How does it affect oceans?']
```

### 2. Confidence Scoring (Hallucination Detection)
Verify if the generated answer is supported by the retrieved document chunks.
```python
from ragkit import ConfidenceScorer

scorer = ConfidenceScorer()  # Uses tiny 100MB model by default
chunks = ["Photosynthesis uses sunlight to convert water and CO2 into oxygen and glucose."]
answer = "Plants convert carbon dioxide and water into glucose using sunlight. They also produce helium."

result = scorer.score(answer, chunks)
print(f"Score: {result['score']}/100 | Verdict: {result['verdict']}")
# Output: Score: 50/100 | Verdict: partially_grounded
print("Reasoning:", result["reasoning"])

# For better accuracy, use the larger model:
# scorer = ConfidenceScorer(model_name="cross-encoder/nli-deberta-v3-base")
```
