Instructions to use AI45Research/ReSI-Safin-1-35B-A3B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use AI45Research/ReSI-Safin-1-35B-A3B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="AI45Research/ReSI-Safin-1-35B-A3B", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("AI45Research/ReSI-Safin-1-35B-A3B", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use AI45Research/ReSI-Safin-1-35B-A3B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "AI45Research/ReSI-Safin-1-35B-A3B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "AI45Research/ReSI-Safin-1-35B-A3B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/AI45Research/ReSI-Safin-1-35B-A3B
- SGLang
How to use AI45Research/ReSI-Safin-1-35B-A3B 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 "AI45Research/ReSI-Safin-1-35B-A3B" \ --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": "AI45Research/ReSI-Safin-1-35B-A3B", "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 "AI45Research/ReSI-Safin-1-35B-A3B" \ --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": "AI45Research/ReSI-Safin-1-35B-A3B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use AI45Research/ReSI-Safin-1-35B-A3B with Docker Model Runner:
docker model run hf.co/AI45Research/ReSI-Safin-1-35B-A3B
ReSI-Safin-1-35B-A3B
This repository contains the Safin-1 (35B-A3B) model after ReSI alignment, together with its inference code and tokenizer.
Quick start
Use Python 3.12 with a CUDA-enabled PyTorch installation. After downloading the repository, install the inference dependencies from requirements.txt:
pip install -r requirements.txt
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "AI45Research/ReSI-Safin-1-35B-A3B"
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(
model_id,
dtype=torch.bfloat16,
device_map="auto",
trust_remote_code=True,
attn_implementation="eager",
).eval()
messages = [{"role": "user", "content": "Explain why the sky is blue in three sentences."}]
text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
inputs = tokenizer(text, add_special_tokens=False, return_tensors="pt").to(
model.get_input_embeddings().weight.device
)
with torch.inference_mode():
outputs = model.generate(**inputs, max_new_tokens=8192)
print(tokenizer.decode(outputs[0, inputs.input_ids.shape[-1]:], skip_special_tokens=True))
Alternatively, run the included script for streaming output:
python inference.py --model . --prompt "Explain why the sky is blue in three sentences."
--model accepts a local model directory or the Hugging Face repository ID. Generation follows the saved defaults: temperature 1.0, top-p 0.95, and top-k 20. The script supports overrides and --greedy; --max-new-tokens defaults to 8,192 and can be increased for longer answers. The model may generate reasoning before its final answer.
Runtime
The verified loading path uses Transformers 5.5.4, BF16 weights, and eager attention. The weights occupy approximately 66.4 GiB; allow additional memory for inference. Keep the bundled Python files alongside the weights and enable trust_remote_code=True. Optional Flash Linear Attention and causal-conv1d packages are not required for this path.
Code and paper
Citation
If you use ReSI in your research, please cite:
@misc{zheng2026resirecursivesafetyimprovement,
title = {ReSI: Recursive Safety Improvement toward
Resistant and Resilient AI},
author = {Jingnan Zheng and Dongcheng Zhang and Yi Zhang and Ming Zhang
and Qiaosheng Zhang and Youbang Sun and An Zhang and Xiangnan He
and Tat-Seng Chua and Xia Hu and Bowen Zhou
and Chaochao Lu and Xiang Wang},
year = {2026},
eprint = {2610.12233},
archivePrefix = {arXiv},
primaryClass = {cs.CR},
url = {https://arxiv.org/abs/2610.12233}
}
- Downloads last month
- 79