NotNow commited on
Commit
77e909c
Β·
verified Β·
1 Parent(s): b1ddd53

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +243 -0
README.md ADDED
@@ -0,0 +1,243 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: en
3
+ license: mit
4
+ library_name: pytorch
5
+ tags:
6
+ - task-routing
7
+ - multi-task-learning
8
+ - foundation-model
9
+ - synthetic-data
10
+ - balanced-training
11
+ - software-engineering
12
+ metrics:
13
+ - accuracy
14
+ model-index:
15
+ - name: corch-v13-balanced
16
+ results:
17
+ - task:
18
+ type: text-classification
19
+ name: Task Routing
20
+ metrics:
21
+ - type: accuracy
22
+ value: 87.30
23
+ name: Average Accuracy
24
+ - type: accuracy
25
+ value: 100.00
26
+ name: Domain Accuracy
27
+ - type: accuracy
28
+ value: 100.00
29
+ name: Capability Accuracy
30
+ ---
31
+
32
+ # Corch V13 Balanced: Task Routing Foundation Model
33
+
34
+ **87.30% Average Accuracy** | Perfect Domain & Capability Classification
35
+
36
+ A multi-task foundation model for intelligent software engineering task routing, achieving breakthrough performance through balanced synthetic data generation.
37
+
38
+ ## Model Description
39
+
40
+ Corch V13 Balanced is a 805K parameter neural network that classifies software engineering tasks across 4 dimensions:
41
+
42
+ 1. **Domain** (19 classes): frontend, backend, machine_learning, etc. - **100% accuracy** 🎯
43
+ 2. **Capability** (8 classes): code_generation, debugging, testing, etc. - **100% accuracy** 🎯
44
+ 3. **Strategy** (2 classes): DIRECT vs ORCHESTRATE - **85.98% accuracy**
45
+ 4. **Execution Type** (5 classes): single_task, multi_step, etc. - **63.20% accuracy**
46
+
47
+ ## Performance
48
+
49
+ | Task | Accuracy | Improvement from V10 |
50
+ |------|----------|---------------------|
51
+ | **Average** | **87.30%** | +20.46% |
52
+ | **Domain** | **100.00%** 🎯 | +14.59% |
53
+ | **Capability** | **100.00%** 🎯 | +39.61% |
54
+ | **Strategy** | **85.98%** | +12.55% |
55
+ | **Execution** | **63.20%** | +7.94% |
56
+
57
+ ## Key Innovation: Balanced Synthetic Data
58
+
59
+ The breakthrough came from solving severe class imbalance (324:1 ratio):
60
+ - Generated **49,307 synthetic examples** using GPT-5-Pro
61
+ - Balanced dataset to ~10K examples per domain
62
+ - Eliminated rare class zero-accuracy problem
63
+
64
+ **Before balancing:**
65
+ - `machine_learning` domain: 88 examples β†’ 0% accuracy
66
+ - `other` domain: 57 examples β†’ 0% accuracy
67
+
68
+ **After balancing:**
69
+ - All domains: ~10K examples β†’ 100% accuracy βœ…
70
+
71
+ ## Architecture
72
+
73
+ ```
74
+ Input Text β†’ BGE-large-en-v1.5 Embedding (1024d)
75
+ ↓
76
+ Shared Layers:
77
+ - Linear(1024 β†’ 512) + ReLU + Dropout(0.3)
78
+ - Linear(512 β†’ 512) + ReLU + Dropout(0.3)
79
+ ↓
80
+ Task-Specific Heads:
81
+ β”œβ”€ Strategy Head β†’ Linear(512 β†’ 2)
82
+ β”œβ”€ Capability Head β†’ Linear(512 β†’ 8)
83
+ β”œβ”€ Domain Head β†’ Linear(512 β†’ 19)
84
+ └─ Execution Head β†’ Linear(512 β†’ 5)
85
+ ```
86
+
87
+ **Parameters:** 804,898
88
+ **Training Time:** ~1 minute (30 epochs, early stopped)
89
+ **Hardware:** AMD MI300X GPU
90
+
91
+ ## Usage
92
+
93
+ ```python
94
+ import torch
95
+ from transformers import AutoTokenizer, AutoModel
96
+
97
+ # Load BGE embedding model
98
+ tokenizer = AutoTokenizer.from_pretrained("BAAI/bge-large-en-v1.5")
99
+ embedding_model = AutoModel.from_pretrained("BAAI/bge-large-en-v1.5")
100
+
101
+ # Load Corch V13 Balanced model
102
+ from huggingface_hub import hf_hub_download
103
+ model_path = hf_hub_download(repo_id="bledden/corch-v13-balanced", filename="model_v13_balanced.pt")
104
+
105
+ # Initialize model
106
+ class FoundationModelV13(torch.nn.Module):
107
+ def __init__(self):
108
+ super().__init__()
109
+ self.shared = torch.nn.Sequential(
110
+ torch.nn.Linear(1024, 512),
111
+ torch.nn.ReLU(),
112
+ torch.nn.Dropout(0.3),
113
+ torch.nn.Linear(512, 512),
114
+ torch.nn.ReLU(),
115
+ torch.nn.Dropout(0.3)
116
+ )
117
+ self.strategy_head = torch.nn.Linear(512, 2)
118
+ self.capability_head = torch.nn.Linear(512, 8)
119
+ self.domain_head = torch.nn.Linear(512, 19)
120
+ self.execution_head = torch.nn.Linear(512, 5)
121
+
122
+ def forward(self, x):
123
+ shared = self.shared(x)
124
+ return {
125
+ 'strategy': self.strategy_head(shared),
126
+ 'capability': self.capability_head(shared),
127
+ 'domain': self.domain_head(shared),
128
+ 'execution': self.execution_head(shared)
129
+ }
130
+
131
+ model = FoundationModelV13()
132
+ checkpoint = torch.load(model_path, weights_only=True)
133
+ model.load_state_dict(checkpoint['model_state_dict'])
134
+ model.eval()
135
+
136
+ # Embed and predict
137
+ def route_task(task_text):
138
+ # Generate embedding
139
+ inputs = tokenizer(task_text, return_tensors="pt", truncation=True, max_length=512)
140
+ with torch.no_grad():
141
+ embedding = embedding_model(**inputs).last_hidden_state[:, 0, :]
142
+
143
+ # Get predictions
144
+ with torch.no_grad():
145
+ outputs = model(embedding)
146
+
147
+ strategy = ["DIRECT", "ORCHESTRATE"][outputs['strategy'].argmax().item()]
148
+ capability = ["code_generation", "debugging", "documentation", "optimization",
149
+ "refactoring", "testing", "design", "data_analysis"][outputs['capability'].argmax().item()]
150
+ domain = ["frontend", "backend", "data_processing", "machine_learning", "devops",
151
+ "testing", "security", "mobile", "data_engineering", "cloud", "database",
152
+ "api", "ui_ux", "general", "iot", "blockchain", "game_dev", "embedded",
153
+ "other"][outputs['domain'].argmax().item()]
154
+ execution = ["single_task", "multi_step", "iterative", "parallel",
155
+ "sequential"][outputs['execution'].argmax().item()]
156
+
157
+ return {
158
+ "strategy": strategy,
159
+ "capability": capability,
160
+ "domain": domain,
161
+ "execution_type": execution
162
+ }
163
+
164
+ # Example
165
+ result = route_task("Build a CNN image classifier using PyTorch for medical imaging")
166
+ print(result)
167
+ # {
168
+ # 'strategy': 'ORCHESTRATE',
169
+ # 'capability': 'code_generation',
170
+ # 'domain': 'machine_learning', # 100% confidence
171
+ # 'execution_type': 'multi_step'
172
+ # }
173
+ ```
174
+
175
+ ## Training Data
176
+
177
+ - **Training set:** 31,592 examples (balanced)
178
+ - **Validation set:** 3,495 examples
179
+ - **Synthetic examples:** 49,307 (generated via GPT-5-Pro)
180
+ - **Real examples:** ~550K (existing dataset)
181
+ - **Final dataset:** Balanced to ~10K per domain
182
+
183
+ ### Synthetic Data Generation
184
+
185
+ Used GPT-5-Pro with domain-specific prompts:
186
+
187
+ ```
188
+ Generate a realistic software engineering task for: {domain}
189
+ Required: {capability}, {execution_type}, {strategy}
190
+ Output: 1-3 sentence task description with realistic terminology
191
+ ```
192
+
193
+ **Cost:** ~$500 for 49,307 examples
194
+ **Quality:** 100% unique, zero duplicates, validated schemas
195
+
196
+ ## Label Mappings
197
+
198
+ **Strategy (2):** DIRECT, ORCHESTRATE
199
+ **Capability (8):** code_generation, debugging, documentation, optimization, refactoring, testing, design, data_analysis
200
+ **Domain (19):** frontend, backend, data_processing, machine_learning, devops, testing, security, mobile, data_engineering, cloud, database, api, ui_ux, general, iot, blockchain, game_dev, embedded, other
201
+ **Execution (5):** single_task, multi_step, iterative, parallel, sequential
202
+
203
+ ## Comparison to Baselines
204
+
205
+ | Model | Architecture | Data | Avg Acc | Domain Acc |
206
+ |-------|--------------|------|---------|------------|
207
+ | Logistic Regression | Single-task | Imbalanced | 74.61% | 74.61% |
208
+ | V10 | Multi-task | Imbalanced | 66.84% | 85.41% |
209
+ | **V13 Balanced** | **Multi-task** | **Balanced** | **87.30%** | **100.00%** |
210
+
211
+ ## Limitations
212
+
213
+ - Execution type prediction (63.20%) still has room for improvement
214
+ - Context-independent (doesn't use conversation history yet)
215
+ - English-only
216
+ - Focused on software engineering tasks
217
+
218
+ ## Citation
219
+
220
+ ```bibtex
221
+ @software{corch_v13_balanced_2024,
222
+ title = {Corch V13 Balanced: Task Routing Foundation Model},
223
+ author = {Bledden, Team},
224
+ year = {2024},
225
+ publisher = {Hugging Face},
226
+ url = {https://huggingface.co/bledden/corch-v13-balanced},
227
+ note = {87.30% accuracy via balanced synthetic data generation}
228
+ }
229
+ ```
230
+
231
+ ## License
232
+
233
+ MIT License
234
+
235
+ ## Links
236
+
237
+ - **GitHub:** https://github.com/bledden/Corch_by_Fac
238
+ - **Release Notes:** [RELEASE_V13_BALANCED.md](https://github.com/bledden/Corch_by_Fac/blob/main/RELEASE_V13_BALANCED.md)
239
+ - **Training Script:** [train_v13_option5_balanced.py](https://github.com/bledden/Corch_by_Fac/blob/main/training/scripts/train_v13_option5_balanced.py)
240
+
241
+ ---
242
+
243
+ Built with ❀️ by the Corch Team | Powered by balanced synthetic data generation