Update README.md
Browse files
README.md
CHANGED
@@ -1,55 +1,104 @@
|
|
1 |
---
|
|
|
|
|
|
|
2 |
base_model: google/gemma-3-270m
|
3 |
library_name: peft
|
4 |
pipeline_tag: text-generation
|
5 |
tags:
|
6 |
- base_model:adapter:google/gemma-3-270m
|
7 |
- transformers
|
|
|
|
|
|
|
|
|
|
|
8 |
---
|
9 |
|
10 |
-
#
|
11 |
|
12 |
-
|
13 |
|
|
|
14 |
|
|
|
15 |
|
16 |
-
|
17 |
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
-
<!-- Provide a longer summary of what this model is. -->
|
21 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
|
|
|
23 |
|
24 |
-
|
25 |
-
- **Funded by [optional]:** [More Information Needed]
|
26 |
-
- **Shared by [optional]:** [More Information Needed]
|
27 |
-
- **Model type:** [More Information Needed]
|
28 |
-
- **Language(s) (NLP):** [More Information Needed]
|
29 |
-
- **License:** [More Information Needed]
|
30 |
-
- **Finetuned from model [optional]:** [More Information Needed]
|
31 |
|
32 |
-
|
|
|
|
|
33 |
|
34 |
-
|
35 |
|
36 |
-
|
37 |
-
- **Paper [optional]:** [More Information Needed]
|
38 |
-
- **Demo [optional]:** [More Information Needed]
|
39 |
|
40 |
-
|
|
|
|
|
41 |
|
42 |
-
|
|
|
|
|
43 |
|
44 |
-
|
45 |
|
46 |
-
|
|
|
|
|
47 |
|
48 |
-
|
|
|
|
|
|
|
49 |
|
50 |
-
|
|
|
|
|
|
|
|
|
|
|
51 |
|
52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
|
54 |
|
55 |
## Evaluation Results
|
|
|
1 |
---
|
2 |
+
license: apache-2.0
|
3 |
+
datasets:
|
4 |
+
- databricks/databricks-dolly-15k
|
5 |
base_model: google/gemma-3-270m
|
6 |
library_name: peft
|
7 |
pipeline_tag: text-generation
|
8 |
tags:
|
9 |
- base_model:adapter:google/gemma-3-270m
|
10 |
- transformers
|
11 |
+
- google
|
12 |
+
- gemma3
|
13 |
+
- prompt-tune
|
14 |
+
- sweelol-ai
|
15 |
+
- peft
|
16 |
---
|
17 |
|
18 |
+
# sweelol/pt-gemma3-270m-dolly
|
19 |
|
20 |
+
This model is part of the **Sweelol AI Hub**, a research project focused on efficient fine-tuning of modern language models on Kaggle accelerators.
|
21 |
|
22 |
+
**Full Research Notebook & Benchmark Results:** [Coming soon]
|
23 |
|
24 |
+
This model is part of the **Sweelol AI Hub** collection, resulting from experiments in efficient fine-tuning, optimization strategies and knowledge distillation on the Gemma-3-270m architecture using the Databricks Dolly-15k dataset on Kaggle TPUs/GPUs.
|
25 |
|
26 |
+
This is a **LoRA-adapted** version of the `google/gemma-3-270m` model. It was fine-tuned on the Databricks Dolly-15k dataset using the **Low-Rank Adaptation (LoRA)** technique. LoRA is a parameter-efficient fine-tuning method that freezes the original model weights and injects trainable low-rank matrices into the attention layers. This allows the model to learn task-specific knowledge (instruction following) while keeping the overall number of trainable parameters low. Only the LoRA adapter weights need to be stored, making this model highly efficient to deploy.
|
27 |
|
28 |
+
- **Developed by:** SweeLOL-ai
|
29 |
+
- **Shared by:** SweeLOL ai
|
30 |
+
- **Model type:** Causal Language Model
|
31 |
+
- **Language(s) (NLP):** English
|
32 |
+
- **License:** Apache 2.0
|
33 |
+
- **Base Model:** `google/gemma-3-270m`
|
34 |
|
|
|
35 |
|
36 |
+
### Description
|
37 |
+
|
38 |
+
Gemma is a family of lightweight, state-of-the-art open models from Google,
|
39 |
+
built from the same research and technology used to create the Gemini models.
|
40 |
+
Gemma 3 models are multimodal, handling text and image input and generating text
|
41 |
+
output, with open weights for both pre-trained variants and instruction-tuned
|
42 |
+
variants. Gemma 3 has a large, 128K context window, multilingual support in over
|
43 |
+
140 languages, and is available in more sizes than previous versions. Gemma 3
|
44 |
+
models are well-suited for a variety of text generation and image understanding
|
45 |
+
tasks, including question answering, summarization, and reasoning. Their
|
46 |
+
relatively small size makes it possible to deploy them in environments with
|
47 |
+
limited resources such as laptops, desktops or your own cloud infrastructure,
|
48 |
+
democratizing access to state of the art AI models and helping foster innovation
|
49 |
+
for everyone.
|
50 |
|
51 |
+
### Usage
|
52 |
|
53 |
+
Below, there are some code snippets on how to get quickly started with running the model. First, install the Transformers library. Gemma 3 is supported starting from transformers 4.50.0.
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
|
55 |
+
```sh
|
56 |
+
$ pip install -U transformers
|
57 |
+
```
|
58 |
|
59 |
+
Then, copy the snippet from the section that is relevant for your use case.
|
60 |
|
61 |
+
#### Running with the `pipeline` API
|
|
|
|
|
62 |
|
63 |
+
```python
|
64 |
+
from transformers import pipeline
|
65 |
+
import torch
|
66 |
|
67 |
+
pipe = pipeline("text-generation", model="sweelol/pt-gemma3-270m-dolly", device="cuda", torch_dtype=torch.bfloat16)
|
68 |
+
output = pipe("Eiffel tower is located in", max_new_tokens=50)
|
69 |
+
```
|
70 |
|
71 |
+
#### Running the model on a single / multi GPU
|
72 |
|
73 |
+
```python
|
74 |
+
import torch
|
75 |
+
from transformers import AutoTokenizer,
|
76 |
|
77 |
+
tokenizer = AutoTokenizer.from_pretrained("sweelol/pt-gemma3-270m-dolly")
|
78 |
+
if tokenizer.pad_token is None:
|
79 |
+
tokenizer.pad_token = tokenizer.eos_token
|
80 |
+
print("✅ Set tokenizer pad_token to eos_token")
|
81 |
|
82 |
+
model = AutoModelForCausalLM.from_pretrained(
|
83 |
+
"sweelol/lora-gemma3-270m-dolly",
|
84 |
+
torch_dtype=torch.bfloat16 if not USE_AMP else torch.float32,
|
85 |
+
attn_implementation='eager'
|
86 |
+
)
|
87 |
+
print(f"✅ Base model loaded (dtype: {model.dtype}).")
|
88 |
|
89 |
+
|
90 |
+
prompt = "Eiffel tower is located in"
|
91 |
+
model_inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
|
92 |
+
|
93 |
+
input_len = model_inputs["input_ids"].shape[-1]
|
94 |
+
|
95 |
+
with torch.inference_mode():
|
96 |
+
generation = model.generate(**model_inputs, max_new_tokens=50, do_sample=False)
|
97 |
+
generation = generation[0][input_len:]
|
98 |
+
|
99 |
+
decoded = tokenizer.decode(generation, skip_special_tokens=True)
|
100 |
+
print(decoded)
|
101 |
+
```
|
102 |
|
103 |
|
104 |
## Evaluation Results
|