# Fine-Tuning Workflow Details Detailed workflow and practical guidelines for executing fine-tuning of LangGraph applications. **πŸ’‘ Tip**: For concrete code examples and templates you can copy and paste, refer to [examples.md](examples.md). ## πŸ“‹ Workflow Overview ``` β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ Phase 1: Preparation and Analysis β”‚ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ β”‚ 1. Read fine-tune.md β†’ Understand goals and criteria β”‚ β”‚ 2. Identify optimization targets with Serena β†’ List LLM nodesβ”‚ β”‚ 3. Create optimization list β†’ Assess improvement potential β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ↓ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ Phase 2: Baseline Evaluation β”‚ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ β”‚ 4. Prepare evaluation environment β†’ Test cases, scripts β”‚ β”‚ 5. Measure baseline β†’ Run 3-5 times, collect statistics β”‚ β”‚ 6. Analyze results β†’ Identify issues, assess improvement β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ↓ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ Phase 3: Iterative Improvement (Iteration Loop) β”‚ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ β”‚ 7. Prioritize β†’ Select most effective improvement area β”‚ β”‚ 8. Implement improvements β†’ Optimize prompts, adjust params β”‚ β”‚ 9. Post-improvement evaluation β†’ Re-evaluate same conditionsβ”‚ β”‚ 10. Compare results β†’ Measure improvement, decide next step β”‚ β”‚ 11. Continue decision β†’ Goal met? Yes β†’ Phase 4 / No β†’ Next β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ↓ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ Phase 4: Completion and Documentation β”‚ β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ β”‚ 12. Create final evaluation report β†’ Summary of improvementsβ”‚ β”‚ 13. Commit code β†’ Version control and documentation update β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ``` ## πŸ“š Phase-by-Phase Detailed Guide ### [Phase 1: Preparation and Analysis](./workflow_phase1.md) Clarify optimization direction and identify targets for improvement: - **Step 1**: Read and understand fine-tune.md - **Step 2**: Identify optimization targets with Serena MCP - **Step 3**: Create optimization target list **Time Required**: 30 minutes - 1 hour ### [Phase 2: Baseline Evaluation](./workflow_phase2.md) Quantitatively measure current performance: - **Step 4**: Prepare evaluation environment - **Step 5**: Measure baseline (3-5 runs) - **Step 6**: Analyze baseline results **Time Required**: 1-2 hours ### [Phase 3: Iterative Improvement](./workflow_phase3.md) Data-driven, incremental prompt optimization: - **Step 7**: Prioritization - **Step 8**: Implement improvements - **Step 9**: Post-improvement evaluation - **Step 10**: Compare results - **Step 11**: Continue decision **Time Required**: 1-2 hours per iteration Γ— number of iterations (typically 3-5) ### [Phase 4: Completion and Documentation](./workflow_phase4.md) Record final results and commit code: - **Step 12**: Create final evaluation report - **Step 13**: Commit code and update documentation **Time Required**: 30 minutes - 1 hour ## 🎯 Workflow Execution Points ### For First-Time Fine-Tuning 1. **Start from Phase 1 in order**: Execute all phases without skipping 2. **Create documentation**: Record results from each phase 3. **Start small**: Experiment with a small number of test cases initially ### Continuous Fine-Tuning 1. **Start from Phase 2**: Measure new baseline 2. **Repeat Phase 3**: Continuous improvement cycle 3. **Consider automation**: Build evaluation pipeline ## πŸ“Š Principles for Success 1. **Data-Driven**: Base all decisions on measurement results 2. **Incremental Improvement**: One change at a time, measure, verify 3. **Documentation**: Record results and learnings from each phase 4. **Statistical Verification**: Run multiple times to confirm significance ## πŸ”— Related Documents - **[Example Collection](./examples.md)** - Code examples and templates for each phase - **[Evaluation Methods](./evaluation.md)** - Details on evaluation metrics and statistical analysis - **[Prompt Optimization](./prompt_optimization.md)** - Detailed optimization techniques - **[SKILL.md](./SKILL.md)** - Overview of the Fine-tune skill ## πŸ’‘ Troubleshooting ### Cannot find optimization targets in Phase 1 β†’ Check search patterns in [workflow_phase1.md#step-2](./workflow_phase1.md#step-2-identify-optimization-targets-with-serena-mcp) ### Evaluation script fails in Phase 2 β†’ Check checklist in [workflow_phase2.md#step-4](./workflow_phase2.md#step-4-prepare-evaluation-environment) ### No improvement effect in Phase 3 β†’ Review priority matrix in [workflow_phase3.md#step-7](./workflow_phase3.md#step-7-prioritization) ### Report creation takes too long in Phase 4 β†’ Utilize templates in [workflow_phase4.md#step-12](./workflow_phase4.md#step-12-create-final-evaluation-report) --- Following this workflow enables: - βœ… Systematic fine-tuning process execution - βœ… Data-driven decision making - βœ… Continuous improvement and verification - βœ… Complete documentation and traceability