Issue
Generating tutorial scripts for FastMCP using different LLM models presented several challenges:
- Hallucinations: Two out of seven models generated inaccurate content, such as introducing unrelated concepts like ‘middleware’ where none existed.
- Verbosity vs. Conciseness: Some models produced overly long outputs (15-40% longer), while others lacked sufficient detail.
- Variability in Technical Depth: Models either provided surface-level explanations or overly detailed architectural insights.
- Grammar Errors: Despite technical accuracy, some models introduced grammar issues like comma splices and spacing errors.
Culprit
The differences in model architecture and specialization drove performance disparities:
- General-purpose models (e.g., Mistral Codestral) struggled with topic alignment and introduced hallucinations.
- Code-specialized models (e.g., Qwen3 Max, Qwen2.5 Coder) maintained accuracy but varied in explanation depth and conciseness.
- Mixture-of-Experts models (e.g., MiniMax-M2) introduced grammar errors despite technical precision.
- Model size ≠ performance: Larger models like Hermes 4 (405B parameters) underperformed compared to smaller, specialized models.
- Fixed parameters (Temperature=0.0) exposed weaknesses in models by disabling creative variability, making errors more apparent.
Solution
Optimal Model Selection: Qwen3 Max
Key Advantages:
- Zero hallucinations across all evaluation criteria.
- Balanced technical depth: Explained both implementation details (‘how’) and architectural context (‘why’).
- Conciseness: Produced outputs that were 20-30% shorter than verbose models while maintaining educational value.
- Practical warnings: Included specific pitfalls and critical notes, such as emphasizing the need to
awaitcoroutine results.
Model Configurations
-
Qwen3 Max (Optimal Choice)
Model: qwen/qwen3-max Configuration: - Temperature: 0.0 - Max Tokens: 4000 - Top-p: 1.0 -
Budget Option: Qwen2.5 Coder
Model: qwen/qwen-2.5-coder-32b-instruct- Achieved 90% of Qwen3 Max quality at lower cost.
- Ideal for draft generation with subsequent human review.
-
Sophisticated Audience: Mistral Medium
Model: mistralai/mistral-medium-3.1- Added architectural depth (e.g., namespace collision prevention).
- Tradeoff: 15-20% longer outputs.
Post-Processing Rules
Implemented validation checks for all models:
- Topic alignment: Ensured the script’s hook matched the actual code content.
- Closing accuracy: Verified no invented concepts were introduced.
- Grammar checks: Detected comma splices and spacing errors.
- Technical terms: Validated correct usage of terms (e.g., ‘AI-callable’ vs ‘AI‑callable’).
Performance Metrics
| Model | Accuracy | Depth | Conciseness | Grammar | Cost |
|---|---|---|---|---|---|
| Qwen3 Max | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐ | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐⭐ | $$$ |
| Mistral Medium | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐ | ⭐⭐⭐⭐⭐ | $$$$ |
| Qwen2.5 Coder | ⭐⭐⭐⭐ | ⭐⭐⭐⭐ | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐⭐ | $ |
Key Insight
Specialized code models (e.g., Qwen3 Max) outperformed general-purpose models (e.g., Hermes 4) regardless of parameter count, demonstrating that architecture specialization > scale for technical documentation tasks.