ajmel commited on
Commit
20bae98
·
1 Parent(s): 2d74db3

Configure subfolder context root and automated actions pipeline

Browse files
.github/workflows/deploy_to_huggingface.yml ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Sync to Hugging Face Space
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ workflow_dispatch:
7
+
8
+ jobs:
9
+ deploy-to-space:
10
+ runs-on: ubuntu-latest
11
+
12
+ steps:
13
+ - name: Checkout repository
14
+ uses: actions/checkout@v4
15
+ with:
16
+ fetch-depth: 0
17
+ lfs: true
18
+
19
+ - name: Configure git identity
20
+ run: |
21
+ git config user.email "github-actions[bot]@users.noreply.github.com"
22
+ git config user.name "github-actions[bot]"
23
+
24
+ - name: Push to Hugging Face Space
25
+ env:
26
+ HF_TOKEN: ${{ secrets.HF_TOKEN }}
27
+ run: |
28
+ git push --force https://ajmel:$HF_TOKEN@huggingface.co/spaces/ajmel/multi-content-engine main
.gitignore CHANGED
@@ -1,9 +1,10 @@
1
- venv
2
  .env
3
- __pycache__/
4
- *.pyc
 
5
  instance/
6
  *.log
7
- chroma_db
 
8
  rag-system/test/loade.py
9
-
 
1
+ venv/
2
  .env
3
+ **/__pycache__/
4
+ **/*.pyc
5
+ **/*.pyo
6
  instance/
7
  *.log
8
+ chroma_db/
9
+ .pytest_cache/
10
  rag-system/test/loade.py
 
README.md CHANGED
@@ -1,276 +1,103 @@
1
- # 🤖 AI Engineering Portfolio
2
-
3
- A structured, end-to-end AI engineering roadmap covering three production-focused projects — from document intelligence and multimodal processing to AI safety and red-teaming. Each project is built with real architecture, not tutorial code.
4
-
5
  ---
6
-
7
- ## 📂 Repository Structure
8
-
9
- ```
10
- ├── rag-system/ # Phase 1 — Chat with PDF (RAG Pipeline)
11
- ├── multimodal-engine/ # Phase 2 — AI Reel Generator (Multimodal)
12
- ├── ai-saftey-audit/ # Phase 3 — Safety & Bias Evaluation Toolkit
13
- ├── requirements.txt # Shared top-level dependencies
14
- ├── .env
15
- ├── .gitignore
16
- └── README.md
17
-
18
- ```
19
-
20
  ---
21
 
22
- ## 🗺️ Project Overview
23
-
24
- ### Phase 1 — RAG System ✅ Complete
25
 
26
- **`/rag-system`**
27
 
28
- A production-grade Retrieval-Augmented Generation pipeline. Upload any PDF and have a grounded, citation-backed conversation with its contents. Features a multi-LLM fallback chain (Ollama → HuggingFace → OpenAI → Google Gemini), persistent ChromaDB vector storage, sentence-aware chunking, and a full Streamlit chat UI.
29
 
30
- 🔗 **Live Demo:** [ragsystem-chatpadf.streamlit.app](https://ragsystem-chatpadf.streamlit.app/)
 
 
 
31
 
32
- **Status:** Fully functional — live deployed on Streamlit Cloud with UI, CLI runner, and diagnostic test suite.
33
 
34
  ---
35
 
36
- ### Phase 2 — Multimodal Engine 🔧 In Progress
37
-
38
- **`/multimodal-engine`**
39
- An AI engine designed to process, analyze, and generate content across multiple data types — text, images, and audio. The core objective is building automated pipelines that link transcription, summarization, and video processing into a single workflow.
40
 
41
- **Planned Deliverable:** AI Reel Generator takes long-form video/audio, transcribes it, identifies key moments, and outputs a short-form highlight reel.
42
-
43
- **Status:** Architecture planned. Implementation in progress.
 
 
44
 
45
  ---
46
 
47
- ### Phase 3 — AI Safety Audit 🔧 In Progress
48
 
49
- **`/ai-saftey-audit`**
50
-
51
- An alignment and auditing framework for stress-testing LLMs against adversarial inputs. Covers prompt injection defense, bias and fairness auditing, toxicity guardrails, and jailbreak red-teaming.
52
-
53
- **Planned Deliverable:** AI Safety Audit Report + automated testing framework.
54
-
55
- **Status:** Architecture planned. Implementation in progress.
56
-
57
- ---
58
-
59
- ## 🏗️ Architecture Overview
60
-
61
- ```text
62
- ┌─────────────────────────────────────────────────────────────────┐
63
- │ AI ENGINEERING PORTFOLIO │
64
- ├─────────────────────────────────────────────────────────────────┤
65
- │ │
66
- │ Phase 1: RAG System │
67
- │ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌────────────┐ │
68
- │ │ loader │──►│ chunker │──►│embedding │──►│ ChromaDB │ │
69
- │ └──────────┘ └──────────┘ └──────────┘ └─────┬──────┘ │
70
- │ │ │
71
- │ ┌──────────┐ ┌─────────��┐ ┌──────────────────┐ │ │
72
- │ │Streamlit │◄──│qa_pipeln │◄──│ retriever │◄┘ │
73
- │ │ UI │ │(LLM chain│ │ (distance filter)│ │
74
- │ └──────────┘ └──────────┘ └──────────────────┘ │
75
- │ │
76
- ├─────────────────────────────────────────────────────────────────┤
77
- │ │
78
- │ Phase 2: Multimodal Engine (Planned) │
79
- │ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌────────────┐ │
80
- │ │ Video │──►│ Whisper │──►│Summarize │──►│Reel Output │ │
81
- │ │ Input │ │(Transcr.)│ │ (LLM) │ │ Generator │ │
82
- │ └──────────┘ └──────────┘ └──────────┘ └────────────┘ │
83
- │ │
84
- ├─────────────────────────────────────────────────────────────────┤
85
- │ │
86
- │ Phase 3: AI Safety Audit (Planned) │
87
- │ ┌──────────┐ ┌──────────┐ ┌──────────┐ ┌────────────┐ │
88
- │ │ Prompt │──►│ Injection│──►│ Bias │──►│ Audit │ │
89
- │ │ Red-Team │ │ Defense │ │ Scanner │ │ Report │ │
90
- │ └──────────┘ └──────────┘ └──────────┘ └────────────┘ │
91
- │ │
92
- └─────────────────────────────────────────────────────────────────┘
93
  ```
94
-
95
- ---
96
-
97
- ## ✅ Features by Project
98
-
99
- ### RAG System
100
-
101
- - PDF text extraction with regex-based cleaning (pypdf)
102
- - NLTK sentence-aware chunking (no mid-sentence cuts)
103
- - Semantic embeddings via `all-MiniLM-L6-v2` (HuggingFace)
104
- - Persistent ChromaDB vector store
105
- - Distance-filtered retrieval (cosine similarity threshold)
106
- - Multi-LLM fallback: Ollama → HuggingFace → OpenAI → Google Gemini
107
- - Strictly grounded prompt — LLM cannot answer outside retrieved context
108
- - Page-level citations with text snippets and distance scores
109
- - Full Streamlit chat UI with session state management
110
- - Chunk quality diagnostic tooling
111
-
112
- ### Multimodal Engine _(planned)_
113
-
114
- - Audio transcription via OpenAI Whisper
115
- - LLM-powered content summarization
116
- - Automated video timeline slicing
117
- - Cross-modal search (text query → image/video results)
118
- - Unified API for vision and language models
119
-
120
- ### AI Safety Audit _(planned)_
121
-
122
- - Prompt injection detection and filtering
123
- - Automated bias and fairness test suites
124
- - Toxicity evaluation layer
125
- - Jailbreak red-teaming framework
126
- - Structured audit report generation
127
-
128
- ---
129
-
130
- ## 🛠️ Tech Stack
131
-
132
- | Category | Technologies |
133
- | -------------- | -------------------------------------------------------- |
134
- | Language | Python 3.10+ |
135
- | UI | Streamlit |
136
- | LLM — Local | Ollama (llama3) |
137
- | LLM — Cloud | OpenAI GPT-4o-mini, Google Gemini 2.5 Flash |
138
- | Embeddings | HuggingFace `sentence-transformers` (`all-MiniLM-L6-v2`) |
139
- | Vector DB | ChromaDB |
140
- | PDF Parsing | pypdf |
141
- | Text Splitting | LangChain, NLTK |
142
- | Audio/Video | OpenAI Whisper _(Phase 2)_ |
143
- | Safety/Eval | Custom framework + `ragas` _(Phase 3)_ |
144
- | Environment | python-dotenv |
145
- | Security | cryptography, pyjwt |
146
-
147
- ---
148
-
149
- ## 📦 Installation
150
-
151
- **1. Clone the repository**
152
-
153
- ```bash
154
- git clone https://github.com/ajme-abes/RAG-Multimodal-SafeAI.git
155
- cd your-repo
156
  ```
157
 
158
- **2. Create and activate a virtual environment**
159
-
160
- ```bash
161
- python -m venv venv
162
-
163
- # Windows
164
- venv\Scripts\activate
165
-
166
- # macOS / Linux
167
- source venv/bin/activate
168
- ```
169
 
170
- **3. Install shared dependencies**
171
 
172
- ```bash
173
- pip install -r requirements.txt
174
- ```
175
 
176
- **4. Set up environment variables**
177
 
178
- Create a `.env` file in the root directory:
179
 
180
- ```env
181
- OPENAI_API_KEY=your_openai_key_here
182
- GOOGLE_API_KEY=your_google_key_here
183
- HF_API_KEY=your_huggingface_key_here
184
- ```
185
 
186
  ---
187
 
188
- ## 🚀 Usage
189
-
190
- ### Run the RAG System
191
-
192
- ```bash
193
- cd rag-system/app
194
- streamlit run app.py
195
- ```
196
-
197
- See [`rag-system/README.md`](./rag-system/README.md) for full setup and usage details.
198
-
199
- ### Run Diagnostic Tests
200
 
201
- ```bash
202
- # Chunk quality audit
203
- python rag-system/test/inspect_chunk.py
204
 
205
- # Semantic search test
206
- python rag-system/test/test_search.py
207
 
208
- # Vector DB connection test
209
- python rag-system/test/testdb_load.py
210
- ```
211
 
212
  ---
213
 
214
- ## 🖼️ Screenshots
215
 
216
- **RAG System** — Live at [ragsystem-chatpadf.streamlit.app](https://ragsystem-chatpadf.streamlit.app/)
217
-
218
- | Dashboard | Document Ingestion | Chat + Citations |
219
- |---|---|---|
220
- | ![Dashboard](rag-system/assets/image.png) | ![Ingestion](rag-system/assets/image_pdfup.png) | ![Chat](rag-system/assets/image_chat.png) |
221
 
222
- > **Multimodal Engine** and **AI Safety Audit** screenshots will be added as each phase ships.
223
 
224
- ---
225
-
226
- ## 📈 Roadmap
227
-
228
- ### Phase 1 — RAG System
229
-
230
- - [x] PDF loader with text cleaning
231
- - [x] NLTK sentence-aware chunker
232
- - [x] HuggingFace embedding model
233
- - [x] ChromaDB persistent vector store
234
- - [x] Distance-filtered retriever
235
- - [x] Multi-LLM fallback chain (Ollama / HF / OpenAI / Gemini)
236
- - [x] Streamlit chat UI with citations
237
- - [x] Conversation memory (chat history in prompt)
238
- - [x] Streaming LLM responses
239
- - [x] Multi-document support
240
- - [x] Confidence gate (block hallucination on off-topic queries)
241
- - [ ] Cross-encoder reranking
242
- - [ ] FastAPI backend
243
- - [ ] Docker deployment
244
-
245
- ### Phase 2 — Multimodal Engine
246
-
247
- - [ ] Whisper audio transcription
248
- - [ ] LLM summarization pipeline
249
- - [ ] Video clip extraction
250
- - [ ] Reel generator output
251
- - [ ] Cross-modal search API
252
-
253
- ### Phase 3 — AI Safety Audit
254
-
255
- - [ ] Prompt injection test suite
256
- - [ ] Bias and fairness scanner
257
- - [ ] Toxicity guardrail layer
258
- - [ ] Jailbreak red-team framework
259
- - [ ] Automated audit report generator
260
 
261
  ---
262
 
263
- ## 🔮 Future Improvements
264
 
265
- - **RAG Evaluation** Integrate `ragas` to score faithfulness, answer relevancy, and context recall across all three phases
266
- - **Unified API Gateway** — Single FastAPI service exposing all three systems under one interface
267
- - **Docker Compose** One-command deployment for the entire portfolio stack
268
- - **CI/CD Pipeline** GitHub Actions for automated testing and linting on every push
269
- - **Async Processing** Parallelize embedding and inference for production-scale throughput
270
- - **Web Scraping Ingestion** Extend the RAG loader to ingest URLs and web pages, not just PDFs
 
 
 
 
 
271
 
272
  ---
273
 
274
  ## 👤 Author
275
 
276
- Built as part of a structured AI engineering internship roadmap — progressing from RAG fundamentals through multimodal systems to AI safety and evaluation.
 
 
 
 
 
1
  ---
2
+ title: multi-content-engine
3
+ emoji: 🎬
4
+ colorFrom: blue
5
+ colorTo: indigo
6
+ sdk: docker
7
+ app_port: 7860
8
+ app_dir: multimodal-engine
 
 
 
 
 
 
 
9
  ---
10
 
11
+ <div align="center">
 
 
12
 
13
+ # 🤖 AI Engineering Portfolio
14
 
15
+ **Three production-grade AI systems built end-to-end, deployed, and tested.**
16
 
17
+ [![Phase 1 Live](https://img.shields.io/badge/Phase_1-Live_on_Streamlit-FF4B4B?logo=streamlit&logoColor=white)](https://ragsystem-chatpadf.streamlit.app/)
18
+ [![Phase 2 — Live](https://img.shields.io/badge/Phase_2-Live_on_HuggingFace-FFD21E?logo=huggingface&logoColor=black)](https://huggingface.co/spaces)
19
+ [![Python](https://img.shields.io/badge/Python-3.12-3776AB?logo=python&logoColor=white)](https://python.org)
20
+ [![Tests](https://img.shields.io/badge/Tests-72_passing-brightgreen?logo=pytest)](multimodal-engine/test/)
21
 
22
+ </div>
23
 
24
  ---
25
 
26
+ ## 📂 Projects
 
 
 
27
 
28
+ | # | Project | What It Does | Stack | Status |
29
+ |---|---|---|---|---|
30
+ | 1 | [**RAG System**](./rag-system/) | Chat with any PDF — grounded answers with page citations | Gemini · ChromaDB · LangChain · Streamlit | ✅ [Live](https://ragsystem-chatpadf.streamlit.app/) |
31
+ | 2 | [**Multimodal Engine**](./multimodal-engine/) | Convert long videos into vertical reels + blog posts | Gemini 2.5 · FFmpeg · Pydantic · Streamlit | ✅ [Live](https://huggingface.co/spaces) |
32
+ | 3 | [**AI Safety Audit**](./ai-saftey-audit/) | LLM red-teaming, bias scanning, prompt injection defense | Custom framework · ragas | 🔧 In progress |
33
 
34
  ---
35
 
36
+ ## 🗂️ Structure
37
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
38
  ```
39
+ ├── rag-system/ # Phase 1 — RAG Pipeline
40
+ ├── multimodal-engine/ # Phase 2 — Multimodal Content Engine
41
+ ├── ai-saftey-audit/ # Phase 3 — AI Safety Toolkit
42
+ ├── .env.example
43
+ ├── .gitignore
44
+ └── README.md
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  ```
46
 
47
+ > Each project has its own detailed README with architecture, setup, and usage guides.
 
 
 
 
 
 
 
 
 
 
48
 
49
+ ---
50
 
51
+ ## Phase 1 — RAG System
 
 
52
 
53
+ **[→ Full README](./rag-system/README.md) · [→ Live Demo](https://ragsystem-chatpadf.streamlit.app/)**
54
 
55
+ Upload any PDF and have a grounded, citation-backed conversation with it. Multi-LLM fallback chain (Ollama → HuggingFace → OpenAI → Gemini), persistent ChromaDB vector store, sentence-aware chunking, and streaming responses.
56
 
57
+ | | | | |
58
+ |---|---|---|---|
59
+ | ![Dashboard](rag-system/assets/image.png) | ![Upload](rag-system/assets/image_pdfup.png) | ![Chat](rag-system/assets/image_chat.png) | ![Score](rag-system/assets/image_scor.png) |
 
 
60
 
61
  ---
62
 
63
+ ## Phase 2 — Multimodal Content Engine
 
 
 
 
 
 
 
 
 
 
 
64
 
65
+ **[→ Full README](./multimodal-engine/README.md) · [→ Live Demo](https://huggingface.co/spaces)**
 
 
66
 
67
+ Upload an MP4 → get a 9:16 vertical reel and a CMS-ready blog post. Parallel audio/visual processing tracks, two-stage AI clip verification, and dual FFmpeg render modes.
 
68
 
69
+ | | | |
70
+ |---|---|---|
71
+ | ![Dashboard](multimodal-engine/assets/dashboard.png) | ![Blog](multimodal-engine/assets/mdpage.png) | ![Reels](multimodal-engine/assets/reelpage.png) |
72
 
73
  ---
74
 
75
+ ## Phase 3 — AI Safety Audit
76
 
77
+ **[→ Full README](./ai-saftey-audit/README.md)**
 
 
 
 
78
 
79
+ An alignment and auditing framework for stress-testing LLMs prompt injection defense, bias and fairness auditing, toxicity guardrails, and jailbreak red-teaming.
80
 
81
+ **Status:** Architecture planned. Implementation in progress.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82
 
83
  ---
84
 
85
+ ## 🛠️ Tech Across All Phases
86
 
87
+ | Category | Tools |
88
+ |---|---|
89
+ | **Language** | Python 3.12 |
90
+ | **UI** | Streamlit |
91
+ | **LLMs** | Google Gemini 2.5 Flash/Pro · OpenAI GPT-4o-mini · Ollama llama3 |
92
+ | **Embeddings** | HuggingFace `all-MiniLM-L6-v2` |
93
+ | **Vector DB** | ChromaDB |
94
+ | **Audio/Video** | FFmpeg · Google Gemini 2.5 Flash/Pro |
95
+ | **Validation** | Pydantic v2 |
96
+ | **Testing** | pytest — 72 tests, 0 failures |
97
+ | **Deployment** | Streamlit Cloud · Hugging Face Spaces · Docker |
98
 
99
  ---
100
 
101
  ## 👤 Author
102
 
103
+ Built as a structured AI engineering roadmap — progressing from RAG fundamentals through multimodal systems to AI safety and evaluation.
multimodal-engine/.gitignore CHANGED
@@ -2,9 +2,15 @@ data/*.mp4
2
  data/*.mp3
3
  data/*.wav
4
  data/*.avi
5
- data/extracted_frames
6
- data/extracted_clips
7
- data/extracted_real
8
- output/clips/*.mp4
 
 
 
9
  assets/video.mp4
10
  multimodal-engine/assets/video.mp4
 
 
 
 
2
  data/*.mp3
3
  data/*.wav
4
  data/*.avi
5
+ data/extracted_frames/
6
+ data/extracted_clips/
7
+ data/extracted_real/
8
+ data/temp_verification_slices/
9
+ data/transcript.json
10
+ output/clips/
11
+ output/*.md
12
  assets/video.mp4
13
  multimodal-engine/assets/video.mp4
14
+ __pycache__/
15
+ *.pyc
16
+ .pytest_cache/
multimodal-engine/Dockerfile CHANGED
@@ -14,15 +14,15 @@ ENV HOME=/home/user \
14
 
15
  WORKDIR $HOME/app
16
 
17
- # Copy local dependency maps into virtual container layers
18
  COPY --chown=user requirements.txt .
19
  RUN pip install --no-cache-dir -r requirements.txt
20
 
21
- # Copy the rest of the application codebase
22
  COPY --chown=user . .
23
 
24
- # Hugging Face Spaces strictly requires port 7860
25
  EXPOSE 7860
26
 
27
- # Run Streamlit on Hugging Face's required port configuration layout
28
- ENTRYPOINT ["streamlit", "run", "multimodal-engine/app/app.py", "--server.port=7860", "--server.address=0.0.0.0"]
 
14
 
15
  WORKDIR $HOME/app
16
 
17
+ # Since app_dir enters the subfolder, local paths are relative to multimodal-engine/
18
  COPY --chown=user requirements.txt .
19
  RUN pip install --no-cache-dir -r requirements.txt
20
 
21
+ # Copy the specific app folder contents safely
22
  COPY --chown=user . .
23
 
24
+ # Hugging Face Spaces strictly routes traffic over port 7860
25
  EXPOSE 7860
26
 
27
+ # Launch Streamlit on the specified port
28
+ ENTRYPOINT ["streamlit", "run", "app/app.py", "--server.port=7860", "--server.address=0.0.0.0"]