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
Download chat_template.jinja from trl-internal-testing/tiny-Qwen4MoeForConditionalGeneration: direct link, hf CLI and curl.
- Browser
- Download file 11.7 kB
-
https://huggingface.co/trl-internal-testing/tiny-Qwen4MoeForConditionalGeneration/resolve/main/chat_template.jinja
- Command line
-
hf download hf://trl-internal-testing/tiny-Qwen4MoeForConditionalGeneration/chat_template.jinja
-
curl -L -o chat_template.jinja https://huggingface.co/trl-internal-testing/tiny-Qwen4MoeForConditionalGeneration/resolve/main/chat_template.jinja
11.7 kB
| {#- 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 -%} | |