This project is a source-grounded Responsible AI Retrieval-Augmented Generation (RAG) assistant for questions related to the EU AI Act, GDPR, and NIST AI Risk Management Framework (AI RMF).
The assistant retrieves relevant information from selected authoritative public sources, formats the retrieved evidence, applies responsible-use guardrails, and generates a structured answer in a reproducible fallback mode. The project also includes an optional OpenAI-assisted generation path, which is disabled by default for safe and reproducible portfolio demonstration.
Portfolio-ready prototype
The project includes:
- Public-source collection and source inventory
- Text extraction from official web pages and PDF sources
- Document chunking
- Sentence-transformer embedding generation
- Chroma vector-store creation
- Multi-source retrieval
- Source-aware retrieval evaluation
- Context-grounded fallback answer generation
- Optional OpenAI LLM generation pathway
- Responsible-use guardrails
- CLI testing interface
- Streamlit demo application
This project is an educational and portfolio-ready prototype.
It does not provide legal advice.
It does not replace qualified legal, privacy, compliance, or regulatory review.
Real compliance decisions should always be reviewed by qualified professionals.
The assistant is designed to demonstrate responsible AI system design patterns, including:
- Source-grounded retrieval
- Transparent retrieved evidence
- Explicit disclaimers
- Fallback behavior when LLM generation is disabled or unavailable
- Separation between local secrets and public repository files
The project uses selected public and authoritative sources covering:
- EU AI Act overview and implementation guidance
- Regulation (EU) 2024/1689 Artificial Intelligence Act
- Regulation (EU) 2016/679 General Data Protection Regulation
- NIST AI Risk Management Framework AI RMF 1.0
- NIST AI RMF overview material
The project builds a structured RAG workflow:
- Load source inventory
- Extract and clean source text
- Chunk documents into retrieval-ready segments
- Generate embeddings using
sentence-transformers/all-MiniLM-L6-v2 - Store chunks and embeddings in Chroma
- Retrieve relevant chunks for user questions
- Format retrieved context
- Generate source-grounded answers
- Display retrieved sources and confidence information
The retrieval pipeline includes lightweight source-awareness logic. For example:
- GDPR questions are routed toward GDPR source material
- NIST AI risk-management questions are routed toward NIST sources
- EU AI Act questions are routed toward EU AI Act sources
This improves retrieval relevance and makes the system easier to inspect.
The assistant includes guardrails such as:
- No legal advice
- No unsupported certainty beyond retrieved context
- Source-aware answer generation
- Retrieved chunk references
- Responsible-use disclaimer
- Fallback mode when API generation is unavailable or disabled
The repository is designed to run without paid OpenAI API usage.
By default:
ENABLE_OPENAI_GENERATION=FalseThis allows the assistant to generate structured, context-grounded fallback answers from retrieved chunks without calling an external LLM.
The project includes an optional OpenAI-assisted answer-generation path. To use it locally, create a .env file from .env.example and configure your own API key.
The real .env file is intentionally excluded from GitHub.
responsible-ai-rag-assistant/
├── app/
│ └── streamlit_app.py
│
├── data/
│ └── README.md
│
├── docs/
│ ├── project_plan.md
│ └── source_register.md
│
├── images/
│ ├── streamlit_app_answer.png
│ └── streamlit_app_sources.png
│
├── notebooks/
│ ├── 01_document_ingestion_and_chunking.ipynb
│ ├── 02_embeddings_and_vector_store.ipynb
│ ├── 03_rag_question_answering.ipynb
│ ├── 04_source_expansion_and_retrieval_evaluation.ipynb
│ ├── 05_multisource_vector_store_and_retrieval_evaluation.ipynb
│ └── 06_llm_rag_assistant_and_guardrails.ipynb
│
├── reports/
│
├── src/
│ ├── __init__.py
│ ├── config.py
│ ├── rag_pipeline.py
│ └── run_rag_cli.py
│
├── tests/
│
├── .env.example
├── .gitignore
├── LICENSE
├── README.md
└── requirements.txt
The repository intentionally does not include raw downloaded files, processed chunks, embeddings, or local vector-store artifacts.
The following local folders are excluded through .gitignore:
data/raw/
data/processed/
data/vector_store/
This keeps the public repository lightweight and avoids uploading generated or potentially large local artifacts.
To reproduce the full workflow locally, run the notebooks in order.
- Python
- pandas
- NumPy
- sentence-transformers
- ChromaDB
- Streamlit
- OpenAI Python SDK
- Jupyter Notebook
- Git / GitHub
Clone the repository:
git clone https://github.com/mahdidadgar-data/responsible-ai-rag-assistant.git
cd responsible-ai-rag-assistantCreate and activate a virtual environment:
python -m venv .venvOn Windows PowerShell:
.\.venv\Scripts\Activate.ps1Install dependencies:
pip install -r requirements.txtCopy the example environment file:
copy .env.example .envThen edit .env locally.
Example:
OPENAI_API_KEY=your_openai_api_key_here
OPENAI_MODEL=gpt-4.1
ENABLE_OPENAI_GENERATION=False
EMBEDDING_MODEL=sentence-transformers/all-MiniLM-L6-v2Important:
.envmust stay local..envmust not be uploaded to GitHub.- The project works in fallback mode when OpenAI generation is disabled.
The project includes a local Streamlit interface for asking Responsible AI, EU AI Act, GDPR, and NIST AI RMF questions.
The interface shows the generated answer, retrieval method, number of retrieved chunks, top retrieval distance, retrieved source count, and a retrieved-sources table for transparency.
From the project root:
streamlit run app/streamlit_app.pyThe app provides a simple interface for asking questions, viewing retrieved sources, and inspecting the responsible RAG prompt.
Example questions:
What is the risk-based approach of the EU AI Act?
What is personal data under the GDPR?
What does NIST say about managing AI risks?
From the project root:
python src/run_rag_cli.py "What is personal data under the GDPR?"Example:
python src/run_rag_cli.py "What does NIST say about managing AI risks?"The CLI prints:
- Answer method
- Preferred sources
- Retrieved sources
- Retrieved chunks
- Top retrieval distance
- Source-grounded fallback answer
- Responsible-use note
The project is documented through six development notebooks.
Creates the initial source register, collects source text, and prepares the first source chunks.
Generates embeddings and creates the first Chroma vector store.
Builds the first context-only RAG answer pipeline and tests baseline retrieval.
Adds additional authoritative sources and evaluates retrieval coverage across EU AI Act, GDPR, and NIST-related questions.
Creates the multi-source Chroma collection and compares baseline retrieval against source-aware retrieval.
Adds optional OpenAI generation, fallback-mode answer generation, guardrails, and final RAG assistant testing.
The project evaluates retrieval quality across representative questions covering:
- EU AI Act risk-based approach
- High-risk AI obligations
- AI transparency
- GDPR personal data
- GDPR processing principles
- NIST AI risk management
- NIST AI RMF functions
- Responsible AI governance
The source-aware retrieval setup improves source matching and provides more transparent retrieval diagnostics.
For a GDPR question, the assistant retrieves GDPR-related chunks and returns a context-grounded answer with a responsible-use disclaimer.
Example metadata:
Answer method: context_only_fallback
Retrieved sources: ['SRC-003']
Retrieved chunks: 5
Retrieval confidence: source_matched_moderate
For a NIST AI risk-management question, the assistant retrieves NIST AI RMF sources.
Example metadata:
Answer method: context_only_fallback
Retrieved sources: ['SRC-005', 'SRC-004']
Retrieved chunks: 5
Retrieval confidence: moderate_to_good
This project follows basic repository safety practices:
.envis excluded from Git- API keys are not committed
- Virtual environments are excluded
- Raw and processed data are excluded
- Chroma vector-store files are excluded
- Python cache files are excluded
The public repository includes .env.example only as a safe template.
This project is a portfolio prototype and has several limitations:
- It is not a legal advice system.
- It uses a small curated source set.
- Retrieval quality depends on chunking, source coverage, and embedding behavior.
- Fallback answers are extractive and evidence-summary based.
- OpenAI-assisted generation is optional and disabled by default.
- The Streamlit app is intended for local demonstration, not production deployment.
This repository is provided publicly for portfolio review, educational demonstration, and employment evaluation purposes only.
No permission is granted to copy, modify, distribute, sublicense, sell, commercialize, or reuse this software, source code, documentation, workflows, or project structure without prior written permission from the copyright holder.
See the LICENSE file for details.
Mahdi Dadgar
PhD-trained analytical professional transitioning into Data Science, Machine Learning, and Responsible AI systems.
GitHub: mahdidadgar-data
This project was built to demonstrate practical skills in:
- Responsible AI system design
- Retrieval-Augmented Generation
- AI governance knowledge support
- Source-grounded answer generation
- Python project structuring
- Vector-store based semantic search
- Streamlit application development
- Reproducible AI/ML portfolio engineering

