Downloads · 30 days
8
53% of all-time downloads
adamsw/aphrc-v2
aphrc-v2 is a text generation model from adamsw. Use it when you need the model to write or continue text. It is set up for peft. The card lists the license as apache-2.0.
This is a fine-tuned LoRA adapter for the Mistral-7B-Instruct-v0.3 model, specifically trained on the aphrc dataset to improve performance on African health and development questions.
Downloads · 30 days
8
53% of all-time downloads
All-time downloads
15
Public
Repo size
336 MB
Likes
0
Public
Click a slice to open those files.
.safetensors336 MB · 99%
From the Hugging Face model README
This is a fine-tuned LoRA adapter for the Mistral-7B-Instruct-v0.3 model, specifically trained on the aphrc dataset to improve performance on African health and development questions.
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
import torch
# Load base model
base_model = "mistralai/Mistral-7B-Instruct-v0.3"
model = AutoModelForCausalLM.from_pretrained(
base_model,
torch_dtype=torch.float16,
device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained(base_model)
# Load the LoRA adapter
model = PeftModel.from_pretrained(model, "adamsw/aphrc-v2")
# Generate text
question = "What are the major health challenges facing Africa today?"
messages = [
{"role": "user", "content": question}
]
input_ids = tokenizer.apply_chat_template(messages, return_tensors="pt").to(model.device)
outputs = model.generate(input_ids=input_ids, max_new_tokens=512, temperature=0.7)
response = tokenizer.decode(outputs[0][input_ids.shape[1]:], skip_special_tokens=True)
print(response)
from transformers import pipeline
from peft import PeftModel, PeftConfig
from transformers import AutoModelForCausalLM, AutoTokenizer
config = PeftConfig.from_pretrained("adamsw/aphrc-v2")
model = AutoModelForCausalLM.from_pretrained(
config.base_model_name_or_path,
torch_dtype=torch.float16,
device_map="auto"
)
model = PeftModel.from_pretrained(model, "adamsw/aphrc-v2")
tokenizer = AutoTokenizer.from_pretrained(config.base_model_name_or_path)
generator = pipeline(
"text-generation",
model=model,
tokenizer=tokenizer,
device_map="auto"
)
question = "What are the major health challenges facing Africa today?"
messages = [
{"role": "user", "content": question}
]
output = generator(
messages,
max_new_tokens=512,
temperature=0.7,
pad_token_id=tokenizer.eos_token_id
)
print(output[0]['generated_text'][-1]['content'])
This model was trained using Supervised Fine-Tuning (SFT) with the TRL library. The training data consisted of African health and development questions with reference answers.
This model was developed by Adams Wakhungu at Adanian Labs, focusing on improving language model performance for African health and development contexts.
If you use this model, please cite:
Cite TRL as:
@misc{vonwerra2022trl,
title = {{TRL: Transformer Reinforcement Learning}},
author = {Leandro von Werra and Younes Belkada and Lewis Tunstall and Edward Beeching and Tristan Thrush and Nathan Lambert and Shengyi Huang and Kashif Rasul and Quentin Gallou{\'e}dec},
year = 2020,
journal = {GitHub repository},
publisher = {GitHub},
howpublished = {\url{https://github.com/huggingface/trl}}
}