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 REDEFINES and OCCURS may produce imperfect output.
  • Intended as a first-pass translation aid, not a production drop-in replacement.
  • No formal benchmark yet โ€” community contributions welcome.

Links

Downloads last month
-
Safetensors
Model size
2B params
Tensor type
BF16
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Space using dishants0605/qwen2.5-cobol-python-translator 1