Text Generation
Transformers
Safetensors
qwen3
diffusion
parallel-decoding
orthrus
conversational
custom_code
text-generation-inference
Instructions to use chiennv/Orthrus-Qwen3-4B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use chiennv/Orthrus-Qwen3-4B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="chiennv/Orthrus-Qwen3-4B", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("chiennv/Orthrus-Qwen3-4B", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("chiennv/Orthrus-Qwen3-4B", trust_remote_code=True) 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=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use chiennv/Orthrus-Qwen3-4B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "chiennv/Orthrus-Qwen3-4B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "chiennv/Orthrus-Qwen3-4B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/chiennv/Orthrus-Qwen3-4B
- SGLang
How to use chiennv/Orthrus-Qwen3-4B 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 "chiennv/Orthrus-Qwen3-4B" \ --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": "chiennv/Orthrus-Qwen3-4B", "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 "chiennv/Orthrus-Qwen3-4B" \ --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": "chiennv/Orthrus-Qwen3-4B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use chiennv/Orthrus-Qwen3-4B with Docker Model Runner:
docker model run hf.co/chiennv/Orthrus-Qwen3-4B
| library_name: transformers | |
| tags: | |
| - text-generation | |
| - diffusion | |
| - parallel-decoding | |
| - orthrus | |
| - qwen3 | |
| license: cc-by-4.0 | |
| pipeline_tag: text-generation | |
| # Orthrus-Qwen3-4B | |
| [**Paper**](https://arxiv.org/abs/2605.12825) | [**GitHub**](https://github.com/chiennv2000/orthrus) | |
| **Orthrus** is a simple and efficient dual-architecture framework that unifies the exact generation fidelity of autoregressive Large Language Models (LLMs) with the high-speed parallel token generation of diffusion models. By augmenting a frozen pre-trained LLM with a lightweight, trainable diffusion module, Orthrus delivers significantly accelerated inference without sacrificing output quality. | |
| <p align="center"> | |
| <img src="orthrus.png" width="80%" alt="Orthrus Dual-View Architecture"> | |
| </p> | |
| - **Repository:** [https://github.com/chiennv2000/orthrus](https://github.com/chiennv2000/orthrus) | |
| - **Architecture:** Dual-View Attention (Autoregressive Base + Parallel Diffusion Head) | |
| ## Key Features | |
| - **Significant Inference Acceleration:** Breaks the sequential bottleneck of standard autoregressive decoding, delivering up to a $7.8\times$ speedup on generation tasks. | |
| - **Strictly Lossless Generation:** Employs an exact intra-model consensus mechanism to guarantee that the output matches the original base model's exact predictive distribution. | |
| - **Zero Redundant Memory Overhead:** Both the autoregressive and diffusion views attend to the exact same high-fidelity Key-Value (KV) cache natively, resulting in only an $O(1)$ memory cache overhead. | |
| - **Parameter Efficient:** Parallel generation capabilities are injected by fine-tuning only 16% of the total model parameters while keeping the base LLM strictly frozen. | |
| ## Installation | |
| Ensure you have `transformers`, `torch`, and [flash-attention](https://github.com/dao-ailab/flash-attention) installed. We used `torch==2.10` and `transformers==5.8.0`. | |
| ## How to Get Started | |
| Use the following code to run inference with the model. Ensure your environment supports FlashAttention and you are passing `trust_remote_code=True` to load the custom Orthrus architecture. | |
| ```python | |
| from transformers import AutoModelForCausalLM, AutoTokenizer, TextStreamer | |
| import torch | |
| MODEL_PATH = "chiennv/Orthrus-Qwen3-4B" | |
| # Load the model and tokenizer | |
| model = AutoModelForCausalLM.from_pretrained( | |
| MODEL_PATH, | |
| dtype=torch.bfloat16, | |
| device_map="cuda", | |
| attn_implementation="flash_attention_2", # options: sdpa | eager | flash_attention_4 | |
| trust_remote_code=True # Note: trust_remote_code=True is required | |
| ).eval() | |
| tokenizer = AutoTokenizer.from_pretrained(MODEL_PATH) | |
| prompt = "Write a program to count the frequency of each word in a paragraph." | |
| messages = [ | |
| {"role": "system", "content": ""}, | |
| {"role": "user", "content": prompt} | |
| ] | |
| input_ids = tokenizer.apply_chat_template( | |
| messages, | |
| tokenize=True, | |
| enable_thinking=False, | |
| add_generation_prompt=True, | |
| return_tensors="pt", | |
| ).input_ids | |
| # Generate text natively utilizing parallel diffusion projection | |
| output_ids = model.generate( | |
| input_ids=input_ids.to(model.device), | |
| max_new_tokens=2048, | |
| use_diffusion_mode=True, | |
| streamer=TextStreamer(tokenizer, skip_prompt=True) # enable streaming | |
| ) | |
| ``` | |
| ## Citation | |
| If you find this model or architecture useful in your work, please cite the original paper: | |
| ```bibtex | |
| @misc{vannguyen2026orthrusmemoryefficientparalleltoken, | |
| title={Orthrus: Memory-Efficient Parallel Token Generation via Dual-View Diffusion}, | |
| author={Chien Van Nguyen and Chaitra Hegde and Van Cuong Pham and Ryan A. Rossi and Franck Dernoncourt and Thien Huu Nguyen}, | |
| year={2026}, | |
| eprint={2605.12825}, | |
| archivePrefix={arXiv}, | |
| primaryClass={cs.LG}, | |
| url={https://arxiv.org/abs/2605.12825}, | |
| } | |
| ``` |