An AI-powered application that classifies food ingredients into risk categories and provides concise safety explanations. This tool helps consumers make informed decisions about the products they buy by analyzing ingredient lists and identifying potential health concerns.
- Ingredient Risk Classification: Classifies food ingredients into 5 risk levels (1-5) using a fine-tuned DeBERTa model
- Concise Safety Explanations: Provides clear, concise explanations for each ingredient's safety profile
- Web Interface: User-friendly Streamlit interface for easy interaction
- API Access: RESTful API for programmatic access to the classification engine
- 🟢 Level 1-2: Very Safe/Safe - Natural ingredients
- 🟡 Level 3: Moderate - Refined but generally safe
- 🟠 Level 4: Concerning - Artificial additives
- 🔴 Level 5: High Risk - Potentially harmful substances
- Backend: FastAPI
- Frontend: Streamlit
- AI Models:
- DeBERTa transformer for ingredient risk classification
- Groq LLM API for generating explanations
- Vector Storage: FAISS
- Embeddings: Sentence Transformers
- Python 3.8+
- Groq API key (set in
.envfile)
-
Clone the repository:
git clone <repository-url> cd bt-el
-
Create a virtual environment:
python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Set up environment variables: Create a
.envfile in the project root with your Groq API key:GROQ_API_KEY=your_api_key_here
uvicorn backend:app --reloadThe backend API will be available at http://localhost:8000.
streamlit run frontend.pyThe web interface will be available at http://localhost:8501.
POST /predict- Classify ingredients and get risk assessmentGET /health- Health check endpointGET /- API information
curl -X POST http://localhost:8000/predict \
-H "Content-Type: application/json" \
-d '{"text": "refined wheat flour, sugar, edible vegetable oil (palmolein), emulsifier (322), synthetic food colour (INS 133)"}'.
├── backend.py # FastAPI backend server
├── frontend.py # Streamlit web interface
├── rag_pipeline.py # LLM explanation generation pipeline
├── dataset_documentation.md # Ingredient safety documentation
├── requirements.txt # Python dependencies
└── .env # Environment variables (not included in repo)
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
This project is licensed under the MIT License.