A production-grade Retrieval-Augmented Generation (RAG) pipeline grounded in published research on railroad condition monitoring, DAS signal processing, and AI-driven manufacturing optimization.
🔗 Try it live → huggingface.co/spaces/arifme071/engineering-knowledge-rag
This app lets you query a knowledge base built from peer-reviewed research papers using natural language. Type a question, and the pipeline:
- Retrieves the most semantically relevant passages from the knowledge base (FAISS + SentenceTransformers)
- Augments a prompt with those passages as context
- Generates a grounded, citation-backed answer (HuggingFace Flan-T5)
No hallucination about domain specifics — every answer is anchored to real research.
User Query
│
▼
┌─────────────────────────┐
│ SentenceTransformers │ → Embed query (MiniLM-L6-v2, 384-dim)
│ (all-MiniLM-L6-v2) │
└────────────┬────────────┘
│ query vector
▼
┌─────────────────────────┐
│ FAISS Vector Index │ → Cosine similarity search (Inner Product)
│ (IndexFlatIP) │ Returns top-k most relevant chunks
└────────────┬────────────┘
│ retrieved chunks + scores
▼
┌─────────────────────────┐
│ Prompt Builder │ → Assembles context + question into LLM prompt
│ │ with source attribution
└────────────┬────────────┘
│ prompt
▼
┌─────────────────────────┐
│ HuggingFace Flan-T5 │ → Generates grounded answer
│ (google/flan-t5-base) │ Open-source, runs locally — no API key needed
└────────────┬────────────┘
│ answer + sources
▼
┌─────────────────────────┐
│ Streamlit Chat UI │ → Displays answer with expandable source cards
│ │ showing relevance scores and paper metadata
└─────────────────────────┘
The app ships with a built-in knowledge base from 7 peer-reviewed publications (184+ citations):
| Paper | Venue | Year | Domain |
|---|---|---|---|
| CNN-LSTM-SW for Railroad Anomaly Detection via DAS | Elsevier GEITS | 2024 | Railroad AI |
| DAS-based Railroad CM with GRU/LSTM | SPIE JARS | 2024 | DAS Signal Processing |
| Review of DAS Applications for Railroad CM | Elsevier MSSP | 2023 | DAS Review |
| HMM-RL for WAAM Intelligent Control | Springer | 2026 | Manufacturing AI |
You can extend the knowledge base by dropping your own PDFs into data/papers/ — the pipeline auto-ingests and indexes them on first run.
How does the CNN-LSTM sliding window correct misclassifications?
What are the four condition classes in the DAS railroad dataset?
How does SMOTE handle class imbalance in the training data?
What is the difference between GRU and LSTM for DAS signal processing?
How does the HMM-RL pipeline optimize WAAM manufacturing?
What features are extracted from DAS signals for model training?
What is the ROC AUC score for each condition class?
How does distributed acoustic sensing work on railroad tracks?
engineering-knowledge-rag/
├── app/
│ └── main.py # Streamlit UI — chat interface, settings sidebar
│
├── src/
│ ├── retrieval/
│ │ └── rag_pipeline.py # Core RAG: embed → FAISS search → LLM generate
│ ├── ingestion/
│ │ ├── builtin_knowledge.py # Pre-loaded paper excerpts (works offline)
│ │ └── document_loader.py # PDF/TXT ingestion + chunking pipeline
│ └── utils/
│ └── ui_helpers.py # Source cards, example query buttons
│
├── data/
│ ├── papers/ # Drop your PDFs here to extend knowledge base
│ └── index/ # Auto-generated FAISS index (git-ignored)
│
├── Dockerfile # Container for HuggingFace Spaces deployment
├── requirements.txt
├── .gitignore
└── README.md
git clone https://github.com/arifme071/engineering-knowledge-rag.git
cd engineering-knowledge-rag
pip install -r requirements.txt
streamlit run app/main.pyOpen http://localhost:8501 — loads instantly with the built-in knowledge base.
# Drop PDFs into data/papers/
cp your_paper.pdf data/papers/
# Delete cached index so it rebuilds
rm -rf data/index/
# Rerun — auto-ingests on startup
streamlit run app/main.pydocker build -t engineering-rag .
docker run -p 7860:7860 engineering-rag- Go to huggingface.co → New Space
- Name:
engineering-knowledge-rag| SDK: Docker/Streamlit | Visibility: Public - Upload all files from this repo
- HuggingFace builds and deploys automatically (~5 min)
- Live URL:
https://huggingface.co/spaces/YOUR_USERNAME/engineering-knowledge-rag
| Component | Technology | Why |
|---|---|---|
| Embeddings | sentence-transformers/all-MiniLM-L6-v2 |
Fast, high-quality 384-dim, runs on CPU |
| Vector store | FAISS IndexFlatIP |
Exact cosine similarity, no server needed |
| LLM | google/flan-t5-base |
Open-source, instruction-tuned, zero API cost |
| Frontend | Streamlit | Shareable demo, native chat components |
| Deployment | HuggingFace Spaces + Docker | Free hosting, permanent public URL |
Swap the LLM — any HuggingFace model works:
llm_model: str = "mistralai/Mistral-7B-Instruct-v0.1" # Better quality, needs GPU
llm_model: str = "google/flan-t5-large" # Bigger, still CPU-friendlyUse OpenAI/Anthropic instead:
from openai import OpenAI
client = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
response = client.chat.completions.create(model="gpt-4o", messages=[...])Persistent vector store with ChromaDB:
import chromadb
client = chromadb.PersistentClient(path="data/chroma")- railroad-anomaly-detection-cnn-lstm — CNN-LSTM-SW paper repo (Elsevier GEITS 2024)
- 📚 Google Scholar — Full publication list
Md Arifur Rahman PIN Fellow (AI in Manufacturing) · Georgia Tech | MSc Applied Engineering · Georgia Southern University
MIT License — see LICENSE for details.