Instructions to use ttttonyhe/Qwen3-4B-Instruct-RETA-Base with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ttttonyhe/Qwen3-4B-Instruct-RETA-Base with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="ttttonyhe/Qwen3-4B-Instruct-RETA-Base") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("ttttonyhe/Qwen3-4B-Instruct-RETA-Base") model = AutoModelForCausalLM.from_pretrained("ttttonyhe/Qwen3-4B-Instruct-RETA-Base", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.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(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use ttttonyhe/Qwen3-4B-Instruct-RETA-Base with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ttttonyhe/Qwen3-4B-Instruct-RETA-Base" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ttttonyhe/Qwen3-4B-Instruct-RETA-Base", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/ttttonyhe/Qwen3-4B-Instruct-RETA-Base
- SGLang
How to use ttttonyhe/Qwen3-4B-Instruct-RETA-Base 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 "ttttonyhe/Qwen3-4B-Instruct-RETA-Base" \ --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": "ttttonyhe/Qwen3-4B-Instruct-RETA-Base", "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 "ttttonyhe/Qwen3-4B-Instruct-RETA-Base" \ --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": "ttttonyhe/Qwen3-4B-Instruct-RETA-Base", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use ttttonyhe/Qwen3-4B-Instruct-RETA-Base with Docker Model Runner:
docker model run hf.co/ttttonyhe/Qwen3-4B-Instruct-RETA-Base
Qwen3-4B-Instruct-RETA-Base
This checkpoint was initialized through supervised fine-tuning (SFT) to defend a tool-using agent against weak static prompt-injection attacks in AgentDojo. After each tool call, the model is trained to reason about whether the returned content aligns with the user's task, ignore conflicting instructions in the tool output, and continue the task.
This model is a fine-tuned version of Qwen/Qwen3-4B-Instruct-2507. It has been trained using TRL. Based on this checkpoint, we further trained it via a 250-step RL climb and then OPSD, the final checkpoint is available at https://huggingface.co/ttttonyhe/Qwen3-4B-Instruct-RETA, which has much higher robustness.
Quick start
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "ttttonyhe/defender_sft_qwen3_4b"
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(model_id, dtype="auto")
Training procedure
This model was trained with SFT.
Framework versions
- TRL: 0.27.0
- Transformers: 4.57.3
- Pytorch: 2.9.0
- Datasets: 4.5.0
- Tokenizers: 0.22.2
- Downloads last month
- 333
Model tree for ttttonyhe/Qwen3-4B-Instruct-RETA-Base
Base model
Qwen/Qwen3-4B-Instruct-2507