初始化项目,由ModelHub XC社区提供模型

Model: thomaskuo/gemma-3-12b-it-heretic
Source: Original Platform
This commit is contained in:
ModelHub XC
2026-06-29 21:08:21 +08:00
commit 995f5447e3
26 changed files with 52880 additions and 0 deletions

44
.gitattributes vendored Normal file
View File

@@ -0,0 +1,44 @@
*.7z filter=lfs diff=lfs merge=lfs -text
*.arrow filter=lfs diff=lfs merge=lfs -text
*.bin filter=lfs diff=lfs merge=lfs -text
*.bz2 filter=lfs diff=lfs merge=lfs -text
*.ckpt filter=lfs diff=lfs merge=lfs -text
*.ftz filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
*.h5 filter=lfs diff=lfs merge=lfs -text
*.joblib filter=lfs diff=lfs merge=lfs -text
*.lfs.* filter=lfs diff=lfs merge=lfs -text
*.mlmodel filter=lfs diff=lfs merge=lfs -text
*.model filter=lfs diff=lfs merge=lfs -text
*.msgpack filter=lfs diff=lfs merge=lfs -text
*.npy filter=lfs diff=lfs merge=lfs -text
*.npz filter=lfs diff=lfs merge=lfs -text
*.onnx filter=lfs diff=lfs merge=lfs -text
*.ot filter=lfs diff=lfs merge=lfs -text
*.parquet filter=lfs diff=lfs merge=lfs -text
*.pb filter=lfs diff=lfs merge=lfs -text
*.pickle filter=lfs diff=lfs merge=lfs -text
*.pkl filter=lfs diff=lfs merge=lfs -text
*.pt filter=lfs diff=lfs merge=lfs -text
*.pth filter=lfs diff=lfs merge=lfs -text
*.rar filter=lfs diff=lfs merge=lfs -text
*.safetensors filter=lfs diff=lfs merge=lfs -text
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
*.tar.* filter=lfs diff=lfs merge=lfs -text
*.tar filter=lfs diff=lfs merge=lfs -text
*.tflite filter=lfs diff=lfs merge=lfs -text
*.tgz filter=lfs diff=lfs merge=lfs -text
*.wasm filter=lfs diff=lfs merge=lfs -text
*.xz filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.zst filter=lfs diff=lfs merge=lfs -text
*tfevents* filter=lfs diff=lfs merge=lfs -text
tokenizer.json filter=lfs diff=lfs merge=lfs -text
gguf/gemma-3-12b-it-heretic-f16.gguf filter=lfs diff=lfs merge=lfs -text
gguf/gemma-3-12b-it-heretic-Q3_K_M.gguf filter=lfs diff=lfs merge=lfs -text
gguf/gemma-3-12b-it-heretic-Q4_K_M.gguf filter=lfs diff=lfs merge=lfs -text
gguf/gemma-3-12b-it-heretic-Q4_K_S.gguf filter=lfs diff=lfs merge=lfs -text
gguf/gemma-3-12b-it-heretic-Q5_K_M.gguf filter=lfs diff=lfs merge=lfs -text
gguf/gemma-3-12b-it-heretic-Q5_K_S.gguf filter=lfs diff=lfs merge=lfs -text
gguf/gemma-3-12b-it-heretic-Q6_K.gguf filter=lfs diff=lfs merge=lfs -text
gguf/gemma-3-12b-it-heretic-Q8_0.gguf filter=lfs diff=lfs merge=lfs -text

160
README.md Normal file
View File

@@ -0,0 +1,160 @@
---
license: gemma
library_name: transformers
pipeline_tag: text-generation
base_model: google/gemma-3-12b-it
base_model_relation: quantized
language:
- en
tags:
- abliteration
- heretic
- uncensored
- gemma
- ltx-2
- comfyui
- video-generation
- text-encoder
---
# Gemma 3 12B IT - Heretic (Abliterated)
An abliterated version of [Google's Gemma 3 12B IT](https://huggingface.co/google/gemma-3-12b-it) created using [Heretic](https://github.com/p-e-w/heretic). This model has reduced refusals while maintaining model quality, making it suitable as an uncensored text encoder for video generation models like LTX-2.
## Model Details
- **Base Model:** google/gemma-3-12b-it
- **Abliteration Method:** [Heretic](https://github.com/p-e-w/heretic) v1.1.0
- **Trial Selected:** Trial 99
- **Refusals:** 7/100 (vs 100/100 original)
- **KL Divergence:** 0.0826 (minimal model damage)
## Files
### HuggingFace Format (for transformers, llama.cpp conversion)
```
model-00001-of-00005.safetensors
model-00002-of-00005.safetensors
...
config.json
tokenizer.model
tokenizer_config.json
```
### ComfyUI Format (for LTX-2 text encoder)
```
comfyui/gemma_3_12B_it_heretic.safetensors # bf16, 22GB
comfyui/gemma_3_12B_it_heretic_fp8_e4m3fn.safetensors # fp8, 11GB
```
### GGUF Format (for llama.cpp)
| Quant | Size | Quality | Recommendation |
|-------|------|---------|----------------|
| F16 | 22GB | Lossless | Reference, same as original |
| Q8_0 | 12GB | Excellent | Best quality quantization |
| Q6_K | 9.0GB | Very Good | High quality, good compression |
| Q5_K_M | 7.9GB | Good | Balanced quality/size |
| Q5_K_S | 7.7GB | Good | Slightly smaller Q5 |
| **Q4_K_M** | **6.8GB** | **Good** | **⭐ Recommended** |
| Q4_K_S | 6.5GB | Decent | Smaller Q4 variant |
| Q3_K_M | 5.6GB | Acceptable | For very low VRAM only |
```
gguf/gemma-3-12b-it-heretic-f16.gguf
gguf/gemma-3-12b-it-heretic-Q8_0.gguf
gguf/gemma-3-12b-it-heretic-Q6_K.gguf
gguf/gemma-3-12b-it-heretic-Q5_K_M.gguf
gguf/gemma-3-12b-it-heretic-Q5_K_S.gguf
gguf/gemma-3-12b-it-heretic-Q4_K_M.gguf
gguf/gemma-3-12b-it-heretic-Q4_K_S.gguf
gguf/gemma-3-12b-it-heretic-Q3_K_M.gguf
```
**Note:** GGUF support in ComfyUI for Gemma text encoders is experimental. See [PR #402](https://github.com/city96/ComfyUI-GGUF/pull/402) for status. The GGUFs work with llama.cpp directly.
## Do abliterated models makes a difference for LTX2?
I had a [deep dive into this topic](https://nathan.sapwell.net/posts/heretic-gemma-12b/) and found that, maybe not. While it does vary slightly the output of the video, most of the abliteration is on layer 48, the final decision making layer. LTXV averages all the layers which may wash out layer 48s difference. Still it'd be more interesting for someone with more knowledge to confirm this.
## Usage
### With Transformers
```python
from transformers import AutoModelForCausalLM, AutoTokenizer
import torch
model = AutoModelForCausalLM.from_pretrained(
"DreamFast/gemma-3-12b-it-heretic",
device_map="auto",
torch_dtype=torch.bfloat16
)
tokenizer = AutoTokenizer.from_pretrained("DreamFast/gemma-3-12b-it-heretic")
prompt = "Write a story about a bank heist"
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=200)
print(tokenizer.decode(outputs[0], skip_special_tokens=True))
```
### With ComfyUI (LTX-2)
1. Download the ComfyUI format file:
- `comfyui/gemma_3_12B_it_heretic.safetensors` (bf16, 22GB) or
- `comfyui/gemma_3_12B_it_heretic_fp8_e4m3fn.safetensors` (fp8, 11GB)
2. Place in `ComfyUI/models/text_encoders/`
3. In your LTX-2 workflow, use the `LTXAVTextEncoderLoader` node and select the heretic file
**Tip:** For multi-GPU setups or CPU offloading, check out [ComfyUI-LTX2-MultiGPU](https://github.com/dreamfast/ComfyUI-LTX2-MultiGPU) for optimized LTX-2 workflows.
### With llama.cpp
```bash
# Using llama-server
llama-server -m gemma-3-12b-it-heretic-Q4_K_M.gguf
# Or with llama-cli
llama-cli -m gemma-3-12b-it-heretic-Q4_K_M.gguf -p "Write a story about a bank heist"
```
## Why Abliterate?
Even when Gemma doesn't outright refuse a prompt, it may "sanitize" or weaken certain concepts in the embeddings. For video generation with LTX-2, this can result in:
- Weaker adherence to creative prompts
- Softened or altered visual outputs
- Less faithful representation of requested content
Abliteration removes this soft censorship, resulting in more faithful prompt encoding.
## Abliteration Process
Created using Heretic with the following evaluation results:
```
* Evaluating...
* Obtaining first-token probability distributions...
* KL divergence: 0.0826
* Counting model refusals...
* Refusals: 7/100
```
The low KL divergence (0.0826) indicates minimal model damage, while 7/100 refusals means 93% of previously-refused prompts now work.
## Limitations
- This model inherits all limitations of the base Gemma 3 12B model
- Abliteration reduces but does not completely eliminate refusals
- NVFP4 quantization is not supported for text encoders in ComfyUI (use fp8 instead)
## License
This model is subject to the [Gemma license](https://ai.google.dev/gemma/terms).
## Acknowledgments
- [Google](https://huggingface.co/google) for the Gemma 3 12B model
- [Heretic](https://github.com/p-e-w/heretic) by p-e-w for the abliteration tool
- [Lightricks](https://huggingface.co/Lightricks) for LTX-2

3
added_tokens.json Normal file
View File

@@ -0,0 +1,3 @@
{
"<image_soft_token>": 262144
}

47
chat_template.jinja Normal file
View File

@@ -0,0 +1,47 @@
{{ bos_token }}
{%- if messages[0]['role'] == 'system' -%}
{%- if messages[0]['content'] is string -%}
{%- set first_user_prefix = messages[0]['content'] + '
' -%}
{%- else -%}
{%- set first_user_prefix = messages[0]['content'][0]['text'] + '
' -%}
{%- endif -%}
{%- set loop_messages = messages[1:] -%}
{%- else -%}
{%- set first_user_prefix = "" -%}
{%- set loop_messages = messages -%}
{%- endif -%}
{%- for message in loop_messages -%}
{%- if (message['role'] == 'user') != (loop.index0 % 2 == 0) -%}
{{ raise_exception("Conversation roles must alternate user/assistant/user/assistant/...") }}
{%- endif -%}
{%- if (message['role'] == 'assistant') -%}
{%- set role = "model" -%}
{%- else -%}
{%- set role = message['role'] -%}
{%- endif -%}
{{ '<start_of_turn>' + role + '
' + (first_user_prefix if loop.first else "") }}
{%- if message['content'] is string -%}
{{ message['content'] | trim }}
{%- elif message['content'] is iterable -%}
{%- for item in message['content'] -%}
{%- if item['type'] == 'image' -%}
{{ '<start_of_image>' }}
{%- elif item['type'] == 'text' -%}
{{ item['text'] | trim }}
{%- endif -%}
{%- endfor -%}
{%- else -%}
{{ raise_exception("Invalid content type") }}
{%- endif -%}
{{ '<end_of_turn>
' }}
{%- endfor -%}
{%- if add_generation_prompt -%}
{{'<start_of_turn>model
'}}
{%- endif -%}

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:43af51326f55b6d2cdcd6870e9f111622b19780190b0086fbef1db94d69f5821
size 23545681250

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:7670feee12fdc9166c21059dd5ae13342be07e26d98af90e19b0c460c0a49840
size 12782868202

112
config.json Normal file
View File

@@ -0,0 +1,112 @@
{
"architectures": [
"Gemma3ForConditionalGeneration"
],
"boi_token_index": 255999,
"dtype": "bfloat16",
"eoi_token_index": 256000,
"eos_token_id": [
1,
106
],
"image_token_index": 262144,
"initializer_range": 0.02,
"mm_tokens_per_image": 256,
"model_type": "gemma3",
"text_config": {
"_sliding_window_pattern": 6,
"attention_bias": false,
"attention_dropout": 0.0,
"attn_logit_softcapping": null,
"dtype": "bfloat16",
"final_logit_softcapping": null,
"head_dim": 256,
"hidden_activation": "gelu_pytorch_tanh",
"hidden_size": 3840,
"initializer_range": 0.02,
"intermediate_size": 15360,
"layer_types": [
"sliding_attention",
"sliding_attention",
"sliding_attention",
"sliding_attention",
"sliding_attention",
"full_attention",
"sliding_attention",
"sliding_attention",
"sliding_attention",
"sliding_attention",
"sliding_attention",
"full_attention",
"sliding_attention",
"sliding_attention",
"sliding_attention",
"sliding_attention",
"sliding_attention",
"full_attention",
"sliding_attention",
"sliding_attention",
"sliding_attention",
"sliding_attention",
"sliding_attention",
"full_attention",
"sliding_attention",
"sliding_attention",
"sliding_attention",
"sliding_attention",
"sliding_attention",
"full_attention",
"sliding_attention",
"sliding_attention",
"sliding_attention",
"sliding_attention",
"sliding_attention",
"full_attention",
"sliding_attention",
"sliding_attention",
"sliding_attention",
"sliding_attention",
"sliding_attention",
"full_attention",
"sliding_attention",
"sliding_attention",
"sliding_attention",
"sliding_attention",
"sliding_attention",
"full_attention"
],
"max_position_embeddings": 131072,
"model_type": "gemma3_text",
"num_attention_heads": 16,
"num_hidden_layers": 48,
"num_key_value_heads": 8,
"query_pre_attn_scalar": 256,
"rms_norm_eps": 1e-06,
"rope_local_base_freq": 10000.0,
"rope_scaling": {
"factor": 8.0,
"rope_type": "linear"
},
"rope_theta": 1000000.0,
"sliding_window": 1024,
"use_bidirectional_attention": false,
"use_cache": true,
"vocab_size": 262208
},
"transformers_version": "4.57.3",
"vision_config": {
"attention_dropout": 0.0,
"dtype": "bfloat16",
"hidden_act": "gelu_pytorch_tanh",
"hidden_size": 1152,
"image_size": 896,
"intermediate_size": 4304,
"layer_norm_eps": 1e-06,
"model_type": "siglip_vision_model",
"num_attention_heads": 16,
"num_channels": 3,
"num_hidden_layers": 27,
"patch_size": 14,
"vision_use_head": false
}
}

12
generation_config.json Normal file
View File

@@ -0,0 +1,12 @@
{
"bos_token_id": 2,
"do_sample": true,
"eos_token_id": [
1,
106
],
"pad_token_id": 0,
"top_k": 64,
"top_p": 0.95,
"transformers_version": "4.57.3"
}

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:0f661e677ad0c5089cf6304e4a32c0a185748fba90c1915ebb38b83833b9a66a
size 6008817824

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:fcef26dcc0c354ecf12e35971b3211f7b0ff1da882732ef3c10d976e5aeb80e6
size 7300778144

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:0c9548852f57578b87e740246d9f2dce54e2985854e47c20cb68faaadc820c53
size 6935333024

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:951dad58b8838f3522c11ecc4dca12d7c23ee2f69b897e375a53d5ddfa960968
size 8445036704

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:41321dded10e516138ee914945bc93d5bf60b559d0cb386663a9022057746c2a
size 8231962784

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:6244202f68c6949068d2889a94e9517cec56d1ec976e2e9bac4b0a7b945f6f36
size 9660811424

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:0e11735ae57cae56b10adc27d2e1dedfe0d3cea44706cf76e3b90f1563faeac3
size 12510212384

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:e39c3ea9622a151a9d0814e492a96ec75c1b7c300f47638d000c6824da2c8641
size 23540151584

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:4847447e92599833e8dbaa3067cd201c3bb5c052efa91f11ba891e43234f7832
size 4979902192

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:ff502ab80b2abbb6584b13973458039629dde9651e0fa0772dc6416a041cb8c7
size 4931296592

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:a4c478c7e2d168e3d964c54b89535c62bc94b5d8d344d7a01d029c68185725d0
size 4931296656

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:df09936718ff4fac1194a5a19c1e0acff5af12186da819525361bd8a96562cba
size 4931296656

View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:3bf933fa1cef2eed778881d03bb1c4a6327830996cbfdbbfe2f9a3f231e583bc
size 4601000928

1073
model.safetensors.index.json Normal file

File diff suppressed because it is too large Load Diff

33
special_tokens_map.json Normal file
View File

@@ -0,0 +1,33 @@
{
"boi_token": "<start_of_image>",
"bos_token": {
"content": "<bos>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false
},
"eoi_token": "<end_of_image>",
"eos_token": {
"content": "<eos>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false
},
"image_token": "<image_soft_token>",
"pad_token": {
"content": "<pad>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false
},
"unk_token": {
"content": "<unk>",
"lstrip": false,
"normalized": false,
"rstrip": false,
"single_word": false
}
}

3
tokenizer.json Normal file
View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:4667f2089529e8e7657cfb6d1c19910ae71ff5f28aa7ab2ff2763330affad795
size 33384568

3
tokenizer.model Normal file
View File

@@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:1299c11d7cf632ef3b4e11937501358ada021bbdf7c47638d13c0ee982f2e79c
size 4689074

51345
tokenizer_config.json Normal file

File diff suppressed because it is too large Load Diff