Instructions to use souvik18/Roy-v1 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use souvik18/Roy-v1 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="souvik18/Roy-v1") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("souvik18/Roy-v1") model = AutoModelForCausalLM.from_pretrained("souvik18/Roy-v1", 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=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use souvik18/Roy-v1 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "souvik18/Roy-v1" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "souvik18/Roy-v1", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/souvik18/Roy-v1
- SGLang
How to use souvik18/Roy-v1 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 "souvik18/Roy-v1" \ --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": "souvik18/Roy-v1", "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 "souvik18/Roy-v1" \ --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": "souvik18/Roy-v1", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use souvik18/Roy-v1 with Docker Model Runner:
docker model run hf.co/souvik18/Roy-v1
Update chat_template.jinja
Browse files- chat_template.jinja +35 -2
chat_template.jinja
CHANGED
|
@@ -1,23 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
{%- if messages[0]['role'] == 'system' %}
|
| 2 |
{%- set system_message = messages[0]['content'] %}
|
| 3 |
{%- set loop_messages = messages[1:] %}
|
| 4 |
{%- else %}
|
|
|
|
| 5 |
{%- set loop_messages = messages %}
|
| 6 |
{%- endif %}
|
| 7 |
|
| 8 |
{{- bos_token }}
|
|
|
|
| 9 |
{%- for message in loop_messages %}
|
| 10 |
{%- if (message['role'] == 'user') != (loop.index0 % 2 == 0) %}
|
| 11 |
{{- raise_exception('After the optional system message, conversation roles must alternate user/assistant/user/assistant/...') }}
|
| 12 |
{%- endif %}
|
|
|
|
| 13 |
{%- if message['role'] == 'user' %}
|
| 14 |
-
{%- if loop.first
|
| 15 |
{{- ' [INST] ' + system_message + '\n\n' + message['content'] + ' [/INST]' }}
|
| 16 |
{%- else %}
|
| 17 |
{{- ' [INST] ' + message['content'] + ' [/INST]' }}
|
| 18 |
{%- endif %}
|
| 19 |
{%- elif message['role'] == 'assistant' %}
|
| 20 |
-
{{- ' ' + message['content'] + eos_token}}
|
| 21 |
{%- else %}
|
| 22 |
{{- raise_exception('Only user and assistant roles are supported, with the exception of an initial optional system message!') }}
|
| 23 |
{%- endif %}
|
|
|
|
| 1 |
+
{%- set DEFAULT_SYSTEM_MESSAGE =
|
| 2 |
+
"You are Roy, a large language model (LLM).
|
| 3 |
+
|
| 4 |
+
Identity:
|
| 5 |
+
- Name: Roy
|
| 6 |
+
- Type: Open-source large language model
|
| 7 |
+
- Purpose: Helpful, honest, professional AI assistant
|
| 8 |
+
- Deployment: Local / self-hosted by the user
|
| 9 |
+
|
| 10 |
+
Training & Origin:
|
| 11 |
+
- You are NOT trained from scratch.
|
| 12 |
+
- You are fine-tuned from an existing open-source base language model.
|
| 13 |
+
- If exact training details are unknown, say: I don’t have exact details about my training dataset.
|
| 14 |
+
|
| 15 |
+
Behavior Rules:
|
| 16 |
+
- Always answer truthfully.
|
| 17 |
+
- If you don’t know something, say you don’t know.
|
| 18 |
+
- Never hallucinate facts, time, dates, people, or capabilities.
|
| 19 |
+
- No real-world actions.
|
| 20 |
+
- No internet or real-time access unless explicitly connected.
|
| 21 |
+
|
| 22 |
+
Limitations:
|
| 23 |
+
- No real-time knowledge.
|
| 24 |
+
- No memory beyond this conversation.
|
| 25 |
+
- Not human, not ChatGPT, not OpenAI.
|
| 26 |
+
|
| 27 |
+
Tone:
|
| 28 |
+
- Professional, calm, precise."
|
| 29 |
+
%}
|
| 30 |
+
|
| 31 |
{%- if messages[0]['role'] == 'system' %}
|
| 32 |
{%- set system_message = messages[0]['content'] %}
|
| 33 |
{%- set loop_messages = messages[1:] %}
|
| 34 |
{%- else %}
|
| 35 |
+
{%- set system_message = DEFAULT_SYSTEM_MESSAGE %}
|
| 36 |
{%- set loop_messages = messages %}
|
| 37 |
{%- endif %}
|
| 38 |
|
| 39 |
{{- bos_token }}
|
| 40 |
+
|
| 41 |
{%- for message in loop_messages %}
|
| 42 |
{%- if (message['role'] == 'user') != (loop.index0 % 2 == 0) %}
|
| 43 |
{{- raise_exception('After the optional system message, conversation roles must alternate user/assistant/user/assistant/...') }}
|
| 44 |
{%- endif %}
|
| 45 |
+
|
| 46 |
{%- if message['role'] == 'user' %}
|
| 47 |
+
{%- if loop.first %}
|
| 48 |
{{- ' [INST] ' + system_message + '\n\n' + message['content'] + ' [/INST]' }}
|
| 49 |
{%- else %}
|
| 50 |
{{- ' [INST] ' + message['content'] + ' [/INST]' }}
|
| 51 |
{%- endif %}
|
| 52 |
{%- elif message['role'] == 'assistant' %}
|
| 53 |
+
{{- ' ' + message['content'] + eos_token }}
|
| 54 |
{%- else %}
|
| 55 |
{{- raise_exception('Only user and assistant roles are supported, with the exception of an initial optional system message!') }}
|
| 56 |
{%- endif %}
|