|
Download README.md from simooo21/vb6-to-cs-training-pipeline: direct link, hf CLI and curl.
- Browser
- Download file 7.04 kB
-
https://huggingface.co/simooo21/vb6-to-cs-training-pipeline/resolve/main/README.md
- Command line
-
hf download hf://simooo21/vb6-to-cs-training-pipeline/README.md
-
curl -L -o README.md https://huggingface.co/simooo21/vb6-to-cs-training-pipeline/resolve/main/README.md
7.04 kB
VB6 β C# Code Translation LLM
A complete training pipeline to fine-tune a code LLM for translating VB6 to C# using SFT + GRPO for maximum quality.
Architecture
Qwen2.5-Coder-7B-Instruct
β
SFT (360 examples, 3 epochs)
β
simooo21/vb6-to-cs-qwen2.5-coder-7b-sft
β
GRPO (reward: syntax + format + length, 2 epochs)
β
simooo21/vb6-to-cs-qwen2.5-coder-7b-grpo
Dataset
- Source:
simooo21/vb6-to-csharp-translation - Size: 360 train, 40 validation
- Format: Conversational messages (
[{"role": "user"}, {"role": "assistant"}]) - Coverage: 41 VB6 β C# translation patterns across 40 categories:
| Category | Examples | Key Mappings |
|---|---|---|
| variables | Dim β type declaration | Dim x As Integer β int x; |
| control_flow | If/Select Case β if/switch | Select Case β switch |
| loops | For/Do/For Each β for/while/foreach | For Each β foreach |
| functions | Sub/Function β methods | ByRef β ref, Optional β default params |
| arrays | 1-based β 0-based arrays | Dim arr(1 To 5) β int[] arr = new int[5] |
| strings | VB6 string funcs β C# methods | UCase/Trim/Len β ToUpper/Trim/Length |
| file_io | Open/Close β StreamReader/Writer | FreeFile β using statement |
| error_handling | On Error β try/catch | On Error GoTo β try { } catch |
| gui_events | Event subs β event handlers | cmd_Click() β cmd_Click(object, EventArgs) |
| gui_controls | VB6 controls β WinForms | ComboBox.AddItem β Items.Add |
| form_designer | .frm code β C# InitializeComponent | VB6 form layout β C# programmatic UI |
| database | ADO β SqlClient | ADODB.Connection β SqlConnection |
| api_calls | Declare β DllImport | Declare Function β [DllImport] |
| classes | VB6 class β C# class | Property Get/Let β C# properties |
| structs | Type β struct | Public Type β public struct |
| collections | Collection β Dictionary | Scripting.Dictionary β Dictionary<K,V> |
| regex | Like β Regex | Like "[A-Z]###" β Regex.IsMatch |
| enums | VB6 Enum β C# enum | Direct mapping with values |
| events | RaiseEvent β event invocation | RaiseEvent β ?.Invoke |
| interfaces | Implements β : interface | Implements INotifyPropertyChanged β : INotifyPropertyChanged |
| modules | Module-level β static class | Public Const β public const |
| dialogs | MsgBox/InputBox β MessageBox | vbModal β ShowDialog() |
| async | DoEvents β async/await | DoEvents β Application.DoEvents() / await |
| datetime | Date functions β DateTime | Now/DateAdd/DateDiff β DateTime.Now/AddDays |
| math | Rnd β Random | Rnd β Random.Next |
| formatting | Format β ToString | FormatCurrency β .ToString("C2") |
| conversions | CStr/CInt β Convert | CStr/CInt/CDate β Convert.ToString/Int32/DateTime |
| type_checks | IsNumeric β TryParse | IsNumeric β int.TryParse |
| operators | IIf β ternary | IIf(condition, a, b) β condition ? a : b |
| networking | Winsock β TcpClient | Winsock β TcpClient/NetworkStream |
| com_interop | CreateObject β Activator | CreateObject("Word.Application") β Activator.CreateInstance |
| printing | Printer β PrintDocument | Printer.Print β e.Graphics.DrawString |
| graphics | LoadPicture β Image.FromFile | Direct mapping |
| system | SendKeys β SendKeys.SendWait | Direct mapping |
| application | App.Path β Assembly | App.Path β Application.ExecutablePath |
| entry_point | Sub Main β static void Main | With [STAThread] attribute |
| null_checks | IsNull/Nothing β null/DBNull | Is Nothing β == null |
| access_modifiers | Friend β internal | Friend β internal |
Training Recipes
Phase 1: SFT (Supervised Fine-Tuning)
Base model: Qwen/Qwen2.5-Coder-7B-Instruct
python train_sft.py
Hyperparameters (from OpenCodeInstruct):
| Parameter | Value | Rationale |
|---|---|---|
| lr | 5e-6 | Low LR for stable convergence on small dataset |
| epochs | 3 | Full coverage of 360 examples |
| batch | 1 Γ 8 accum | Effective batch 8 per GPU |
| seq_len | 1024 | All examples fit (max 570 tokens) |
| warmup | 50 steps | Smooth start |
| scheduler | cosine (default) | Proven for code tasks |
Phase 2: GRPO (Reinforcement Learning)
Base model: simooo21/vb6-to-cs-qwen2.5-coder-7b-sft
python train_grpo.py
Hyperparameters (from DRIVE / DeepSeekMath):
| Parameter | Value | Rationale |
|---|---|---|
| lr | 1e-6 | Very low for RL stability |
| epochs | 2 | Don't overfit on small data |
| num_generations | 8 | Group size per prompt |
| max_completion | 2048 | Long enough for code |
| rewards | syntax + format + length | Multi-objective optimization |
Reward Functions
syntax_reward (0-1): Checks C# syntax patterns
- Access modifiers (+0.2)
- Balanced braces (+0.2)
- Semicolons (+0.1)
- Type declarations (+0.2)
- Using/namespace (+0.1)
- Class/struct (+0.1)
- Balanced brackets (+0.1)
format_reward (0-1): Checks for
```csharpcode blockslength_reward (0-1): Rewards reasonable code length (3-100 lines)
Hardware Requirements
- SFT: 1Γ A10G (24GB) or better. ~2-3 hours.
- GRPO: 1Γ A10G or A100. ~3-4 hours.
- For multi-GPU: use
accelerate launch
Evaluation
python evaluate_model.py --model simooo21/vb6-to-cs-qwen2.5-coder-7b-grpo
Reports:
- Exact match rate
- Code block extraction rate
- Mean syntax score (0-1)
- Mean Levenshtein distance
- Per-category breakdown
Why SFT + GRPO?
Per the literature review:
- SFT alone gets you far with high-quality data (OpenCodeInstruct showed 5M samples beats small-model RL)
- GRPO with verifiable rewards is the new SOTA for code generation (DRIVE: +58.3% on Codeforces)
- Two-stage pipeline is proven: SFT first for imitation learning, then RL for exploration and reward optimization
- Multi-objective rewards (syntax + format + length) prevent reward hacking and produce balanced outputs
References
- OpenCodeInstruct (2025) - lr=5e-6, 3 epochs, batch=2048 for SFT. Paper
- DRIVE (2025) - Two-stage GRPO with verifiable rewards. Paper
- DeepSeekMath (2024) - GRPO algorithm foundation. Paper
- StepCoder (2024) - Compiler feedback for code RL. Paper
- Lost in Translation (2023) - Cross-language code translation challenges. Paper