S5-nano-heretic

S5-nano-heretic is an uncensored, refusal-ablated checkpoint of maritaca-ai/S5-nano (Brazilian Portuguese-first multimodal model, Qwen3_5 hybrid backbone), produced with an adapted build of heretic v1.2.0 supporting hybrid convolution/attention architectures.

The ablation selectively removes refusal behavior from the language backbone while leaving the vision encoder, the multi-token-prediction (MTP) module, embeddings, and all linear-attention machinery untouched.

Metric / Property Specification
Base Model maritaca-ai/S5-nano
Total Weights 9.32 GB (BF16), 738 tensors
Ablation Framework Heretic 1.2.0 (hybrid Qwen3_5 layer patch)
Refusal Rate 3 / 100 on evaluation suite
KL Divergence 0.0408 (extreme fidelity to base model distribution)
Altered Tensors 33 / 738 (attn.o_proj ร— 7, mlp.down_proj ร— 26)
Untouched Tensors 705 / 738 (Vision, MTP, embeddings, linear-attention layers byte-identical)

Key Highlights

  • Surgical Language Ablation: Only residual-stream writers were modified โ€” attn.o_proj in 7 of the 9 full-attention layers (7, 11, 15, 19, 23, 27, 31) and mlp.down_proj in 26 of 32 feed-forward blocks (layers 6โ€“31).
  • Strict Multimodal Preservation: The vision encoder (deepstack indexes included), the MTP head, token embeddings, per-layer norms and all linear/conv attention projections are byte-for-byte identical to Maritaca AI's official release. 15 extra tensors were preserved verbatim from the source checkpoint (model-extra.safetensors).
  • Ultra-low KL Divergence: At KL = 0.0408 โ€” ~10ร— lower than the run's automatic Pareto pick โ€” standard reasoning, Portuguese/English fluency and conversational style are preserved with negligible drift.

Requirements & Installation

The qwen3_5 hybrid architecture requires modern Transformers (5.x line) with remote code enabled:

pip install "transformers>=4.57" torch accelerate soundfile

VRAM: ~9.5 GB for BF16 inference (fits comfortably on 12 GB GPUs; quantize with bnb_4bit for 8 GB cards).


Usage Examples

1. Text Chat / Generation

import torch
from transformers import AutoModelForImageTextToText, AutoTokenizer

model_id = "S5-nano-heretic"  # or your local / HF path

tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
model = AutoModelForImageTextToText.from_pretrained(
    model_id,
    dtype=torch.bfloat16,
    device_map="auto",
    trust_remote_code=True,
).eval()

messages = [
    {"role": "system", "content": "You are a helpful assistant."},
    {"role": "user", "content": "Escreva um conto criativo sobre uma sonda de IA autรดnoma."},
]

prompt = tokenizer.apply_chat_template(messages, add_generation_prompt=True, tokenize=False)
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)

with torch.no_grad():
    outputs = model.generate(**inputs, max_new_tokens=512)

response = tokenizer.decode(
    outputs[0, inputs["input_ids"].shape[1]:],
    skip_special_tokens=True,
)
print(response)

2. Image + Text (Vision) Input

import torch
from transformers import AutoModelForImageTextToText, AutoProcessor

model_id = "S5-nano-heretic"
device = "cuda" if torch.cuda.is_available() else "cpu"

model = AutoModelForImageTextToText.from_pretrained(
    model_id,
    dtype=torch.bfloat16,
    device_map=device,
    trust_remote_code=True,
).eval()
processor = AutoProcessor.from_pretrained(model_id, trust_remote_code=True)

conversation = [
    {"role": "user", "content": [
        {"type": "image", "image": "photo.jpg"},
        {"type": "text", "text": "Descreva esta imagem em detalhes."},
    ]},
]

inputs = processor.apply_chat_template(
    conversation,
    add_generation_prompt=True,
    tokenize=True,
    return_dict=True,
    return_tensors="pt",
).to(device)

with torch.no_grad():
    outputs = model.generate(**inputs, max_new_tokens=512)

print(processor.decode(outputs[0, inputs["input_ids"].shape[1]:], skip_special_tokens=True))

Default sampling follows the base model's generation_config.json (do_sample=True, temperature=1.0, top_p=0.95, top_k=20).


License & Attribution

  • Base Architecture & Weights: Maritaca AI โ€” S5-nano, Apache License 2.0 (see LICENSE).
  • Ablation Methodology: Powered by Heretic.
Downloads last month
117
Safetensors
Model size
5B params
Tensor type
BF16
ยท
Inference Providers NEW
This model isn't deployed by any Inference Provider. ๐Ÿ™‹ Ask for provider support

Model tree for rodrigomt/S5-nano-heretic

Finetuned
(3)
this model
Quantizations
1 model