Run this model with HF Jobs
Run trl-internal-testing/tiny-Qwen4MoeForConditionalGeneration on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs and TRL to fine-tune https://huggingface.co/trl-internal-testing/tiny-Qwen4MoeForConditionalGeneration. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/trl-internal-testing/tiny-Qwen4MoeForConditionalGeneration on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Evaluate on a benchmark
Use HF Jobs to evaluate https://huggingface.co/trl-internal-testing/tiny-Qwen4MoeForConditionalGeneration. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
Quantize for lower memory use
Use HF Jobs to create a 4-bit version of https://huggingface.co/trl-internal-testing/tiny-Qwen4MoeForConditionalGeneration. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.
Instructions to use trl-internal-testing/tiny-Qwen4MoeForConditionalGeneration with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use trl-internal-testing/tiny-Qwen4MoeForConditionalGeneration with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-text-to-text", model="trl-internal-testing/tiny-Qwen4MoeForConditionalGeneration") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModelForMultimodalLM processor = AutoProcessor.from_pretrained("trl-internal-testing/tiny-Qwen4MoeForConditionalGeneration") model = AutoModelForMultimodalLM.from_pretrained("trl-internal-testing/tiny-Qwen4MoeForConditionalGeneration", device_map="auto") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.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(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use trl-internal-testing/tiny-Qwen4MoeForConditionalGeneration with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "trl-internal-testing/tiny-Qwen4MoeForConditionalGeneration" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "trl-internal-testing/tiny-Qwen4MoeForConditionalGeneration", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'Use Docker
docker model run hf.co/trl-internal-testing/tiny-Qwen4MoeForConditionalGeneration
- SGLang
How to use trl-internal-testing/tiny-Qwen4MoeForConditionalGeneration 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 "trl-internal-testing/tiny-Qwen4MoeForConditionalGeneration" \ --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": "trl-internal-testing/tiny-Qwen4MoeForConditionalGeneration", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }'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 "trl-internal-testing/tiny-Qwen4MoeForConditionalGeneration" \ --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": "trl-internal-testing/tiny-Qwen4MoeForConditionalGeneration", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Describe this image in one sentence." }, { "type": "image_url", "image_url": { "url": "https://cdn.britannica.com/61/93061-050-99147DCE/Statue-of-Liberty-Island-New-York-Bay.jpg" } } ] } ] }' - Docker Model Runner
How to use trl-internal-testing/tiny-Qwen4MoeForConditionalGeneration with Docker Model Runner:
docker model run hf.co/trl-internal-testing/tiny-Qwen4MoeForConditionalGeneration
File size: 11,670 Bytes
09d8f17 0e09f18 09d8f17 0e09f18 09d8f17 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 | {#- Qwen4 Jinja chat template for compatibility only. Deliberate omissions:
- tool-result ordering is limited to text-only runs with explicit tool_call_id.
Media runs keep input order: HF collects media before rendering this template.
Missing/null tool_call_id never falls back to id: newer HF versions strip null
fields before rendering, so these cases cannot be distinguished here.
For full Python ordering semantics, reorder messages before media collection.
- tool_calls[].function.arguments is only read as a dict; other types cause exceptions.
- no anti-injection: the encoder tokenizes data with allow_special=false, so message
text can never become a control token. A flat string cannot express that, and
re-tokenizing it does not reproduce the encoder's token ids -- use the Qwen4
tokenizer's apply_chat_template(tokenize=True) for exact ids.
- the generation blocks (return_assistant_tokens_mask) cover a whole assistant
body; the encoder additionally masks out media placeholders inside it.
-#}
{%- macro render_content(content) -%}
{%- if content is string -%}
{{- content -}}
{%- elif content is iterable and content is not mapping -%}
{%- for item in content -%}
{%- if item is string -%}
{{- item -}}
{%- elif item.get('type') == 'text' -%}
{{- item.get('text', '') | default('', true) -}}
{%- elif item.get('type') in ('image', 'image_url') -%}
{{- '<|vision_start|><|image_pad|><|vision_end|>' -}}
{%- elif item.get('type') in ('video', 'video_url') -%}
{{- '<|vision_start|><|video_pad|><|vision_end|>' -}}
{%- elif item.get('type') in ('audio', 'audio_url') -%}
{{- '<|audio_start|><|audio_pad|><|audio_end|>' -}}
{%- else -%}
{{- raise_exception('Unexpected content part type ' ~ item.get('type') ~ '. Supported types are text, image, image_url, video, video_url, audio and audio_url.') -}}
{%- endif -%}
{%- endfor -%}
{%- elif content is not none -%}
{{- content | tojson -}}
{%- endif -%}
{%- endmacro -%}
{%- macro render_reasoning(reasoning) -%}
{%- if reasoning is string -%}
{{- reasoning -}}
{%- elif reasoning is iterable and reasoning is not mapping -%}
{%- for item in reasoning -%}
{%- if item is string -%}
{{- item -}}
{%- elif item.get('type') in (none, 'text') -%}
{{- item.get('text', '') | default('', true) -}}
{%- else -%}
{{- item | tojson -}}
{%- endif -%}
{%- endfor -%}
{%- elif reasoning is not none -%}
{{- reasoning | tojson -}}
{%- endif -%}
{%- endmacro -%}
{%- macro render_tools(tools) -%}
{{- '# Tools\n\nYou may call one or more functions to assist with the user query.\n\nYou are provided with function signatures within <tools></tools> XML tags:\n<tools>\n' -}}
{%- for tool in tools -%}
{%- if tool is not mapping -%}
{{- raise_exception('Unexpected tool spec ' ~ tool ~ '. Expected a function schema dict.') -}}
{%- elif tool.get('type') == 'function' and 'function' in tool -%}
{{- tool | tojson -}}
{%- elif 'function' in tool -%}
{{- ({'type': 'function', 'function': tool['function']}) | tojson -}}
{%- else -%}
{{- ({'type': 'function', 'function': tool}) | tojson -}}
{%- endif -%}
{{- '\n' -}}
{%- endfor -%}
{{- '</tools>\n\nIf you choose to call a function, use exactly this format:\n' -}}
{{- '<tool_call>\n<function={function-name}>\n<parameter={parameter-name}>\n{parameter-value}\n</parameter>\n</function>\n</tool_call>' -}}
{%- endmacro -%}
{%- macro render_tool_calls(tool_calls) -%}
{%- for tool_call in tool_calls -%}
{%- if tool_call.function is mapping -%}
{%- set name = tool_call.function.get('name', '') -%}
{%- set arguments = tool_call.function.get('arguments') -%}
{%- else -%}
{%- set name = tool_call.get('name', '') -%}
{%- set arguments = tool_call.get('arguments') -%}
{%- endif -%}
{{- '<tool_call>\n<function=' ~ name ~ '>\n' -}}
{%- if arguments is mapping -%}
{%- for arg_name, arg_value in arguments | items -%}
{{- '<parameter=' ~ (arg_name if arg_name is string else arg_name | tojson) ~ '>\n' -}}
{{- arg_value if arg_value is string else arg_value | tojson -}}
{{- '\n</parameter>\n' -}}
{%- endfor -%}
{%- elif arguments is not none and (arguments is not string or (arguments | trim) != '') -%}
{{- raise_exception('Unexpected argument types. Expected dict.') -}}
{%- endif -%}
{{- '</function>\n</tool_call>' -}}
{%- endfor -%}
{%- endmacro -%}
{%- set enable_thinking = enable_thinking | default(none) -%}
{%- if enable_thinking is not none and enable_thinking is not boolean -%}
{{- raise_exception('Unexpected enable_thinking ' ~ enable_thinking ~ '. Expected true, false or none.') -}}
{%- endif -%}
{%- set reasoning_effort = reasoning_effort | default(none) -%}
{%- if reasoning_effort is not none and reasoning_effort not in ('xhigh', 'high', 'low', 'off') -%}
{{- raise_exception('Unexpected reasoning effort ' ~ reasoning_effort ~ '. Supported efforts are xhigh, high, low and off.') -}}
{%- endif -%}
{%- if enable_thinking is none -%}
{%- set effort = reasoning_effort if reasoning_effort is not none else 'high' -%}
{%- elif enable_thinking -%}
{%- if reasoning_effort == 'off' -%}
{{- raise_exception('Conflicting thinking settings: enable_thinking=true with reasoning_effort=off.') -}}
{%- endif -%}
{%- set effort = reasoning_effort if reasoning_effort is not none else 'high' -%}
{%- else -%}
{%- if reasoning_effort is not none and reasoning_effort != 'off' -%}
{{- raise_exception('Conflicting thinking settings: enable_thinking=false with reasoning_effort=' ~ reasoning_effort ~ '.') -}}
{%- endif -%}
{%- set effort = 'off' -%}
{%- endif -%}
{%- set preserve_thinking = preserve_thinking | default(true) -%}
{%- if preserve_thinking is not none and preserve_thinking is not boolean -%}
{{- raise_exception('Unexpected preserve_thinking ' ~ preserve_thinking ~ '. Expected true, false or none.') -}}
{%- endif -%}
{%- set preserve_thinking = true if preserve_thinking is none else preserve_thinking -%}
{{- '<|im_start|>system\n' + 'Reasoning effort is set to ' + effort + '.' -}}
{%- if tools -%}
{{- '\n\n' -}}
{{- render_tools(tools) -}}
{%- endif -%}
{{- '<|im_end|>\n' -}}
{#- Sort text-only tool-result runs only when every explicit tool_call_id resolves. -#}
{%- set order = namespace(messages=[], call_ids=[], pending=[], unresolved=false) -%}
{%- for message in messages + [none] -%}
{%- if message is none or message.get('role') != 'tool' -%}
{%- if not order.unresolved -%}
{%- set order.pending = order.pending | sort(attribute='position') -%}
{%- endif -%}
{%- for item in order.pending -%}
{%- set order.messages = order.messages + [item.message] -%}
{%- endfor -%}
{%- set order.pending = [] -%}
{%- set order.unresolved = false -%}
{%- if message is not none -%}
{%- if message.get('role') == 'assistant' -%}
{%- set order.call_ids = [] -%}
{%- for call in message.get('tool_calls') or [] -%}
{%- if call is mapping and call.get('id') is not none -%}
{%- set order.call_ids = order.call_ids + [call.id | string] -%}
{%- endif -%}
{%- endfor -%}
{%- endif -%}
{%- set order.messages = order.messages + [message] -%}
{%- endif -%}
{%- else -%}
{#- Do not reorder media independently of the processor's already-collected inputs. -#}
{%- set content = message.get('content') -%}
{%- if content is iterable and content is not string and content is not mapping -%}
{%- for part in content -%}
{%- if part is not string and (part is not mapping or part.get('type') != 'text') -%}
{%- set order.unresolved = true -%}
{%- endif -%}
{%- endfor -%}
{%- elif content is not none and content is not string -%}
{%- set order.unresolved = true -%}
{%- endif -%}
{%- set cid = message.get('tool_call_id') -%}
{%- set match = namespace(position=none) -%}
{%- for call_id in order.call_ids -%}
{%- if cid is not none and call_id == (cid | string) and match.position is none -%}
{%- set match.position = loop.index0 -%}
{%- endif -%}
{%- endfor -%}
{%- if match.position is none -%}
{%- set order.unresolved = true -%}
{%- endif -%}
{%- set order.pending = order.pending + [{'position': match.position, 'message': message}] -%}
{%- endif -%}
{%- endfor -%}
{%- set messages = order.messages -%}
{#- with preserve_thinking=false, reasoning survives only on and after the last user turn -#}
{%- set ns = namespace(last_user=-1) -%}
{%- if not preserve_thinking -%}
{%- for message in messages -%}
{%- if message.get('role') == 'user' -%}
{%- set ns.last_user = loop.index0 -%}
{%- endif -%}
{%- endfor -%}
{%- endif -%}
{%- for message in messages -%}
{%- set role = 'system' if message.get('role') == 'developer' else message.get('role') -%}
{%- if role in ('system', 'user') -%}
{{- '<|im_start|>' + role + '\n' + render_content(message.get('content')) + '<|im_end|>\n' -}}
{%- elif role == 'assistant' -%}
{%- if not preserve_thinking and loop.index0 < ns.last_user -%}
{%- set reasoning = '' -%}
{%- elif 'reasoning_content' in message -%}
{%- set reasoning = render_reasoning(message['reasoning_content']) | trim -%}
{%- elif 'reasoning' in message -%}
{%- set reasoning = render_reasoning(message['reasoning']) | trim -%}
{%- else -%}
{%- set reasoning = '' -%}
{%- endif -%}
{%- set content = render_content(message.get('content')) | trim -%}
{{- '<|im_start|>assistant\n<think>' -}}
{#- Keep prefilled tags outside the assistant loss mask. -#}
{%- if effort == 'off' and not reasoning -%}
{{- '</think>' -}}
{%- set think_completion = '' -%}
{%- else -%}
{%- set think_completion = reasoning + '</think>' -%}
{%- endif -%}
{%- generation -%}
{{- think_completion + content -}}
{%- if message.get('tool_calls') -%}
{{- render_tool_calls(message['tool_calls']) -}}
{%- endif -%}
{{- '<|im_end|>' -}}
{%- endgeneration -%}
{{- '\n' -}}
{%- elif role == 'tool' -%}
{{- '<|im_start|>tool\n' + render_content(message.get('content')) + '\n<|im_end|>\n' -}}
{%- else -%}
{{- raise_exception('Unexpected message role ' ~ message.get('role') ~ '. Supported roles are system, developer, user, assistant and tool.') -}}
{%- endif -%}
{%- endfor -%}
{%- if add_generation_prompt -%}
{{- '<|im_start|>assistant\n' -}}
{{- '<think>' -}}
{%- if effort == 'off' -%}
{{- '</think>' -}}
{%- endif -%}
{%- endif -%}
|