syed7741 commited on
Commit
ff66fd1
Β·
verified Β·
1 Parent(s): d630e48

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +471 -47
README.md CHANGED
@@ -1,100 +1,352 @@
1
  ---
2
  license: apache-2.0
 
3
  language:
4
  - en
5
 
6
- base_model:
7
- - google/flan-t5-small
8
-
9
- library_name: transformers
10
 
 
11
  pipeline_tag: text2text-generation
12
 
 
 
 
13
  tags:
 
 
 
14
  - rag
15
  - industrial-ai
16
  - generative-ai
17
  - semantic-search
18
- - sentence-transformers
19
- - fastapi
20
  - document-intelligence
21
  - robotics
22
  - predictive-maintenance
23
  - worker-safety
24
  - workflow-automation
 
25
  - huggingface
26
  ---
27
 
28
  # AEGIS Industrial RAG Assistant
29
 
30
- **AEGIS Industrial RAG Assistant** is the Retrieval-Augmented Generation component of the AEGIS AI industrial intelligence platform.
31
 
32
- The project demonstrates how an industrial AI application can combine:
33
 
34
- - Hugging Face datasets
35
- - semantic search
36
- - sentence-transformer embeddings
37
- - vector retrieval
38
- - local language models
39
- - FastAPI
40
- - React / TypeScript
41
- - source attribution
42
- - industrial knowledge retrieval
 
 
43
 
44
  ---
45
 
46
- ## Important Status
 
 
47
 
48
- This repository currently documents the **AEGIS RAG model pipeline and model configuration**.
49
 
50
- It is **not currently a separately fine-tuned language model checkpoint**.
51
 
52
- The current prototype uses:
 
 
 
 
53
 
54
- ### Language Model
 
 
55
 
56
- `google/flan-t5-small`
57
 
58
- ### Embedding Model
59
 
60
- `sentence-transformers/all-MiniLM-L6-v2`
61
 
62
- ### Knowledge Dataset
 
 
63
 
64
- `syed7741/aegis-industrial-ai-dataset`
65
 
66
- A future version of this repository is planned to contain a genuinely fine-tuned AEGIS model or adapter trained for industrial question answering.
67
 
68
  ---
69
 
70
- # AEGIS AI
 
 
71
 
72
- AEGIS AI is an end-to-end industrial artificial intelligence platform designed as an AI engineering portfolio project.
 
 
73
 
74
- The platform explores:
 
 
 
 
 
 
75
 
76
- - Retrieval-Augmented Generation
77
- - AI Agents
78
- - Industrial Document Intelligence
79
  - Worker Safety
80
  - Predictive Maintenance
81
  - Robot Monitoring
82
- - Computer Vision
83
  - AI Alerts
84
- - Factory Operations
85
  - Workflow Automation
86
- - Real-Time Monitoring
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
 
88
  ---
89
 
90
- # RAG Architecture
91
 
92
- The current pipeline is:
93
 
94
  ```text
95
  User Question
96
  ↓
97
- React / TypeScript UI
98
  ↓
99
  FastAPI
100
  ↓
@@ -102,14 +354,186 @@ AEGIS RAG Service
102
  ↓
103
  Sentence Transformer
104
  ↓
105
- 384-Dimensional Query Embedding
106
- ↓
107
- Local Vector Search
108
  ↓
109
- Relevant Industrial Knowledge
110
  ↓
111
- FLAN-T5
112
  ↓
113
- Grounded Answer
114
  ↓
115
- Source Attribution
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  license: apache-2.0
3
+
4
  language:
5
  - en
6
 
7
+ base_model: google/flan-t5-small
8
+ base_model_relation: adapter
 
 
9
 
10
+ library_name: peft
11
  pipeline_tag: text2text-generation
12
 
13
+ datasets:
14
+ - syed7741/aegis-industrial-ai-dataset
15
+
16
  tags:
17
+ - peft
18
+ - lora
19
+ - flan-t5
20
  - rag
21
  - industrial-ai
22
  - generative-ai
23
  - semantic-search
 
 
24
  - document-intelligence
25
  - robotics
26
  - predictive-maintenance
27
  - worker-safety
28
  - workflow-automation
29
+ - fastapi
30
  - huggingface
31
  ---
32
 
33
  # AEGIS Industrial RAG Assistant
34
 
35
+ **AEGIS Industrial RAG Assistant** is a LoRA/PEFT adapter fine-tuned on the AEGIS Industrial AI Dataset for industrial question answering and Retrieval-Augmented Generation experiments.
36
 
37
+ The adapter was trained on top of:
38
 
39
+ ```text
40
+ google/flan-t5-small
41
+ ```
42
+
43
+ using:
44
+
45
+ ```text
46
+ LoRA / PEFT
47
+ ```
48
+
49
+ The project is part of **AEGIS AI**, an end-to-end industrial artificial intelligence platform combining RAG, document intelligence, semantic search, AI agents, computer vision, predictive maintenance, robotics monitoring, and workflow automation.
50
 
51
  ---
52
 
53
+ # Model Status
54
+
55
+ βœ… **This repository now contains a genuinely trained LoRA adapter.**
56
 
57
+ It is no longer only a documentation repository.
58
 
59
+ The trained adapter weights are stored in:
60
 
61
+ ```text
62
+ adapter_model.safetensors
63
+ ```
64
+
65
+ The LoRA configuration is stored in:
66
 
67
+ ```text
68
+ adapter_config.json
69
+ ```
70
 
71
+ The adapter was trained locally on CPU using the public AEGIS synthetic industrial dataset.
72
 
73
+ ---
74
 
75
+ # Base Model
76
 
77
+ ```text
78
+ google/flan-t5-small
79
+ ```
80
 
81
+ The original FLAN-T5-small parameters remain the base model.
82
 
83
+ AEGIS fine-tuning was performed using parameter-efficient LoRA adaptation rather than full-model fine-tuning.
84
 
85
  ---
86
 
87
+ # Training Dataset
88
+
89
+ The adapter was trained using:
90
 
91
+ ```text
92
+ syed7741/aegis-industrial-ai-dataset
93
+ ```
94
 
95
+ The dataset currently contains:
96
+
97
+ ```text
98
+ 64 synthetic industrial records
99
+ ```
100
+
101
+ covering:
102
 
 
 
 
103
  - Worker Safety
104
  - Predictive Maintenance
105
  - Robot Monitoring
106
+ - Vision Inspection
107
  - AI Alerts
 
108
  - Workflow Automation
109
+ - Document Assistant
110
+ - Factory Status
111
+
112
+ Industries represented include:
113
+
114
+ - Manufacturing
115
+ - Oil & Gas
116
+ - Warehousing / Logistics
117
+ - Robotics
118
+
119
+ ---
120
+
121
+ # Training Data Preparation
122
+
123
+ The original 64 industrial records were split before prompt expansion to reduce leakage between the training and evaluation sets.
124
+
125
+ Training split:
126
+
127
+ ```text
128
+ 54 records
129
+ ```
130
+
131
+ Evaluation split:
132
+
133
+ ```text
134
+ 10 records
135
+ ```
136
+
137
+ Each source record was transformed into multiple instruction/question-answer formats.
138
+
139
+ Final training examples:
140
+
141
+ ```text
142
+ 162
143
+ ```
144
+
145
+ Final evaluation examples:
146
+
147
+ ```text
148
+ 30
149
+ ```
150
+
151
+ ---
152
+
153
+ # Fine-Tuning Method
154
+
155
+ The model was trained using **LoRA β€” Low-Rank Adaptation** through Hugging Face PEFT.
156
+
157
+ Configuration:
158
+
159
+ | Parameter | Value |
160
+ |---|---:|
161
+ | Base model | google/flan-t5-small |
162
+ | Method | LoRA / PEFT |
163
+ | Task | SEQ_2_SEQ_LM |
164
+ | LoRA rank | 4 |
165
+ | LoRA alpha | 16 |
166
+ | LoRA dropout | 0.05 |
167
+ | Target modules | q, v |
168
+ | Learning rate | 3e-4 |
169
+ | Batch size | 1 |
170
+ | Gradient accumulation | 4 |
171
+ | Epochs | 2 |
172
+ | Device | CPU |
173
+
174
+ ---
175
+
176
+ # Trainable Parameters
177
+
178
+ The LoRA configuration trained:
179
+
180
+ ```text
181
+ 172,032 parameters
182
+ ```
183
+
184
+ out of approximately:
185
+
186
+ ```text
187
+ 77.1 million total parameters
188
+ ```
189
+
190
+ Trainable percentage:
191
+
192
+ ```text
193
+ 0.223%
194
+ ```
195
+
196
+ This demonstrates parameter-efficient adaptation without retraining the complete FLAN-T5-small model.
197
+
198
+ ---
199
+
200
+ # Training Results
201
+
202
+ ## Epoch 1
203
+
204
+ ```text
205
+ Training Loss: 1.6501
206
+ Evaluation Loss: 1.1663
207
+ ```
208
+
209
+ ## Epoch 2
210
+
211
+ ```text
212
+ Training Loss: 1.1880
213
+ Evaluation Loss: 0.7744
214
+ ```
215
+
216
+ Both the training and evaluation loss decreased during the two training epochs.
217
+
218
+ ---
219
+
220
+ # Fine-Tuned Test Result
221
+
222
+ Test question:
223
+
224
+ ```text
225
+ What should I do before maintaining CONV-02?
226
+ ```
227
+
228
+ Fine-tuned adapter response:
229
+
230
+ ```text
231
+ isolate all energy sources, apply lockout/tagout, verify zero-energy state, and record the responsible technician.
232
+ ```
233
+
234
+ This example demonstrates that the trained adapter learned the expected industrial safety response from the AEGIS training examples.
235
+
236
+ ---
237
+
238
+ # Using the Adapter
239
+
240
+ Install the required libraries:
241
+
242
+ ```bash
243
+ pip install transformers peft torch sentencepiece
244
+ ```
245
+
246
+ Then load the AEGIS adapter:
247
+
248
+ ```python
249
+ from transformers import (
250
+ AutoModelForSeq2SeqLM,
251
+ AutoTokenizer,
252
+ )
253
+
254
+ from peft import (
255
+ PeftConfig,
256
+ PeftModel,
257
+ )
258
+
259
+
260
+ ADAPTER_ID = (
261
+ "syed7741/"
262
+ "aegis-industrial-rag-assistant"
263
+ )
264
+
265
+
266
+ config = PeftConfig.from_pretrained(
267
+ ADAPTER_ID
268
+ )
269
+
270
+ base_model = (
271
+ AutoModelForSeq2SeqLM
272
+ .from_pretrained(
273
+ config.base_model_name_or_path
274
+ )
275
+ )
276
+
277
+ tokenizer = (
278
+ AutoTokenizer
279
+ .from_pretrained(
280
+ ADAPTER_ID
281
+ )
282
+ )
283
+
284
+ model = PeftModel.from_pretrained(
285
+ base_model,
286
+ ADAPTER_ID,
287
+ )
288
+
289
+ model.eval()
290
+ ```
291
+
292
+ PEFT adapters are loaded together with their original base model.
293
+
294
+ ---
295
+
296
+ # Example Inference
297
+
298
+ ```python
299
+ prompt = """
300
+ industrial qa:
301
+ Context: Before maintenance on CONV-02,
302
+ isolate all energy sources, apply lockout/tagout,
303
+ verify zero-energy state, and record the responsible
304
+ technician.
305
+
306
+ Question:
307
+ What should I do before maintaining CONV-02?
308
+ """.strip()
309
+
310
+
311
+ inputs = tokenizer(
312
+ prompt,
313
+ return_tensors="pt",
314
+ )
315
+
316
+
317
+ output = model.generate(
318
+ **inputs,
319
+ max_new_tokens=96,
320
+ num_beams=4,
321
+ do_sample=False,
322
+ )
323
+
324
+
325
+ answer = tokenizer.decode(
326
+ output[0],
327
+ skip_special_tokens=True,
328
+ )
329
+
330
+
331
+ print(answer)
332
+ ```
333
+
334
+ Expected response:
335
+
336
+ ```text
337
+ isolate all energy sources, apply lockout/tagout, verify zero-energy state, and record the responsible technician.
338
+ ```
339
 
340
  ---
341
 
342
+ # AEGIS RAG Architecture
343
 
344
+ The trained adapter is designed to work as part of the larger AEGIS Retrieval-Augmented Generation system.
345
 
346
  ```text
347
  User Question
348
  ↓
349
+ React / TypeScript
350
  ↓
351
  FastAPI
352
  ↓
 
354
  ↓
355
  Sentence Transformer
356
  ↓
357
+ Semantic Vector Search
 
 
358
  ↓
359
+ Retrieved Industrial Knowledge
360
  ↓
361
+ AEGIS LoRA Adapter
362
  ↓
363
+ Grounded Response
364
  ↓
365
+ Source Attribution
366
+ ```
367
+
368
+ ---
369
+
370
+ # Embedding Model
371
+
372
+ The AEGIS RAG pipeline currently uses:
373
+
374
+ ```text
375
+ sentence-transformers/all-MiniLM-L6-v2
376
+ ```
377
+
378
+ Embedding dimensions:
379
+
380
+ ```text
381
+ 384
382
+ ```
383
+
384
+ The embedding model performs semantic retrieval over the industrial knowledge base before relevant context is supplied to the language model.
385
+
386
+ ---
387
+
388
+ # Technology Stack
389
+
390
+ ### AI / Machine Learning
391
+
392
+ - Hugging Face
393
+ - Transformers
394
+ - PEFT
395
+ - LoRA
396
+ - FLAN-T5
397
+ - Sentence Transformers
398
+ - Retrieval-Augmented Generation
399
+ - Semantic Search
400
+ - Vector Embeddings
401
+
402
+ ### Backend
403
+
404
+ - Python
405
+ - FastAPI
406
+ - REST APIs
407
+ - PostgreSQL
408
+
409
+ ### Frontend
410
+
411
+ - React
412
+ - TypeScript
413
+ - Material UI
414
+
415
+ ### AI Platform Components
416
+
417
+ - RAG
418
+ - AI Agents
419
+ - Document Intelligence
420
+ - Computer Vision
421
+ - Predictive Maintenance
422
+ - Robot Monitoring
423
+ - Worker Safety
424
+ - Workflow Automation
425
+
426
+ ---
427
+
428
+ # Current AEGIS Capabilities
429
+
430
+ Implemented:
431
+
432
+ - βœ… Public Hugging Face industrial dataset
433
+ - βœ… Dataset loader
434
+ - βœ… Document construction
435
+ - βœ… Text chunking
436
+ - βœ… Sentence-transformer embeddings
437
+ - βœ… Vector indexing
438
+ - βœ… Semantic retrieval
439
+ - βœ… Local language model
440
+ - βœ… FastAPI RAG endpoint
441
+ - βœ… React / TypeScript integration
442
+ - βœ… Retrieved-source attribution
443
+ - βœ… LoRA/PEFT fine-tuning
444
+ - βœ… Trained adapter checkpoint
445
+ - βœ… Hugging Face model repository
446
+ - βœ… CPU-based training pipeline
447
+ - βœ… No paid LLM API required
448
+
449
+ ---
450
+
451
+ # Development Roadmap
452
+
453
+ Planned improvements include:
454
+
455
+ - Larger industrial training dataset
456
+ - Arabic + English training data
457
+ - Arabic industrial terminology
458
+ - Multilingual question answering
459
+ - RAG evaluation suite
460
+ - Base-model vs fine-tuned-model benchmarking
461
+ - Hybrid semantic + keyword retrieval
462
+ - Reranking
463
+ - AI agents
464
+ - Conversation memory
465
+ - Document ingestion
466
+ - Computer vision integration
467
+ - Workflow automation
468
+ - Cloud deployment
469
+
470
+ ---
471
+
472
+ # Enterprise AI Engineering
473
+
474
+ AEGIS demonstrates concepts applicable to enterprise AI systems including:
475
+
476
+ - LLM application development
477
+ - Parameter-efficient fine-tuning
478
+ - RAG
479
+ - Document intelligence
480
+ - Semantic search
481
+ - Conversational AI
482
+ - Multilingual AI
483
+ - AI backend APIs
484
+ - Workflow automation
485
+ - Grounded generation
486
+ - Source attribution
487
+
488
+ ---
489
+
490
+ # Safety Notice
491
+
492
+ The AEGIS training dataset currently contains **synthetic industrial records** created for:
493
+
494
+ - AI engineering experimentation
495
+ - learning
496
+ - prototyping
497
+ - research
498
+ - portfolio demonstration
499
+
500
+ The model must not be treated as an authoritative source for industrial safety or operational decisions.
501
+
502
+ Its outputs must not replace:
503
+
504
+ - approved operating procedures
505
+ - manufacturer documentation
506
+ - workplace safety requirements
507
+ - engineering review
508
+ - regulatory requirements
509
+ - qualified professional judgment
510
+
511
+ ---
512
+
513
+ # Related Work
514
+
515
+ ## Dataset
516
+
517
+ ```text
518
+ syed7741/aegis-industrial-ai-dataset
519
+ ```
520
+
521
+ ## Model / Adapter
522
+
523
+ ```text
524
+ syed7741/aegis-industrial-rag-assistant
525
+ ```
526
+
527
+ ## GitHub
528
+
529
+ ```text
530
+ github.com/syedasim7741/AEGIS-AI
531
+ ```
532
+
533
+ ---
534
+
535
+ # Author
536
+
537
+ **Sayyad Asim**
538
+
539
+ AI Engineering β€’ RAG β€’ AI Agents β€’ LLM Fine-Tuning β€’ Document Intelligence β€’ Computer Vision β€’ Robotics β€’ Industrial AI