Upload 17 files
Browse files- .gitattributes +1 -0
- README.md +97 -3
- added_tokens.json +3 -0
- chat_template.json +3 -0
- config.json +40 -0
- generation_config.json +11 -0
- model-00001-of-00005.safetensors +3 -0
- model-00002-of-00005.safetensors +3 -0
- model-00003-of-00005.safetensors +3 -0
- model-00004-of-00005.safetensors +3 -0
- model-00005-of-00005.safetensors +3 -0
- model.safetensors.index.json +0 -0
- preprocessor_config.json +29 -0
- processor_config.json +4 -0
- special_tokens_map.json +27 -0
- tokenizer.json +3 -0
- tokenizer.model +3 -0
- tokenizer_config.json +0 -0
.gitattributes
CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
README.md
CHANGED
@@ -1,3 +1,97 @@
|
|
1 |
-
---
|
2 |
-
license:
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: gemma
|
3 |
+
library_name: transformers
|
4 |
+
pipeline_tag: image-text-to-text
|
5 |
+
extra_gated_heading: Access Gemma on Hugging Face
|
6 |
+
extra_gated_prompt: To access Gemma on Hugging Face, you’re required to review and
|
7 |
+
agree to Google’s usage license. To do this, please ensure you’re logged in to Hugging
|
8 |
+
Face and click below. Requests are processed immediately.
|
9 |
+
extra_gated_button_content: Acknowledge license
|
10 |
+
base_model: google/gemma-3-12b-pt
|
11 |
+
tags:
|
12 |
+
- abliterated
|
13 |
+
- uncensored
|
14 |
+
---
|
15 |
+
|
16 |
+
# huihui-ai/gemma-3-12b-it-abliterated
|
17 |
+
|
18 |
+
|
19 |
+
This is an uncensored version of [google/gemma-3-12b-it](https://huggingface.co/google/gemma-3-12b-it) created with abliteration (see [remove-refusals-with-transformers](https://github.com/Sumandora/remove-refusals-with-transformers) to know more about it).
|
20 |
+
This is a crude, proof-of-concept implementation to remove refusals from an LLM model without using TransformerLens.
|
21 |
+
|
22 |
+
It was only the text part that was processed, not the image part.
|
23 |
+
|
24 |
+
The abliterated model will no longer say "I'm sorry, but I cannot fulfill your request to ..."
|
25 |
+
|
26 |
+
## Use with ollama
|
27 |
+
ollama only supports text dialogue and does not support image recognition.
|
28 |
+
|
29 |
+
You can use [huihui_ai/gemma3-abliterated](https://ollama.com/huihui_ai/gemma3-abliterated) directly
|
30 |
+
```
|
31 |
+
ollama run huihui_ai/gemma3-abliterated:12b
|
32 |
+
```
|
33 |
+
|
34 |
+
## Usage
|
35 |
+
You can use this model in your applications by loading it with Hugging Face's `transformers` library:
|
36 |
+
|
37 |
+
|
38 |
+
```python
|
39 |
+
# pip install accelerate
|
40 |
+
|
41 |
+
from transformers import AutoProcessor, Gemma3ForConditionalGeneration
|
42 |
+
from PIL import Image
|
43 |
+
import requests
|
44 |
+
import torch
|
45 |
+
|
46 |
+
model_id = "huihui-ai/gemma-3-12b-it-abliterated"
|
47 |
+
|
48 |
+
model = Gemma3ForConditionalGeneration.from_pretrained(
|
49 |
+
model_id, device_map="auto"
|
50 |
+
).eval()
|
51 |
+
|
52 |
+
processor = AutoProcessor.from_pretrained(model_id)
|
53 |
+
|
54 |
+
messages = [
|
55 |
+
{
|
56 |
+
"role": "system",
|
57 |
+
"content": [{"type": "text", "text": "You are a helpful assistant."}]
|
58 |
+
},
|
59 |
+
{
|
60 |
+
"role": "user",
|
61 |
+
"content": [
|
62 |
+
{"type": "image", "image": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/bee.jpg"},
|
63 |
+
{"type": "text", "text": "Describe this image in detail."}
|
64 |
+
]
|
65 |
+
}
|
66 |
+
]
|
67 |
+
|
68 |
+
inputs = processor.apply_chat_template(
|
69 |
+
messages, add_generation_prompt=True, tokenize=True,
|
70 |
+
return_dict=True, return_tensors="pt"
|
71 |
+
).to(model.device, dtype=torch.bfloat16)
|
72 |
+
|
73 |
+
input_len = inputs["input_ids"].shape[-1]
|
74 |
+
|
75 |
+
with torch.inference_mode():
|
76 |
+
generation = model.generate(**inputs, max_new_tokens=100, do_sample=False)
|
77 |
+
generation = generation[0][input_len:]
|
78 |
+
|
79 |
+
decoded = processor.decode(generation, skip_special_tokens=True)
|
80 |
+
print(decoded)
|
81 |
+
|
82 |
+
# **Overall Impression:** The image is a close-up shot of a vibrant garden scene,
|
83 |
+
# focusing on a cluster of pink cosmos flowers and a busy bumblebee.
|
84 |
+
# It has a slightly soft, natural feel, likely captured in daylight.
|
85 |
+
```
|
86 |
+
|
87 |
+
### Donation
|
88 |
+
|
89 |
+
If you like it, please click 'like' and follow us for more updates.
|
90 |
+
You can follow [x.com/support_huihui](https://x.com/support_huihui) to get the latest model information from huihui.ai.
|
91 |
+
|
92 |
+
##### Your donation helps us continue our further development and improvement, a cup of coffee can do it.
|
93 |
+
- bitcoin:
|
94 |
+
```
|
95 |
+
bc1qqnkhuchxw0zqjh2ku3lu4hq45hc6gy84uk70ge
|
96 |
+
```
|
97 |
+
|
added_tokens.json
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"<image_soft_token>": 262144
|
3 |
+
}
|
chat_template.json
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"chat_template": "{{ bos_token }}\n{%- if messages[0]['role'] == 'system' -%}\n {%- if messages[0]['content'] is string -%}\n {%- set first_user_prefix = messages[0]['content'] + '\n\n' -%}\n {%- else -%}\n {%- set first_user_prefix = messages[0]['content'][0]['text'] + '\n\n' -%}\n {%- endif -%}\n {%- set loop_messages = messages[1:] -%}\n{%- else -%}\n {%- set first_user_prefix = \"\" -%}\n {%- set loop_messages = messages -%}\n{%- endif -%}\n{%- for message in loop_messages -%}\n {%- if (message['role'] == 'user') != (loop.index0 % 2 == 0) -%}\n {{ raise_exception(\"Conversation roles must alternate user/assistant/user/assistant/...\") }}\n {%- endif -%}\n {%- if (message['role'] == 'assistant') -%}\n {%- set role = \"model\" -%}\n {%- else -%}\n {%- set role = message['role'] -%}\n {%- endif -%}\n {{ '<start_of_turn>' + role + '\n' + (first_user_prefix if loop.first else \"\") }}\n {%- if message['content'] is string -%}\n {{ message['content'] | trim }}\n {%- elif message['content'] is iterable -%}\n {%- for item in message['content'] -%}\n {%- if item['type'] == 'image' -%}\n {{ '<start_of_image>' }}\n {%- elif item['type'] == 'text' -%}\n {{ item['text'] | trim }}\n {%- endif -%}\n {%- endfor -%}\n {%- else -%}\n {{ raise_exception(\"Invalid content type\") }}\n {%- endif -%}\n {{ '<end_of_turn>\n' }}\n{%- endfor -%}\n{%- if add_generation_prompt -%}\n {{'<start_of_turn>model\n'}}\n{%- endif -%}\n"
|
3 |
+
}
|
config.json
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"architectures": [
|
3 |
+
"Gemma3ForConditionalGeneration"
|
4 |
+
],
|
5 |
+
"boi_token_index": 255999,
|
6 |
+
"eoi_token_index": 256000,
|
7 |
+
"eos_token_id": [
|
8 |
+
1,
|
9 |
+
106
|
10 |
+
],
|
11 |
+
"image_token_index": 262144,
|
12 |
+
"initializer_range": 0.02,
|
13 |
+
"mm_tokens_per_image": 256,
|
14 |
+
"model_type": "gemma3",
|
15 |
+
"text_config": {
|
16 |
+
"hidden_size": 3840,
|
17 |
+
"intermediate_size": 15360,
|
18 |
+
"model_type": "gemma3_text",
|
19 |
+
"num_attention_heads": 16,
|
20 |
+
"num_hidden_layers": 48,
|
21 |
+
"num_key_value_heads": 8,
|
22 |
+
"rope_scaling": {
|
23 |
+
"factor": 8.0,
|
24 |
+
"rope_type": "linear"
|
25 |
+
},
|
26 |
+
"sliding_window": 1024
|
27 |
+
},
|
28 |
+
"torch_dtype": "bfloat16",
|
29 |
+
"transformers_version": "4.50.0.dev0",
|
30 |
+
"vision_config": {
|
31 |
+
"hidden_size": 1152,
|
32 |
+
"image_size": 896,
|
33 |
+
"intermediate_size": 4304,
|
34 |
+
"model_type": "siglip_vision_model",
|
35 |
+
"num_attention_heads": 16,
|
36 |
+
"num_hidden_layers": 27,
|
37 |
+
"patch_size": 14,
|
38 |
+
"vision_use_head": false
|
39 |
+
}
|
40 |
+
}
|
generation_config.json
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_from_model_config": true,
|
3 |
+
"bos_token_id": 2,
|
4 |
+
"cache_implementation": "hybrid",
|
5 |
+
"eos_token_id": [
|
6 |
+
1,
|
7 |
+
106
|
8 |
+
],
|
9 |
+
"pad_token_id": 0,
|
10 |
+
"transformers_version": "4.50.0.dev0"
|
11 |
+
}
|
model-00001-of-00005.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:5a71f20826869005cc37b4c3c9ddfcff919a7235eda1452047aab5c86a305fe6
|
3 |
+
size 4979902192
|
model-00002-of-00005.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:71b2f3c8e4aa3b72e0a8dc5375d9c657007a05df79b602a497bd874738b2b54b
|
3 |
+
size 4931296592
|
model-00003-of-00005.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:32e2da0780a1b277562d52650cf572dfdd296fea78e29d6b15019e4d7d5e8950
|
3 |
+
size 4931296656
|
model-00004-of-00005.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:0ce07b2279dd6f0b42b2e40c4fd39c42c2cbbb39caf009fa92fb22c0ce5beda6
|
3 |
+
size 4931296656
|
model-00005-of-00005.safetensors
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:35529638fdd1588f39205a882a72251d838d2dfc4e42657b3706076c39f144c4
|
3 |
+
size 4601000928
|
model.safetensors.index.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|
preprocessor_config.json
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"do_convert_rgb": null,
|
3 |
+
"do_normalize": true,
|
4 |
+
"do_pan_and_scan": null,
|
5 |
+
"do_rescale": true,
|
6 |
+
"do_resize": true,
|
7 |
+
"image_mean": [
|
8 |
+
0.5,
|
9 |
+
0.5,
|
10 |
+
0.5
|
11 |
+
],
|
12 |
+
"image_processor_type": "Gemma3ImageProcessor",
|
13 |
+
"image_seq_length": 256,
|
14 |
+
"image_std": [
|
15 |
+
0.5,
|
16 |
+
0.5,
|
17 |
+
0.5
|
18 |
+
],
|
19 |
+
"pan_and_scan_max_num_crops": null,
|
20 |
+
"pan_and_scan_min_crop_size": null,
|
21 |
+
"pan_and_scan_min_ratio_to_activate": null,
|
22 |
+
"processor_class": "Gemma3Processor",
|
23 |
+
"resample": 2,
|
24 |
+
"rescale_factor": 0.00392156862745098,
|
25 |
+
"size": {
|
26 |
+
"height": 896,
|
27 |
+
"width": 896
|
28 |
+
}
|
29 |
+
}
|
processor_config.json
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"image_seq_length": 256,
|
3 |
+
"processor_class": "Gemma3Processor"
|
4 |
+
}
|
special_tokens_map.json
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"boi_token": "<start_of_image>",
|
3 |
+
"bos_token": {
|
4 |
+
"content": "<bos>",
|
5 |
+
"lstrip": false,
|
6 |
+
"normalized": false,
|
7 |
+
"rstrip": false,
|
8 |
+
"single_word": false
|
9 |
+
},
|
10 |
+
"eoi_token": "<end_of_image>",
|
11 |
+
"eos_token": {
|
12 |
+
"content": "<eos>",
|
13 |
+
"lstrip": false,
|
14 |
+
"normalized": false,
|
15 |
+
"rstrip": false,
|
16 |
+
"single_word": false
|
17 |
+
},
|
18 |
+
"image_token": "<image_soft_token>",
|
19 |
+
"pad_token": "<eos>",
|
20 |
+
"unk_token": {
|
21 |
+
"content": "<unk>",
|
22 |
+
"lstrip": false,
|
23 |
+
"normalized": false,
|
24 |
+
"rstrip": false,
|
25 |
+
"single_word": false
|
26 |
+
}
|
27 |
+
}
|
tokenizer.json
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:4667f2089529e8e7657cfb6d1c19910ae71ff5f28aa7ab2ff2763330affad795
|
3 |
+
size 33384568
|
tokenizer.model
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:1299c11d7cf632ef3b4e11937501358ada021bbdf7c47638d13c0ee982f2e79c
|
3 |
+
size 4689074
|
tokenizer_config.json
ADDED
The diff for this file is too large to render.
See raw diff
|
|