Instructions to use dnotitia/Qwen3-4B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use dnotitia/Qwen3-4B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="dnotitia/Qwen3-4B") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("dnotitia/Qwen3-4B") model = AutoModelForCausalLM.from_pretrained("dnotitia/Qwen3-4B") 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]:])) - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use dnotitia/Qwen3-4B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "dnotitia/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": "dnotitia/Qwen3-4B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/dnotitia/Qwen3-4B
- SGLang
How to use dnotitia/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 "dnotitia/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": "dnotitia/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 "dnotitia/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": "dnotitia/Qwen3-4B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use dnotitia/Qwen3-4B with Docker Model Runner:
docker model run hf.co/dnotitia/Qwen3-4B
Update chat_template.jinja
Browse files- chat_template.jinja +11 -10
chat_template.jinja
CHANGED
|
@@ -30,9 +30,8 @@
|
|
| 30 |
{%- endif %}
|
| 31 |
{%- if (message.role == "user") or (message.role == "system" and not loop.first) %}
|
| 32 |
{{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }}
|
| 33 |
-
{%- elif message.role == "assistant"
|
| 34 |
-
{%
|
| 35 |
-
{%- set reasoning_content = '' -%}
|
| 36 |
{%- if message.reasoning_content is string %}
|
| 37 |
{%- set reasoning_content = message.reasoning_content %}
|
| 38 |
{%- else %}
|
|
@@ -41,16 +40,17 @@
|
|
| 41 |
{%- set content = content.split('</think>')[-1].lstrip('\n') %}
|
| 42 |
{%- endif %}
|
| 43 |
{%- endif %}
|
|
|
|
|
|
|
| 44 |
{%- if loop.index0 > ns.last_query_index %}
|
| 45 |
{%- if loop.last or (not loop.last and reasoning_content) %}
|
| 46 |
-
{{- '<
|
| 47 |
{%- else %}
|
| 48 |
-
{{-
|
| 49 |
{%- endif %}
|
| 50 |
{%- else %}
|
| 51 |
-
{{-
|
| 52 |
-
{%- endif
|
| 53 |
-
{% endgeneration %}
|
| 54 |
{%- if message.tool_calls %}
|
| 55 |
{%- for tool_call in message.tool_calls %}
|
| 56 |
{%- if (loop.first and content) or (not loop.first) %}
|
|
@@ -70,7 +70,8 @@
|
|
| 70 |
{{- '}\n</tool_call>' }}
|
| 71 |
{%- endfor %}
|
| 72 |
{%- endif %}
|
| 73 |
-
{{- '<|im_end|>
|
|
|
|
| 74 |
{%- elif message.role == "tool" %}
|
| 75 |
{%- if loop.first or (messages[loop.index0 - 1].role != "tool") %}
|
| 76 |
{{- '<|im_start|>user' }}
|
|
@@ -88,4 +89,4 @@
|
|
| 88 |
{%- if enable_thinking is defined and enable_thinking is false %}
|
| 89 |
{{- '<think>\n\n</think>\n\n' }}
|
| 90 |
{%- endif %}
|
| 91 |
-
{%- endif %}
|
|
|
|
| 30 |
{%- endif %}
|
| 31 |
{%- if (message.role == "user") or (message.role == "system" and not loop.first) %}
|
| 32 |
{{- '<|im_start|>' + message.role + '\n' + content + '<|im_end|>' + '\n' }}
|
| 33 |
+
{%- elif message.role == "assistant" %}
|
| 34 |
+
{%- set reasoning_content = '' %}
|
|
|
|
| 35 |
{%- if message.reasoning_content is string %}
|
| 36 |
{%- set reasoning_content = message.reasoning_content %}
|
| 37 |
{%- else %}
|
|
|
|
| 40 |
{%- set content = content.split('</think>')[-1].lstrip('\n') %}
|
| 41 |
{%- endif %}
|
| 42 |
{%- endif %}
|
| 43 |
+
{{- '<|im_start|>' + message.role }}
|
| 44 |
+
{% generation %}
|
| 45 |
{%- if loop.index0 > ns.last_query_index %}
|
| 46 |
{%- if loop.last or (not loop.last and reasoning_content) %}
|
| 47 |
+
{{- '<think>\n' + reasoning_content.strip('\n') + '\n</think>\n\n' + content.lstrip('\n') }}
|
| 48 |
{%- else %}
|
| 49 |
+
{{- content }}
|
| 50 |
{%- endif %}
|
| 51 |
{%- else %}
|
| 52 |
+
{{- content }}
|
| 53 |
+
{%- endif %}
|
|
|
|
| 54 |
{%- if message.tool_calls %}
|
| 55 |
{%- for tool_call in message.tool_calls %}
|
| 56 |
{%- if (loop.first and content) or (not loop.first) %}
|
|
|
|
| 70 |
{{- '}\n</tool_call>' }}
|
| 71 |
{%- endfor %}
|
| 72 |
{%- endif %}
|
| 73 |
+
{{- '<|im_end|>' }}
|
| 74 |
+
{% endgeneration %}
|
| 75 |
{%- elif message.role == "tool" %}
|
| 76 |
{%- if loop.first or (messages[loop.index0 - 1].role != "tool") %}
|
| 77 |
{{- '<|im_start|>user' }}
|
|
|
|
| 89 |
{%- if enable_thinking is defined and enable_thinking is false %}
|
| 90 |
{{- '<think>\n\n</think>\n\n' }}
|
| 91 |
{%- endif %}
|
| 92 |
+
{%- endif %}
|