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
|
@@ -103,19 +103,47 @@ By guiding generation through specific topics, I built a synthetic dataset of 30
|
|
| 103 |
|
| 104 |
#### Supervised Fine-Tuning
|
| 105 |
|
| 106 |
-
|
| 107 |
|
| 108 |
-
|
| 109 |
|
| 110 |
-
|
| 111 |
-
- batch size = 4
|
| 112 |
-
- gradient accumulation steps = 4
|
| 113 |
-
- learning rate = 2e-5
|
| 114 |
-
- lr scheduler type = cosine
|
| 115 |
-
- weight decay = 0.01
|
| 116 |
|
| 117 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
|
|
|
|
| 119 |

|
| 120 |
|
| 121 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
|
| 104 |
#### Supervised Fine-Tuning
|
| 105 |
|
| 106 |
+
The annotated example dataset was split into training and validation sets (80/20 split), and used to perform full fine-tuning of the model.
|
| 107 |
|
| 108 |
+
Training was carried out for 10 epochs.
|
| 109 |
|
| 110 |
+
The key hyperparameters were:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 111 |
|
| 112 |
+
* batch size = 4
|
| 113 |
+
* gradient accumulation steps = 4
|
| 114 |
+
* learning rate = 2e-5
|
| 115 |
+
* learning rate scheduler = cosine
|
| 116 |
+
* weight decay = 0.01
|
| 117 |
|
| 118 |
+

|
| 119 |

|
| 120 |
|
| 121 |
|
| 122 |
+
#### Reinforcement Learning with Verifiable Rewards
|
| 123 |
+
|
| 124 |
+
In this stage, a QLoRA adapter was trained using the GRPO algorithm to refine the generated Fortran programs.
|
| 125 |
+
The goal was to reduce compilation errors and further improve the accuracy of the generated solutions.
|
| 126 |
+
|
| 127 |
+
The model was quantized to 4-bit, and a LoRA adapter was used with `rank=32` and `alpha=64`.
|
| 128 |
+
|
| 129 |
+
The reward function used throughout this phase was very simple:
|
| 130 |
+
|
| 131 |
+
* A reward of 1 was given if the generated program compiled successfully
|
| 132 |
+
* An additional 3 points were awarded if it passed the test case
|
| 133 |
+
This results in a reward range of \[0, 4].
|
| 134 |
+
|
| 135 |
+
The initial training phase was run for 3 epochs with:
|
| 136 |
+
|
| 137 |
+
* batch size = 16
|
| 138 |
+
* number of generations = 4
|
| 139 |
+
* learning rate = 1e-5
|
| 140 |
+
* learning rate scheduler = cosine
|
| 141 |
+
* weight decay = 0.1
|
| 142 |
+
* max gradient norm = 0.5
|
| 143 |
+
|
| 144 |
+
A second phase followed, resetting the learning rate to `1e-6` with a linear decay schedule.
|
| 145 |
+
|
| 146 |
+
|
| 147 |
+
|
| 148 |
+
|
| 149 |
+
|