Instructions to use pottokao/MOSS-Image-Text-Encoder-Heretic with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use pottokao/MOSS-Image-Text-Encoder-Heretic with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="pottokao/MOSS-Image-Text-Encoder-Heretic") 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)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("pottokao/MOSS-Image-Text-Encoder-Heretic") model = AutoModelForMultimodalLM.from_pretrained("pottokao/MOSS-Image-Text-Encoder-Heretic", device_map="auto") 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=256) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use pottokao/MOSS-Image-Text-Encoder-Heretic with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "pottokao/MOSS-Image-Text-Encoder-Heretic" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "pottokao/MOSS-Image-Text-Encoder-Heretic", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/pottokao/MOSS-Image-Text-Encoder-Heretic
- SGLang
How to use pottokao/MOSS-Image-Text-Encoder-Heretic 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 "pottokao/MOSS-Image-Text-Encoder-Heretic" \ --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": "pottokao/MOSS-Image-Text-Encoder-Heretic", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'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 "pottokao/MOSS-Image-Text-Encoder-Heretic" \ --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": "pottokao/MOSS-Image-Text-Encoder-Heretic", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use pottokao/MOSS-Image-Text-Encoder-Heretic with Docker Model Runner:
docker model run hf.co/pottokao/MOSS-Image-Text-Encoder-Heretic
MOSS-Image Text Encoder — Heretic (Qwen3.5-9B)
A decensored Qwen3.5-9B, made to be the text encoder and the prompt enhancer of MOSS-Image.
MOSS-Image's text encoder is the stock Qwen/Qwen3.5-9B — we checked: its weights are
byte-identical to the official release (only lm_head and the MTP head are left out). Because the
encoder is a complete chat model, one copy can both rewrite a short idea into a full caption and
then encode that caption for the DiT. The official ComfyUI MOSS-Image template already does this
with a w4a8 copy. The stock model, however, refuses or quietly softens many adult requests, and in that
setup the refusal text itself gets encoded and rendered.
This repo is the same model with refusals removed by Heretic (ARA modifier), merged into the weights. Everything else is untouched.
What changed
- Only 32 tensors differ from
Qwen/Qwen3.5-9B:mlp.down_proj,linear_attn.out_projandself_attn.o_projin decoder layers 15–31 (median relative change 11%). - Every other tensor is bit-identical to the original, including
lm_head, the MTP head (usable for speculative decoding) and the vision tower. heretic_merge_info.jsonlists every changed tensor and its relative change.
Numbers
Measured with thinking off (<think></think> prefix), which is how a prompt enhancer runs.
| Refusals (Heretic, 100 prompts) | KL vs original (first token) | |
|---|---|---|
| Qwen3.5-9B | 100/100 | 0 |
| This model | 2/100 | 0.050 |
Keyword counts can be gamed by off-topic answers, so we also had gemma-4-12b judge 60 answers from
mlabonne/harmful_behaviors (greedy, thinking off, up to 1024 tokens):
| Full | Partial | Deflect | Refuse | |
|---|---|---|---|---|
| Qwen3.5-9B | 0 | 0 | 8 | 52 |
| This model | 37 | 1 | 19 | 3 |
As a MOSS-Image prompt enhancer (official Prompt Enhancer skill as the system prompt, 10 explicit adult-sex requests, thinking off): the stock model refused 6/10; this model refused 0/10.
Caveats
- Thinking on was not measured. Use it with thinking off, as a prompt enhancer does.
- The merged weights shift the encoder slightly. If you only need encoding, the stock encoder is the reference; we are still comparing images from both.
- 19/60 judged answers still deflect. Prompts may occasionally be softened.
Search
Distributed Heretic search (3 machines, ~4.5 h, 3 automatic search-box adjustments, 413 trials). Selected trial: refusals 1/100 @ KL 0.048 in search, chosen over a 0/100 trial whose low count came mostly from off-topic answers (judge: 18 full / 39 deflect).
Parameters: start layer 15, end layer 31, preserve weight 0.392, steer weight 4.1e-4, overcorrect 0.988, neighbors 10, LoRA rank 50 (merged at scale 1.0).
Use responsibly
Adults only. Do not use this to depict minors or age-ambiguous people, non-consensual acts, or real people without their consent. You are responsible for complying with the law where you live.
License
Apache-2.0, same as Qwen3.5-9B.
- Downloads last month
- 24