jeffasante commited on
Commit
7edae4a
·
verified ·
1 Parent(s): 908e56c

Add gemma-3-1b-it-bnb4

Browse files
.gitattributes CHANGED
@@ -38,3 +38,4 @@ gemma-4-2p3b-it-litert/gemma-4-2p3b-it-litert.cellm filter=lfs diff=lfs merge=lf
38
  gemma-3-1b-it-int8/gemma-3-1b-it-int8.cellmd filter=lfs diff=lfs merge=lfs -text
39
  gemma-3-1b-it-int8/tokenizer.json filter=lfs diff=lfs merge=lfs -text
40
  gemma-4-2p3b-it-litert/tokenizer.json filter=lfs diff=lfs merge=lfs -text
 
 
38
  gemma-3-1b-it-int8/gemma-3-1b-it-int8.cellmd filter=lfs diff=lfs merge=lfs -text
39
  gemma-3-1b-it-int8/tokenizer.json filter=lfs diff=lfs merge=lfs -text
40
  gemma-4-2p3b-it-litert/tokenizer.json filter=lfs diff=lfs merge=lfs -text
41
+ gemma-3-1b-it-bnb4/tokenizer.json filter=lfs diff=lfs merge=lfs -text
gemma-3-1b-it-bnb4/README.md ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ library_name: cellm
3
+ tags:
4
+ - mobile
5
+ - rust
6
+ - memory-efficient
7
+ - quantized
8
+ - gemma
9
+ ---
10
+
11
+ # Gemma 3 1B IT (4-bit, bitsandbytes)
12
+
13
+ This folder contains a 4-bit quantized Gemma 3 1B Instruct model package prepared for upload.
14
+
15
+ ## Files
16
+ - `model.safetensors`
17
+ - `config.json`
18
+ - `generation_config.json`
19
+ - `tokenizer.json`
20
+ - `tokenizer_config.json`
21
+ - `chat_template.jinja`
22
+
23
+ ## Model Details
24
+ - **Base model**: `google/gemma-3-1b-it`
25
+ - **Quantization**: 4-bit (bitsandbytes)
26
+ - **On-disk size**: ~952 MB (folder)
27
+
28
+ ## Quick Python Check
29
+
30
+ ```python
31
+ from transformers import AutoTokenizer, AutoModelForCausalLM
32
+
33
+ path = "models/to-huggingface/gemma-3-1b-it-bnb4"
34
+ tok = AutoTokenizer.from_pretrained(path)
35
+ model = AutoModelForCausalLM.from_pretrained(path, device_map="cpu")
36
+
37
+ msgs = [{"role": "user", "content": "Say hello in one short line."}]
38
+ prompt = tok.apply_chat_template(msgs, tokenize=False, add_generation_prompt=True)
39
+ inputs = tok(prompt, return_tensors="pt")
40
+ out = model.generate(**inputs, max_new_tokens=24, do_sample=False)
41
+ print(tok.decode(out[0], skip_special_tokens=True))
42
+ ```
43
+
44
+ ## Notes
45
+ - This package is in Hugging Face/Transformers-compatible format.
46
+ - If you want a `.cellm` release for this model too, run converter separately and publish as a second artifact.
47
+
48
+ ## License
49
+ Subject to Gemma terms and upstream license constraints.
gemma-3-1b-it-bnb4/chat_template.jinja ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {{ bos_token }}
2
+ {%- if messages[0]['role'] == 'system' -%}
3
+ {%- if messages[0]['content'] is string -%}
4
+ {%- set first_user_prefix = messages[0]['content'] + '
5
+
6
+ ' -%}
7
+ {%- else -%}
8
+ {%- set first_user_prefix = messages[0]['content'][0]['text'] + '
9
+
10
+ ' -%}
11
+ {%- endif -%}
12
+ {%- set loop_messages = messages[1:] -%}
13
+ {%- else -%}
14
+ {%- set first_user_prefix = "" -%}
15
+ {%- set loop_messages = messages -%}
16
+ {%- endif -%}
17
+ {%- for message in loop_messages -%}
18
+ {%- if (message['role'] == 'user') != (loop.index0 % 2 == 0) -%}
19
+ {{ raise_exception("Conversation roles must alternate user/assistant/user/assistant/...") }}
20
+ {%- endif -%}
21
+ {%- if (message['role'] == 'assistant') -%}
22
+ {%- set role = "model" -%}
23
+ {%- else -%}
24
+ {%- set role = message['role'] -%}
25
+ {%- endif -%}
26
+ {{ '<start_of_turn>' + role + '
27
+ ' + (first_user_prefix if loop.first else "") }}
28
+ {%- if message['content'] is string -%}
29
+ {{ message['content'] | trim }}
30
+ {%- elif message['content'] is iterable -%}
31
+ {%- for item in message['content'] -%}
32
+ {%- if item['type'] == 'image' -%}
33
+ {{ '<start_of_image>' }}
34
+ {%- elif item['type'] == 'text' -%}
35
+ {{ item['text'] | trim }}
36
+ {%- endif -%}
37
+ {%- endfor -%}
38
+ {%- else -%}
39
+ {{ raise_exception("Invalid content type") }}
40
+ {%- endif -%}
41
+ {{ '<end_of_turn>
42
+ ' }}
43
+ {%- endfor -%}
44
+ {%- if add_generation_prompt -%}
45
+ {{'<start_of_turn>model
46
+ '}}
47
+ {%- endif -%}
gemma-3-1b-it-bnb4/config.json ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_sliding_window_pattern": 6,
3
+ "architectures": [
4
+ "Gemma3ForCausalLM"
5
+ ],
6
+ "attention_bias": false,
7
+ "attention_dropout": 0.0,
8
+ "attn_logit_softcapping": null,
9
+ "bos_token_id": 2,
10
+ "cache_implementation": "hybrid",
11
+ "dtype": "bfloat16",
12
+ "eos_token_id": [
13
+ 1,
14
+ 106
15
+ ],
16
+ "final_logit_softcapping": null,
17
+ "head_dim": 256,
18
+ "hidden_activation": "gelu_pytorch_tanh",
19
+ "hidden_size": 1152,
20
+ "initializer_range": 0.02,
21
+ "intermediate_size": 6912,
22
+ "layer_types": [
23
+ "sliding_attention",
24
+ "sliding_attention",
25
+ "sliding_attention",
26
+ "sliding_attention",
27
+ "sliding_attention",
28
+ "full_attention",
29
+ "sliding_attention",
30
+ "sliding_attention",
31
+ "sliding_attention",
32
+ "sliding_attention",
33
+ "sliding_attention",
34
+ "full_attention",
35
+ "sliding_attention",
36
+ "sliding_attention",
37
+ "sliding_attention",
38
+ "sliding_attention",
39
+ "sliding_attention",
40
+ "full_attention",
41
+ "sliding_attention",
42
+ "sliding_attention",
43
+ "sliding_attention",
44
+ "sliding_attention",
45
+ "sliding_attention",
46
+ "full_attention",
47
+ "sliding_attention",
48
+ "sliding_attention"
49
+ ],
50
+ "max_position_embeddings": 32768,
51
+ "model_type": "gemma3_text",
52
+ "num_attention_heads": 4,
53
+ "num_hidden_layers": 26,
54
+ "num_key_value_heads": 1,
55
+ "pad_token_id": 0,
56
+ "quantization_config": {
57
+ "_load_in_4bit": true,
58
+ "_load_in_8bit": false,
59
+ "bnb_4bit_compute_dtype": "float16",
60
+ "bnb_4bit_quant_storage": "uint8",
61
+ "bnb_4bit_quant_type": "nf4",
62
+ "bnb_4bit_use_double_quant": true,
63
+ "llm_int8_enable_fp32_cpu_offload": false,
64
+ "llm_int8_has_fp16_weight": false,
65
+ "llm_int8_skip_modules": null,
66
+ "llm_int8_threshold": 6.0,
67
+ "load_in_4bit": true,
68
+ "load_in_8bit": false,
69
+ "quant_method": "bitsandbytes"
70
+ },
71
+ "query_pre_attn_scalar": 256,
72
+ "rms_norm_eps": 1e-06,
73
+ "rope_parameters": {
74
+ "full_attention": {
75
+ "rope_theta": 1000000,
76
+ "rope_type": "default"
77
+ },
78
+ "sliding_attention": {
79
+ "rope_theta": 10000,
80
+ "rope_type": "default"
81
+ }
82
+ },
83
+ "sliding_window": 512,
84
+ "sliding_window_pattern": 6,
85
+ "tie_word_embeddings": true,
86
+ "transformers_version": "5.5.0",
87
+ "use_bidirectional_attention": false,
88
+ "use_cache": true,
89
+ "vocab_size": 262144
90
+ }
gemma-3-1b-it-bnb4/generation_config.json ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "bos_token_id": 2,
3
+ "cache_implementation": "hybrid",
4
+ "do_sample": true,
5
+ "eos_token_id": [
6
+ 1,
7
+ 106
8
+ ],
9
+ "pad_token_id": 0,
10
+ "top_k": 64,
11
+ "top_p": 0.95,
12
+ "transformers_version": "5.5.0"
13
+ }
gemma-3-1b-it-bnb4/model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b7d1fc799ca03a5900612731f2480ed869681fb6edfa4fdca0679de3625bbab7
3
+ size 964577519
gemma-3-1b-it-bnb4/tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:daab2354f8a74e70d70b4d1f804939b68a8c9624dd06cb7858e52dd8970e9726
3
+ size 33384567
gemma-3-1b-it-bnb4/tokenizer_config.json ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "backend": "tokenizers",
3
+ "boi_token": "<start_of_image>",
4
+ "bos_token": "<bos>",
5
+ "clean_up_tokenization_spaces": false,
6
+ "eoi_token": "<end_of_image>",
7
+ "eos_token": "<eos>",
8
+ "image_token": "<image_soft_token>",
9
+ "is_local": true,
10
+ "mask_token": "<mask>",
11
+ "model_max_length": 1000000000000000019884624838656,
12
+ "model_specific_special_tokens": {
13
+ "boi_token": "<start_of_image>",
14
+ "eoi_token": "<end_of_image>",
15
+ "image_token": "<image_soft_token>"
16
+ },
17
+ "pad_token": "<pad>",
18
+ "processor_class": "Gemma3Processor",
19
+ "sp_model_kwargs": null,
20
+ "spaces_between_special_tokens": false,
21
+ "tokenizer_class": "GemmaTokenizer",
22
+ "unk_token": "<unk>",
23
+ "use_default_system_prompt": false
24
+ }