Views
No views yet
1from unsloth import FastLanguageModel
2import torch
3
4# Load model
5model, tokenizer = FastLanguageModel.from_pretrained(
6 model_name="Arittro2/gemma3-4b-sgd-grpo",
7 max_seq_length=2048,
8 dtype=None,
9 load_in_4bit=True,
10)
11
12# Prepare for inference
13FastLanguageModel.for_inference(model)
14
15# Example prompt
16prompt = """You are a helpful virtual assistant. Generate an appropriate response.
17
18<CONTEXT>
19User: I need to book a restaurant for dinner tonight.
20System: I can help you with that. What type of cuisine are you interested in?
21
22Dialog acts to realize:
23 - Act: REQUEST, Slot: location
24</CONTEXT>
25
26Generate a natural, helpful response between <RESPONSE> and </RESPONSE> tags."""
27
28messages = [{"role": "user", "content": prompt}]
29input_text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
30inputs = tokenizer(input_text, return_tensors="pt").to("cuda")
31
32# Generate
33output = model.generate(
34 **inputs,
35 max_new_tokens=256,
36 temperature=0.7,
37 top_p=0.9,
38 do_sample=True,
39 repetition_penalty=1.1
40)
41
42print(tokenizer.decode(output[0], skip_special_tokens=True))1@misc{gemma3-sgd-grpo,
2 author = {Arittro2},
3 title = {Gemma-3-4B Fine-tuned on Schema-Guided Dialog with GRPO},
4 year = {2025},
5 publisher = {Hugging Face},
6 howpublished = {\url{https://huggingface.co/Arittro2/gemma3-4b-sgd-grpo}}
7}