bhismaperkasa commited on
Commit
21bc8b9
Β·
verified Β·
1 Parent(s): 4ffacb6

Upload README.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. README.md +150 -37
README.md CHANGED
@@ -1,62 +1,175 @@
1
  ---
2
  base_model: google/gemma-3-270m-it
3
  library_name: peft
4
- model_name: form-generator-gemma-adapters
5
  tags:
6
- - base_model:adapter:google/gemma-3-270m-it
 
 
 
7
  - lora
8
- - sft
9
- - transformers
10
- - trl
11
- licence: license
12
- pipeline_tag: text-generation
 
 
13
  ---
14
 
15
- # Model Card for form-generator-gemma-adapters
16
 
17
- This model is a fine-tuned version of [google/gemma-3-270m-it](https://huggingface.co/google/gemma-3-270m-it).
18
- It has been trained using [TRL](https://github.com/huggingface/trl).
19
 
20
- ## Quick start
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
  ```python
23
- from transformers import pipeline
 
 
 
 
 
 
 
 
 
24
 
25
- 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?"
26
- generator = pipeline("text-generation", model="None", device="cuda")
27
- output = generator([{"role": "user", "content": question}], max_new_tokens=128, return_full_text=False)[0]
28
- print(output["generated_text"])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  ```
30
 
31
- ## Training procedure
32
 
33
-
 
 
 
 
 
 
 
34
 
 
35
 
36
- This model was trained with SFT.
 
 
 
 
 
37
 
38
- ### Framework versions
39
 
40
- - PEFT 0.17.1
41
- - TRL: 0.24.0
42
- - Transformers: 4.57.1
43
- - Pytorch: 2.9.0
44
- - Datasets: 4.3.0
45
- - Tokenizers: 0.22.1
46
 
47
- ## Citations
48
 
 
 
 
 
49
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50
 
51
- Cite TRL as:
52
-
53
  ```bibtex
54
- @misc{vonwerra2022trl,
55
- title = {{TRL: Transformer Reinforcement Learning}},
56
- author = {Leandro von Werra and Younes Belkada and Lewis Tunstall and Edward Beeching and Tristan Thrush and Nathan Lambert and Shengyi Huang and Kashif Rasul and Quentin Gallou{\'e}dec},
57
- year = 2020,
58
- journal = {GitHub repository},
59
- publisher = {GitHub},
60
- howpublished = {\url{https://github.com/huggingface/trl}}
61
  }
62
- ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
  base_model: google/gemma-3-270m-it
3
  library_name: peft
 
4
  tags:
5
+ - text-generation
6
+ - form-generation
7
+ - json
8
+ - gemma
9
  - lora
10
+ - peft
11
+ - bahasa-indonesia
12
+ language:
13
+ - id
14
+ datasets:
15
+ - bhismaperkasa/form_dinamis
16
+ license: apache-2.0
17
  ---
18
 
19
+ # Form Generator - Gemma 3 270M (LoRA Adapters)
20
 
21
+ Fine-tuned LoRA adapters for `google/gemma-3-270m-it` to generate form definitions in JSON format from natural language descriptions in Bahasa Indonesia.
 
22
 
23
+ ## 🎯 Model Description
24
+
25
+ This repository contains **LoRA adapters** (not a merged model) that can be loaded on top of the base Gemma 3 270M model. The adapters were trained to generate dynamic form definitions in JSON format.
26
+
27
+ ## ⚠️ Important Note
28
+
29
+ **This is a LoRA adapter model, NOT a standalone model.** You need to load it together with the base model `google/gemma-3-270m-it`.
30
+
31
+ ## πŸš€ Usage
32
+
33
+ ### Installation
34
+
35
+ ```bash
36
+ pip install transformers peft torch
37
+ ```
38
+
39
+ ### Loading the Model
40
 
41
  ```python
42
+ from transformers import AutoModelForCausalLM, AutoTokenizer
43
+ from peft import PeftModel
44
+ import torch
45
+
46
+ # Load base model
47
+ base_model = AutoModelForCausalLM.from_pretrained(
48
+ "google/gemma-3-270m-it",
49
+ device_map="auto",
50
+ torch_dtype=torch.bfloat16
51
+ )
52
 
53
+ # Load LoRA adapters
54
+ model = PeftModel.from_pretrained(base_model, "bhismaperkasa/form-generator-lora-adapters")
55
+ tokenizer = AutoTokenizer.from_pretrained("bhismaperkasa/form-generator-lora-adapters")
56
+
57
+ # Generate
58
+ messages = [
59
+ {"role": "system", "content": "You are a helpful assistant that generates form definitions in JSON format based on user requests."},
60
+ {"role": "user", "content": "buatkan form pendaftaran event dengan nama dan email"}
61
+ ]
62
+
63
+ input_text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
64
+ inputs = tokenizer(input_text, return_tensors="pt").to(model.device)
65
+
66
+ outputs = model.generate(
67
+ **inputs,
68
+ max_new_tokens=512,
69
+ temperature=0.7,
70
+ do_sample=True
71
+ )
72
+
73
+ result = tokenizer.decode(outputs[0], skip_special_tokens=True)
74
+ generated = result.split("<start_of_turn>model\n")[-1].strip()
75
+ print(generated)
76
  ```
77
 
78
+ ## πŸ“Š Training Details
79
 
80
+ - **Base Model**: google/gemma-3-270m-it
81
+ - **Method**: QLoRA (4-bit quantization + LoRA)
82
+ - **Dataset**: bhismaperkasa/form_dinamis (10,000 samples)
83
+ - **Training Samples**: ~9,000
84
+ - **Validation Samples**: ~1,000
85
+ - **Epochs**: 3
86
+ - **Final Eval Loss**: 0.2256
87
+ - **Token Accuracy**: 93.5%
88
 
89
+ ### Hyperparameters
90
 
91
+ - LoRA Rank: 16
92
+ - LoRA Alpha: 32
93
+ - LoRA Dropout: 0.05
94
+ - Learning Rate: 5e-5
95
+ - Batch Size: 4
96
+ - Max Length: 512 tokens
97
 
98
+ ## πŸ“ˆ Performance
99
 
100
+ - **Evaluation Loss**: 0.2256
101
+ - **Token Accuracy**: 93.50%
102
+ - **Train-Eval Gap**: 4.9% (healthy, no overfitting)
103
+ - **Entropy**: 0.1881 (high confidence)
 
 
104
 
105
+ ## πŸ’‘ Example Outputs
106
 
107
+ **Input:**
108
+ ```
109
+ buatkan form login sederhana
110
+ ```
111
 
112
+ **Output:**
113
+ ```json
114
+ {
115
+ "id": "form_login_sims",
116
+ "title": "Form Login",
117
+ "description": "Form untuk login akun",
118
+ "formDefinition": {
119
+ "fields": [
120
+ {"fieldId": "email", "label": "Email", "fieldType": "EMAIL", "required": true},
121
+ {"fieldId": "password", "label": "Password", "fieldType": "PASSWORD", "required": true}
122
+ ]
123
+ }
124
+ }
125
+ ```
126
+
127
+ ## πŸŽ“ Use Cases
128
+
129
+ - Dynamic form generation for web applications
130
+ - Survey and questionnaire creation
131
+ - User registration forms
132
+ - Data collection forms
133
+ - Event registration forms
134
+
135
+ ## βš™οΈ Technical Details
136
+
137
+ ### Why LoRA Adapters?
138
+
139
+ - **Smaller size**: ~50MB vs ~500MB for merged model
140
+ - **Better quality**: Works more reliably than merged model
141
+ - **Flexibility**: Can be combined with different base models
142
+ - **Efficiency**: Faster to download and deploy
143
+
144
+ ### Model Architecture
145
+
146
+ - Base: Gemma 3 270M (270 million parameters)
147
+ - Adapters: LoRA with rank 16 (few million trainable parameters)
148
+ - Target modules: All linear layers
149
+ - Quantization: 4-bit NormalFloat (NF4)
150
+
151
+ ## πŸ“ Citation
152
 
 
 
153
  ```bibtex
154
+ @misc{form-generator-gemma-lora,
155
+ author = {bhismaperkasa},
156
+ title = {Form Generator - Gemma 3 270M LoRA Adapters},
157
+ year = {2025},
158
+ publisher = {Hugging Face},
159
+ howpublished = {\url{https://huggingface.co/bhismaperkasa/form-generator-lora-adapters}}
 
160
  }
161
+ ```
162
+
163
+ ## πŸ“„ License
164
+
165
+ This model is based on Gemma 3 270M which is licensed under Apache 2.0.
166
+
167
+ ## πŸ™ Acknowledgments
168
+
169
+ - Google for Gemma 3 270M model
170
+ - Hugging Face for transformers, PEFT, and TRL libraries
171
+ - Dataset: bhismaperkasa/form_dinamis
172
+
173
+ ---
174
+
175
+ **Note**: For production use, consider using these adapters instead of a merged model for better reliability and performance.