Views
No views yet

transformers>=5.5.pip install -U "transformers>=5.5" accelerate torch flash-attn1import torch
2from transformers import AutoTokenizer, Qwen3_5ForConditionalGeneration
3
4MODEL = "choonok/VetJarvis-1.1-4B-Instruct"
5
6tokenizer = AutoTokenizer.from_pretrained(MODEL)
7model = Qwen3_5ForConditionalGeneration.from_pretrained(
8 MODEL,
9 dtype=torch.bfloat16,
10 device_map="auto",
11 attn_implementation="flash_attention_2",
12)
13model.eval()
14
15messages = [
16 {
17 "role": "system",
18 "content": "You are 'VetJarvis', a clinical-support AI assistant for veterinarians.",
19 },
20 {"role": "user", "content": "Please tell me the metronidazole protocol."},
21]
22
23text = tokenizer.apply_chat_template(
24 messages,
25 tokenize=False,
26 add_generation_prompt=True,
27 enable_thinking=True,
28)
29
30inputs = tokenizer(text, return_tensors="pt").to(model.device)
31
32with torch.no_grad():
33 outputs = model.generate(
34 **inputs,
35 max_new_tokens=32768,
36 temperature=0.8,
37 top_p=0.9,
38 do_sample=True,
39 pad_token_id=tokenizer.eos_token_id,
40 )
41
42print(tokenizer.decode(
43 outputs[0][inputs.input_ids.shape[-1]:],
44 skip_special_tokens=True,
45))attn_implementation="sdpa".vllm>=0.18 supports the Qwen3.5 architecture, and the jointly trained MTP layer can be used for speculative decoding to improve throughput.pip install "vllm>=0.18"1vllm serve choonok/VetJarvis-1.1-4B-Instruct \
2 --served-model-name VetJarvis-1.1-4B-Instruct \
3 --port 8000 \
4 --max-model-len 65535 \
5 --dtype bfloat16 \
6 --gpu-memory-utilization 0.85 \
7 --speculative-config '{"method":"qwen3_next_mtp","num_speculative_tokens":2}'1from openai import OpenAI
2
3client = OpenAI(
4 base_url="http://localhost:8000/v1",
5 api_key="EMPTY",
6)
7
8response = client.chat.completions.create(
9 model="VetJarvis-1.1-4B-Instruct",
10 messages=[
11 {
12 "role": "system",
13 "content": "You are 'VetJarvis', a clinical-support AI assistant for veterinarians.",
14 },
15 {
16 "role": "user",
17 "content": "Please tell me the metronidazole protocol.",
18 },
19 ],
20 max_tokens=32768,
21 temperature=0.8,
22 top_p=0.9,
23 extra_body={
24 "chat_template_kwargs": {"enable_thinking": True},
25 },
26)
27
28print(response.choices[0].message.content)| Parameter | Value |
|---|---|
| Temperature | 0.8 |
| Top-p | 0.9 |
| max_new_tokens | 32,768 |
| enable_thinking | True (recommended) |
| Context length | ≤ 262,144 tokens |
think option enabled, version 1.1 addresses this limitation and delivers meaningful performance gains in think mode.