Text Generation
Transformers
Safetensors
qwen2
unsloth
grpo
sft
fortran
reinforcement learning
conversational
text-generation-inference
Instructions to use GiuLeo01/FortranCodeGen-3B-SynthData with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use GiuLeo01/FortranCodeGen-3B-SynthData with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="GiuLeo01/FortranCodeGen-3B-SynthData") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("GiuLeo01/FortranCodeGen-3B-SynthData") model = AutoModelForCausalLM.from_pretrained("GiuLeo01/FortranCodeGen-3B-SynthData", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use GiuLeo01/FortranCodeGen-3B-SynthData with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "GiuLeo01/FortranCodeGen-3B-SynthData" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "GiuLeo01/FortranCodeGen-3B-SynthData", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/GiuLeo01/FortranCodeGen-3B-SynthData
- SGLang
How to use GiuLeo01/FortranCodeGen-3B-SynthData with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "GiuLeo01/FortranCodeGen-3B-SynthData" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "GiuLeo01/FortranCodeGen-3B-SynthData", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "GiuLeo01/FortranCodeGen-3B-SynthData" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "GiuLeo01/FortranCodeGen-3B-SynthData", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Unsloth Desktop
- Docker Model Runner
How to use GiuLeo01/FortranCodeGen-3B-SynthData with Docker Model Runner:
docker model run hf.co/GiuLeo01/FortranCodeGen-3B-SynthData
Update README.md
Browse files
README.md
CHANGED
|
@@ -10,12 +10,12 @@ base_model:
|
|
| 10 |
- Qwen/Qwen2.5-Coder-3B-Instruct
|
| 11 |
---
|
| 12 |
|
| 13 |
-
#
|
| 14 |
|
| 15 |
<!-- Provide a quick summary of what the model is/does. -->
|
| 16 |
This model is a prototype of a large language model specifically fine-tuned for Fortran90 code generation. It is based on the Qwen 2.5 Coder 3B Instruct model and has been refined using Supervised Fine-Tuning and Reinforcement Learning with Verifiable Rewards (via GRPO).
|
| 17 |
|
| 18 |
-
This model was fine-tuned briefly, without any human-labeled data and using only a single consumer GPU. Despite these clear constraints, the training process led to a 400% boost in performance on tasks involving simple to moderately complex program generation (HumanEval). Compilation errors dropped as well, and the model now performs close to much larger
|
| 19 |
|
| 20 |
## Evaluation
|
| 21 |
Due to the lack of existing benchmarks for Fortran code generation, a quick-and-dirty adaptation of the HumanEval benchmark was created for Fortran in order to evaluate the model. This benchmark is currently under review and will be released publicly at a later date.
|
|
@@ -25,6 +25,7 @@ According to the current demo version of the FortranHumanEval benchmark:
|
|
| 25 |
| Model | pass@1 | Compile Error Rate |
|
| 26 |
|----------------------|--------|--------------------|
|
| 27 |
| **FortranCodeGen 3B** | 23.17% | 17.68% |
|
|
|
|
| 28 |
| Qwen 2.5 Coder 3B | 5.48% | 63.41% |
|
| 29 |
| GPT-4o mini | 18.90% | 43.90% |
|
| 30 |
| GPT-4o | 32.31% | 17.07% |
|
|
@@ -100,3 +101,7 @@ By guiding generation through specific topics, I built a synthetic dataset of 30
|
|
| 100 |
|
| 101 |
### Training Procedure
|
| 102 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
- Qwen/Qwen2.5-Coder-3B-Instruct
|
| 11 |
---
|
| 12 |
|
| 13 |
+
# Introduction
|
| 14 |
|
| 15 |
<!-- Provide a quick summary of what the model is/does. -->
|
| 16 |
This model is a prototype of a large language model specifically fine-tuned for Fortran90 code generation. It is based on the Qwen 2.5 Coder 3B Instruct model and has been refined using Supervised Fine-Tuning and Reinforcement Learning with Verifiable Rewards (via GRPO).
|
| 17 |
|
| 18 |
+
This model was fine-tuned briefly, without any human-labeled data and using only a single consumer GPU. Despite these clear constraints, the training process led to a 400% boost in performance on tasks involving simple to moderately complex fortran program generation (HumanEval-like). Compilation errors dropped as well, and the model now performs close to much larger general-purpose models that weren’t specifically trained for this task.
|
| 19 |
|
| 20 |
## Evaluation
|
| 21 |
Due to the lack of existing benchmarks for Fortran code generation, a quick-and-dirty adaptation of the HumanEval benchmark was created for Fortran in order to evaluate the model. This benchmark is currently under review and will be released publicly at a later date.
|
|
|
|
| 25 |
| Model | pass@1 | Compile Error Rate |
|
| 26 |
|----------------------|--------|--------------------|
|
| 27 |
| **FortranCodeGen 3B** | 23.17% | 17.68% |
|
| 28 |
+
|**FortranCodeGen 3B only sft** | 19.51% | 31.09% |
|
| 29 |
| Qwen 2.5 Coder 3B | 5.48% | 63.41% |
|
| 30 |
| GPT-4o mini | 18.90% | 43.90% |
|
| 31 |
| GPT-4o | 32.31% | 17.07% |
|
|
|
|
| 101 |
|
| 102 |
### Training Procedure
|
| 103 |
|
| 104 |
+
#### Supervised Fine-Tuning
|
| 105 |
+
|
| 106 |
+
Ihttps://wandb.ai/giulioleonardi2001-universit-di-pisa/Fortran-Qwen2.5-Coder-3B_fine_tuning/runs/hjmptz72/panel/6kalharhb?
|
| 107 |
+
|