Views
No views yet
Model Accuracy shot by_letter category
0 Malaysian-Gemma3-1b 42.816210 0shot True STEM
1 Malaysian-Gemma3-1b 48.091603 0shot True Language
2 Malaysian-Gemma3-1b 38.999711 0shot True Social science
3 Malaysian-Gemma3-1b 40.969057 0shot True Others
4 Malaysian-Gemma3-1b 47.849829 0shot True Humanities
{'Social science': np.int64(6918), 'Language': np.int64(6288), 'Humanities': np.int64(4395), 'Others': np.int64(4169), 'STEM': np.int64(2443)}
Model : Malaysian-Gemma3-1b
Metric : first
Shot : 0shot
average accuracy 43.69140544335688
accuracy for STEM 42.81620957838722
accuracy for Language 48.091603053435115
accuracy for Social science 38.99971089910379
accuracy for Others 40.96905732789638
accuracy for Humanities 47.84982935153584
1from datasets import load_dataset, concatenate_datasets
2
3# Login using e.g. `huggingface-cli login` to access this dataset
4ds = load_dataset("mesolitica/Malaysian-SFT", "default")
5
6def convert_to_chatml(example):
7 return {
8 "conversations": [
9 {"role": "user", "content": example["input"]},
10 {"role": "assistant", "content": example["output"]}
11 ]
12 }
13
14dataset = ds.map(convert_to_chatml)
15
16def formatting_prompts_func(examples):
17 convos = examples["conversations"]
18 texts = []
19 for convo in convos:
20 try:
21 # Attempt to apply the chat template
22 text = tokenizer.apply_chat_template(convo, tokenize=False, add_generation_prompt=False).removeprefix('<bos>')
23 texts.append(text)
24 except Exception as e:
25 # If an error occurs, print it and append a placeholder instead of skipping
26 print(f"Error processing a conversation: {e}")
27 print(f"Problematic conversation: {convo}")
28 texts.append(None) # Use None or an empty string as a placeholder
29
30 return {"text": texts}
31
32dataset = dataset.map(formatting_prompts_func, batched=True, num_proc=4)
33dataset = dataset.filter(lambda example: example['text'] is not None)
34combined_dataset = concatenate_datasets([dataset[split] for split in dataset.keys()])1model, tokenizer = FastModel.from_pretrained(
2 model_name = "unsloth/gemma-3-1b-it",
3 max_seq_length = 2048, # Choose any for long context!
4 load_in_4bit = False, # 4 bit quantization to reduce memory
5 load_in_8bit = False, # [NEW!] A bit more accurate, uses 2x memory
6 full_finetuning = True, # [NEW!] We have full finetuning now!
7)1from trl import SFTTrainer, SFTConfig
2import os
3trainer = SFTTrainer(
4 model = model,
5 tokenizer = tokenizer,
6 train_dataset = combined_dataset,
7 eval_dataset = None, # Can set up evaluation!
8 args = SFTConfig(
9 dataset_text_field = "text",
10 per_device_train_batch_size = 64,
11 gradient_accumulation_steps = 1, # Use GA to mimic batch size!
12 warmup_steps = 5,
13 num_train_epochs = 1, # Set this for 1 full training run.
14 max_steps = 300,
15 learning_rate = 1e-5, # Reduce to 2e-5 for long training runs
16 logging_steps = 1,
17 optim = "adamw_8bit",
18 weight_decay = 0.01,
19 lr_scheduler_type = "linear",
20 seed = 3407,
21 output_dir="outputs",
22 report_to = "none", # Use this for WandB etc
23 ),
24 num_workers=os.cpu_count()
25)