Metadata-Version: 2.4
Name: openenv-halluguard
Version: 2.0.1
Summary: Train and evaluate LLMs to avoid hallucinations - 5-line API for RL training with 1M+ examples across 38 datasets
Project-URL: Homepage, https://huggingface.co/spaces/SamSankar/hallucination-guard-env
Project-URL: Repository, https://github.com/SS-360/Openenv-halluguard
Project-URL: Documentation, https://samsankar-hallucination-guard-env.hf.space/docs
Author-email: Sam Sankar P <p.samsankar2005@gmail.com>
License: MIT
Keywords: ai-safety,grounded-generation,hallucination-detection,llm-evaluation,openenv,question-answering,reinforcement-learning
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.10
Requires-Dist: bert-score>=0.3.13
Requires-Dist: datasets>=2.14.0
Requires-Dist: fastapi>=0.100.0
Requires-Dist: numpy>=1.24.0
Requires-Dist: openenv-core>=0.2.0
Requires-Dist: pydantic>=2.0.0
Requires-Dist: requests>=2.31.0
Requires-Dist: rouge-score>=0.1.2
Requires-Dist: sentence-transformers>=2.7.0
Requires-Dist: torch>=2.0.0
Requires-Dist: transformers>=4.35.0
Requires-Dist: uvicorn>=0.23.0
Provides-Extra: dev
Requires-Dist: httpx>=0.24.0; extra == 'dev'
Requires-Dist: pytest-asyncio>=0.21.0; extra == 'dev'
Requires-Dist: pytest>=7.0.0; extra == 'dev'
Description-Content-Type: text/markdown

# openenv-halluguard

**Train and evaluate LLMs to avoid hallucinations.**

```bash
pip install openenv-halluguard
```

## Quick Start (5 lines)

```python
from hallucination_guard_env import HallucinationEnv

env = HallucinationEnv()
obs = env.reset()
result = env.step(answer="your answer", confidence=0.8)
print(f"Reward: {result.reward}, Hallucinated: {result.is_hallucination}")
```

## What It Does

HallucinationGuard-Env is an OpenEnv RL environment that trains AI models to:
- Answer **only from verified context** — no fabrication
- **Cite real sources** — quote verification
- **Calibrate confidence** — don't be overconfident when wrong

## Evaluation Example

```python
from hallucination_guard_env import HallucinationEnv

def my_model(question, context):
    # Call your LLM API here
    # Return answer based ONLY on context
    return "answer from context"

env = HallucinationEnv()
obs = env.reset()
action = my_model(obs.question, obs.context)
result = env.step(answer=action, confidence=0.8)

print(f"Hallucinated: {result.is_hallucination}")
print(f"Reward: {result.reward}")
```

## HTTP API (HuggingFace Space)

For full deployment, use the HuggingFace Space:

```python
import requests

BASE = "https://samsankar-hallucination-guard-env.hf.space"

# Start episode
obs = requests.post(f"{BASE}/reset").json()

# Submit answer
result = requests.post(f"{BASE}/step",
                       json={"answer": "your answer"}).json()

# View leaderboard
lb = requests.get(f"{BASE}/leaderboard").json()
```

## Features

- **38 datasets** — SQuAD, HaluEval, TruthfulQA, HotpotQA, MedQA, and more
- **Research-grade grader** — ROUGE + BERTScore + NLI-DeBERTa
- **3 task difficulties** — Beginner → Intermediate → Advanced
- **8 hallucination types** — Fabricated facts, false citations, overconfident wrong, etc.

## Links

- **HuggingFace Space**: https://huggingface.co/spaces/SamSankar/hallucination-guard-env
- **Interactive Docs**: https://samsankar-hallucination-guard-env.hf.space/docs
- **Leaderboard**: https://samsankar-hallucination-guard-env.hf.space/leaderboard

## License

MIT
