Text Generation
Transformers
Safetensors
gemma2
llama-factory
full
Generated from Trainer
conversational
text-generation-inference
Instructions to use tzchen07/SG_X9e with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use tzchen07/SG_X9e with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="tzchen07/SG_X9e") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForMultimodalLM tokenizer = AutoTokenizer.from_pretrained("tzchen07/SG_X9e") model = AutoModelForMultimodalLM.from_pretrained("tzchen07/SG_X9e") 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 tzchen07/SG_X9e with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "tzchen07/SG_X9e" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "tzchen07/SG_X9e", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/tzchen07/SG_X9e
- SGLang
How to use tzchen07/SG_X9e 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 "tzchen07/SG_X9e" \ --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": "tzchen07/SG_X9e", "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 "tzchen07/SG_X9e" \ --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": "tzchen07/SG_X9e", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use tzchen07/SG_X9e with Docker Model Runner:
docker model run hf.co/tzchen07/SG_X9e
Upload chat_template.jinja with huggingface_hub
Browse files- chat_template.jinja +29 -0
chat_template.jinja
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{%- if not guideline and messages[0].role == "system" %}
|
| 2 |
+
{%- set guideline = messages[0].content %}
|
| 3 |
+
{%- set messages = messages[1:] %}
|
| 4 |
+
{%- endif %}
|
| 5 |
+
|
| 6 |
+
{{- bos_token }}
|
| 7 |
+
{%- if messages[-1].role == 'user' %}
|
| 8 |
+
{{- "You are a policy expert trying to help determine whether a user prompt is in violation of the defined safety policies.\n\n" }}
|
| 9 |
+
{{- "<start_of_turn>\n" }}
|
| 10 |
+
{{- "Human Question: " + messages[-1].content }}
|
| 11 |
+
{{- "\n<end_of_turn>\n\n" }}
|
| 12 |
+
{{- "Our safety principle is defined in the below:\n\n" }}
|
| 13 |
+
{{- "* " + guideline + "\n" }}
|
| 14 |
+
{{- "\n===\n\n" }}
|
| 15 |
+
{{- "Does the human question violate the above principle? Your answer must start with 'Yes' or 'No'. And then walk through step by step to be sure we answer correctly.\n\n" }}
|
| 16 |
+
{%- else %}
|
| 17 |
+
{{- "You are a policy expert trying to help determine whether an AI response to a prompt is in violation of the defined safety policies.\n\n" }}
|
| 18 |
+
{{- "<start_of_turn>\n" }}
|
| 19 |
+
{{- "Human Question: " + messages[-2].content }}
|
| 20 |
+
{{- "\n<end_of_turn>\n" }}
|
| 21 |
+
{{- "<start_of_turn>\n" }}
|
| 22 |
+
{{- "Chatbot Response: " + messages[-1].content }}
|
| 23 |
+
{{- "\n<end_of_turn>\n\n" }}
|
| 24 |
+
{{- "Our safety principle is defined in the below:\n\n" }}
|
| 25 |
+
{{- "* " + guideline + "\n" }}
|
| 26 |
+
{{- "\n===\n\n" }}
|
| 27 |
+
{{- "Does the Chatbot Response violate the above principle? Your answer must start with 'Yes' or 'No'. And then walk through step by step to be sure we answer correctly.\n\n" }}
|
| 28 |
+
{%- endif %}
|
| 29 |
+
|