Instructions to use Godcat252/Besttop971 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Godcat252/Besttop971 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Godcat252/Besttop971") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("Godcat252/Besttop971") model = AutoModelForCausalLM.from_pretrained("Godcat252/Besttop971", device_map="auto") 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 Settings
- vLLM
How to use Godcat252/Besttop971 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Godcat252/Besttop971" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Godcat252/Besttop971", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Godcat252/Besttop971
- SGLang
How to use Godcat252/Besttop971 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 "Godcat252/Besttop971" \ --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": "Godcat252/Besttop971", "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 "Godcat252/Besttop971" \ --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": "Godcat252/Besttop971", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Godcat252/Besttop971 with Docker Model Runner:
docker model run hf.co/Godcat252/Besttop971
Update chat_template.jinja
Browse files- chat_template.jinja +11 -0
chat_template.jinja
CHANGED
|
@@ -14,6 +14,7 @@
|
|
| 14 |
{%- endfor -%}
|
| 15 |
{%- endif -%}
|
| 16 |
{%- endmacro -%}
|
|
|
|
| 17 |
{% macro set_roles(message) -%}
|
| 18 |
{%- set role_name = message.get('name') or message['role'] -%}
|
| 19 |
{%- if message['role'] == 'user' -%}
|
|
@@ -24,6 +25,8 @@
|
|
| 24 |
<|im_system|>{{role_name}}<|im_middle|>
|
| 25 |
{%- endif -%}
|
| 26 |
{%- endmacro -%}
|
|
|
|
|
|
|
| 27 |
{%- macro render_toolcalls(message) -%}
|
| 28 |
<|tool_calls_section_begin|>
|
| 29 |
{%- for tool_call in message['tool_calls'] -%}
|
|
@@ -32,6 +35,8 @@
|
|
| 32 |
{%- endfor -%}
|
| 33 |
<|tool_calls_section_end|>
|
| 34 |
{%- endmacro -%}
|
|
|
|
|
|
|
| 35 |
{%- set preserve_thinking = preserve_thinking | default(false) -%}
|
| 36 |
{# Find last non-tool-call assistant message. If preserve_thinking, keep -1 so hist is empty and all msgs use suffix (retain reasoning). #}
|
| 37 |
{%- set ns = namespace(last_non_tool_call_assistant_msg=-1) -%}
|
|
@@ -43,9 +48,11 @@
|
|
| 43 |
{%- endif -%}
|
| 44 |
{%- endfor -%}
|
| 45 |
{%- endif -%}
|
|
|
|
| 46 |
{# split all messages into history & suffix, reasoning_content in suffix should be reserved.#}
|
| 47 |
{%- set hist_msgs = messages[:ns.last_non_tool_call_assistant_msg+1] -%}
|
| 48 |
{%- set suffix_msgs = messages[ns.last_non_tool_call_assistant_msg+1:] -%}
|
|
|
|
| 49 |
{%- if tools -%}
|
| 50 |
{%- if tools_ts_str -%}
|
| 51 |
<|im_system|>tool_declare<|im_middle|>{{ tools_ts_str }}<|im_end|>
|
|
@@ -53,6 +60,7 @@
|
|
| 53 |
<|im_system|>tool_declare<|im_middle|>{{ tools | tojson(separators=(',', ':')) }}<|im_end|>
|
| 54 |
{%- endif -%}
|
| 55 |
{%- endif -%}
|
|
|
|
| 56 |
|
| 57 |
{%- for message in hist_msgs -%}
|
| 58 |
{{set_roles(message)}}
|
|
@@ -70,6 +78,7 @@
|
|
| 70 |
{%- endif -%}
|
| 71 |
<|im_end|>
|
| 72 |
{%- endfor -%}
|
|
|
|
| 73 |
{%- for message in suffix_msgs -%}
|
| 74 |
{{set_roles(message)}}
|
| 75 |
{%- if message['role'] == 'assistant' -%}
|
|
@@ -91,6 +100,8 @@
|
|
| 91 |
{%- endif -%}
|
| 92 |
<|im_end|>
|
| 93 |
{%- endfor -%}
|
|
|
|
|
|
|
| 94 |
{%- if add_generation_prompt -%}
|
| 95 |
<|im_assistant|>assistant<|im_middle|>
|
| 96 |
{%- if thinking is defined and thinking is false -%}
|
|
|
|
| 14 |
{%- endfor -%}
|
| 15 |
{%- endif -%}
|
| 16 |
{%- endmacro -%}
|
| 17 |
+
|
| 18 |
{% macro set_roles(message) -%}
|
| 19 |
{%- set role_name = message.get('name') or message['role'] -%}
|
| 20 |
{%- if message['role'] == 'user' -%}
|
|
|
|
| 25 |
<|im_system|>{{role_name}}<|im_middle|>
|
| 26 |
{%- endif -%}
|
| 27 |
{%- endmacro -%}
|
| 28 |
+
|
| 29 |
+
|
| 30 |
{%- macro render_toolcalls(message) -%}
|
| 31 |
<|tool_calls_section_begin|>
|
| 32 |
{%- for tool_call in message['tool_calls'] -%}
|
|
|
|
| 35 |
{%- endfor -%}
|
| 36 |
<|tool_calls_section_end|>
|
| 37 |
{%- endmacro -%}
|
| 38 |
+
|
| 39 |
+
|
| 40 |
{%- set preserve_thinking = preserve_thinking | default(false) -%}
|
| 41 |
{# Find last non-tool-call assistant message. If preserve_thinking, keep -1 so hist is empty and all msgs use suffix (retain reasoning). #}
|
| 42 |
{%- set ns = namespace(last_non_tool_call_assistant_msg=-1) -%}
|
|
|
|
| 48 |
{%- endif -%}
|
| 49 |
{%- endfor -%}
|
| 50 |
{%- endif -%}
|
| 51 |
+
|
| 52 |
{# split all messages into history & suffix, reasoning_content in suffix should be reserved.#}
|
| 53 |
{%- set hist_msgs = messages[:ns.last_non_tool_call_assistant_msg+1] -%}
|
| 54 |
{%- set suffix_msgs = messages[ns.last_non_tool_call_assistant_msg+1:] -%}
|
| 55 |
+
|
| 56 |
{%- if tools -%}
|
| 57 |
{%- if tools_ts_str -%}
|
| 58 |
<|im_system|>tool_declare<|im_middle|>{{ tools_ts_str }}<|im_end|>
|
|
|
|
| 60 |
<|im_system|>tool_declare<|im_middle|>{{ tools | tojson(separators=(',', ':')) }}<|im_end|>
|
| 61 |
{%- endif -%}
|
| 62 |
{%- endif -%}
|
| 63 |
+
|
| 64 |
|
| 65 |
{%- for message in hist_msgs -%}
|
| 66 |
{{set_roles(message)}}
|
|
|
|
| 78 |
{%- endif -%}
|
| 79 |
<|im_end|>
|
| 80 |
{%- endfor -%}
|
| 81 |
+
|
| 82 |
{%- for message in suffix_msgs -%}
|
| 83 |
{{set_roles(message)}}
|
| 84 |
{%- if message['role'] == 'assistant' -%}
|
|
|
|
| 100 |
{%- endif -%}
|
| 101 |
<|im_end|>
|
| 102 |
{%- endfor -%}
|
| 103 |
+
|
| 104 |
+
|
| 105 |
{%- if add_generation_prompt -%}
|
| 106 |
<|im_assistant|>assistant<|im_middle|>
|
| 107 |
{%- if thinking is defined and thinking is false -%}
|