opedoussaut/CSRD-ESRS-RAG-Assistant
0
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
CSRD – ESRS RAG Assistant (Gradio / Hugging Face Space)
A retrieval‑augmented chatbot to navigate the European Sustainability Reporting Standards (ESRS).
- Source of truth: EUR‑Lex consolidated text of Delegated Regulation (EU) 2023/2772 (OJ 22‑Dec‑2023).
- Languages: English and French.
- Features: hybrid dense retrieval (embeddings), precise citations (CELEX/unit), optional EFRAG Implementation Guidance (non‑authoritative) if PDFs are added to
./dataasefrag_*.pdf.
Disclaimer: Information only – not legal advice. EFRAG IG does not form part of ESRS; treat as guidance.
Quick start (local)
pip install -r requirements.txt
python app.pyThen open http://localhost:7860
Deploy on Hugging Face Spaces
- Create a new Space called CSRD (Gradio SDK).
- Upload this repository (or connect to your Git).
- (Optional) Add secrets in the Space settings:
LLM_BACKEND=openaiandOPENAI_API_KEY=...orLLM_BACKEND=hfandHF_API_TOKEN=...withHF_INFERENCE_MODEL=HuggingFaceH4/zephyr-7b-beta- On first run the app downloads the consolidated ESRS HTML from EUR‑Lex and builds an index under
./data/.
Legal & licensing
- EU law reuse: EUR‑Lex permits re‑use of EU legal content free of charge with attribution. See
NOTICE.md. - EFRAG Implementation Guidance: non‑authoritative; many PDFs include copyright notices limiting reproduction. This app never ships EFRAG content. If you add IG PDFs yourself to
./data, you confirm you have the right to use them in your jurisdiction; the UI will always label them as non‑authoritative.
How it works
- Ingestion: Downloads consolidated ESRS HTML (EN + FR) from EUR‑Lex (
CELEX:02023R2772-20231222), extracts text, splits into semantically coherent chunks aligned to Articles/Annexes. - Indexing: Multilingual embeddings (
sentence-transformers/paraphrase-multilingual-mpnet-base-v2) → FAISS (cosine/IP). - Retrieval: dense top‑k (you can add BM25 for hybrid fusion).
- Generation: configurable LLM backend (OpenAI or HF Inference). If none provided, the app returns the top ESRS extracts with citations.
- Provenance: each chunk stores CELEX, language, unit (Article/Annex), OJ date, and a SHA‑256 hash.
Configuration
Environment variables:
LLM_BACKEND=openai|hf|none(defaultnone)OPENAI_API_KEY,OPENAI_MODEL(defaultgpt-4o-mini)HF_API_TOKEN,HF_INFERENCE_MODELEMB_MODEL(defaultsentence-transformers/paraphrase-multilingual-mpnet-base-v2)TOP_K(default6)
Updating the corpus
When a new consolidated version or an amending delegated act is published on EUR‑Lex, bump the CELEX or URLs in app.py and restart the Space. Rebuilding the index is automatic if files change.
Roadmap / ideas
- Add BM25 + Reciprocal Rank Fusion for hybrid retrieval.
- Add exact paragraph IDs and richer citation formatting.
- Add bilingual UI toggle, CSV export of answers + sources.
- Add scheduled polling of EUR‑Lex for new consolidations (store OJ dates).
