Views
No views yet
Answer the following multiple-choice question about [subject].
Question: [isiZulu question]
Choices:
A) [choice 1]
B) [choice 2]
C) [choice 3]
D) [choice 4]
Select the correct answer (A, B, C, or D) first before you explain. The first character in your answer should be your choice (A,B,C, or D):1from transformers import AutoTokenizer, AutoModelForCausalLM
2from peft import PeftModel
3
4# Load model
5base_model = AutoModelForCausalLM.from_pretrained("google/gemma-3-4b-it")
6tokenizer = AutoTokenizer.from_pretrained("google/gemma-3-4b-it")
7model = PeftModel.from_pretrained(base_model, "Dineochiloane/gemma-3-4b-isizulu-afrimmlu")
8
9# Format question
10messages = [{
11 "role": "user",
12 "content": "Answer the following multiple-choice question about elementary mathematics.\n\nQuestion: Lithini inani lika p ku 24 = 2p?\n\nChoices:\nA) p = 4\nB) p = 8\nC) p = 12\nD) p = 24\n\nSelect the correct answer (A, B, C, or D) first before you explain. The first character in your answer should be your choice (A,B,C, or D):"
13}]
14
15input_ids = tokenizer.apply_chat_template(messages, return_tensors="pt")
16outputs = model.generate(input_ids, max_new_tokens=100, temperature=0.0)
17response = tokenizer.decode(outputs[0], skip_special_tokens=True)
18print(response)