Text Generation
Transformers
Safetensors
PEFT
English
Nigerian Pidgin
text-generation-inference
unsloth
gemma4
trl
lora
nigerian-pidgin
conversational
Instructions to use Ephraimmm/pidgin_gemma_4_lora with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Ephraimmm/pidgin_gemma_4_lora with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Ephraimmm/pidgin_gemma_4_lora") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("Ephraimmm/pidgin_gemma_4_lora", device_map="auto") - PEFT
How to use Ephraimmm/pidgin_gemma_4_lora with PEFT:
Task type is invalid.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Ephraimmm/pidgin_gemma_4_lora with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Ephraimmm/pidgin_gemma_4_lora" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Ephraimmm/pidgin_gemma_4_lora", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Ephraimmm/pidgin_gemma_4_lora
- SGLang
How to use Ephraimmm/pidgin_gemma_4_lora with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "Ephraimmm/pidgin_gemma_4_lora" \ --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": "Ephraimmm/pidgin_gemma_4_lora", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
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 "Ephraimmm/pidgin_gemma_4_lora" \ --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": "Ephraimmm/pidgin_gemma_4_lora", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Unsloth Studio
How to use Ephraimmm/pidgin_gemma_4_lora with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for Ephraimmm/pidgin_gemma_4_lora to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for Ephraimmm/pidgin_gemma_4_lora to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for Ephraimmm/pidgin_gemma_4_lora to start chatting
Load model with FastModel
pip install unsloth from unsloth import FastModel model, tokenizer = FastModel.from_pretrained( model_name="Ephraimmm/pidgin_gemma_4_lora", max_seq_length=2048, ) - Docker Model Runner
How to use Ephraimmm/pidgin_gemma_4_lora with Docker Model Runner:
docker model run hf.co/Ephraimmm/pidgin_gemma_4_lora
Improve model card with professional documentation
Browse files
README.md
CHANGED
|
@@ -1,4 +1,5 @@
|
|
| 1 |
---
|
|
|
|
| 2 |
base_model: unsloth/gemma-4-e4b-it-unsloth-bnb-4bit
|
| 3 |
tags:
|
| 4 |
- text-generation-inference
|
|
@@ -6,31 +7,110 @@ tags:
|
|
| 6 |
- unsloth
|
| 7 |
- gemma4
|
| 8 |
- trl
|
| 9 |
-
|
|
|
|
|
|
|
| 10 |
language:
|
| 11 |
- en
|
|
|
|
|
|
|
| 12 |
---
|
| 13 |
|
| 14 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
|
|
|
| 19 |
|
| 20 |
-
|
|
|
|
| 21 |
|
| 22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
-
|
| 27 |
-
|
|
|
|
| 28 |
|
| 29 |
-
|
| 30 |
-
|------|-------------|
|
| 31 |
-
| **Training Loss** | Raw cross-entropy loss per step — should trend downward |
|
| 32 |
-
| **Gradient Norm** | L2 norm of gradients (slope of loss surface) — stabilises near convergence |
|
| 33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
|
| 35 |
-
|
| 36 |
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
base_model: unsloth/gemma-4-e4b-it-unsloth-bnb-4bit
|
| 4 |
tags:
|
| 5 |
- text-generation-inference
|
|
|
|
| 7 |
- unsloth
|
| 8 |
- gemma4
|
| 9 |
- trl
|
| 10 |
+
- lora
|
| 11 |
+
- peft
|
| 12 |
+
- nigerian-pidgin
|
| 13 |
language:
|
| 14 |
- en
|
| 15 |
+
- pcm
|
| 16 |
+
pipeline_tag: text-generation
|
| 17 |
---
|
| 18 |
|
| 19 |
+
# Pidgin Gemma 4 LoRA
|
| 20 |
+
|
| 21 |
+
## Overview
|
| 22 |
+
|
| 23 |
+
This repository contains a LoRA (Low-Rank Adaptation) adapter for **Gemma 4 E4B (instruction-tuned)**, fine-tuned to generate and converse in **Nigerian Pidgin English (Naija / `pcm`)**. The adapter was trained with [Unsloth](https://github.com/unslothai/unsloth) and [TRL](https://github.com/huggingface/trl) on top of the 4-bit quantized base model `unsloth/gemma-4-e4b-it-unsloth-bnb-4bit`, and only the text/language pathway of the base model was adapted.
|
| 24 |
+
|
| 25 |
+
The base model is a multimodal (text/image/audio/video) Gemma 4 checkpoint, but this LoRA adapter targets only the language backbone's attention and MLP projections, so it is intended for **text-in / text-out Pidgin generation**, not for adapting the model's vision or audio capabilities.
|
| 26 |
+
|
| 27 |
+
## Training Details
|
| 28 |
+
|
| 29 |
+
| Detail | Value |
|
| 30 |
+
|---|---|
|
| 31 |
+
| Base model | `unsloth/gemma-4-e4b-it-unsloth-bnb-4bit` (Gemma 4 E4B, instruction-tuned, 4-bit) |
|
| 32 |
+
| Fine-tuning method | LoRA via PEFT |
|
| 33 |
+
| Training acceleration | [Unsloth](https://github.com/unslothai/unsloth) |
|
| 34 |
+
| Trainer | TRL |
|
| 35 |
+
| LoRA rank (`r`) | 8 |
|
| 36 |
+
| LoRA alpha | 8 |
|
| 37 |
+
| LoRA dropout | 0 |
|
| 38 |
+
| Bias | none |
|
| 39 |
+
| Target modules | Attention & MLP projections of the language backbone (`q_proj`, `k_proj`, `v_proj`, `o_proj`, `gate_proj`, `up_proj`, `down_proj`), matched via a regex scoped to the text/language submodules — vision, audio, and video towers were left frozen |
|
| 40 |
+
| Task type | `CAUSAL_LM` |
|
| 41 |
+
| PEFT version | 0.19.1 |
|
| 42 |
+
| License | Apache 2.0 |
|
| 43 |
+
| Reported final training loss | 1.239603 (see `loss_curve.png` in this repo) |
|
| 44 |
+
| Adapter size | ~73.5 MB (`adapter_model.safetensors`) |
|
| 45 |
+
|
| 46 |
+
Exact step count, number of epochs, learning rate, and batch size are not published in this repository (no `trainer_state.json` or training-arguments file is included), so they are intentionally omitted rather than guessed.
|
| 47 |
+
|
| 48 |
+
## Intended Use
|
| 49 |
+
|
| 50 |
+
- Generating conversational responses in Nigerian Pidgin English.
|
| 51 |
+
- Translating or rephrasing English text into Pidgin-flavored text for chatbots, content localization, or cultural-language experimentation.
|
| 52 |
+
- Research and educational exploration of low-resource / under-represented African language varieties with LLMs.
|
| 53 |
+
|
| 54 |
+
This adapter is **not** intended for high-stakes decision-making, medical/legal/financial advice, or use cases requiring guaranteed factual accuracy.
|
| 55 |
+
|
| 56 |
+
## How to Use
|
| 57 |
+
|
| 58 |
+
Because the base model is a 4-bit Unsloth checkpoint, loading with Unsloth is the most reliable path (it is also how the adapter was trained):
|
| 59 |
+
|
| 60 |
+
```python
|
| 61 |
+
from unsloth import FastModel
|
| 62 |
+
|
| 63 |
+
model, tokenizer = FastModel.from_pretrained(
|
| 64 |
+
model_name="unsloth/gemma-4-e4b-it-unsloth-bnb-4bit",
|
| 65 |
+
max_seq_length=2048,
|
| 66 |
+
load_in_4bit=True,
|
| 67 |
+
)
|
| 68 |
+
model.load_adapter("Ephraimmm/pidgin_gemma_4_lora")
|
| 69 |
+
|
| 70 |
+
messages = [
|
| 71 |
+
{"role": "user", "content": "How you dey? Wetin dey happen for Lagos today?"}
|
| 72 |
+
]
|
| 73 |
+
inputs = tokenizer.apply_chat_template(
|
| 74 |
+
messages, add_generation_prompt=True, return_tensors="pt"
|
| 75 |
+
).to("cuda")
|
| 76 |
+
|
| 77 |
+
outputs = model.generate(input_ids=inputs, max_new_tokens=128, temperature=0.7)
|
| 78 |
+
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
|
| 79 |
+
```
|
| 80 |
+
|
| 81 |
+
Alternatively, using `transformers` + `peft` directly (requires a `transformers` version that supports the Gemma 4 architecture, `Gemma4ForConditionalGeneration`):
|
| 82 |
|
| 83 |
+
```python
|
| 84 |
+
import torch
|
| 85 |
+
from transformers import AutoModelForCausalLM, AutoProcessor
|
| 86 |
+
from peft import PeftModel
|
| 87 |
|
| 88 |
+
base_model_id = "unsloth/gemma-4-e4b-it-unsloth-bnb-4bit"
|
| 89 |
+
adapter_id = "Ephraimmm/pidgin_gemma_4_lora"
|
| 90 |
|
| 91 |
+
processor = AutoProcessor.from_pretrained(adapter_id)
|
| 92 |
+
model = AutoModelForCausalLM.from_pretrained(
|
| 93 |
+
base_model_id, device_map="auto", torch_dtype=torch.bfloat16
|
| 94 |
+
)
|
| 95 |
+
model = PeftModel.from_pretrained(model, adapter_id)
|
| 96 |
|
| 97 |
+
messages = [{"role": "user", "content": "Abeg, explain wetin be Nigerian Pidgin."}]
|
| 98 |
+
inputs = processor.apply_chat_template(
|
| 99 |
+
messages, add_generation_prompt=True, tokenize=True, return_tensors="pt"
|
| 100 |
+
).to(model.device)
|
| 101 |
|
| 102 |
+
output = model.generate(**inputs, max_new_tokens=150)
|
| 103 |
+
print(processor.decode(output[0], skip_special_tokens=True))
|
| 104 |
+
```
|
| 105 |
|
| 106 |
+
## Limitations
|
|
|
|
|
|
|
|
|
|
| 107 |
|
| 108 |
+
- No quantitative evaluation (perplexity, BLEU, human preference scores, etc.) is published alongside this checkpoint — treat generation quality claims as unverified until you evaluate on your own data.
|
| 109 |
+
- Only the language/text component of the multimodal base model was fine-tuned; any image, audio, or video understanding inherited from the base model is unmodified and has not been tested for Pidgin-related tasks.
|
| 110 |
+
- Nigerian Pidgin has substantial regional, orthographic, and code-switching variation; the exact size, source, and dialectal coverage of the training data are not documented in this repository's published files.
|
| 111 |
+
- The base model is loaded in 4-bit quantization, which can introduce minor quality trade-offs versus full precision.
|
| 112 |
+
- As with any LLM, outputs may be inaccurate, inconsistent, or contain unintended bias, and should be reviewed by a human before use in user-facing or sensitive applications.
|
| 113 |
|
| 114 |
+
## Author
|
| 115 |
|
| 116 |
+
Developed by [Ephraimmm](https://huggingface.co/Ephraimmm)
|