shaikhsalman commited on
Commit
dcaee5e
·
verified ·
1 Parent(s): fcd836f

Training in progress, step 100

Browse files
README.md CHANGED
@@ -1,81 +1,59 @@
1
  ---
2
  base_model: Qwen/Qwen2.5-3B-Instruct
3
- library_name: peft
4
- datasets:
5
- - shaikhsalman/ZabaanAI-Urdu-3B-data
6
- language:
7
- - ur
8
- pipeline_tag: text-generation
9
  tags:
10
- - urdu
11
- - qlora
12
- - conversational
13
- - qwen2.5
14
- - ml-intern
15
  ---
16
 
17
- # ZabaanAI-Urdu-3B (v4)
18
 
19
- A LoRA adapter fine-tuning **Qwen/Qwen2.5-3B-Instruct** into a conversational **Urdu** AI assistant.
 
20
 
21
- ## v4 — Clean Urdu-Script Data (current)
22
 
23
- v3 produced gibberish under sampling because its data contained **Roman-Urdu poetry**
24
- (Latin script), teaching the model to mix scripts. v4 fixes this:
25
 
26
- - **Dataset:** [shaikhsalman/ZabaanAI-Urdu-3B-data](https://huggingface.co/datasets/shaikhsalman/ZabaanAI-Urdu-3B-data) ~58K train / 1.8K test, all **native Urdu script**, conversational `messages` format.
27
- - Core: [large-traversaal/urdu-instruct](https://huggingface.co/datasets/large-traversaal/urdu-instruct) (the *Alif* paper data — reasoning, QA, ethics, generation, classification, sentiment, translation)
28
- - Chat turns: [Najaf/urdu_chat_makhzan](https://huggingface.co/datasets/Najaf/urdu_chat_makhzan) (capped at 10K)
29
- - Quality gate: rows whose assistant answer is <85% Urdu script were dropped (translation/reasoning handled specially).
30
- - **Recipe:** QLoRA (4-bit nf4), r=16, alpha=32, dropout=0.05, target_modules=all-linear.
31
- - **Training:** 2 epochs (~7,286 steps), LR 1e-4 cosine, **assistant-only loss** (trains only on assistant turns), eff. batch 16.
32
- - **Hardware:** free Kaggle/Colab T4 (fp16, no FlashAttention). ~3h.
33
 
34
- ## Usage
35
 
36
- ```python
37
- import torch
38
- from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
39
- from peft import PeftModel
40
 
41
- tok = AutoTokenizer.from_pretrained("Qwen/Qwen2.5-3B-Instruct")
42
- model = AutoModelForCausalLM.from_pretrained(
43
- "Qwen/Qwen2.5-3B-Instruct",
44
- quantization_config=BitsAndBytesConfig(load_in_4bit=True, bnb_4bit_compute_dtype=torch.float16),
45
- device_map="auto")
46
- model = PeftModel.from_pretrained(model, "shaikhsalman/ZabaanAI-Urdu-3B")
47
- model.eval()
48
 
49
- msgs = [
50
- {"role": "system", "content": "آپ ایک ذہین اردو AI اسسٹنٹ ہیں۔"},
51
- {"role": "user", "content": "پاکستان کا دارالحکومت کیا ہے؟"},
52
- ]
53
- text = tok.apply_chat_template(msgs, tokenize=False, add_generation_prompt=True)
54
- inputs = tok(text, return_tensors="pt").to(model.device)
55
- out = model.generate(**inputs, max_new_tokens=200, do_sample=True,
56
- temperature=0.5, top_p=0.9, repetition_penalty=1.2)
57
- print(tok.decode(out[0][inputs.input_ids.shape[1]:], skip_special_tokens=True))
58
- ```
59
 
60
- > Tip: use moderate temperature (0.3–0.6) + `repetition_penalty=1.2` for best Urdu coherence.
61
 
62
- ## Training (reproduce on Kaggle/Colab T4)
63
-
64
- ```python
65
- !pip install -q trl peft transformers accelerate datasets bitsandbytes trackio
66
- import os; os.environ["HF_TOKEN"] = "hf_YOUR_TOKEN"
67
- !rm -f train_colab_gpu.py
68
- !wget -q https://huggingface.co/shaikhsalman/ZabaanAI-Urdu-3B/resolve/main/train_colab_gpu.py
69
- !python train_colab_gpu.py
70
- ```
71
 
72
- The script resumes across sessions via `training_progress.json` (target 7,286 steps).
73
- Healthy training loss is **0.8–1.5**; if loss dives below ~0.4 it is memorizing (the v3 failure mode).
74
 
75
- <!-- ml-intern-provenance -->
76
- ## Generated by ML Intern
77
 
78
- This model repository was generated by [ML Intern](https://github.com/huggingface/ml-intern), an agent for machine learning research and development on the Hugging Face Hub.
79
 
80
- - Try ML Intern: https://smolagents-ml-intern.hf.space
81
- - Source code: https://github.com/huggingface/ml-intern
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  base_model: Qwen/Qwen2.5-3B-Instruct
3
+ library_name: transformers
4
+ model_name: ZabaanAI-Urdu-3B
 
 
 
 
5
  tags:
6
+ - generated_from_trainer
7
+ - trackio:https://shaikhsalman-ml-intern-zabaanai.hf.space?project=zabaanai-urdu-3b&runs=sft_qwen2.5-3b_urdu_v4-clean-urdu-58k_lr0.0001&sidebar=collapsed
8
+ - trl
9
+ - sft
10
+ licence: license
11
  ---
12
 
13
+ # Model Card for ZabaanAI-Urdu-3B
14
 
15
+ This model is a fine-tuned version of [Qwen/Qwen2.5-3B-Instruct](https://huggingface.co/Qwen/Qwen2.5-3B-Instruct).
16
+ It has been trained using [TRL](https://github.com/huggingface/trl).
17
 
18
+ ## Quick start
19
 
20
+ ```python
21
+ from transformers import pipeline
22
 
23
+ question = "If you had a time machine, but could only go to the past or the future once and never return, which would you choose and why?"
24
+ generator = pipeline("text-generation", model="shaikhsalman/ZabaanAI-Urdu-3B", device="cuda")
25
+ output = generator([{"role": "user", "content": question}], max_new_tokens=128, return_full_text=False)[0]
26
+ print(output["generated_text"])
27
+ ```
 
 
28
 
29
+ ## Training procedure
30
 
31
+
32
+ [<img src="https://raw.githubusercontent.com/gradio-app/trackio/refs/heads/main/trackio/assets/badge.png" alt="Visualize in Trackio" title="Visualize in Trackio" width="150" height="24"/>](https://shaikhsalman-ml-intern-zabaanai.hf.space?project=zabaanai-urdu-3b&runs=sft_qwen2.5-3b_urdu_v4-clean-urdu-58k_lr0.0001&sidebar=collapsed)
 
 
33
 
 
 
 
 
 
 
 
34
 
35
+ This model was trained with SFT.
 
 
 
 
 
 
 
 
 
36
 
37
+ ### Framework versions
38
 
39
+ - TRL: 1.5.1
40
+ - Transformers: 5.0.0
41
+ - Pytorch: 2.10.0+cu128
42
+ - Datasets: 4.8.3
43
+ - Tokenizers: 0.22.2
 
 
 
 
44
 
45
+ ## Citations
 
46
 
 
 
47
 
 
48
 
49
+ Cite TRL as:
50
+
51
+ ```bibtex
52
+ @software{vonwerra2020trl,
53
+ title = {{TRL: Transformers Reinforcement Learning}},
54
+ author = {von Werra, Leandro and Belkada, Younes and Tunstall, Lewis and Beeching, Edward and Thrush, Tristan and Lambert, Nathan and Huang, Shengyi and Rasul, Kashif and Gallouédec, Quentin},
55
+ license = {Apache-2.0},
56
+ url = {https://github.com/huggingface/trl},
57
+ year = {2020}
58
+ }
59
+ ```
adapter_config.json CHANGED
@@ -18,7 +18,7 @@
18
  "loftq_config": {},
19
  "lora_alpha": 32,
20
  "lora_bias": false,
21
- "lora_dropout": 0.1,
22
  "megatron_config": null,
23
  "megatron_core": "megatron.core",
24
  "modules_to_save": null,
@@ -29,13 +29,13 @@
29
  "rank_pattern": {},
30
  "revision": null,
31
  "target_modules": [
32
- "k_proj",
33
- "q_proj",
34
- "o_proj",
35
  "up_proj",
36
  "v_proj",
37
  "down_proj",
38
- "gate_proj"
 
 
39
  ],
40
  "target_parameters": null,
41
  "task_type": "CAUSAL_LM",
 
18
  "loftq_config": {},
19
  "lora_alpha": 32,
20
  "lora_bias": false,
21
+ "lora_dropout": 0.05,
22
  "megatron_config": null,
23
  "megatron_core": "megatron.core",
24
  "modules_to_save": null,
 
29
  "rank_pattern": {},
30
  "revision": null,
31
  "target_modules": [
32
+ "gate_proj",
 
 
33
  "up_proj",
34
  "v_proj",
35
  "down_proj",
36
+ "o_proj",
37
+ "q_proj",
38
+ "k_proj"
39
  ],
40
  "target_parameters": null,
41
  "task_type": "CAUSAL_LM",
adapter_model.safetensors CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:4513a109c3529721b87b7cf086ebf3de19e358cb58a9dd0182d150f4695f1ff9
3
  size 59934640
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8fe5e187efa9dc0dc7f4f8df3d1b494124f27e2e2e5c0a77d78b326998805837
3
  size 59934640
training_args.bin CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:d3136a8da07614e0a1556a694133ca0ed45b06f6f21c75ee2037ff52965abad0
3
- size 5713
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:236ec4e2a9299c9ce34635495e93ae3121fdd255273453f8782522f42956bc08
3
+ size 5777