Views
No views yet
[!NOTE] The is the full precision model.If you prefer the LoRA adapter only, check my other repo safouaneelg/gpt-oss-20b_DPO_ultrafeedback-lora
openai/gpt-oss-20b base model, aligned using stream argilla/ultrafeedback-binarized-preferences-cleaned dataset. The fine-tuning uses LoRA adapters. The model retains the causal language modeling capabilities of the base while improving alignment to human preferences.transformers==4.56.2
trl==0.21.0
peft==0.17.1
torch==2.8.0+cu1281import torch
2from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
3
4model_name = "safouaneelg/gpt-oss-20b_DPO_ultrafeedback"
5
6tokenizer = AutoTokenizer.from_pretrained(model_name)
7model = AutoModelForCausalLM.from_pretrained(
8 model_name,
9 torch_dtype=torch.bfloat16,
10 device_map="auto",
11 trust_remote_code=True
12)
13
14generator = pipeline(
15 "text-generation",
16 model=model,
17 tokenizer=tokenizer,
18 torch_dtype=torch.bfloat16,
19 device_map="auto"
20)
21
22prompt = """
23 Can you write a C++ program that prompts the user to enter the name of a country and checks if it borders the Mediterranean Sea? Here's some starter code to help you out:
24 #include <iostream>
25 #include <string>
26 using namespace std;
27 int main() {
28 string country;
29 // prompt user for input
30 cout << "Enter the name of a country: ";
31 cin >> country;
32 // check if country borders the Mediterranean Sea
33 // [C++ code]
34 return 0;
35 }.
36""",
37
38outputs = generator(
39 prompt,
40 max_new_tokens=100,
41 do_sample=True,
42 temperature=0.7,
43 top_p=0.9,
44 pad_token_id=tokenizer.eos_token_id
45)
46print(outputs[0]["generated_text"])device_map="auto" for sharding).tokenizer.apply_chat_template([{"role": "user", "content": prompt}]).argilla/ultrafeedback-binarized-preferences-cleaned dataset, a cleaned subset of Ultrafeedback containing ~60k binarized preference pairs (prompt, chosen response, rejected response) for alignment. Preprocessing: Filtered for length (>20 chars, 10-512 tokens), formatted with chat templates. Full dataset card: Hugging Face.| Parameter | Value |
|---|---|
| LoRA rank (r) | 16 |
| LoRA alpha | 32 |
| LoRA dropout | 0.1 |
| Bias | none |
| Target modules | q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj |
| Per device batch size | 1 |
| Gradient accumulation steps | 16 |
| Learning rate | 5e-6 |
| Number of epochs | 1 |
| Warmup ratio | 0.1 |
| Beta (DPO) | 0.1 |
| Max sequence length | 512 |
| Optimizer | adamw_torch |
| LR scheduler | cosine |
| Weight decay | 0.01 |
| Max grad norm | 1.0 |
| Gradient checkpointing | True |
| BF16 | True |
| Seed | 42 |
