Instructions to use rodrigomt/S5-nano-heretic with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use rodrigomt/S5-nano-heretic with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="rodrigomt/S5-nano-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("rodrigomt/S5-nano-heretic") model = AutoModelForMultimodalLM.from_pretrained("rodrigomt/S5-nano-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 rodrigomt/S5-nano-heretic with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "rodrigomt/S5-nano-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": "rodrigomt/S5-nano-heretic", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/rodrigomt/S5-nano-heretic
- SGLang
How to use rodrigomt/S5-nano-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 "rodrigomt/S5-nano-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": "rodrigomt/S5-nano-heretic", "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 "rodrigomt/S5-nano-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": "rodrigomt/S5-nano-heretic", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use rodrigomt/S5-nano-heretic with Docker Model Runner:
docker model run hf.co/rodrigomt/S5-nano-heretic
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_projin 7 of the 9 full-attention layers (7, 11, 15, 19, 23, 27, 31) andmlp.down_projin 26 of 32 feed-forward blocks (layers 6โ31). - Strict Multimodal Preservation: The vision encoder (
deepstackindexes 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