Spaces:
Sleeping
Download README.md from mnoorchenar/docmind: direct link, hf CLI and curl.
- Browser
- Download file 11.8 kB
-
https://huggingface.co/spaces/mnoorchenar/docmind/resolve/main/README.md
- Command line
-
hf download hf://spaces/mnoorchenar/docmind/README.md
-
curl -L -o README.md https://huggingface.co/spaces/mnoorchenar/docmind/resolve/main/README.md
title: DocMind-Agentic-Research
colorFrom: blue
colorTo: indigo
sdk: docker
π§ DocMind β Agentic Research Platform
π§ DocMind β A clean, minimal agentic document research platform. Five specialized LangGraph agents plan, retrieve, grade, generate, and critique answers from uploaded PDFs and web pages using hybrid search and Qwen 2.5-7B β all running free on HuggingFace Spaces.
Table of Contents
- Features
- Architecture
- Getting Started
- Docker Deployment
- App Modules
- ML Models
- Project Structure
- Author
- Contributing
- Disclaimer
- License
β¨ Features
| π§ LangGraph State Machine | Five agents wired into a linear StateGraph β Planner β Retriever β Grader β Generator β Critic. |
| π Hybrid RAG (FAISS + BM25) | Semantic vector search combined with BM25 keyword search, fused via Reciprocal Rank Fusion for precision retrieval. |
| π€ Multi-Agent Orchestration | Planner, Retriever, Grader, Generator, and Critic agents each with specialized roles β only 3 LLM calls per query. |
| β‘ Score-Based Grading | Grader uses hybrid search scores + keyword overlap β no LLM call needed, instant and deterministic relevance scoring. |
| π PDF & URL Ingestion | Upload PDF files up to 10 MB or paste any public URL β both are chunked, embedded, and indexed automatically. |
| π Secure by Design | Stateless REST backend, no user data persisted, HF token kept server-side only. |
| π³ Containerized Deployment | Docker-first with Gunicorn, embedding model pre-downloaded at build time for fast cold starts. |
ποΈ Architecture
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β DocMind β LangGraph Flow β
β β
β PDF / URL βββΆ Ingestor βββΆ FAISS+BM25 Hybrid Vector Store β
β β β
β User Query βββΆ [PLANNER Agent] β (Qwen 2.5-7B, 0.3) β
β β β β
β [RETRIEVER] ββββββββ (FAISS+BM25+RRF) β
β β β
β [GRADER] (score-based, no LLM call) β
β β β
β [GENERATOR] (Qwen 2.5-7B, 0.4) β
β β β
β [CRITIC] (Qwen 2.5-7B, 0.1) β
β β β
β [OUTPUT] Flask API + Single-Page UI β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
π Getting Started
Prerequisites
- Python 3.10+ Β· Docker Β· Git Β· Free HuggingFace account
Local Installation
git clone https://github.com/mnoorchenar/docmind.git
cd docmind
python -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txt
cp .env.example .env
# Edit .env β set HF_TOKEN to your free HuggingFace Read token
python app.py
Open http://localhost:7860 π
Getting your free HuggingFace token
- Create a free account at huggingface.co
- Go to Settings β Access Tokens β New Token β Role: Read
- Copy the token and set it as
HF_TOKENin your.envfile or Space secrets
π³ Docker Deployment
docker build -t docmind .
docker run -p 7860:7860 -e HF_TOKEN=hf_your_token_here docmind
π App Modules
| Module | Description | Status |
|---|---|---|
| π€ Upload & Index | PDF / URL ingest, chunk, embed (local BAAI model), FAISS+BM25 index | β Live |
| π Research Query | LangGraph 5-agent pipeline with real-time trace log | β Live |
π§ ML Models
stack = {
# ββ LLM (LangChain LCEL chains) ββββββββββββββββββββββββββββββββββββββββββ
"llm": "Qwen/Qwen2.5-7B-Instruct", # via HF Router
"lcel_chain": "ChatPromptTemplate | ChatOpenAI | StrOutputParser",
"retry": "ChatOpenAI.with_retry(stop_after_attempt=2)",
# ββ RAG (LangChain + custom hybrid) ββββββββββββββββββββββββββββββββββββββ
"splitter": "RecursiveCharacterTextSplitter (langchain-text-splitters)",
"documents": "langchain_core.documents.Document",
"embeddings": "HuggingFaceEmbeddings (BAAI/bge-small-en-v1.5, local)",
"vector_index": "FAISS IndexFlatIP (cosine)",
"keyword_index": "BM25Okapi (rank-bm25)",
"fusion": "Reciprocal Rank Fusion (RRF k=60)",
"grader": "score-based (hybrid score Γ 0.7 + keyword overlap Γ 0.3)",
# ββ Orchestration (LangGraph) βββββββββββββββββββββββββββββββββββββββββββββ
"graph": "LangGraph 0.2 StateGraph β 5 nodes, linear pipeline",
}
π Project Structure
docmind/
β
βββ π agents/
β βββ __init__.py
β βββ critic.py
β βββ generator.py
β βββ grader.py
β βββ llm_factory.py
β βββ planner.py
β βββ β¦ 1 more
βββ π data/
β βββ processed/
β βββ raw/
βββ π docs/
β βββ 013-docmind.html
βββ π graph/
β βββ __init__.py
β βββ research_graph.py
βββ π rag/
β βββ __init__.py
β βββ embeddings.py
β βββ ingestor.py
β βββ vector_store.py
βββ π templates/ # HTML templates
β βββ index.html
βββ π tools/
β βββ __init__.py
β βββ calculator.py
β βββ code_tool.py
β βββ web_search.py
βββ π tracing/
β βββ __init__.py
β βββ tracer.py
βββ π .env.example # Environment variable template
βββ π Dockerfile # Port 7860, embedding model pre-downloaded
βββ π app.py # Flask entry point, 5 REST routes
βββ π code.txt
βββ π requirements.txt # Python dependencies
βββ π write_html.py
π¨βπ» Author
Mohammad Noorchenarboo
π Ontario, Canada π§ mohammadnoorchenarboo@gmail.com ββββββββββββββββββββββββββββββββββββββ |
π€ Contributing
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
β οΈ Disclaimer
This project is developed strictly for educational and research purposes. All LLM outputs are AI-generated and may contain inaccuracies. No real user data is stored. Provided "as is" without warranty of any kind.
π License
Distributed under the MIT License.