You need to agree to share your contact information to access this model

This repository is publicly accessible, but you have to accept the conditions to access its files and content.

Log in or Sign Up to review the conditions and access this model content.

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
-
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for ghananlpcommunity/twi-gen-minicpm4

Adapter
(2)
this model
Free AI Image Generator No sign-up. Instant results. Open Now