COBOL → Python Translator
Fine-tuned Qwen2.5-Coder-1.5B to translate legacy COBOL code into idiomatic Python using QLoRA via Unsloth.
Why this exists
Billions of lines of COBOL still run in banking, insurance, and government systems. Migrating them manually is expensive and error-prone. This model automates the first pass — producing readable Python that preserves the original business logic.
Training
| Setting | Value |
|---|---|
| Base model | Qwen2.5-Coder-1.5B |
| Method | QLoRA (rank 16, alpha 32) |
| Framework | Unsloth |
| Hardware | T4 GPU (Google Colab) |
| Training loss | 2.14 → 0.13 (125 steps) |
| Dataset | Custom COBOL↔Python pairs |
Example
Input (COBOL)
COMPUTE WS-TAX = WS-PRICE * WS-TAX-RATE
Output (Python)
from decimal import Decimal
ws_tax = Decimal(str(ws_price)) * Decimal(str(ws_tax_rate))
Usage
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained("dishants0605/qwen2.5-cobol-python-translator")
tokenizer = AutoTokenizer.from_pretrained("dishants0605/qwen2.5-cobol-python-translator")
prompt = """Translate this COBOL to Python:
MOVE WS-NAME TO WS-OUTPUT-NAME
Python:"""
inputs = tokenizer(prompt, return_tensors="pt")
outputs = model.generate(**inputs, max_new_tokens=200)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
Limitations
- Trained on a relatively small dataset; complex COBOL patterns such as
REDEFINESandOCCURSmay produce imperfect output. - Intended as a first-pass translation aid, not a production drop-in replacement.
- No formal benchmark yet — community contributions welcome.