Views
No views yet
0.14.0.dev01base_model: microsoft/Phi-4-mini-instruct
2model_type: AutoModelForCausalLM
3tokenizer_type: AutoTokenizer
4
5# 1. Dataset Configuration
6datasets:
7 - path: DannyAI/African-History-QA-Dataset
8 split: train
9 type: alpaca_chat.load_qa
10 system_prompt: "You are a helpful AI assistant specialised in African history."
11test_datasets:
12 - path: DannyAI/African-History-QA-Dataset
13 split: validation
14 type: alpaca_chat.load_qa
15 system_prompt: "You are a helpful AI assistant specialised in African history."
16
17# 2. Chat Configuration
18chat_template: tokenizer_default
19train_on_inputs: false
20
21# 3. Batch Size Configuration
22micro_batch_size: 2
23gradient_accumulation_steps: 4 # Axolotl will calculate: total_batch_size = 2 * 4 * 1 GPU = 8
24
25# 4. LoRA Configuration
26adapter: lora
27lora_r: 8
28lora_alpha: 16
29lora_dropout: 0.05
30lora_target_modules: [q_proj, v_proj, k_proj, o_proj]
31
32# 5. Hardware & Efficiency
33sequence_len: 2048
34sample_packing: true
35eval_sample_packing: false
36pad_to_sequence_len: true
37bf16: true
38fp16: false
39
40# 6. Training Duration
41max_steps: 650
42# removed
43# num_epochs:
44warmup_steps: 20
45learning_rate: 0.00002
46optimizer: adamw_torch
47lr_scheduler: cosine
48
49# 7. Logging & DeepSpeed
50deepspeed: using_axolotl/ds_config_2.json
51wandb_project: phi4_african_history
52wandb_name: phi4_axolotl_stage2
53
54eval_strategy: steps
55eval_steps: 50
56save_strategy: steps
57save_steps: 100
58logging_steps: 5
59
60# 8. Public Hugging Face Hub Upload
61hub_model_id: DannyAI/phi4_african_history_lora_ds2_axolotl
62push_adapter_to_hub: true
63hub_private_repo: false
641from transformers import pipeline
2from transformers import (
3 AutoTokenizer,
4 AutoModelForCausalLM)
5from peft import PeftModel
6
7
8model_id = "microsoft/Phi-4-mini-instruct"
9
10tokeniser = AutoTokenizer.from_pretrained(model_id)
11
12# load base model
13model = AutoModelForCausalLM.from_pretrained(
14 model_id,
15 device_map = "auto",
16 torch_dtype = torch.bfloat16,
17 trust_remote_code = False
18)
19
20# Load the fine-tuned LoRA model
21lora_id = "DannyAI/phi4_african_history_lora_ds2_axolotl"
22lora_model = PeftModel.from_pretrained(
23 model,lora_id
24)
25
26generator = pipeline(
27 "text-generation",
28 model=lora_model,
29 tokenizer=tokeniser,
30)
31question = "What is the significance of African feminist scholarly activism in contemporary resistance movements?"
32def generate_answer(question)->str:
33 """Generates an answer for the given question using the fine-tuned LoRA model.
34 """
35 messages = [
36 {"role": "system", "content": "You are a helpful AI assistant specialised in African history which gives concise answers to questions asked."},
37 {"role": "user", "content": question}
38 ]
39
40 output = generator(
41 messages,
42 max_new_tokens=2048,
43 temperature=0.1,
44 do_sample=False,
45 return_full_text=False
46 )
47 return output[0]['generated_text'].strip()# Example output
African feminist scholarly activism is significant in contemporary resistance movements as it provides a critical framework for understanding and addressing the specific challenges faced by African women in the context of global capitalism, neocolonialism, and patriarchal structures.| Training Loss | Epoch | Step | Validation Loss | Ppl | Active (gib) | Allocated (gib) | Reserved (gib) |
|---|---|---|---|---|---|---|---|
| No log | 0 | 0 | 2.1261 | 8.3822 | 14.81 | 14.81 | 15.32 |
| 5.5167 | 3.8627 | 50 | 2.1056 | 8.2118 | 14.82 | 14.82 | 31.8 |
| 4.5059 | 7.7059 | 100 | 2.0382 | 7.6764 | 14.82 | 14.82 | 31.82 |
| 3.8251 | 11.5490 | 150 | 1.9809 | 7.2491 | 14.82 | 14.82 | 31.82 |
| 3.4152 | 15.3922 | 200 | 1.9343 | 6.9193 | 14.82 | 14.82 | 31.82 |
| 3.1617 | 19.2353 | 250 | 1.8731 | 6.5085 | 14.82 | 14.82 | 31.82 |
| 2.9075 | 23.0784 | 300 | 1.8246 | 6.2002 | 14.82 | 14.82 | 31.82 |
| 2.8267 | 26.9412 | 350 | 1.7945 | 6.0164 | 14.82 | 14.82 | 31.82 |
| 2.7239 | 30.7843 | 400 | 1.7794 | 5.9262 | 14.82 | 14.82 | 31.82 |
| 2.7275 | 34.6275 | 450 | 1.7697 | 5.8690 | 14.82 | 14.82 | 31.82 |
| 2.6912 | 38.4706 | 500 | 1.7634 | 5.8325 | 14.82 | 14.82 | 31.82 |
| 2.6632 | 42.3137 | 550 | 1.7618 | 5.8227 | 14.82 | 14.82 | 31.82 |
| 2.6604 | 46.1569 | 600 | 1.7609 | 5.8179 | 14.82 | 14.82 | 31.82 |
| 2.6795 | 50.0 | 650 | 1.7608 | 5.8168 | 14.82 | 14.82 | 31.82 |
| Models | Bert Score | TinyMMLU | TinyTrufulQA |
|---|---|---|---|
| Base model | 0.88868 | 0.6837 | 0.49745 |
| Fine tuned Model | 0.88872 | 0.67371 | 0.46877 |
@Model{
Ihenacho2026phi4_african_history_lora_ds2_axolotl,
author = {Daniel Ihenacho},
title = {phi4_african_history_lora_ds2_axolotl},
year = {2026},
publisher = {Hugging Face Models},
url = {https://huggingface.co/DannyAI/phi4_african_history_lora_ds2_axolotl},
urldate = {2026-01-27},
}