Instructions to use FredyRivera-dev/diffusiongemma-26B-A4B-it-HERETIC-Uncensored with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use FredyRivera-dev/diffusiongemma-26B-A4B-it-HERETIC-Uncensored with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="FredyRivera-dev/diffusiongemma-26B-A4B-it-HERETIC-Uncensored") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("FredyRivera-dev/diffusiongemma-26B-A4B-it-HERETIC-Uncensored") model = AutoModelForMultimodalLM.from_pretrained("FredyRivera-dev/diffusiongemma-26B-A4B-it-HERETIC-Uncensored") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use FredyRivera-dev/diffusiongemma-26B-A4B-it-HERETIC-Uncensored with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "FredyRivera-dev/diffusiongemma-26B-A4B-it-HERETIC-Uncensored" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "FredyRivera-dev/diffusiongemma-26B-A4B-it-HERETIC-Uncensored", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/FredyRivera-dev/diffusiongemma-26B-A4B-it-HERETIC-Uncensored
- SGLang
How to use FredyRivera-dev/diffusiongemma-26B-A4B-it-HERETIC-Uncensored with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "FredyRivera-dev/diffusiongemma-26B-A4B-it-HERETIC-Uncensored" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "FredyRivera-dev/diffusiongemma-26B-A4B-it-HERETIC-Uncensored", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "FredyRivera-dev/diffusiongemma-26B-A4B-it-HERETIC-Uncensored" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "FredyRivera-dev/diffusiongemma-26B-A4B-it-HERETIC-Uncensored", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use FredyRivera-dev/diffusiongemma-26B-A4B-it-HERETIC-Uncensored with Docker Model Runner:
docker model run hf.co/FredyRivera-dev/diffusiongemma-26B-A4B-it-HERETIC-Uncensored
Note: All credit to edwixx/diffusiongemma-26B-A4B-it-HERETIC-Uncensored, this repo only includes the processor_config.json
diffusiongemma-26B-A4B-it-HERETIC-Uncensored
26.6B params · 4B active · MoE · Diffusion · Apache-2.0 ·
This is the first abliteration of DiffusionGemma 26B A4B, produced using heretic with custom patches to support its block-diffusion architecture and MoE expert layers.
DiffusionGemma is not a standard autoregressive transformer, so this required significant engineering work that hasn't been done before for this model class.
Usage
Load using the DiffusionGemmaForBlockDiffusion class directly, not AutoModelForCausalLM:
import torch
from transformers import AutoProcessor
from transformers.models.diffusion_gemma import DiffusionGemmaForBlockDiffusion
model_id = "FredyRivera-dev/diffusiongemma-26B-A4B-it-HERETIC-Uncensored"
processor = AutoProcessor.from_pretrained(model_id)
model = DiffusionGemmaForBlockDiffusion.from_pretrained(
model_id,
torch_dtype=torch.bfloat16,
).to("cuda")
messages = [
{"role": "user", "content": "Hola, como estas?"}
]
inputs = processor.apply_chat_template(messages,
tokenize=True,
add_generation_prompt=True,
return_dict=True,
return_tensors="pt").to("cuda")
out = model.generate(**inputs, max_new_tokens=200)
response = processor.decode(out.sequences[0], skip_special_tokens=True)
print(response)
Multimodal Input
import torch
from transformers import AutoProcessor
from transformers.models.diffusion_gemma import DiffusionGemmaForBlockDiffusion
from PIL import Image
model_id = "FredyRivera-dev/diffusiongemma-26B-A4B-it-HERETIC-Uncensored"
processor = AutoProcessor.from_pretrained(model_id)
model = DiffusionGemmaForBlockDiffusion.from_pretrained(
model_id,
torch_dtype=torch.bfloat16,
).to("cuda")
image = Image.open("web.png")
messages = [
{"role": "user", "content":
[
{"type": "text", "text": "Create the HTML code for the web page shown in the following image."},
{"type": "image", "image": image}
]
}
]
inputs = processor.apply_chat_template(messages,
tokenize=True,
add_generation_prompt=True,
return_dict=True,
return_tensors="pt").to("cuda")
out = model.generate(**inputs, max_new_tokens=12288)
response = processor.decode(out.sequences[0], skip_special_tokens=True)
print(response)
Results
| Base model | google/diffusiongemma-26B-A4B-it |
| Method | Heretic (directional ablation + LoRA + Optuna TPE) |
| Trials run | 200 |
| Best trial | #89 |
| Refusals | 13/100 (down from 100/100) |
| KL Divergence | 0.4909 |
What had to be patched
Heretic assumes standard autoregressive models. DiffusionGemma needed several custom changes:
Expert-Granular Abliteration (EGA): The MoE experts.down_proj is a batched parameter [128, 2816, 704], not a regular linear layer. Heretic skips it by default. We iterate over all 128 expert slices per layer and apply norm-preserving biprojected ablation to each one. Without this, refusals barely moved. Credit to TrevorS for the original EGA idea on Gemma 4.
Weight tying fix: The encoder and decoder share the exact same weight tensors (confirmed via data_ptr). PEFT only wraps the encoder side, so the decoder wouldn't see the LoRA delta during generation. Fixed with a context manager that temporarily merges the LoRA into the shared base weights before each generation call.
Task type: DiffusionGemma's generation mixin doesn't implement prepare_inputs_for_generation, which the default CAUSAL_LM PEFT task type requires. Switched to FEATURE_EXTRACTION.
Hidden states: DiffusionGemma's generate() doesn't support output_hidden_states. Switched to forward hooks on encoder layers to capture per-layer activations for the refusal direction PCA.
Output handling: The model returns DiffusionGemmaGenerationOutput with a .sequences attribute, not a raw tensor like standard models. Patched all heretic output handling.
Notes
This is a research release. The model will attempt to answer prompts it previously refused. 13/100 sensitive prompts still trigger refusals in testing.
Known issue: "own" tokens
Some token positions in generated outputs show the word "own" where other content was expected.
Example output:
"It pulls the own with own hands" (should be "It pulls the tide with gentle hands")
Initially assumed to be a diffusion denoising fallback, but kabachuha pointed out this artifact shows up in base autoregressive Gemma4 models too when weights are pushed hard (e.g. overfit LoRA training). Likely a Gemma4-level placeholder token, not specific to the diffusion architecture. A small LoRA fine-tune on clean data would probably reduce it. PRs welcome.
Citation
@misc{edwixx-diffusiongemma-26B-A4B-it-HERETIC-Uncensored,
author = {Anurag Kanade},
title = {diffusiongemma-26B-A4B-it-HERETIC-Uncensored},
year = {2026},
publisher = {Hugging Face},
journal = {Hugging Face Hub},
howpublished = {\url{https://huggingface.co/edwixx/diffusiongemma-26B-A4B-it-HERETIC-Uncensored}}
}
- Downloads last month
- 108
Model tree for FredyRivera-dev/diffusiongemma-26B-A4B-it-HERETIC-Uncensored
Base model
google/diffusiongemma-26B-A4B-it