Spaces:
Build error
Build error
A newer version of the Gradio SDK is available: 6.24.0
metadata
title: RAG for Vrikshayurveda
emoji: πΏ
colorFrom: green
colorTo: green
sdk: gradio
sdk_version: 4.44.1
app_file: app.py
pinned: false
license: mit
πΏ RAG for Vrikshayurveda
Retrieval-Augmented Generation for Surapala's Science of Plant Life (ΰ€΅ΰ₯ΰ€ΰ₯ΰ€·ΰ€Ύΰ€―ΰ₯ΰ€°ΰ₯ΰ€΅ΰ₯ΰ€¦)
A full-stack AI system that diagnoses plant disorders and recommends traditional Ayurvedic treatments based on the ancient Vrikshayurveda text by Surapala. Combines modern RAG architecture with a classical forward + backward chaining inference engine.
ποΈ Architecture
User Query
β
βΌ
ββββββββββββββββββββ
β Query Expansion β β Groq (Llama 3.3 70B) generates 3 rephrasings
β (4 variants) β
ββββββββββ¬ββββββββββ
β
βΌ
ββββββββββββββββββββ
β BGE-large-en β β BAAI/bge-large-en-v1.5 (1024-dim embeddings)
β Encoding β
ββββββββββ¬ββββββββββ
β
βΌ
ββββββββββββββββββββ
β Pinecone Vector β β Top-K retrieval + deduplication by parent ID
β Search β
ββββββββββ¬ββββββββββ
β
ββββββ΄βββββ
βΌ βΌ
ββββββββββ βββββββββββββββββββββββ
β Contextβ β Inference Engine β
β Build β β β’ Symptom Extractor β
β β β β’ Forward Chaining β
β β β β’ Backward Chaining β
β β β β’ 42 Ayurvedic Rulesβ
βββββ¬βββββ ββββββββββββ¬βββββββββββ
β β
ββββββββββ¬βββββββββ
βΌ
ββββββββββββββββββββ
β Groq LLM β β Llama 3.3 70B generates final response
β (RAG + Inference β
β grounded) β
ββββββββββββββββββββ
β¨ Features
π©Ί Diagnose Tab
- Describe plant symptoms in natural language
- Get Ayurvedic diagnosis with dosha classification (Vata/Pitta/Kapha)
- View the full reasoning chain from the inference engine
- Receive traditional treatment recommendations from Vrikshayurveda
- See retrieved source passages with relevance scores
π Symptom Chain Explorer
- Interactive visual inference engine
- Select symptoms from 27 observable indicators
- Watch forward chaining fire rules in real-time on a canvas
- Step through rules one at a time or auto-run the full chain
- See proof trace with colored condition/conclusion pills
- Stats bar showing fact count, rules fired, and diagnosed disorders
π§ Inference Engine
The inference engine implements 42 Ayurvedic diagnostic rules from the Vrikshayurveda text:
| Component | Description |
|---|---|
| Symptom Extractor | NLP-based extraction of atomic facts from natural language |
| Forward Chaining | Priority-sorted rule firing to derive disorders and remedies |
| Backward Chaining | Differential diagnosis across 10 disorder categories |
| Rule Base | 42 YAML-defined rules covering 3 doshas, 10 disorders, 8 causes |
Disorder Categories
- Internal: Vata, Pitta, Kapha disorders
- External: Heat/Frost, Stormy Wind, Fire/Lightning/Drought
- Other: Mechanical Wound, Faulty Seed, Insect Infestation, Excessive Watering
π Setup
Prerequisites
- Python 3.10+
- API keys for Pinecone, Groq
Installation
git clone https://github.com/Viraj-77/RAG4Vrikshayurveda.git
cd RAG4Vrikshayurveda
pip install -r requirements.txt
Environment Variables
Create a .env file:
GROQ_API_KEY=your_groq_api_key
PINECONE_API_KEY=your_pinecone_api_key
PINECONE_INDEX_NAME=jaim3
Run
python app.py
The app launches at http://127.0.0.1:7860
π Project Structure
RAG4Vrikshayurveda/
βββ app.py # Gradio web interface + Symptom Chain Explorer
βββ rag_pipeline.py # Core RAG pipeline (embed β retrieve β generate)
βββ inference/
β βββ engine.py # Unified inference entry point
β βββ forward_chain.py # Forward chaining engine
β βββ backward_chain.py # Backward chaining + differential diagnosis
β βββ symptom_extractor.py # NLP fact extraction from text
βββ vrikshayurveda_rules.yaml # 42 Ayurvedic diagnostic rules
βββ db.pdf # Vrikshayurveda source text
βββ embed_pdf.py # PDF β Pinecone indexing script
βββ augment_and_reindex.py # Data augmentation + reindexing
βββ requirements.txt
βββ .env # API keys (not committed)
π§ Tech Stack
| Component | Technology |
|---|---|
| Embeddings | BAAI/bge-large-en-v1.5 (1024 dimensions) |
| Vector DB | Pinecone |
| LLM | Llama 3.3 70B via Groq |
| Inference | Custom forward + backward chaining engine |
| Frontend | Gradio 4.x |
| Knowledge Base | Vrikshayurveda by Surapala |
π References
- Vrikshayurveda β The Science of Plant Life by Surapala (ancient Indian botanical text)
- Surapala's Vrikshayurveda covers plant diseases, their causes (doshas), and Ayurvedic treatments using natural materials
π License
This project is licensed under the MIT License.