Fine-tuning Damage Cause Encoder with Imbalanced Class Weights Using Darwin-Gödel Learning
🎯 Latest: v0.7 Multi-Objective Pareto DGM - NSGA-II optimization achieved Best Macro F1 = 0.9583 with 11 Pareto-optimal solutions!
This project implements a Darwin-Gödel Machine (DGM) self-improvement framework to optimize class weights for imbalanced bridge damage classification. The system uses LLM-based coding agents to iteratively propose weight configurations, evaluated through LoRA fine-tuning on a Japanese BERT model.
- ✅ DGM Architecture: Self-improving optimization loop with genealogy tracking
- ✅ Multi-Agent Comparison: 3 coding LLMs (DeepSeek-Coder, Qwen2.5-Coder, Codestral)
- ✅ Multi-Agent DGM (v0.3): Collaborative 3-agent system with consensus mechanism
- ✅ Auto-Regressive DGM (v0.4): Chain-of-thought weight generation with diversity sampling
- ✅ Optuna Adaptive DGM (v0.5): TPE Bayesian optimization with LLM validation ⭐ F1=0.9433
- ✅ Boosted DGM (v0.6): Gradient Boosting ensemble + Optuna TPE
- ✅ Multi-Objective Pareto DGM (v0.7): NSGA-II optimizing 10 class accuracies simultaneously 🎯 Best Macro F1=0.9583
- ✅ Trajectory Clustering: Mathematical analysis of improvement strategies (Conservative/Innovative/Super-Intelligence)
- ✅ GPU Management: Automatic Ollama preload/unload to prevent memory contention
- ✅ Fair Evaluation: Unified 15-epoch training for all experiments
- ✅ Efficient LoRA: r=16, α=32 configuration (50% parameter reduction)
- ✅ JSONL Archive: Persistent agent genealogy with incremental updates
| Model | Parameters | Best F1 | Improvement | Runtime | Acceptance |
|---|---|---|---|---|---|
| DeepSeek-Coder | 6.7B | 0.9359 | +8.18% | 2h 29m | 3/9 (33.3%) |
| Qwen2.5-Coder | 7B | 0.9129 | +5.52% | 2h 27m | 3/9 (33.3%) |
| Codestral | 22B | 0.9209 | +5.58% | 2h 28m | 3/9 (33.3%) |
| Version | Strategy | Best F1 | Min Recall | Acceptance | Runtime |
|---|---|---|---|---|---|
| v0.3 Multi-Agent | 3-agent collaboration | 0.9418 | 0.733 | 7.4% (2/27) | 6h 12m |
| v0.4 Auto-Regressive | Chain-of-thought | 0.9331 | 0.917 | 14.3% (4/28) | 7h 43m |
| v0.5 Optuna Adaptive | TPE Bayesian + LLM | 0.9433 | 0.733 | 9.4% (3/32) | 8h 55m |
| v0.6 Boosted | Ensemble + Bayesian | 0.9428 | 0.917 | 18.8% (6/32) | 9h 01m |
| v0.7 Multi-Objective 🏆 | NSGA-II Pareto | 0.9583 ⭐ | 0.733 | 22.0% (11/50) | 11h 20m |
🏆 v0.7 Critical Achievement:
- Highest Macro F1 in all experiments: 0.9583 (+1.5% over v0.5)
- 11 Pareto-optimal solutions: Multi-objective optimization provides user choice (Best Macro vs Best Balance)
- Best Min Accuracy: 0.7333 (Trial #4) - most balanced solution
- Highest acceptance rate: 22.0% (NSGA-II exploration efficiency)
Critical Insight from v0.2: Smallest model (DeepSeek 6.7B) achieved the highest F1 score, demonstrating that parameter count does not guarantee better DGM performance. Task-specific efficiency matters more than model size.
Critical Insight from v0.7: Multi-objective optimization (NSGA-II) > Single-objective (TPE) - simultaneously optimizing 10 class accuracies yields both higher Macro F1 AND diverse trade-off solutions.
┌─────────────────────────────────────────────────────────────┐
│ DGM Self-Improvement Loop │
├─────────────────────────────────────────────────────────────┤
│ 1. Archive │ JSONL-based agent storage │
│ 2. ParentSelector │ P(a) ∝ F1(a) × 1/(1+n_children(a)) │
│ 3. CodingAgent │ Ollama LLM → new class_weights │
│ 4. Evaluator │ LoRA fine-tuning (20 epochs) │
│ 5. Acceptance │ ΔF1 > +0.01 → Add to archive │
└─────────────────────────────────────────────────────────────┘
| Module | File | Description |
|---|---|---|
| Archive | dgm_exp/agent/archive.py |
JSONL persistence, genealogy tracking |
| ParentSelector | dgm_exp/agent/parent_selector.py |
Weighted sampling with exploration bonus |
| CodingAgent | dgm_exp/agent/coding_agent.py |
Ollama API client with GPU management |
| Evaluator | dgm_exp/agent/evaluator.py |
Subprocess executor for fine-tuning |
| DGMLoop | dgm_exp/agent/dgm_loop.py |
Main orchestration loop |
- Base Model:
cl-tohoku/bert-large-japanese-v2(344M params) - LoRA: r=16, α=32, dropout=0.1, FP32 precision
- Dataset: Golden testset (train=536, val=115, test=116)
- Class Weights: Uniform
[1.0, 1.0, ..., 1.0](sum=10) - Training: 15 epochs (converges at epoch 14), batch_size=8, grad_accum=4 (effective batch=32)
- GPU: NVIDIA RTX 5090 (32GB VRAM, sm_120 Blackwell)
Macro F1: 0.8651 (best at epoch 14: 0.9285)
Training Time: 9 min 7 sec (15 epochs: ~6.8 min)
Per-Class Recall:
[0] 塩害 1.0000
[1] 凍害 0.7333
[2] 土砂化 1.0000
[3] 疲労 1.0000
[4] 鉄筋腐食 0.5000
[5] ASR 0.9167
[6] ボイド管浮き陥没 0.5000
[7] 滞水 1.0000
[8] 連結桁 1.0000
[9] その他 1.0000
Observation: Classes [1], [4], [6] show lower recall (<0.75), indicating imbalance requiring optimization.
Mathematical analysis of agent improvement trajectories using 10-dimensional feature vectors projected to 2D space via UMAP, revealing 3 distinct improvement strategies.
-
Feature Extraction: 10D vectors (weight-space + performance-space + genealogy-space)
- Weight-space:
w_var,w_skew,w_norm,w_delta_norm - Performance-space:
delta_f1,delta_recall_low3,f1_efficiency - Genealogy-space:
depth,children_count,selection_prob
- Weight-space:
-
Dimensionality Reduction: UMAP (n_neighbors=5, min_dist=0.1)
-
Clustering: HDBSCAN (min_cluster_size=2) with KMeans fallback
-
Strategy Labeling: Based on average ΔF1 ranking
| Strategy | Agents | Avg ΔF1 | Weight Change | Efficiency | Characteristics |
|---|---|---|---|---|---|
| Conservative | 3 | 0.0228 | 1.160 (max) | 0.021 (min) | Large weight changes, small improvements |
| Innovative | 4 | 0.0286 | 0.556 | 0.052 | Balanced approach, stable improvements |
| Super-Intelligence | 2 | 0.0314 (max) | 0.653 | 0.054 (max) | Highest F1 & efficiency, Generation 3 only |
- Super-Intelligence Strategy Emerges Late: Only appears in Generation 3 (final iteration), achieved by Qwen A3 and Codestral A3
- Conservative Strategy is Inefficient: 3× lower efficiency despite maximum weight perturbations (all in Generation 1)
- Model-Agnostic Strategy Space: All 3 models explored the same strategy space, validating DGM universality
dgm_exp/results/strategy_clustering_umap.png- 2D strategy space with convex hullsdgm_exp/results/feature_distributions_by_strategy.png- 10-feature boxplots
- Python 3.10+
- CUDA 12.8+ (for RTX 5090 sm_120 support)
- Ollama installed and running
python -m venv .venv-trplv6
.venv-trplv6\Scripts\Activate.ps1
pip install torch==2.11.0+cu128 transformers datasets accelerate peft scikit-learnpython -m venv .venv-codeagt
.venv-codeagt\Scripts\Activate.ps1
pip install requests pyyaml numpy pandas scikit-learn# Download coding agents (runs in background)
ollama pull deepseek-coder:6.7b
ollama pull qwen2.5-coder:7b
ollama pull codestral[System.Environment]::SetEnvironmentVariable("OLLAMA_NUM_GPU", "1", "User")
[System.Environment]::SetEnvironmentVariable("CUDA_VISIBLE_DEVICES", "0", "User")Ensure data/golden_testset.json exists with stratified train/val/test splits.
# Activate training environment
.venv-trplv6\Scripts\Activate.ps1
# Run baseline training (20 epochs, ~9 min)
.\dgm_exp\scripts\init_baseline.ps1Output:
- Model:
models/encoder_baseline_dgm/ - Archive:
dgm_exp/results/dgm_archive.jsonl(1 entry) - Log:
dgm_exp/results/baseline_training.log
# Activate agent environment
.venv-codeagt\Scripts\Activate.ps1
# Run DeepSeek-Coder agent (~2h 30min)
.\dgm_exp\scripts\run_dgm_single_agent.ps1 -CodingModel 'deepseek-coder:6.7b' -Iterations 9
# Run Qwen2.5-Coder agent (~2h 27min)
.\dgm_exp\scripts\run_dgm_single_agent.ps1 -CodingModel 'qwen2.5-coder:7b' -Iterations 9
# Run Codestral agent (~2h 29min)
.\dgm_exp\scripts\run_dgm_single_agent.ps1 -CodingModel 'codestral' -Iterations 9.\dgm_exp\scripts\run_dgm.ps1# Run complete trajectory analysis pipeline
python dgm_exp/analysis/run_trajectory_analysis.py --method umap --clustering hdbscanOutput Files:
trajectory_features.csv- 10D feature matrix (9 agents × 10 features)trajectory_embedding_umap.csv- 2D UMAP projectioncluster_assignments.csv- Strategy assignments per agentstrategy_statistics.json- Detailed cluster statisticsstrategy_clustering_umap.png- Main 2D visualizationfeature_distributions_by_strategy.png- Feature boxplots
.\dgm_exp\scripts\run_adapt_dgm.ps1 -Model 'codestral:latest' -TotalBudget 32Best single-objective result: F1=0.9433 (9.4% acceptance)
.\dgm_exp\scripts\run_multi_objective_dgm.ps1 -TotalBudget 50 -PopulationSize 20Output:
dgm_archive_multiobj_v7.jsonl- Standard genealogy archivedgm_archive_multiobj_v7_pareto_frontier.jsonl- 11 Pareto-optimal solutionsdgm_archive_multiobj_v7_multiobj_log.jsonl- Per-iteration 10D objectives
Visualize Pareto Frontier:
python dgm_exp\scripts\visualize_pareto_frontier_v7.pyOutput: 3 types of 2D plots
pareto_two_min_classes.png- Two minimum accuracy classes frontierpareto_macro_vs_min.png- Macro F1 vs Min class accuracy trade-offpareto_tsne_projection.png- t-SNE 2D projection of 10-class space
Best results:
- Trial #3: Macro F1=0.9583 (highest overall)
- Trial #4: Min Acc=0.7333 (most balanced)
# View archive (all accepted agents)
python dgm_exp/scripts/view_archive.py
# Export results to CSV
python dgm_exp/scripts/export_results.py| Model | Size | Description | Status |
|---|---|---|---|
| deepseek-coder:6.7b | 6.7B | Instruction-tuned code generation | ✅ Best performer (F1=0.9359) |
| qwen2.5-coder:7b | 7B | Qwen's code-specialized model | ✅ Tested (F1=0.9129) |
| codestral | 22B | Mistral's large code model | ✅ Tested (F1=0.9209) |
| 7B | Meta's code-specialized LLaMA | ❌ Excluded (JSON generation failure) |
Recommendation: deepseek-coder:6.7b achieved highest F1 despite being the smallest model.
- GPU: 32GB+ VRAM (tested on RTX 5090)
- CUDA: 12.8+ with sm_120 support
- Disk: ~20GB for models and checkpoints
- Framework: PyTorch 2.11.0+cu128
- Transformers: Hugging Face v4.46+
- LoRA: PEFT (Parameter-Efficient Fine-Tuning)
- LLM Server: Ollama API (http://localhost:11434)
- ❗ BF16 Unsupported: RTX 5090 sm_120 requires FP32 LoRA
- ❗ Windows CP932: All emoji characters removed from code
- ❗ PCIe Power Saving: Must be disabled in BIOS/Device Manager
- ❗ GPU Management: Ollama preload/unload prevents memory contention
- ✅ Compare 3 coding agents (DeepSeek, Qwen, Codestral) over 9 iterations each
- ✅ Optimize class_weights[10] for improved macro F1
- ✅ Analyze improvement trajectories via mathematical clustering
- ✅ Document agent effectiveness and strategy patterns
- Primary: Macro F1 score improvement (Δ > +0.01)
- Secondary: Per-class recall balance (target weak classes [1,4,6])
- Efficiency: F1 improvement / weight perturbation magnitude
- Total Iterations: 27 (9 per agent × 3 agents)
- Acceptance Threshold: ΔF1 > +0.01 vs parent
- Total Runtime: ~7.5 hours (2.5h per agent)
- Training per Iteration: 20 epochs (~2 min)
- Expected Duration: ~3-4 hours total
damage_encoder_dgm/
├── dgm_exp/
│ ├── core/ # DGM core modules (v0.1)
│ │ ├── archive.py # JSONL persistence
│ │ ├── selector.py # Parent selection (weighted sampling)
│ │ ├── agent.py # Ollama LLM client with GPU management
│ │ ├── evaluator.py # Subprocess executor for fine-tuning
│ │ └── dgm_loop.py # Main orchestration loop
│ ├── agent/ # Refactored core (v0.3+)
│ │ ├── archive.py # Enhanced JSONL archive with AgentEntry dataclass
│ │ ├── parent_selector.py # Weighted sampling with exploration bonus
│ │ ├── coding_agent.py # Base agent class
│ │ ├── evaluator.py # LoRA fine-tuning evaluator
│ │ └── dgm_loop.py # Main loop template
│ ├── multi_agent/ # Multi-Agent DGM (v0.3)
│ │ ├── multi_agent_system.py # 3-agent consensus mechanism
│ │ └── multi_agent_loop.py # Multi-agent orchestration
│ ├── autoreg_agent/ # Auto-Regressive DGM (v0.4)
│ │ ├── autoreg_agent.py # Chain-of-thought weight generation
│ │ └── autoreg_loop.py # Auto-regressive loop
│ ├── adapt_agent/ # Optuna Adaptive DGM (v0.5)
│ │ ├── optuna_sampler.py # TPE Bayesian optimizer wrapper
│ │ ├── adapt_agent.py # LLM validator for Optuna suggestions
│ │ └── adapt_loop.py # Adaptive DGM loop
│ ├── boosted_agent/ # Boosted DGM (v0.6)
│ │ ├── boosted_adapt_agent.py # Ensemble + TPE hybrid
│ │ └── boosted_adapt_loop.py # Boosted loop
│ ├── multi_objective_agent/ # Multi-Objective Pareto DGM (v0.7) 🏆
│ │ ├── pareto_archive.py # Pareto frontier management
│ │ ├── multi_objective_sampler.py # NSGA-II optimizer wrapper
│ │ ├── multi_objective_agent.py # LLM validator for NSGA-II
│ │ └── multi_objective_loop.py # Multi-objective loop
│ ├── analysis/ # Trajectory clustering (v0.2)
│ │ ├── __init__.py
│ │ ├── extract_trajectory_features.py
│ │ ├── reduce_dimensions.py
│ │ ├── cluster_strategies.py
│ │ ├── visualize_trajectory_clustering.py
│ │ └── run_trajectory_analysis.py
│ ├── scripts/
│ │ ├── init_baseline.ps1 # Initialize baseline
│ │ ├── run_dgm_single_agent.ps1 # Run single agent (v0.2)
│ │ ├── run_dgm.ps1 # Run all agents (v0.2)
│ │ ├── run_adapt_dgm.ps1 # Run Optuna Adaptive (v0.5)
│ │ ├── run_boosted_dgm.ps1 # Run Boosted DGM (v0.6)
│ │ ├── run_multi_objective_dgm.ps1 # Run Multi-Objective Pareto (v0.7)
│ │ ├── visualize_pareto_frontier_v7.py # v0.7 Pareto visualization
│ │ └── create_archive_collection.py # Collection for v0.6
│ ├── configs/
│ │ ├── finetune_config.yaml # LoRA training parameters
│ │ └── triple_config.yaml # RAG retrieval config
│ └── results/
│ ├── dgm_archive.jsonl # Main genealogy (v0.2)
│ ├── dgm_archive_*.jsonl # Per-experiment archives
│ ├── dgm_archive_multiobj_v7.jsonl # v0.7 standard archive
│ ├── dgm_archive_multiobj_v7_pareto_frontier.jsonl # 11 Pareto solutions
│ ├── dgm_archive_multiobj_v7_multiobj_log.jsonl # 10D objectives log
│ ├── dgm_archive_collection.jsonl # Best 14 entries (for v0.6)
│ ├── RESULT_DGM.md # Comprehensive report (1100+ lines, v0.2)
│ ├── RESULT_MultiObjectDGM.md # v0.7 analysis (500+ lines) 🏆
│ ├── trajectory_*.csv # Clustering results (v0.2)
│ ├── strategy_*.json/png # Trajectory analysis outputs (v0.2)
│ ├── visualizations_v7_pareto/ # v0.7 Pareto frontier plots (3 PNG)
│ └── *.png # Per-agent visualizations (12 files, v0.2)
├── docs/
│ ├── LESSON_OptunaDGM.md # v0.5 Optuna analysis (400+ lines)
│ └── DESIGN_v07_MultiObjective.md # v0.7 design specification
├── 0_LogBAK/v06_GPU32Test/src/
│ └── 05_finetune_encoder.py # LoRA fine-tuning script
├── models/
│ ├── encoder_baseline_dgm/ # Baseline checkpoint (included)
│ ├── encoder_v06_*_lora/ # Experiment models (gitignored)
│ └── encoder_v06_*_qlora/ # QLoRA experiments (gitignored)
├── .gitignore # Exclude venvs, data, indices, models (except baseline)
├── README.md # This file
└── requirements_analysis.txt # Trajectory analysis dependencies
- DGM architecture implementation (5 core modules)
- GPU management for Ollama-training coexistence
- Fair evaluation (unified 15 epochs)
- Efficient LoRA (r=16, α=32, FP32 precision)
- Baseline initialization (F1=0.8651, converged at epoch 14: 0.9285)
- PowerShell automation scripts
- Windows CP932 encoding compatibility
- Experimental suite completed (3 agents × 9 iterations)
- DeepSeek-Coder experiment (F1=0.9359, +8.18%)
- Qwen2.5-Coder experiment (F1=0.9129, +5.52%)
- Codestral experiment (F1=0.9209, +5.58%)
- Trajectory clustering analysis (UMAP + HDBSCAN)
- Strategy identification (Conservative/Innovative/Super-Intelligence)
- Comprehensive documentation (RESULT_DGM.md, 1100+ lines)
- Visualization suite (12 PNG files + 2 trajectory plots)
- Multi-Agent DGM (3-agent collaboration with consensus mechanism)
- Best F1=0.9418 (27 iterations, 2 accepted, 7.4%)
- Strategy: DeepSeek → Qwen → Codestral rotation per iteration
- Auto-Regressive DGM (chain-of-thought weight generation)
- Best F1=0.9331 (28 iterations, 4 accepted, 14.3%)
- Strategy: Temperature=0.8 diversity sampling
- Optuna Adaptive DGM (TPE Bayesian optimization + LLM validation)
- Best F1=0.9433 (32 iterations, 3 accepted, 9.4%) ⭐ Best single-objective
- Strategy: n_startup_trials=5, temperature=0.4
- Documentation: LESSON_OptunaDGM.md (400+ lines)
- Boosted DGM (Gradient Boosting Phase 1 + TPE Phase 2)
- Best F1=0.9428 (32 iterations, 6 accepted, 18.8%)
- Strategy: Ensemble sampling (iters 1-5) → Bayesian (iters 6+)
- Multi-Objective Pareto DGM (NSGA-II optimizing 10 class accuracies)
- Best Macro F1=0.9583 (50 iterations, 11 Pareto solutions, 22.0%) 🎯
- Best Min Accuracy=0.7333 (Trial #4, most balanced)
- 11 Pareto-optimal solutions (trade-off: Macro vs Balance)
- Strategy: population_size=20, mutation_prob=0.1, crossover_prob=0.9
- Visualization: 3 types of 2D Pareto frontier plots (t-SNE projection)
- Documentation: RESULT_MultiObjectDGM.md (500+ lines)
- Key insight: Multi-objective > Single-objective (higher F1 + diverse solutions)
- Hypervolume-based early stopping (50 iters → 25-30 iters)
- Constrained multi-objective (Min Acc ≥ 0.70 constraint)
- Adaptive population sizing (30 → 20 → 10 schedule)
- Multi-fidelity optimization (5 epochs fast-eval → 15 epochs Pareto candidates)
- NSGA-III with reference points (uniform 10-objective exploration)
DeepSeek-Coder 6.7B (smallest) outperformed Codestral 22B (3.3× larger) by 1.5 percentage points (F1: 0.9359 vs 0.9209). Task-specific efficiency and JSON generation quality matter more than raw model size.
All 3 agents showed:
- 33.3% acceptance rate (3/9 iterations)
- Convergence at Generation 4 (no improvements beyond A3)
- Class [1] degradation (-8.2% across all agents, suggesting dataset limitation)
The most efficient strategy (highest F1 improvement per weight change) only appeared in Generation 3 (final accepted iteration), achieved by Qwen A3 and Codestral A3. DeepSeek's conservative approach prevented reaching this strategy.
Conservative strategy (largest weight changes, smallest improvements) had 1/3 the efficiency of Super-Intelligence strategy, demonstrating that large perturbations don't guarantee better outcomes.
- Issue: CUDA launch failures during training
- Root Cause: PCIe power saving mode + non-deterministic errors
- Solution: Disable power saving in BIOS, use CUDA_LAUNCH_BLOCKING=1 for debugging
- Issue: GPU freeze at 22.5GB when both processes used GPU
- Solution: Implemented _preload_model() → inference → _unload_model() workflow
- Issue: Baseline (20 epochs) vs proposals (5 epochs fast-eval) unfair comparison
- Solution: Unified to 20 epochs for all evaluations (Δ cost: ~1.5 min/iteration)
- Finding: r=32/α=64 → r=16/α=32 reduced params 50%, F1 dropped 2.4% (0.8890 → 0.8651)
- Decision: Accepted trade-off for faster experimentation (9 min vs 10 min training)
Features:
- Complete DGM architecture with 5 core modules (Archive, ParentSelector, CodingAgent, Evaluator, DGMLoop)
- Ollama-based coding agent with GPU management (preload/unload)
- JSONL-based agent genealogy with incremental persistence
- Unified 20-epoch evaluation for fair baseline comparison
- Efficient LoRA configuration (r=16, α=32, 50% parameter reduction)
- PowerShell automation scripts (init_baseline.ps1, run_dgm_single_agent.ps1)
- Windows CP932 encoding compatibility (all emoji removed)
Baseline Results:
- Model: cl-tohoku/bert-large-japanese-v2 + LoRA r=16/α=32
- Macro F1: 0.9285 (converges at epoch 14, 15 epochs total, ~6.8 min training)
- Dataset: Golden testset (train=536, val=115, test=116)
- Per-class recall:
[1.0, 0.73, 1.0, 1.0, 0.5, 0.92, 0.5, 1.0, 1.0, 1.0]
Technical Achievements:
- ✅ GPU stability on RTX 5090 sm_120 (PCIe power saving mitigation)
- ✅ Ollama-training coexistence (automatic GPU memory management)
- ✅ Fair evaluation methodology (unified 15 epochs, convergence analysis)
- ✅ Robust JSON parsing for LLM responses (multiple regex patterns)
- ✅ CUDA error handling with CUDA_LAUNCH_BLOCKING=1 support
Known Issues:
- BF16 precision unsupported on sm_120 (workaround: FP32 LoRA)
- Requires PCIe power saving disabled in BIOS/Device Manager
- Windows CP932 encoding limitation (no Unicode emoji support)
Next Steps:
- Run full experimental suite (3 agents × 9 iterations = 27 total)
- Statistical analysis and visualization
- arXiv paper draft
Experiments Completed:
- DeepSeek-Coder 6.7B: 9 iterations, 3 accepted, best F1=0.9359 (+8.18%), 2h 29m 24s
- Qwen2.5-Coder 7B: 9 iterations, 3 accepted, best F1=0.9129 (+5.52%), 2h 27m 20s
- Codestral 22B: 9 iterations, 3 accepted, best F1=0.9209 (+5.58%), 2h 28m 44s
- CodeLlama 7B: Excluded due to JSON generation failure (produced Python code instead)
Trajectory Clustering Analysis:
- Implemented 10D feature extraction (weight-space + performance-space + genealogy-space)
- UMAP dimensionality reduction to 2D strategy space
- HDBSCAN clustering with KMeans fallback
- Identified 3 improvement strategies:
- Conservative (3 agents): Large weight changes, low efficiency (0.021)
- Innovative (4 agents): Balanced approach, medium efficiency (0.052)
- Super-Intelligence (2 agents): Highest F1 & efficiency (0.054), Generation 3 only
Key Findings:
- Smallest model (DeepSeek 6.7B) achieved highest F1 (+1.5pp over Codestral 22B)
- Universal convergence at Generation 4 (33.3% acceptance rate across all agents)
- Class [1] degradation (-8.2%) universal across agents (dataset limitation)
- Super-Intelligence strategy emerges only in final generation (Qwen A3, Codestral A3)
Documentation:
- RESULT_DGM.md: Comprehensive 1100+ line experimental report
- 14 visualization files: 12 per-agent PNGs + 2 trajectory clustering plots
- Archive backups: 3 JSONL files (dgm_archive_deepseek/qwen/codestral.jsonl)
- Trajectory analysis outputs: 3 CSVs + 1 JSON + 2 PNGs
New Modules:
dgm_exp/analysis/package (5 Python files)extract_trajectory_features.py: 10D feature vectors from archivesreduce_dimensions.py: UMAP/t-SNE wrappercluster_strategies.py: HDBSCAN + strategy labelingvisualize_trajectory_clustering.py: 2D plots with convex hullsrun_trajectory_analysis.py: Complete pipeline orchestrator
Technical Improvements:
- Updated evaluation from 20 epochs → 15 epochs (baseline convergence analysis)
- Fixed legend positioning in trajectory plots (lower left/right)
- Japanese font support for visualizations (MS Gothic/Yu Gothic/Meiryo)
Next Steps:
- Statistical significance testing (t-tests, confidence intervals)
- Time-series analysis and ablation studies
- arXiv paper methodology section
Strategy:
- 3-agent collaborative system with consensus mechanism
- DeepSeek → Qwen → Codestral rotation per iteration
- Each agent validates previous agent's proposal
Results:
- 27 iterations, 2 accepted, best F1=0.9418 (+8.87%)
- Acceptance rate: 7.4%
- Runtime: 6h 12m
- Key insight: Consensus mechanism filters low-quality proposals
Strategy:
- Chain-of-thought weight generation (sequential class-by-class)
- Temperature=0.8 diversity sampling
- Codestral:latest as reasoning model
Results:
- 28 iterations (12 iters → fixed → 16 iters), 4 accepted, best F1=0.9331
- Acceptance rate: 14.3%
- Runtime: 7h 43m
- Key insight: Higher temperature improves exploration but reduces peak F1
Strategy:
- TPE Bayesian optimization with LLM validation
- Tool-call framing: Optuna suggestions as external expert
- Temperature=0.4 for validation (not generation)
- n_startup_trials=5 (random exploration → Bayesian exploitation)
Results:
- 32 iterations, 3 accepted, best F1=0.9433 (+9.04%)
- Acceptance rate: 9.4%
- Runtime: 8h 55m
- Best single-objective result in all experiments
Documentation:
- LESSON_OptunaDGM.md: 400+ line analysis
- Key insight: LLM + Optuna tool-call integration superior to pure LLM approaches
Strategy:
- Phase 1 (iters 1-5): Ensemble sampling from archive collection (14 best entries)
- Phase 2 (iters 6+): Optuna TPE Bayesian optimization
- Gradient Boosting concept applied to DGM
Results:
- 32 iterations, 6 accepted, best F1=0.9428
- Acceptance rate: 18.8% (highest before v0.7)
- Runtime: 9h 01m
- Key insight: Ensemble initialization improves convergence (Phase 1: 2/5 accepted)
Strategy:
- NSGA-II multi-objective optimization (10 objectives = per-class accuracies)
- Population size=20, mutation_prob=0.1, crossover_prob=0.9
- Tool-call framing: NSGA-II suggestions + LLM validation (temperature=0.4)
- Pareto frontier: non-dominated solutions for trade-off selection
Results:
- 50 iterations, 11 Pareto-optimal solutions, acceptance rate: 22.0%
- Best Macro F1=0.9583 (Trial #3, +10.77%, BEST IN ALL EXPERIMENTS) 🏆
- Best Min Accuracy=0.7333 (Trial #4, most balanced)
- Hypervolume: 4.1472 (Pareto frontier quality metric)
- Runtime: 11h 20m
Key Solutions:
- Trial #3: Macro=0.9583, Min=0.6667 (highest overall performance)
- Trial #4: Macro=0.9400, Min=0.7333 (best balance, all classes ≥0.73)
- Trial #30: Macro=0.9379, Min=0.7333 (alternative balanced solution)
Visualization:
- 3 types of 2D Pareto frontier plots:
- Two minimum accuracy classes 2D frontier
- Macro F1 vs Min class accuracy trade-off
- t-SNE 2D projection of 10-class accuracy space
- Output:
visualizations_v7_pareto/(3 PNG files)
Documentation:
- RESULT_MultiObjectDGM.md: 500+ line comprehensive analysis
- Pareto frontier analysis with 11 solutions detailed
- v0.5 vs v0.7 quantitative comparison
- Top 3 recommended solutions with use-case guidance
Key Insights:
- Multi-objective > Single-objective: NSGA-II achieved both higher Macro F1 AND diverse trade-off solutions
- Highest acceptance rate: 22.0% (NSGA-II exploration efficiency > TPE 9.4%)
- User choice: 11 Pareto solutions enable application-specific optimization (high Macro vs balanced)
- Class imbalance fundamental: Min Acc 0.73 is upper limit (dataset/model architecture constraint)
Comparison with v0.5 (Single-Objective TPE):
| Metric | v0.5 (TPE) | v0.7 (NSGA-II) | Winner |
|---|---|---|---|
| Best Macro F1 | 0.9433 | 0.9583 | v0.7 ✅ (+0.015) |
| Min Recall | 0.7333 | 0.7333 | TIE |
| # Solutions | 1 | 11 | v0.7 ✅ (diversity) |
| Acceptance Rate | 9.4% | 22.0% | v0.7 ✅ (+12.6 pt) |
Next Steps:
- Hypervolume-based early stopping (50 iters → 25-30 iters)
- Constrained multi-objective (Min Acc ≥ 0.70 constraint)
- Adaptive population sizing (30 → 20 → 10 schedule)
- Multi-fidelity optimization (5 epochs fast-eval → 15 epochs Pareto candidates)
- NSGA-III with reference points (uniform 10-objective exploration)
If you use this code for research, please cite:
@misc{damage_encoder_dgm_2026,
title={Fine-tuning Damage Cause Encoder with Imbalanced Class Weights Using Darwin-Gödel Learning},
author={[準備中]},
year={2026},
note={MVP v0.7 completed: Multi-Objective Pareto DGM with NSGA-II (Best Macro F1=0.9583)}
}This project is licensed under the MIT License - see the LICENSE file for details.
- Base Model: cl-tohoku/bert-large-japanese-v2
- Coding Agents: DeepSeek-Coder, Qwen2.5-Coder, Codestral (via Ollama)
- DGM Theory: Inspired by Jürgen Schmidhuber's Gödel Machine
For questions or collaboration, please open an issue in the GitHub repository.
Status: MVP v0.2 Completed (2026-08-09) - arXiv Submission Preparation In Progress
Status: v0.1 Implementation Complete | Ready for Full Experimental Run