COBOL-Coder: Domain-Adapted Large Language Models for COBOL Code Generation and Translation
Paper • 2604.03986 • Published
COBOL-Coder is a family of domain-adapted LLMs specialized for COBOL code generation and bidirectional COBOL-Java code translation. Built on top of Qwen2.5-Coder, COBOL-Coder addresses the critical gap in LLM capabilities for legacy programming languages.
Here provides a code snippet with apply_chat_template to show you how to load the tokenizer and model and how to generate contents.
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("Fsoft-AIC/COBOL-Coder-7B-Instruct")
model = AutoModelForCausalLM.from_pretrained("Fsoft-AIC/COBOL-Coder-7B-Instruct")
prompt = """Complete the given COBOL code:
"""
messages = [
{"role": "system", "content": "You are a helpful assistant for COBOL generation."},
{"role": "user", "content": prompt}
]
inputs = tokenizer.apply_chat_template(messages, add_generation_prompt=True, return_tensors="pt").to(model.device)
outputs = model.generate(inputs, max_new_tokens=512, do_sample=False, top_k=50, top_p=0.95, num_return_sequences=1, eos_token_id=tokenizer.eos_token_id)
print(tokenizer.decode(outputs[0][len(inputs[0]):], skip_special_tokens=True))
More details can be found in our paper.
If you're using COBOL-Coder, please cite using this BibTeX:
@article{dau2026cobol,
title={COBOL-Coder: Domain-Adapted Large Language Models for COBOL Code Generation and Translation},
author={Dau, Anh TV and Tan, Shin Hwei and Yang, Jinqiu and Bui, Nghi DQ and Nguyen, Anh Tuan},
journal={arXiv preprint arXiv:2604.03986},
year={2026}
}