Ms. Potts is an AI-powered nutrition chatbot that provides meal recommendations, dietary advice, and meal logging, personalized based on user profile information. This project follows MLOps best practices with comprehensive monitoring, experiment tracking, and configuration management.
- Retrieval-Augmented Generation (RAG) Pipeline
- Intent Classification
- Personalized Meal Planning
- Meal Logging
- Gemini API Integration
- MLOps Best Practices (Phase 2)
- FastAPI (Backend API)
- Gradio (Frontend UI)
- Sentence-Transformers
- Google Gemini API
- Docker Containerization with Docker Compose
- MLflow Experiment Tracking
- Hydra Configuration Management
- Enhanced Logging and Monitoring
The project has been containerized using separate Dockerfiles for frontend and backend, orchestrated with Docker Compose:
# Build and run with Docker Compose
docker-compose up --build
# Access the frontend at http://localhost:7860
# Access the backend at http://localhost:8080The Dockerfiles include:
- Python 3.10 base image
- All required dependencies
- Proper directory structure
- Environment variable configuration
- Separate entry points for frontend and backend
π Monitoring & Debugging Documentation For setup, examples, and troubleshooting guides, click here.
Comprehensive monitoring and debugging tools have been integrated:
# Initialize monitoring
from utils.monitoring import ModelMonitor
monitor = ModelMonitor(metrics_dir="./metrics")
monitor.start_monitoring(interval=5)
# Log model metrics
monitor.log_model_metrics({
"latency_ms": latency_ms,
"tokens_generated": tokens_generated
})
# Initialize debugging
from utils.debugging import DebugTracer, debug_value
tracer = DebugTracer(output_dir="./debug_traces")
# Trace function calls
@tracer.trace_function
def process_query(query):
# Function code
return resultMonitoring metrics include:
- System resources (CPU, memory, disk usage)
- Model performance (latency, token count)
- Application metrics (request processing time, endpoint usage)
For Profiling details and Results, click here.
Profiling tools have been added to identify performance bottlenecks:
# Initialize profilers
from utils.profiling import CodeProfiler, MLProfiler
code_profiler = CodeProfiler(output_dir="./profiling_results")
ml_profiler = MLProfiler(output_dir="./ml_profiling_results")
# Profile functions
@code_profiler.profile_function
def embed_query(query):
# Function code
return embedding
# Profile specific code blocks
with code_profiler.profile_block("similarity_search"):
similarities = calculate_similarities()Profiling results are saved to:
./profiling_results/for Python code profiling./ml_profiling_results/for ML model profiling
For Profiling details and Results, click here.
MLflow has been integrated for experiment tracking:
# Start the MLflow UI
mlflow ui
# Access the UI at http://localhost:5000The application automatically logs:
- Model parameters (embedding model, similarity threshold)
- Performance metrics (retrieval time, response time)
- Query and response data
- Model artifacts
For Logging Details, click here. Rich, structured logging has been implemented:
# Initialize enhanced logger
from utils.enhanced_logging import EnhancedLogger, log_with_context
enhanced_logger = EnhancedLogger(
name="ms_potts",
level="info",
log_dir="./logs",
console_output=True,
file_output=True,
json_output=True,
rich_formatting=True
)
logger = enhanced_logger.get_logger()
# Context-aware logging
log_with_context(
logger,
"info",
"Processing query request",
request_id=request_id,
query=query
)Logs are stored in ./logs/ with detailed context information.
For Configuration Managment, click here. Hydra has been integrated for hierarchical configuration management:
# Run with default (production) configuration
python -m src.ms_potts.main
# Run with development configuration
python -m src.ms_potts.main +mode=development
# Override specific parameters
python -m src.ms_potts.main model.batch_size=64 app.port=9000Configuration files are organized in the conf/ directory:
config.yaml: Main configurationdevelopment.yaml: Development environment overridesproduction.yaml: Production environment overridestesting.yaml: Testing environment overrides
- Python 3.10+
- Docker and Docker Compose (for containerized deployment)
- Clone this repository:
git clone https://github.com/Vedant-1012/ms-potts-mlops.git
cd ms-potts-mlops- Create a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies:
pip install -r requirements.txt- Create a
.envfile with your Gemini API Key:
GEMINI_API_KEY=your_api_key_here
- Run the application:
python src/ms_potts/main.py # Backend
python src/ms_potts/interface.py # Frontend- Access the frontend at
http://localhost:7860and the API athttp://localhost:8080
- Build and run with Docker Compose:
docker-compose up --build- Access the frontend at
http://localhost:7860and the API athttp://localhost:8080
βββ LICENSE
βββ Makefile <- Makefile with commands like `make data` or `make train`
βββ README.md <- The top-level README for developers using this project.
βββ data
β βββ external <- Data from third party sources.
β βββ interim <- Intermediate data that has been transformed.
β βββ processed <- The final, canonical data sets for modeling.
β βββ raw <- The original, immutable data dump.
β
βββ docs <- A default Sphinx project; see sphinx-doc.org for details
β
βββ models <- Trained and serialized models, model predictions, or model summaries
β
βββ notebooks <- Jupyter notebooks. Naming convention is a number (for ordering),
β the creator's initials, and a short `-` delimited description, e.g.
β `1.0-jqp-initial-data-exploration`.
β
βββ references <- Data dictionaries, manuals, and all other explanatory materials.
β
βββ reports <- Generated analysis as HTML, PDF, LaTeX, etc.
β βββ figures <- Generated graphics and figures to be used in reporting
β
βββ requirements.txt <- The requirements file for reproducing the analysis environment, e.g.
β generated with `pip freeze > requirements.txt`
β
βββ setup.py <- makes project pip installable (pip install -e .) so src can be imported
βββ src <- Source code for use in this project.
β βββ __init__.py <- Makes src a Python module
β β
β βββ data <- Scripts to download or generate data
β β βββ make_dataset.py
β β
β βββ features <- Scripts to turn raw data into features for modeling
β β βββ build_features.py
β β
β βββ models <- Scripts to train models and then use trained models to make
β β β predictions
β β βββ predict_model.py
β β βββ train_model.py
β β
β βββ visualization <- Scripts to create exploratory and results oriented visualizations
β βββ visualize.py
β
βββ docker-compose.yml <- Docker Compose configuration
βββ Dockerfile.backend <- Dockerfile for the backend service
βββ Dockerfile.frontend <- Dockerfile for the frontend service
β
βββ conf <- Hydra configuration files
β βββ config.yaml <- Main configuration
β βββ development.yaml <- Development environment overrides
β βββ production.yaml <- Production environment overrides
β βββ testing.yaml <- Testing environment overrides
β
βββ mlruns <- MLflow experiment tracking data
β
βββ logs <- Application logs
β
βββ metrics <- Monitoring metrics
β
βββ profiling_results <- Code profiling results
β
βββ tox.ini <- tox file with settings for running tox; see tox.readthedocs.ioThis project follows these MLOps best practices:
- Containerization: Docker and Docker Compose for consistent deployment
- Monitoring: Tracking system and application metrics
- Debugging: Tracing and value inspection tools
- Profiling: Performance analysis for Python and ML code
- Experiment Tracking: MLflow for tracking parameters, metrics, and artifacts
- Enhanced Logging: Rich, structured logging with context
- Configuration Management: Hydra for hierarchical configuration
MIT License
Project based on the cookiecutter data science project template. #cookiecutterdatascience

