Text Generation
Transformers
Safetensors
qwen3
diffusion
parallel-decoding
orthrus
conversational
custom_code
text-generation-inference
Instructions to use chiennv/Orthrus-Qwen3-8B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use chiennv/Orthrus-Qwen3-8B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="chiennv/Orthrus-Qwen3-8B", trust_remote_code=True) 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("chiennv/Orthrus-Qwen3-8B", trust_remote_code=True) model = AutoModelForCausalLM.from_pretrained("chiennv/Orthrus-Qwen3-8B", trust_remote_code=True, 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 chiennv/Orthrus-Qwen3-8B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "chiennv/Orthrus-Qwen3-8B" # 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-8B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/chiennv/Orthrus-Qwen3-8B
- SGLang
How to use chiennv/Orthrus-Qwen3-8B 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-8B" \ --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-8B", "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-8B" \ --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-8B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use chiennv/Orthrus-Qwen3-8B with Docker Model Runner:
docker model run hf.co/chiennv/Orthrus-Qwen3-8B
Upload OrthrusLM
Browse files- modeling_orthrus.py +17 -1
modeling_orthrus.py
CHANGED
|
@@ -12,6 +12,7 @@ from transformers import AutoTokenizer, TextStreamer
|
|
| 12 |
from transformers.generation import GenerationMixin
|
| 13 |
from transformers.modeling_outputs import BaseModelOutputWithPast, CausalLMOutputWithPast
|
| 14 |
from transformers.cache_utils import Cache, DynamicCache
|
|
|
|
| 15 |
|
| 16 |
from transformers.models.qwen3.modeling_qwen3 import (
|
| 17 |
Qwen3RotaryEmbedding as OrthrusRotaryEmbedding,
|
|
@@ -158,7 +159,10 @@ class OrthrusAttention(Qwen3Attention):
|
|
| 158 |
attn_output = fused_flex_attention(query_states, key_states, value_states, mask=flex_block_mask)
|
| 159 |
attn_output = attn_output.transpose(1, 2)
|
| 160 |
else:
|
| 161 |
-
attention_interface: Callable = ALL_ATTENTION_FUNCTIONS
|
|
|
|
|
|
|
|
|
|
| 162 |
attn_output, attn_weights = attention_interface(
|
| 163 |
self,
|
| 164 |
query_states,
|
|
@@ -291,9 +295,21 @@ class OrthrusModel(OrthrusPreTrainedModel):
|
|
| 291 |
causal_limit=causal_limit,
|
| 292 |
)
|
| 293 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 294 |
for decoder_layer in self.layers[: self.config.num_hidden_layers]:
|
| 295 |
hidden_states = decoder_layer(
|
| 296 |
hidden_states,
|
|
|
|
| 297 |
position_embeddings=position_embeddings,
|
| 298 |
position_ids=position_ids,
|
| 299 |
past_key_values=past_key_values,
|
|
|
|
| 12 |
from transformers.generation import GenerationMixin
|
| 13 |
from transformers.modeling_outputs import BaseModelOutputWithPast, CausalLMOutputWithPast
|
| 14 |
from transformers.cache_utils import Cache, DynamicCache
|
| 15 |
+
from transformers.masking_utils import create_causal_mask
|
| 16 |
|
| 17 |
from transformers.models.qwen3.modeling_qwen3 import (
|
| 18 |
Qwen3RotaryEmbedding as OrthrusRotaryEmbedding,
|
|
|
|
| 159 |
attn_output = fused_flex_attention(query_states, key_states, value_states, mask=flex_block_mask)
|
| 160 |
attn_output = attn_output.transpose(1, 2)
|
| 161 |
else:
|
| 162 |
+
attention_interface: Callable = ALL_ATTENTION_FUNCTIONS.get_interface(
|
| 163 |
+
self.config._attn_implementation, eager_attention_forward
|
| 164 |
+
)
|
| 165 |
+
|
| 166 |
attn_output, attn_weights = attention_interface(
|
| 167 |
self,
|
| 168 |
query_states,
|
|
|
|
| 295 |
causal_limit=causal_limit,
|
| 296 |
)
|
| 297 |
|
| 298 |
+
if is_diffusion_pass or self.config._attn_implementation not in ["eager", "sdpa"]:
|
| 299 |
+
causal_mask = attention_mask
|
| 300 |
+
else:
|
| 301 |
+
causal_mask = create_causal_mask(
|
| 302 |
+
config=self.config,
|
| 303 |
+
inputs_embeds=inputs_embeds,
|
| 304 |
+
attention_mask=attention_mask,
|
| 305 |
+
past_key_values=past_key_values,
|
| 306 |
+
position_ids=position_ids,
|
| 307 |
+
)
|
| 308 |
+
|
| 309 |
for decoder_layer in self.layers[: self.config.num_hidden_layers]:
|
| 310 |
hidden_states = decoder_layer(
|
| 311 |
hidden_states,
|
| 312 |
+
attention_mask=causal_mask,
|
| 313 |
position_embeddings=position_embeddings,
|
| 314 |
position_ids=position_ids,
|
| 315 |
past_key_values=past_key_values,
|