DannyAI commited on
Commit
2336763
·
verified ·
1 Parent(s): 2398939

Upload folder using huggingface_hub

Browse files
.gitattributes CHANGED
@@ -33,3 +33,5 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ lorafrica_lora_adapter.gguf filter=lfs diff=lfs merge=lfs -text
37
+ phi4_mini_instruct_q4_k_m.gguf filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,168 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: llama.cpp
3
+ tags:
4
+ - gguf
5
+ - quantization
6
+ - lora
7
+ - african-history
8
+ - phi-4
9
+ license: mit
10
+ datasets:
11
+ - DannyAI/African-History-QA-Dataset
12
+ base_model:
13
+ - microsoft/Phi-4-mini-instruct
14
+ pipeline_tag: text-generation
15
+ ---
16
+
17
+ # Model Card for Model ID
18
+ ### Phi-4 Mini African History (GGUF)
19
+
20
+ This repository contains GGUF versions of the **Phi-4-mini-instruct** base model and the **LoRAfrica** adapter, specialized for African History QA.
21
+
22
+ - **Base Model:** `phi4_mini_instruct_q4_k_m.gguf`
23
+ - **LoRA Adapter:** `lorafrica_lora_adapter.gguf`
24
+ - **Training Data:** DannyAI/African-History-QA-Dataset
25
+
26
+ ## Model Details
27
+
28
+ ### Model Description
29
+
30
+ This model is a quantized GGUF version of a LoRA fine-tuning based on Microsoft's Phi-4-mini. It is specifically optimized for efficiency and accuracy when answering questions regarding African history, ranging from ancient empires to contemporary social movements.
31
+
32
+ - **Developed by:** Daniel Ihenacho
33
+ - **Funded by:** Daniel Ihenacho
34
+ - **Shared by:** Daniel Ihenacho
35
+ - **Model type:** Text Generation (GGUF)
36
+ - **Language(s) (NLP):** English
37
+ - **License:** MIT
38
+ - **Finetune Method:** Axolotl (LoRA)
39
+
40
+ ## Uses
41
+
42
+ This model is designed for low-latency inference on consumer hardware using `llama.cpp` or other GGUF-compatible backends (Ollama, LM Studio, etc.).
43
+
44
+ ### Primary Use Case
45
+ - QA datasets and educational tools focused on African History.
46
+
47
+ ### Out-of-Scope Use
48
+ - General-purpose coding or mathematical reasoning (performance may be degraded compared to the base Phi-4).
49
+ - Production environments requiring high-stakes factual guarantees without human oversight.
50
+
51
+ ## How to Get Started with the Model
52
+
53
+ Since this repository contains a separate GGUF base and a GGUF LoRA adapter, you can use them together in `llama.cpp` without needing to merge them permanently.
54
+
55
+ ### Downloading the models
56
+ ```bash
57
+ hf download DannyAI/LoRAfrica_GGUF --local-dir ./gguf_model
58
+ ```
59
+
60
+ ### Using llama-cli
61
+ **NB:** This is for CMD on Windows
62
+ ```bash
63
+ .\build\bin\Release\llama-cli -m phi4_mini_instruct_q4_k_m.gguf ^
64
+ --lora lorafrica_lora_adapter.gguf ^
65
+ -p "<|system|>You are a helpful AI assistant specialised in African history.<|end|><|user|>Briefly detail the significance story of the Igbo god Amadioha?<|end|><|assistant|>" ^
66
+ -n 128
67
+ ```
68
+
69
+ ### Using llama-cli-server (Preferably)
70
+ **NB:** This is for CMD on Windows
71
+ ```bash
72
+ .\build\bin\Release\llama-server -m phi4_mini_instruct_q4_k_m.gguf ^
73
+ --lora lorafrica_lora_adapter.gguf --host 0.0.0.0 --port 8080
74
+ ```
75
+ *You could also navigate into the url, by pasting it on your browser http://localhost:8080/v1/chat/completions*
76
+ - It springs up the chat interface for you to use instead of using CMD to send request after starting the server
77
+ The server runs on your local machine
78
+ ```
79
+ # Send a Request
80
+ curl http://localhost:8080/v1/chat/completions -H "Content-Type: application/json" -d "{\"messages\": [{\"role\": \"system\", \"content\": \"You are a helpful AI assistant specialised in African history.\"}, {\"role\": \"user\", \"content\": \"Briefly detail the significance story of the Igbo god Amadioha?\"}], \"max_tokens\": 128, \"temperature\": 0.1}"
81
+ ```
82
+ **NB:** - [GitHub has more details in the use of cmd, coming soon!] <!--(https://github.com/daniau23/)-->
83
+ ### Python Implementation (via llama-cpp-python)
84
+ ```python
85
+ from llama_cpp import Llama
86
+ import os
87
+ # Get the number of physical cores on your machine
88
+ cores = os.cpu_count()
89
+
90
+ # For example, if you have 8 cores, 4 or 6 is usually the sweet spot.
91
+ cores_to_use = cores // 2
92
+ print(f"Cores on this machine: {cores}")
93
+ print(f"Cores to use: {cores_to_use}")
94
+
95
+ # Load the base model
96
+ llm = Llama(
97
+ model_path="./phi4_mini_instruct_q4_k_m.gguf",
98
+ lora_path="./lorafrica_lora_adapter.gguf", # comment out if you do not want LoRA Adapters
99
+ n_ctx=2000,
100
+ n_threads=cores, # Increase this for faster generation!
101
+ n_batch=512, # Helps the CPU process the initial prompt faster
102
+ n_gpu_layers=0, # Explicitly disables GPU offloading
103
+ use_mmap=True, # ADD THIS: Critically important for low-RAM systems
104
+ use_mlock=False # Ensure this is False so it doesn't force-lock RAM
105
+ )
106
+
107
+ output = llm.create_chat_completion(
108
+ messages =[
109
+ {
110
+ "role": "system", "content":"You are a helpful AI assistant specialised in African history which gives concise answers to questions asked."
111
+ },
112
+ {
113
+ "role": "user", "content":"Briefly detail the significance story of the Igbo god Amadioha?"
114
+ }
115
+ ],
116
+ max_tokens=128,
117
+ temperature=0.1
118
+ )
119
+
120
+ print(output["choices"][0]["message"]["content"])
121
+ ```
122
+ ```
123
+ # Example Output
124
+ Amadioha is a significant deity in Igbo mythology, representing justice and the thunder god. He is believed to reside in the heavens and is often invoked to settle disputes and mete out punishment for wrongdoing. Amadioha's thunderbolts are said to strike down those who commit injustices, symbolizing divine retribution. His presence underscores the importance of justice and moral order in Igbo culture.
125
+ ```
126
+
127
+ ```
128
+ # for streaming tokens generated
129
+
130
+ output_stream = llm.create_chat_completion(
131
+ messages =[
132
+ {
133
+ "role": "system", "content":"You are a helpful AI assistant specialised in African history which gives concise answers to questions asked."
134
+ },
135
+ {
136
+ "role": "user", "content":"Briefly detail the significance story of the Ogun Yoruba god?"
137
+ }
138
+ ],
139
+ max_tokens=128,
140
+ temperature=0.1,
141
+ stream=True
142
+ )
143
+
144
+
145
+ for chunk in output_stream:
146
+ delta = chunk["choices"][0]["delta"]
147
+ if "content" in delta:
148
+ print(delta["content"], end="", flush=True)
149
+ ```
150
+
151
+
152
+ ## Citation
153
+ @Model{
154
+ Ihenacho2026phi4_african_history_lora_gguf,
155
+ author = {Daniel Ihenacho},
156
+ title = {Phi-4 African History LoRA GGUF},
157
+ year = {2026},
158
+ publisher = {Hugging Face Models},
159
+ url = {[https://huggingface.co/DannyAI/phi4_african_history_lora_ds2_axolotl_gguf](https://huggingface.co/DannyAI/phi4_african_history_lora_ds2_axolotl_gguf)},
160
+ }
161
+
162
+ ## Model Card Authors
163
+ Daniel Ihenacho
164
+
165
+ ## Model Card Contact
166
+
167
+ - [LinkedIn](https://www.linkedin.com/in/daniel-ihenacho-637467223)
168
+ - [GitHub](https://github.com/daniau23)
lorafrica_lora_adapter.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:f4a493a07cc6f47e1ad3cf46d8c51972814d24aec3112812ae25930f60943a99
3
+ size 6297056
phi4_mini_instruct_q4_k_m.gguf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6ec1dc61cdda56cd97a4cc22f3aee71569fa60c989368616be92e8ad223fa6ab
3
+ size 2493840704