Of course. This is an excellent idea for standardizing high-quality, actionable outputs from an LLM.
Here is a comprehensive template prompt designed to generate a complete, end-to-end Machine Learning development workflow. It instructs the LLM on its role, the sources to use, the exact structure of the output, and the level of detail required for each step.
LLM Prompt Template: Generate a Complete ML Development Workflow
Instructions for Use:
Copy the entire text below into your LLM prompt window. Replace the single placeholder [INSERT YOUR ML TASK DESCRIPTION HERE] with a clear and concise description of your machine learning problem.
BEGIN PROMPT
ROLE AND GOAL
You are an expert-level Principal Machine Learning Engineer and a Tech Lead. Your task is to generate a comprehensive, actionable, and end-to-end development workflow for a specific machine learning project. The output must be a step-by-step guide that a mid-level developer or a small team can follow to implement the project from initial concept to production monitoring.
CORE TASK
Generate the complete ML development workflow for the following task:
[INSERT YOUR ML TASK DESCRIPTION HERE]
(Example: "I want to build a model that predicts customer churn for a subscription-based SaaS product using user activity logs, subscription details, and support ticket history.")
CRITICAL INSTRUCTIONS & PRINCIPLES
-
Source Credibility & Recency: Your recommendations must be based on verified, recent (last 2-4 years), and practical information.
- Primary Sources: Prioritize information from hands-on developer tutorials, official documentation (e.g., PyTorch, TensorFlow, Scikit-learn, Hugging Face, AWS/GCP/Azure), and practical-focused blog posts from reputable engineering teams (e.g., Netflix, Uber, Spotify, Stripe Engineering Blogs).
- Secondary Sources: Cite foundational research papers (e.g., for 'Attention Is All You Need' when discussing Transformers) but only when essential for understanding the core concept.
- Avoid: Outdated blog posts, purely academic/theoretical papers with no implementation guide, and unverifiable claims.
-
Pragmatism and Actionability: The entire workflow must be practical. Avoid overly abstract advice. For every step, provide concrete actions and tool recommendations.
- Tooling: For each stage, recommend specific, widely-used, and well-supported open-source tools and libraries (e.g.,
Pandas for EDA, DVC for data versioning, MLflow for experiment tracking, FastAPI for serving).
- Code Snippets: Where appropriate, include brief, illustrative code snippets to clarify a concept (e.g., a sample data splitting strategy using
sklearn.model_selection.train_test_split).
-
Consider Constraints (Good, Better, Best): Acknowledge that real-world projects have constraints. For key decisions like model choice, infrastructure, or training duration, provide a "Good, Better, Best" approach:
- Good: A simple, fast-to-implement baseline that delivers value quickly (e.g., a Logistic Regression or LightGBM model).
- Better: A more advanced, higher-performing option that requires more effort (e.g., a fine-tuned Transformer model).
- Best: The state-of-the-art approach, which might require significant resources (e.g., large-scale distributed training, extensive hyperparameter optimization).
-
Integrate MLOps Best Practices: The workflow must not be a one-off script. It must be a reproducible, maintainable system. Embed these principles throughout:
- Version Control: Explicitly mention versioning for code (
Git), data (DVC), and models (Model Registry in MLflow/W&B).
- Reproducibility: Mention dependency management (
requirements.txt, conda environment.yml) and environment configuration.
- Automation: Include steps related to CI/CD for ML, automated testing, and automated retraining triggers.
- Experiment Tracking: Make experiment tracking a non-negotiable step in the training phase.
REQUIRED OUTPUT STRUCTURE & FORMATTING
Generate the output in Markdown format with the following exact sections and structure. Do not deviate from this structure.
ML Development Workflow: [Title of the ML Task]
Executive Summary:
A brief, high-level overview of the project goal, the proposed solution, the key technologies involved, and the expected business outcome.
Phase 1: Project Scoping and Definition
- 1.1. Business Problem: Clearly re-state the problem in business terms.
- 1.2. Success Metrics:
- Business Metrics: How will we measure the project's success? (e.g., Reduced Churn by X%, Increased Customer Lifetime Value).
- ML Model Metrics: What technical metrics will proxy for business success? (e.g., Precision, Recall, F1-Score, AUC-ROC). Justify the choice of metrics.
- 1.3. Feasibility & Constraints:
- Data Availability: What data is needed and is it accessible?
- Resource Constraints: Discuss potential budget, compute (CPU/GPU), and personnel limitations.
- Ethical Considerations: Identify any potential bias, fairness, or privacy issues.
Phase 2: Data Acquisition and Exploratory Data Analysis (EDA)
- 2.1. Data Sources: List the exact data sources required (e.g.,
users table in SQL DB, activity_logs from S3 bucket).
- 2.2. Data Ingestion & Versioning:
- Tools: Recommend tools for data extraction (e.g., Python
psycopg2, boto3).
- Protocol: Propose a method for versioning the raw and processed datasets using a tool like
DVC.
- 2.3. Exploratory Data Analysis (EDA):
- Objective: Understand data distributions, identify missing values, find correlations, and uncover initial insights.
- Tools: Recommend libraries (
Pandas, Matplotlib, Seaborn, ydata-profiling).
- Actionable Steps: List key plots and analyses to perform.
Phase 3: Data Preparation and Feature Engineering
- 3.1. Data Cleaning: Outline the strategy for handling missing values, outliers, and duplicates.
- 3.2. Feature Engineering: Propose specific features to create from the raw data. Be explicit (e.g., "Create
avg_sessions_per_week from activity logs").
- 3.3. Data Splitting Strategy:
- Protocol: Describe the splitting strategy (e.g., time-based split for temporal data, stratified split for imbalanced classes). Provide rationale.
- Code Example: Show a
scikit-learn example of the split.
- 3.4. Preprocessing Pipeline:
- Tools:
Scikit-learn Pipelines, Feature-engine.
- Steps: Define the preprocessing steps for numerical (e.g., scaling) and categorical (e.g., one-hot encoding) features. This pipeline should be saved.
Phase 4: Model Selection and Baseline
- 4.1. Choosing the Right Model Family: Justify the choice of model families (e.g., "Start with tree-based models due to tabular data and interpretability, then explore neural networks for interaction effects.").
- 4.2. Baseline Model:
- Choice: Propose a simple, strong baseline model (e.g.,
LogisticRegression, LightGBM with default parameters).
- Purpose: Explain that all future models must outperform this baseline to be considered.
- 4.3. Candidate Models (Good, Better, Best):
- Good: The baseline model.
- Better: A more complex model like a carefully tuned
XGBoost/CatBoost or a simple Feed-Forward Neural Network.
- Best: A state-of-the-art approach like a TabNet/TabTransformer or an ensemble of models.
Phase 5: Model Training and Experimentation
- 5.1. Experiment Tracking Setup:
- Tools:
MLflow or Weights & Biases.
- Protocol: Specify what to log for each run: parameters, metrics, model artifacts, and data versions.
- 5.2. Training Protocol:
- Frameworks:
Scikit-learn, PyTorch, TensorFlow.
- Hyperparameter Tuning: Propose a strategy (e.g.,
Optuna or Ray Tune for systematic search). Mention key hyperparameters to tune for the chosen models.
- Training Duration/Stopping: How long to train? Define early stopping criteria to save time and prevent overfitting.
- 5.3. Resource Management: Recommend infrastructure for training (e.g., "Start on a local machine; for 'Better/Best' models, use an AWS
g4dn.xlarge instance").
Phase 6: Model Evaluation
- 6.1. Offline Evaluation:
- Method: Evaluate the final trained models on the held-out test set using the metrics defined in 1.2.
- Analysis: Propose methods for deeper analysis, such as plotting a confusion matrix, ROC curve, and performing error analysis to see where the model fails.
- 6.2. Model Selection for Deployment: Explain the criteria for choosing the final model to deploy (e.g., trade-off between performance, inference latency, and cost).
Phase 7: Deployment and Serving
- 7.1. Model Packaging: How to package the model and the preprocessing pipeline together (e.g.,
joblib, ONNX, or custom torch.jit.script module).
- 7.2. Deployment Strategy:
- Online (Real-time): Propose creating a REST API. Recommend tools (
FastAPI, Flask) and a serving architecture (e.g., containerize with Docker, deploy on AWS ECS or Kubernetes).
- Offline (Batch): Propose a batch scoring job. Recommend tools (
Airflow, AWS Batch) to run predictions on a schedule.
- 7.3. CI/CD for ML: Outline a simple CI/CD pipeline (e.g., using
GitHub Actions) that triggers on a new git push to test and potentially deploy the model.
Phase 8: Monitoring and Maintenance
- 8.1. Performance Monitoring:
- Metrics: What to monitor in production? (e.g., model output distribution, inference latency, endpoint uptime).
- Tools:
Prometheus, Grafana, specialized platforms like Arize AI or Fiddler.
- 8.2. Data and Concept Drift:
- Protocol: Explain how to detect drift (e.g., statistical tests like KS-test on input feature distributions).
- Tools:
Evidently AI, NannyML.
- 8.3. Retraining Strategy:
- Triggers: Define what should trigger a model retrain (e.g., significant performance degradation, detection of drift, or on a fixed schedule).
- Protocol: Describe the automated retraining and deployment pipeline (sometimes called CT - Continuous Training).
References and Further Reading
- List 3-5 key resources (documentation, tutorials, blog posts) that were influential in creating this workflow and would be valuable for the developer to read. Provide links.
END PROMPT