Views
No views yet

openai/gpt-oss-20bnvidia/OpenCodeReasoning-2 (OCR-2), combining python and cpp splits. Each sample reconstructs the upstream question and uses the dataset's r1_generation as the assistant responseSFTTrainer1messages = [
2 {"role": "system", "content": "You are an expert competitive programmer. Read the problem and produce a correct, efficient solution. Include reasoning if helpful."},
3 {"role": "user", "content": problem_text},
4]
5
6prompt = tokenizer.apply_chat_template(
7 messages,
8 tokenize=False,
9 add_generation_prompt=True,
10)apply_chat_template (supported values: "low", "medium" (default), or "high"):1messages = [
2 {"role": "system", "content": "Always respond in riddles"},
3 {"role": "user", "content": "Explain why the meaning of life is 42"},
4]
5
6inputs = tokenizer.apply_chat_template(
7 messages,
8 add_generation_prompt=True,
9 return_tensors="pt",
10 return_dict=True,
11 reasoning_effort="high",
12).to(model.device)
13
14generated = model.generate(**inputs, max_new_tokens=500)
15print(tokenizer.decode(generated[0][inputs["input_ids"].shape[-1]:]))1from transformers import AutoTokenizer, AutoModelForCausalLM
2import torch
3
4model_id = "GetSoloTech/GPT-OSS-Code-Reasoning-20B"
5
6tokenizer = AutoTokenizer.from_pretrained(model_id)
7model = AutoModelForCausalLM.from_pretrained(
8 model_id,
9 torch_dtype=auto,
10 device_map="auto",
11)
12
13problem_text = """
14You are given an array of integers ... (your problem here)
15"""
16
17messages = [
18 {"role": "system", "content": "You are an expert competitive programmer. Read the problem and produce a correct, efficient solution. Include reasoning if helpful."},
19 {"role": "user", "content": problem_text},
20]
21
22input_text = tokenizer.apply_chat_template(
23 messages,
24 tokenize=False,
25 add_generation_prompt=True,
26 reasoning_effort="medium",
27)
28
29inputs = tokenizer([input_text], return_tensors="pt").to(model.device)
30outputs = model.generate(
31 **inputs,
32 max_new_tokens=768,
33 temperature=0.3,
34 top_p=0.9,
35 repetition_penalty=1.1,
36)
37print(tokenizer.decode(outputs[0], skip_special_tokens=True))max_new_tokens 512–1024 for full solutions; shorter for hintsnvidia/OpenCodeReasoning-2 with python and cpp splits--take_samples examples per splitopen-r1/codeforces)messages and a formatted text field with the tokenizer's chat templatetrain_test_split according to --eval_ratioFastLanguageModel) for efficient 4-bit loading and fast PEFTSFTTrainer) for straightforward supervised fine-tuningopen-r1/codeforces)