DannyAI/African-History-QA-Dataset
Viewer • Updated • 2.41k • 61 • 2
How to use DannyAI/phi4_african_history_lora_ds2_axolotl_merged with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="DannyAI/phi4_african_history_lora_ds2_axolotl_merged", trust_remote_code=True)
messages = [
{"role": "user", "content": "Who are you?"},
]
pipe(messages) # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("DannyAI/phi4_african_history_lora_ds2_axolotl_merged", trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained("DannyAI/phi4_african_history_lora_ds2_axolotl_merged", trust_remote_code=True, device_map="auto")
messages = [
{"role": "user", "content": "Who are you?"},
]
inputs = tokenizer.apply_chat_template(
messages,
add_generation_prompt=True,
tokenize=True,
return_dict=True,
return_tensors="pt",
).to(model.device)
outputs = model.generate(**inputs, max_new_tokens=40)
print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:]))How to use DannyAI/phi4_african_history_lora_ds2_axolotl_merged with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "DannyAI/phi4_african_history_lora_ds2_axolotl_merged"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "DannyAI/phi4_african_history_lora_ds2_axolotl_merged",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker model run hf.co/DannyAI/phi4_african_history_lora_ds2_axolotl_merged
How to use DannyAI/phi4_african_history_lora_ds2_axolotl_merged with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "DannyAI/phi4_african_history_lora_ds2_axolotl_merged" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "DannyAI/phi4_african_history_lora_ds2_axolotl_merged",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'docker run --gpus all \
--shm-size 32g \
-p 30000:30000 \
-v ~/.cache/huggingface:/root/.cache/huggingface \
--env "HF_TOKEN=<secret>" \
--ipc=host \
lmsysorg/sglang:latest \
python3 -m sglang.launch_server \
--model-path "DannyAI/phi4_african_history_lora_ds2_axolotl_merged" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/chat/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "DannyAI/phi4_african_history_lora_ds2_axolotl_merged",
"messages": [
{
"role": "user",
"content": "What is the capital of France?"
}
]
}'How to use DannyAI/phi4_african_history_lora_ds2_axolotl_merged with Docker Model Runner:
docker model run hf.co/DannyAI/phi4_african_history_lora_ds2_axolotl_merged
This is the merged version of LoRAfrica and base Phi4 Model
This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.
This can be used for QA datasets about African History
Can be used beyond African History but should not.
from transformers import pipeline
from transformers import (
AutoTokenizer,
AutoModelForCausalLM)
model_id = "DannyAI/phi4_african_history_lora_ds2_axolotl_merged"
tokeniser = AutoTokenizer.from_pretrained(model_id)
# load merged model
model = AutoModelForCausalLM.from_pretrained(
model_id,
device_map = "auto",
torch_dtype = torch.bfloat16,
trust_remote_code = False
)
generator = pipeline(
"text-generation",
model=model,
tokenizer=tokeniser,
)
question = "What is the significance of African feminist scholarly activism in contemporary resistance movements?"
def generate_answer(question)->str:
"""Generates an answer for the given question using the fine-tuned LoRA model.
"""
messages = [
{"role": "system", "content": "You are a helpful AI assistant specialised in African history which gives concise answers to questions asked."},
{"role": "user", "content": question}
]
output = generator(
messages,
max_new_tokens=2048,
temperature=0.1,
do_sample=False,
return_full_text=False
)
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.
If you use this dataset, please cite:
@Model{
Ihenacho2026phi4_african_history_lora_ds2_axolotl_merged,
author = {Daniel Ihenacho},
title = {phi4_african_history_lora_ds2_axolotl_merged},
year = {2026},
publisher = {Hugging Face Models},
url = {https://huggingface.co/DannyAI/phi4_african_history_lora_ds2_axolotl_merged},
urldate = {2026-03-21},
}
Daniel Ihenacho
Base model
microsoft/Phi-4-mini-instruct