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
|
@@ -2,6 +2,10 @@
|
|
| 2 |
library_name: transformers
|
| 3 |
tags:
|
| 4 |
- unsloth
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
base_model:
|
| 6 |
- Qwen/Qwen2.5-Coder-3B-Instruct
|
| 7 |
---
|
|
@@ -11,10 +15,12 @@ base_model:
|
|
| 11 |
<!-- Provide a quick summary of what the model is/does. -->
|
| 12 |
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).
|
| 13 |
|
|
|
|
|
|
|
| 14 |
## Evaluation
|
| 15 |
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.
|
| 16 |
|
| 17 |
-
According to the current version of the benchmark:
|
| 18 |
|
| 19 |
| Model | pass@1 | Compile Error Rate |
|
| 20 |
|----------------------|--------|--------------------|
|
|
@@ -24,13 +30,12 @@ According to the current version of the benchmark:
|
|
| 24 |
| GPT-4o | x | x |
|
| 25 |
|
| 26 |
|
| 27 |
-
|
| 28 |
-
## Model Details
|
| 29 |
-
|
| 30 |
-
|
| 31 |
## Uses
|
| 32 |
|
| 33 |
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
|
|
|
|
|
|
|
|
|
| 34 |
|
| 35 |
### Out-of-Scope Use
|
| 36 |
|
|
@@ -52,4 +57,4 @@ Use the code below to get started with the model.
|
|
| 52 |
|
| 53 |
[More Information Needed]
|
| 54 |
|
| 55 |
-
### Training Procedure
|
|
|
|
| 2 |
library_name: transformers
|
| 3 |
tags:
|
| 4 |
- unsloth
|
| 5 |
+
- grpo
|
| 6 |
+
- reinforcement_learning
|
| 7 |
+
- sft
|
| 8 |
+
- fortran
|
| 9 |
base_model:
|
| 10 |
- Qwen/Qwen2.5-Coder-3B-Instruct
|
| 11 |
---
|
|
|
|
| 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, 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.
|
| 22 |
|
| 23 |
+
According to the current demo version of the FortranHumanEval benchmark:
|
| 24 |
|
| 25 |
| Model | pass@1 | Compile Error Rate |
|
| 26 |
|----------------------|--------|--------------------|
|
|
|
|
| 30 |
| GPT-4o | x | x |
|
| 31 |
|
| 32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
## Uses
|
| 34 |
|
| 35 |
<!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
|
| 36 |
+
The model is highly specialized in generating Fortran90 programs that read input from stdin and print output to stdout. It’s recommended to use the model with a low temperature (or even disable sampling entirely) to maximize accuracy.
|
| 37 |
+
|
| 38 |
+
Before running any generated code, it’s always a good idea to check how the program handles input from stdin, especially for users who are new to Fortran.
|
| 39 |
|
| 40 |
### Out-of-Scope Use
|
| 41 |
|
|
|
|
| 57 |
|
| 58 |
[More Information Needed]
|
| 59 |
|
| 60 |
+
### Training Procedure
|