Instructions to use ghananlpcommunity/twi-gen-minicpm4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use ghananlpcommunity/twi-gen-minicpm4 with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("openbmb/MiniCPM4-8B") model = PeftModel.from_pretrained(base_model, "ghananlpcommunity/twi-gen-minicpm4") - Notebooks
- Google Colab
- Kaggle
TwiGen MiniCPM4
LoRA adapter for MiniCPM4-8B fine-tuned on Twi (Akan) instruction data. Part of the TwiGen project.
Generates coherent Twi text from English instructions.
Usage
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
base_id = "openbmb/MiniCPM4-8B"
lora_id = "ghananlpcommunity/twi-gen-minicpm4"
tokenizer = AutoTokenizer.from_pretrained(base_id, trust_remote_code=True)
tokenizer.pad_token = tokenizer.eos_token
model = AutoModelForCausalLM.from_pretrained(
base_id, trust_remote_code=True, torch_dtype=torch.bfloat16, device_map="cuda:0",
)
model = PeftModel.from_pretrained(model, lora_id)
model.eval()
messages = [{"role": "user", "content": "Write a story about a farmer in Ghana."}]
prompt = tokenizer.apply_chat_template(messages, tokenize=False) + "<|im_start|>assistant\n"
inputs = tokenizer(prompt, return_tensors="pt", truncation=True, max_length=2048).to(model.device)
outputs = model.generate(**inputs, max_new_tokens=512, temperature=0.7, do_sample=True)
print(tokenizer.decode(outputs[0][inputs.input_ids.shape[1]:], skip_special_tokens=True))
Training
- Base model: MiniCPM4-8B
- Data: ~495k Twi instruction samples (translated + synthetic)
- Method: LoRA (rank 16, alpha 32)
- Hardware: NVIDIA H200 (140 GB VRAM)
- Framework: LLaMA-Factory
Model
| Model | Adapter |
|---|---|
| twi-gen-qwen | Qwen3.5-0.8B version (lighter, faster) |
- Downloads last month
- -
Model tree for ghananlpcommunity/twi-gen-minicpm4
Base model
openbmb/MiniCPM4-8B