Text Generation
Transformers
Safetensors
English
hunyuan_v1_dense
python
code-generation
code-assistant
causal-lm
full-finetune
hunyuan
instruct
conversational
Instructions to use WithinUsAI/Hunyuan-PythonGOD-0.5B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use WithinUsAI/Hunyuan-PythonGOD-0.5B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="WithinUsAI/Hunyuan-PythonGOD-0.5B") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("WithinUsAI/Hunyuan-PythonGOD-0.5B") model = AutoModelForCausalLM.from_pretrained("WithinUsAI/Hunyuan-PythonGOD-0.5B") 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]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use WithinUsAI/Hunyuan-PythonGOD-0.5B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "WithinUsAI/Hunyuan-PythonGOD-0.5B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "WithinUsAI/Hunyuan-PythonGOD-0.5B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/WithinUsAI/Hunyuan-PythonGOD-0.5B
- SGLang
How to use WithinUsAI/Hunyuan-PythonGOD-0.5B 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 "WithinUsAI/Hunyuan-PythonGOD-0.5B" \ --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": "WithinUsAI/Hunyuan-PythonGOD-0.5B", "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 "WithinUsAI/Hunyuan-PythonGOD-0.5B" \ --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": "WithinUsAI/Hunyuan-PythonGOD-0.5B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use WithinUsAI/Hunyuan-PythonGOD-0.5B with Docker Model Runner:
docker model run hf.co/WithinUsAI/Hunyuan-PythonGOD-0.5B
File size: 4,820 Bytes
224d698 | 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 | {%- if not add_generation_prompt is defined %}
{%- set add_generation_prompt = false %}
{%- endif %}
{%- set ns = namespace(is_first=false, is_tool=false, is_output_first=true, system_prompt='', is_first_sp=true, is_first_user=true, is_last_user=false) %}
{%- for message in messages %}
{%- if message['role'] == 'system' %}
{%- if ns.is_first_sp %}
{%- set ns.system_prompt = ns.system_prompt + message['content'] %}
{%- set ns.is_first_sp = false %}
{%- else %}
{% set ns.system_prompt = ns.system_prompt + '
' + message['content'] %}
{%- endif %}
{%- endif %}
{%- endfor %}
{{- bos_token }}
{{- ns.system_prompt }}
{%- if tools %}
{%- if ns.system_prompt != '' %}
{{- '
# Tools
You may call one or more functions to assist with the user query.' }}
{%- else %}
{{- '# Tools
You may call one or more functions to assist with the user query.' }}
{%- endif %}
{{- '
You are provided with function signatures within <tools></tools> XML tags:' }}
{{- '
<tools>
' }}
{%- for tool in tools %}
{%- if loop.index0 > 1 %}
{{- '
' }}
{%- endif %}
{{- tool | tojson }}
{%- endfor %}
{{- '
</tools>
' }}
{{- 'For function call returns, you should first print <tool_calls>' }}
{{- 'For each function call, you should return object like:
' }}
{{- '<tool_call>function_name
```json
function_arguments_in_json_format
```</tool_call>' }}
{{- 'At the end of function call returns, you should print </tool_calls>' }}
{%- endif %}
{%- if ns.system_prompt != '' or tools %}
{{- '<|hy_place▁holder▁no▁3|>' }}
{%- endif %}
{%- for message in messages %}
{%- if message['role'] == 'user' %}
{%- set ns.is_tool = false %}
{%- set ns.is_first = false %}
{%- set ns.is_last_user = true %}
{{- '<|hy_User|>' + message['content'] + '<|hy_Assistant|>' }}
{%- endif %}
{%- if message['role'] == 'assistant' and message['tool_calls'] is defined and message['tool_calls'] is not none %}
{%- set ns.is_last_user = false %}
{%- if ns.is_tool %}
{{- '</tool_responses>' + '<|hy_Assistant|>' }}
{%- endif %}
{%- set ns.is_first = false %}
{%- set ns.is_tool = false %}
{%- set ns.is_output_first = true %}
{%- for tool in message['tool_calls'] %}
{%- set arguments = tool['function']['arguments'] %}
{%- if arguments is not string %}
{%- set arguments = arguments | tojson %}
{%- endif %}
{%- if not ns.is_first %}
{%- if message['content'] is none %}
{{- '<tool_calls><tool_call>' + tool['function']['name'] + '
' + '```json' + '
' + arguments + '
' + '```' + '</tool_call>' }}
{%- else %}
{{- message['content'] + '<tool_calls><tool_call>' + tool['function']['name'] + '
' + '```json' + '
' + arguments + '
' + '```' + '</tool_call>' }}
{%- endif %}
{%- set ns.is_first = true %}
{%- else %}
{{- '
' + '<tool_call>' + tool['function']['name'] + '
' + '```json' + '
' + arguments + '
' + '```' + '</tool_call>' }}
{%- endif %}
{%- endfor %}
{{- '</tool_calls>' + eos_token }}
{%- endif %}
{%- if message['role'] == 'assistant' and (message['tool_calls'] is not defined or message['tool_calls'] is none) %}
{%- set content = message['content'] %}
{%- if '<answer>' in content and not loop.last %}
{%- set content = content.split('<answer>')[-1].strip('</answer>').strip() %}
{%- endif %}
{%- set ns.is_last_user = false %}
{%- if ns.is_tool %}
{{- '</tool_responses>' + '<|hy_Assistant|>' + content + eos_token }}
{%- set ns.is_tool = false %}
{%- else %}
{{- content + eos_token }}
{%- endif %}
{%- endif %}
{%- if message['role'] == 'tool' %}
{%- set ns.is_last_user = false %}
{%- set ns.is_tool = true %}
{%- if ns.is_output_first %}
{{- '<|hy_User|>' + '<tool_responses><tool_response>' + message['content'] + '</tool_response>' }}
{%- set ns.is_output_first = false %}
{%- else %}
{{- '
<tool_response>' + message['content'] + '</tool_response>' }}
{%- endif %}
{%- endif %}
{%- endfor %}
{%- if ns.is_tool %}
{{- '</tool_responses>' + '<|hy_Assistant|>' }}
{%- endif %}
{%- if add_generation_prompt and not ns.is_last_user and not ns.is_tool %}
{{- '<|hy_Assistant|>' }}
{%- endif %}
{%- if enable_thinking is defined and not enable_thinking %}
{{- '<think>
</think>
' }}
{%- endif %} |