Ephraimmm commited on
Commit
c3717b4
·
verified ·
1 Parent(s): 53439cf

Improve model card with professional documentation

Browse files
Files changed (1) hide show
  1. README.md +95 -15
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
- license: apache-2.0
 
 
10
  language:
11
  - en
 
 
12
  ---
13
 
14
- # Uploaded model
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
 
16
- - **Developed by:** Ephraimmm
17
- - **License:** apache-2.0
18
- - **Finetuned from model :** unsloth/gemma-4-e4b-it-unsloth-bnb-4bit
 
19
 
20
- This gemma4 model was trained 2x faster with [Unsloth](https://github.com/unslothai/unsloth)
 
21
 
22
- [<img src="https://raw.githubusercontent.com/unslothai/unsloth/main/images/unsloth%20made%20with%20love.png" width="200"/>](https://github.com/unslothai/unsloth)
 
 
 
 
23
 
24
- ## Training Curves
 
 
 
25
 
26
- ### Loss
27
- ![Training Loss & Gradient Norm](loss_curve.png)
 
28
 
29
- | Plot | Description |
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
- Training loss: 1.239603
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)