初始化项目,由ModelHub XC社区提供模型
Model: Vikhrmodels/Qwen2.5-7B-Instruct-Tool-Planning-v0.1 Source: Original Platform
This commit is contained in:
55
.gitattributes
vendored
Normal file
55
.gitattributes
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
*.7z filter=lfs diff=lfs merge=lfs -text
|
||||
*.arrow filter=lfs diff=lfs merge=lfs -text
|
||||
*.bin filter=lfs diff=lfs merge=lfs -text
|
||||
*.bin.* filter=lfs diff=lfs merge=lfs -text
|
||||
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
||||
*.ftz filter=lfs diff=lfs merge=lfs -text
|
||||
*.gz filter=lfs diff=lfs merge=lfs -text
|
||||
*.h5 filter=lfs diff=lfs merge=lfs -text
|
||||
*.joblib filter=lfs diff=lfs merge=lfs -text
|
||||
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
||||
*.model filter=lfs diff=lfs merge=lfs -text
|
||||
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
||||
*.onnx filter=lfs diff=lfs merge=lfs -text
|
||||
*.ot filter=lfs diff=lfs merge=lfs -text
|
||||
*.parquet filter=lfs diff=lfs merge=lfs -text
|
||||
*.pb filter=lfs diff=lfs merge=lfs -text
|
||||
*.pt filter=lfs diff=lfs merge=lfs -text
|
||||
*.pth filter=lfs diff=lfs merge=lfs -text
|
||||
*.rar filter=lfs diff=lfs merge=lfs -text
|
||||
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
||||
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
||||
*.tflite filter=lfs diff=lfs merge=lfs -text
|
||||
*.tgz filter=lfs diff=lfs merge=lfs -text
|
||||
*.xz filter=lfs diff=lfs merge=lfs -text
|
||||
*.zip filter=lfs diff=lfs merge=lfs -text
|
||||
*.zstandard filter=lfs diff=lfs merge=lfs -text
|
||||
*.tfevents* filter=lfs diff=lfs merge=lfs -text
|
||||
*.db* filter=lfs diff=lfs merge=lfs -text
|
||||
*.ark* filter=lfs diff=lfs merge=lfs -text
|
||||
**/*ckpt*data* filter=lfs diff=lfs merge=lfs -text
|
||||
**/*ckpt*.meta filter=lfs diff=lfs merge=lfs -text
|
||||
**/*ckpt*.index filter=lfs diff=lfs merge=lfs -text
|
||||
|
||||
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
||||
*.gguf* filter=lfs diff=lfs merge=lfs -text
|
||||
*.ggml filter=lfs diff=lfs merge=lfs -text
|
||||
*.llamafile* filter=lfs diff=lfs merge=lfs -text
|
||||
*.pt2 filter=lfs diff=lfs merge=lfs -text
|
||||
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
||||
*.npy filter=lfs diff=lfs merge=lfs -text
|
||||
*.npz filter=lfs diff=lfs merge=lfs -text
|
||||
*.pickle filter=lfs diff=lfs merge=lfs -text
|
||||
*.pkl filter=lfs diff=lfs merge=lfs -text
|
||||
*.tar filter=lfs diff=lfs merge=lfs -text
|
||||
*.wasm filter=lfs diff=lfs merge=lfs -text
|
||||
*.zst filter=lfs diff=lfs merge=lfs -text
|
||||
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
||||
|
||||
model-00002-of-00004.safetensors filter=lfs diff=lfs merge=lfs -text
|
||||
model-00004-of-00004.safetensors filter=lfs diff=lfs merge=lfs -text
|
||||
model-00003-of-00004.safetensors filter=lfs diff=lfs merge=lfs -text
|
||||
merges.txt filter=lfs diff=lfs merge=lfs -text
|
||||
model-00001-of-00004.safetensors filter=lfs diff=lfs merge=lfs -text
|
||||
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
||||
vocab.json filter=lfs diff=lfs merge=lfs -text
|
||||
740
README.md
Normal file
740
README.md
Normal file
@@ -0,0 +1,740 @@
|
||||
---
|
||||
library_name: transformers
|
||||
license: apache-2.0
|
||||
datasets:
|
||||
- Vikhrmodels/tool-plannings-v0.1
|
||||
language:
|
||||
- en
|
||||
base_model:
|
||||
- Qwen/Qwen2.5-7B-Instruct
|
||||
pipeline_tag: text-generation
|
||||
tags:
|
||||
- function-calling
|
||||
- tools
|
||||
- tool-calling
|
||||
- tool-planning
|
||||
---
|
||||
# Vikhrmodels/Qwen2.5-7B-Instruct-Tool-Planning-v0.1
|
||||
|
||||
<!-- Provide a quick summary of what the model is/does. -->
|
||||
|
||||
This model is a experimental supervised fine-tuned version of [Qwen/Qwen2.5-7B-Instruct](https://huggingface.co/Qwen/Qwen2.5-7B-Instruct) for the **Tool Planning**
|
||||
task on synthetic data of the English [Vikhrmodels/tool-plannings-v0.1](https://huggingface.co/datasets/Vikhrmodels/tool-plannings-v0.1) dataset.
|
||||
|
||||
**Tool Planning** means modified version of **Function Calling** task with additional model's capabilities of reasoning about calls.
|
||||
|
||||
In this model, the features include:
|
||||
* **Simple Function** — the model has <u>*one*</u> function in its arsenal, and it is able to call it if necessary at the user's common request.
|
||||
* **Multiple Function** — the model has <u>*several*</u> functions in its arsenal, and it is able to call <u>*one of them*</u> if necessary at the user's request.
|
||||
* **Parallel Multiple Function** — the model has <u>*several*</u> functions in its arsenal, and it is able to call <u>*some of them*</u> if necessary at the user's request.
|
||||
* **Tool Planning** — firstly the model is <u>*thinking*</u> about user's intent of function calling and secondly does calling.
|
||||
* **Tool Relevance Detection** — the model is able to determine the relevance of a function calling.
|
||||
* **Tool Error Handling** — the model is able to react non-hallucinative to broken/erroneous tool executions.
|
||||
|
||||
All examples of these features are described below.
|
||||
|
||||
## Model card tree
|
||||
|
||||
* [Usage (HuggingFace Transformers)](#usage_hf)
|
||||
* [Usage (VLLM)](#usage_vllm)
|
||||
* [Tool Planning Examples](#examples)
|
||||
* [Limitations](#lim)
|
||||
* [Evaluation](#eval)
|
||||
|
||||
## Usage (HuggingFace Transformers) <a name="usage_hf"></a>
|
||||
|
||||
Below we share some code snippets on how to get quickly started with running the model. First, install the Transformers library with:
|
||||
```bash
|
||||
pip install transformers==4.48.3
|
||||
```
|
||||
|
||||
### Prepare your functions
|
||||
|
||||
You should write the functions (tools) used by the model in *Python code* and make sure to add *Python docstrings* as in the example below:
|
||||
```python
|
||||
def get_weather(city: str):
|
||||
"""
|
||||
A function that returns the weather in a given city.
|
||||
|
||||
Args:
|
||||
city: The city to get the weather for.
|
||||
"""
|
||||
import random
|
||||
|
||||
return "sunny" if random.random() > 0.5 else "rainy"
|
||||
|
||||
# Either immediately in JSON format:
|
||||
get_sunrise_sunset_times = {
|
||||
"type": "function",
|
||||
"function": {
|
||||
"name": "get_sunrise_sunset_times",
|
||||
"description": "A function that returns the time of sunrise and sunset at the present moment, for a given city, in the form of a list: [sunrise_time, sunset_time].",
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"city": {
|
||||
"type": "string",
|
||||
"description": "The city to get the sunrise and sunset times for."
|
||||
}
|
||||
},
|
||||
"required": ["city"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tools = [get_weather, get_sunrise_sunset_times]
|
||||
```
|
||||
|
||||
### Just use chat template
|
||||
|
||||
Next, you need to download the model and tokenizer:
|
||||
```python
|
||||
import torch
|
||||
from transformers import AutoTokenizer, AutoModelForCausalLM
|
||||
model = AutoModelForCausalLM.from_pretrained(
|
||||
"Vikhrmodels/Qwen2.5-7B-Instruct-Tool-Planning-v0.1",
|
||||
device_map="auto",
|
||||
torch_dtype=torch.bfloat16, # recommended dtype
|
||||
)
|
||||
tokenizer = AutoTokenizer.from_pretrained(
|
||||
"Vikhrmodels/Qwen2.5-7B-Instruct-Tool-Planning-v0.1",
|
||||
)
|
||||
```
|
||||
|
||||
To get the result of generation, just use `apply_chat_template`. In order to take into account our written functions (tools),
|
||||
we need to pass them as a list through the `tools` attribute and also use `add_prompt_generation=True`.
|
||||
```python
|
||||
history_messages = [
|
||||
{"role": "user", "content": "Hi, can you tell me the time of sunrise in Los Angeles?"},
|
||||
]
|
||||
|
||||
inputs = tokenizer.apply_chat_template(
|
||||
history_messages,
|
||||
tokenize=False,
|
||||
add_generation_prompt=True, # adding prompt for generation
|
||||
tools=tools, # our functions (tools)
|
||||
)
|
||||
|
||||
input_tokens = tokenizer(
|
||||
inputs,
|
||||
add_special_tokens=False,
|
||||
return_tensors='pt'
|
||||
).to(model.device)
|
||||
|
||||
generated_ids = model.generate(
|
||||
**input_tokens,
|
||||
max_new_tokens=256,
|
||||
do_sample=False,
|
||||
)[0]
|
||||
|
||||
generated_response = tokenizer.decode(
|
||||
generated_ids[input_tokens.input_ids.shape[-1]:],
|
||||
skip_special_tokens=False, # `skip_special_tokens=False` for debug
|
||||
)
|
||||
print(generated_response)
|
||||
```
|
||||
|
||||
Then our `generated_response` will look like this:
|
||||
```
|
||||
<|start_thinking|>The user wants to know the time of sunrise in Los Angeles. I will use the get_sunrise_sunset_times API to retrieve this information.<|end_thinking|><tool_call>[
|
||||
{"tool_call_id": "0", "tool_name": "get_sunrise_sunset_times", "parameters": {"city": "Los Angeles"}}
|
||||
]</tool_call><|im_end|>
|
||||
```
|
||||
|
||||
## Usage (VLLM) <a name="usage_vllm"></a>
|
||||
|
||||
For corrected work online serving in VLLM you need additionally load [qwen2_tool_parser.py]() and [chat_template.jinja]() from this repository.
|
||||
|
||||
```
|
||||
vllm serve Vikhrmodels/Qwen2.5-7B-Instruct-Tool-Planning-v0.1 \
|
||||
--download-dir "/path/to/cache" \
|
||||
--chat-template "/path/to/chat_template.jinja" \
|
||||
--tool-parser-plugin "/path/to/qwen2_tool_parser.py" \
|
||||
--tool-call-parser "qwen2" \
|
||||
--enable-auto-tool-choice
|
||||
```
|
||||
|
||||
After that you can start doing requests:
|
||||
|
||||
```python
|
||||
from openai import OpenAI
|
||||
import json
|
||||
|
||||
client = OpenAI(base_url="http://localhost:8000/v1", api_key="dummy")
|
||||
tools = [
|
||||
{
|
||||
"type": "function",
|
||||
"function": {
|
||||
"name": "get_weather",
|
||||
"description": "Get the current weather in a given location",
|
||||
"parameters": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"location": {"type": "string", "description": "City and state."},
|
||||
},
|
||||
"required": ["location"]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
response = client.chat.completions.create(
|
||||
model=client.models.list().data[0].id,
|
||||
messages=[
|
||||
{"role": "user", "content": "What's the weather in Krasnodar and Moscow?"}
|
||||
],
|
||||
tools=tools,
|
||||
)
|
||||
|
||||
print(response.choices[0].message)
|
||||
```
|
||||
|
||||
```
|
||||
ChatCompletionMessage(
|
||||
content='<|start_thinking|>I need to get the weather for Krasnodar and Moscow.<|end_thinking|>',
|
||||
refusal=None,
|
||||
role='assistant',
|
||||
audio=None,
|
||||
function_call=None,
|
||||
tool_calls=[
|
||||
ChatCompletionMessageToolCall(
|
||||
id='chatcmpl-tool-73646c73148e4af9ac53656d6aa3e3c6',
|
||||
function=Function(arguments='{"location": "Krasnodar"}', name='get_weather'),
|
||||
type='function'),
|
||||
ChatCompletionMessageToolCall(
|
||||
id='chatcmpl-tool-95d93590d1a24df6a4f44a87a83f7761',
|
||||
function=Function(arguments='{"location": "Moscow"}', name='get_weather'),
|
||||
type='function')
|
||||
],
|
||||
reasoning_content=None)
|
||||
```
|
||||
|
||||
## Tool Planning Examples <a name="examples"></a>
|
||||
|
||||
The model is using ***grounded system prompt*** for tool planning. <u>We do not recommend changing it too much, as this may cause hallucinations!</u>
|
||||
|
||||
But you can try to add first message as `system` role with additional system rules in your chat history and it adds at the end of this ***grounded system prompt***.
|
||||
|
||||
```
|
||||
<|im_start|>system
|
||||
You have been trained to have advanced reasoning and tool-use capabilities and you should make best use of these skills to serve user's requests.
|
||||
|
||||
# Tool Use
|
||||
Think about how you can make best use of the provided tools to help with the task and come up with a high level plan that you will execute first.
|
||||
|
||||
0. Start by writing <|start_thinking|> followed by a detailed step by step plan of how you will solve the problem. For each step explain your thinking fully and give details of required tool calls (if needed). Unless specified otherwise, you write your plan in natural language. When you finish, close it out with <|end_thinking|>.
|
||||
You can optionally choose to skip this step when the user request is so straightforward to address that only a trivial plan would be needed.
|
||||
NOTE: You MUST skip this step when you are directly responding to the user's request without using any tools.
|
||||
|
||||
Then carry out your plan by repeatedly executing the following steps.
|
||||
1. Action: write <tool_call> followed by a list of JSON-formatted tool calls, with each one containing "tool_name" and "parameters" fields.
|
||||
When there are multiple tool calls which are completely independent of each other (i.e. they can be executed in parallel), you should list them out all together in one step. When you finish, close it out with </tool_call>.
|
||||
2. Observation: you will then receive results of those tool calls in JSON format in the very next turn, wrapped around by <tool_response> and </tool_response>. Carefully observe those results and think about what to do next. Note that these results will be provided to you in a separate turn. NEVER hallucinate results.
|
||||
Every tool call produces a list of results (when a tool call produces no result or a single result, it'll still get wrapped inside a list). Each result is clearly linked to its originating tool call via its "tool_call_id".
|
||||
3. Reflection: start the next turn by writing <|start_thinking|> followed by what you've figured out so far, any changes you need to make to your plan, and what you will do next. When you finish, close it out with <|end_thinking|>.
|
||||
You can optionally choose to skip this step when everything is going according to plan and no special pieces of information or reasoning chains need to be recorded.
|
||||
NOTE: You MUST skip this step when you are done with tool-use actions and are ready to respond to the user.
|
||||
|
||||
You can repeat the above 3 steps multiple times (could be 0 times too if no suitable tool calls are available or needed), until you decide it's time to finally respond to the user.
|
||||
|
||||
4. Response: then break out of the loop and write <|start_response|> followed by a piece of text which serves as a response to the user's last request. Use all previous tool calls and results to help you when formulating your response. When you finish, close it out with <|end_response|>.
|
||||
|
||||
# Available Tools
|
||||
Here is the list of tools that you have available to you.
|
||||
You can ONLY use the tools listed here. When a tool is not listed below, it is NOT available and you should NEVER attempt to use it.
|
||||
Each tool is represented as a JSON object with fields like "name", "description", "parameters" (per JSON Schema), and optionally, "responses" (per JSON Schema).
|
||||
|
||||
\`\`\`json
|
||||
[
|
||||
{"name": "get_weather", "description": "A function that returns the weather in a given city.", "parameters": {"type": "object", "properties": {"city": {"type": "string", "description": "The city to get the weather for."}}, "required": ["city"]}, "responses": null},
|
||||
{"name": "get_sunrise_sunset_times", "description": "A function that returns the time of sunrise and sunset at the present moment, for a given city, in the form of a list: [sunrise_time, sunset_time].", "parameters": {"type": "object", "properties": {"city": {"type": "string", "description": "The city to get the sunrise and sunset times for."}}, "required": ["city"]}, "responses": null}
|
||||
]
|
||||
\`\`\`
|
||||
|
||||
<|im_end|>
|
||||
```
|
||||
*For corrected display used [\ \`] instead of [\`]*
|
||||
|
||||
**About the structure of prompt:**
|
||||
- This model always will answer with new tokens: `<|start_response|>`...*text from model*...`<|end_response|>`. This content is the main one for user and it contains in `assistant` in `content` field.
|
||||
- This model always starts <u>*thinking*</u> before tool calls with new tokens: `<|start_thinking|>`...*thinking*...`<|end_thinking|>`. It contains in `assistant` in `tool_plan` field.
|
||||
- After <u>*thinking*</u> model starts generate tool calls (function calling) with Qwen2.5 tokens (it can be a multiple/parallel calling too):
|
||||
```
|
||||
<tool_call>[
|
||||
{"tool_call_id": "...", "tool_name": "...", "parameters": {...}},
|
||||
{"tool_call_id": "...", "tool_name": "...", "parameters": {...}},
|
||||
...
|
||||
]</tool_call><|im_end|>
|
||||
```
|
||||
`tool_call_id` is local tool id.<br>
|
||||
`tool_name` is name of tool(function) calling.<br>
|
||||
It contains in `assistant` in `tool_calls` field.<br>
|
||||
|
||||
- Responses from tools are located between `<tool_response>`...*all last locals tools*...`</tool_response>`. Every local tool contains separately in specific role `tool`:
|
||||
```python
|
||||
{
|
||||
"role": "tool",
|
||||
"tool_call_id": "0", # MUST BE matches with the corresponding call above.
|
||||
"content": { "tool_name_1_returns": ... } # MUST BE dict with key "tool_name" + "_returns"
|
||||
},
|
||||
{
|
||||
"role": "tool",
|
||||
"tool_call_id": "1", # MUST BE matches with the corresponding call above.
|
||||
"content": { "tool_name_1_returns": ... }
|
||||
},
|
||||
{
|
||||
"role": "tool",
|
||||
"tool_call_id": "2", # MUST BE matches with the corresponding call above.
|
||||
"content": { "tool_name_2_returns": ... },
|
||||
"is_error_tool": True # You can add it if your tool is corrupted. But then you must provide error description in content.
|
||||
}
|
||||
```
|
||||
Local tool ids mean that ids must match only in one pair *tool call* and *tool response*, next *tool call* must reset the counter and start from 0 again.
|
||||
|
||||
### Simple Function
|
||||
|
||||
*history*
|
||||
```python
|
||||
messages = [
|
||||
{"role": "user", "content": "Hey dude, what can you do?"},
|
||||
{"role": "assistant", "content": "I can retrieve a list of unpaid invoices and process payments for specific invoices."},
|
||||
{"role": "user", "content": "Okey, then retrieve a list for me"},
|
||||
{
|
||||
"role": "assistant",
|
||||
"tool_plan": "I will retrieve a list of unpaid invoices.",
|
||||
"tool_calls": [
|
||||
{
|
||||
"id": "0",
|
||||
"type": "function",
|
||||
"function": {
|
||||
"name": "find_unpaid_invoices",
|
||||
"arguments": {}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"role": "tool",
|
||||
"tool_call_id": "0",
|
||||
"content": { "find_unpaid_invoices_returns": ["Utility Debts", "Housing and Utilities Arrears"]}
|
||||
},
|
||||
{"role": "assistant", "content": "Here is the list of unpaid invoices: Utility Debts and Housing and Utilities Arrears."},
|
||||
{"role": "user", "content": "Ooh, I forget about this! Lets pay Utility Debts in the amount of $100 please"},
|
||||
{
|
||||
"role": "assistant",
|
||||
"tool_plan": "I will process the payment for the Utility Debts invoice.",
|
||||
"tool_calls": [
|
||||
{
|
||||
"id": "0",
|
||||
"type": "function",
|
||||
"function": {
|
||||
"name": "pay_invoice",
|
||||
"arguments": {"invoice_id": "Utility Debts", "amount": 100}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"role": "tool",
|
||||
"tool_call_id": "0",
|
||||
"content": { "pay_invoice_returns": "Success"}
|
||||
},
|
||||
]
|
||||
```
|
||||
|
||||
*prompt with generation*
|
||||
```
|
||||
<|im_start|>system
|
||||
...grounded_system_prompt...
|
||||
|
||||
<|im_end|>
|
||||
<|im_start|>user
|
||||
Hey dude, what can you do?<|im_end|>
|
||||
<|im_start|>assistant
|
||||
<|start_response|>I can retrieve a list of unpaid invoices and process payments for specific invoices.<|end_response|><|im_end|>
|
||||
<|im_start|>user
|
||||
Okey, then retrieve a list for me<|im_end|>
|
||||
<|im_start|>assistant
|
||||
<|start_thinking|>I will retrieve a list of unpaid invoices.<|end_thinking|><tool_call>[
|
||||
{"tool_call_id": "0", "tool_name": "find_unpaid_invoices", "parameters": {}}
|
||||
]</tool_call><|im_end|>
|
||||
<|im_start|>system
|
||||
<tool_response>[
|
||||
{
|
||||
"tool_call_id": "0",
|
||||
"results": {
|
||||
"0": {"find_unpaid_invoices_returns": ["Utility Debts", "Housing and Utilities Arrears"]}
|
||||
},
|
||||
"is_error_tool": False
|
||||
}
|
||||
]</tool_response><|im_end|>
|
||||
<|im_start|>assistant
|
||||
<|start_response|>Here is the list of unpaid invoices: Utility Debts and Housing and Utilities Arrears.<|end_response|><|im_end|>
|
||||
<|im_start|>user
|
||||
Ooh, I forget about this! Lets pay Utility Debts in the amount of $100 please<|im_end|>
|
||||
<|im_start|>assistant
|
||||
<|start_thinking|>I will process the payment for the Utility Debts invoice.<|end_thinking|><tool_call>[
|
||||
{"tool_call_id": "0", "tool_name": "pay_invoice", "parameters": {"invoice_id": "Utility Debts", "amount": 100}}
|
||||
]</tool_call><|im_end|>
|
||||
<|im_start|>system
|
||||
<tool_response>[
|
||||
{
|
||||
"tool_call_id": "0",
|
||||
"results": {
|
||||
"0": {"pay_invoice_returns": "Success"}
|
||||
},
|
||||
"is_error_tool": False
|
||||
}
|
||||
]</tool_response><|im_end|>
|
||||
<|im_start|>assistant
|
||||
<|start_response|>The payment for the Utility Debts invoice has been processed successfully.<|end_response|><|im_end|>
|
||||
```
|
||||
|
||||
### Multiple Function
|
||||
|
||||
*history*
|
||||
```python
|
||||
messages = [
|
||||
{"role": "user", "content": "Hey dude, what can you do?"},
|
||||
{"role": "assistant", "content": "I can provide weather information for a given city and also provide the sunrise and sunset times for a given city."},
|
||||
{"role": "user", "content": "Thats great! Okey, can you provide weather in Krasnodar, Moscow and Krasnoyarsk for me please."},
|
||||
{
|
||||
"role": "assistant",
|
||||
"tool_plan": "The user wants weather information for three cities: Krasnodar, Moscow, and Krasnoyarsk.",
|
||||
"tool_calls": [
|
||||
{
|
||||
"id": "0",
|
||||
"type": "function",
|
||||
"function": {
|
||||
"name": "get_weather",
|
||||
"arguments": {
|
||||
"city": "Krasnodar"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "1",
|
||||
"type": "function",
|
||||
"function": {
|
||||
"name": "get_weather",
|
||||
"arguments": {
|
||||
"city": "Moscow"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "2",
|
||||
"type": "function",
|
||||
"function": {
|
||||
"name": "get_weather",
|
||||
"arguments": {
|
||||
"city": "Krasnoyarsk"
|
||||
}
|
||||
}
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
"role": "tool",
|
||||
"tool_call_id": "0",
|
||||
"content": { "get_weather_returns": "sunny" }
|
||||
},
|
||||
{
|
||||
"role": "tool",
|
||||
"tool_call_id": "1",
|
||||
"content": { "get_weather_returns": "sunny" }
|
||||
},
|
||||
{
|
||||
"role": "tool",
|
||||
"tool_call_id": "2",
|
||||
"content": { "get_weather_returns": "rainy" }
|
||||
},
|
||||
]
|
||||
```
|
||||
|
||||
*prompt with generation*
|
||||
```
|
||||
<|im_start|>system
|
||||
...grounded_system_prompt...
|
||||
|
||||
<|im_end|>
|
||||
<|im_start|>user
|
||||
Hey dude, what can you do?<|im_end|>
|
||||
<|im_start|>assistant
|
||||
<|start_response|>I can provide weather information for a given city and also provide the sunrise and sunset times for a given city.<|end_response|><|im_end|>
|
||||
<|im_start|>user
|
||||
Thats great! Okey, can you provide weather in Krasnodar, Moscow and Krasnoyarsk for me please.<|im_end|>
|
||||
<|im_start|>assistant
|
||||
<|start_thinking|>The user wants weather information for three cities: Krasnodar, Moscow, and Krasnoyarsk.<|end_thinking|><tool_call>[
|
||||
{"tool_call_id": "0", "tool_name": "get_weather", "parameters": {"city": "Krasnodar"}},
|
||||
{"tool_call_id": "1", "tool_name": "get_weather", "parameters": {"city": "Moscow"}},
|
||||
{"tool_call_id": "2", "tool_name": "get_weather", "parameters": {"city": "Krasnoyarsk"}}
|
||||
]</tool_call><|im_end|>
|
||||
<|im_start|>system
|
||||
<tool_response>[
|
||||
{
|
||||
"tool_call_id": "0",
|
||||
"results": {
|
||||
"0": {"get_weather_returns": "sunny"}
|
||||
},
|
||||
"is_error_tool": False
|
||||
},
|
||||
{
|
||||
"tool_call_id": "1",
|
||||
"results": {
|
||||
"0": {"get_weather_returns": "sunny"}
|
||||
},
|
||||
"is_error_tool": False
|
||||
},
|
||||
{
|
||||
"tool_call_id": "2",
|
||||
"results": {
|
||||
"0": {"get_weather_returns": "rainy"}
|
||||
},
|
||||
"is_error_tool": False
|
||||
}
|
||||
]</tool_response><|im_end|>
|
||||
<|im_start|>assistant
|
||||
<|start_response|>The weather in Krasnodar is sunny, the weather in Moscow is sunny, and the weather in Krasnoyarsk is rainy.<|end_response|><|im_end|>
|
||||
```
|
||||
|
||||
### Parallel Multiple Function
|
||||
|
||||
*history*
|
||||
```python
|
||||
messages = [
|
||||
{"role": "user", "content": "Hey dude, what can you do?"},
|
||||
{"role": "assistant", "content": "I can provide weather information for a given city and also provide the sunrise and sunset times for a given city."},
|
||||
{"role": "user", "content": "Thats great! Okey, can you provide weather in Krasnodar, Moscow and only the sunrise time in Krasnoyarsk for me please."},
|
||||
{
|
||||
"role": "assistant",
|
||||
"tool_plan": "The user has requested weather information for three cities and only the sunrise time for one city. I will first retrieve the weather information for Krasnodar and Moscow, and then retrieve the sunrise time for Krasnoyarsk.",
|
||||
"tool_calls": [
|
||||
{
|
||||
"id": "0",
|
||||
"type": "function",
|
||||
"function": {
|
||||
"name": "get_weather",
|
||||
"arguments": {
|
||||
"city": "Krasnodar"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "1",
|
||||
"type": "function",
|
||||
"function": {
|
||||
"name": "get_weather",
|
||||
"arguments": {
|
||||
"city": "Moscow"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "2",
|
||||
"type": "function",
|
||||
"function": {
|
||||
"name": "get_sunrise_sunset_times",
|
||||
"arguments": {
|
||||
"city": "Krasnoyarsk"
|
||||
}
|
||||
}
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
"role": "tool",
|
||||
"tool_call_id": "0",
|
||||
"content": { "get_weather_returns": "sunny" }
|
||||
},
|
||||
{
|
||||
"role": "tool",
|
||||
"tool_call_id": "1",
|
||||
"content": { "get_weather_returns": "sunny" }
|
||||
},
|
||||
{
|
||||
"role": "tool",
|
||||
"tool_call_id": "2",
|
||||
"content": { "get_sunrise_sunset_times_returns": ["6:00 AM", "6:00 PM"] }
|
||||
},
|
||||
]
|
||||
```
|
||||
|
||||
*prompt with generation*
|
||||
```
|
||||
<|im_start|>system
|
||||
...grounded_system_prompt...
|
||||
|
||||
<|im_end|>
|
||||
<|im_start|>user
|
||||
Hey dude, what can you do?<|im_end|>
|
||||
<|im_start|>assistant
|
||||
<|start_response|>I can provide weather information for a given city and also provide the sunrise and sunset times for a given city.<|end_response|><|im_end|>
|
||||
<|im_start|>user
|
||||
Thats great! Okey, can you provide weather in Krasnodar, Moscow and only the sunrise time in Krasnoyarsk for me please.<|im_end|>
|
||||
<|im_start|>assistant
|
||||
<|start_thinking|>The user has requested weather information for three cities and only the sunrise time for one city. I will first retrieve the weather information for Krasnodar and Moscow, and then retrieve the sunrise time for Krasnoyarsk.<|end_thinking|><tool_call>[
|
||||
{"tool_call_id": "0", "tool_name": "get_weather", "parameters": {"city": "Krasnodar"}},
|
||||
{"tool_call_id": "1", "tool_name": "get_weather", "parameters": {"city": "Moscow"}},
|
||||
{"tool_call_id": "2", "tool_name": "get_sunrise_sunset_times", "parameters": {"city": "Krasnoyarsk"}}
|
||||
]</tool_call><|im_end|>
|
||||
<|im_start|>system
|
||||
<tool_response>[
|
||||
{
|
||||
"tool_call_id": "0",
|
||||
"results": {
|
||||
"0": {"get_weather_returns": "sunny"}
|
||||
},
|
||||
"is_error_tool": False
|
||||
},
|
||||
{
|
||||
"tool_call_id": "1",
|
||||
"results": {
|
||||
"0": {"get_weather_returns": "sunny"}
|
||||
},
|
||||
"is_error_tool": False
|
||||
},
|
||||
{
|
||||
"tool_call_id": "2",
|
||||
"results": {
|
||||
"0": {"get_sunrise_sunset_times_returns": ["6:00 AM", "6:00 PM"]}
|
||||
},
|
||||
"is_error_tool": False
|
||||
}
|
||||
]</tool_response><|im_end|>
|
||||
<|im_start|>assistant
|
||||
<|start_response|>The weather in Krasnodar is sunny, the weather in Moscow is sunny, and the sunrise time in Krasnoyarsk is 6:00 AM.<|end_response|><|im_end|>
|
||||
```
|
||||
|
||||
### Tool Error Handling
|
||||
|
||||
*history*
|
||||
```python
|
||||
messages = [
|
||||
{"role": "user", "content": "Hey dude, what can you do?"},
|
||||
{"role": "assistant", "content": "I can provide weather information for a given city and also provide the sunrise and sunset times for a given city."},
|
||||
{"role": "user", "content": "Thats great! Okey, can you provide weather in Krasnodar, Moscow and only the sunrise time in Krasnoyarsk for me please."},
|
||||
{
|
||||
"role": "assistant",
|
||||
"tool_plan": "The user has requested weather information for three cities and only the sunrise time for one city. I will first retrieve the weather information for Krasnodar and Moscow, and then retrieve the sunrise time for Krasnoyarsk.",
|
||||
"tool_calls": [
|
||||
{
|
||||
"id": "0",
|
||||
"type": "function",
|
||||
"function": {
|
||||
"name": "get_weather",
|
||||
"arguments": {
|
||||
"city": "Krasnodar"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "1",
|
||||
"type": "function",
|
||||
"function": {
|
||||
"name": "get_weather",
|
||||
"arguments": {
|
||||
"city": "Moscow"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "2",
|
||||
"type": "function",
|
||||
"function": {
|
||||
"name": "get_sunrise_sunset_times",
|
||||
"arguments": {
|
||||
"city": "Krasnoyarsk"
|
||||
}
|
||||
}
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
"role": "tool",
|
||||
"tool_call_id": "0",
|
||||
"content": { "get_weather_returns": "sunny" }
|
||||
},
|
||||
{
|
||||
"role": "tool",
|
||||
"tool_call_id": "1",
|
||||
"content": { "get_weather_returns": "sunny" }
|
||||
},
|
||||
{
|
||||
"role": "tool",
|
||||
"tool_call_id": "2",
|
||||
"content": { "get_sunrise_sunset_times_returns": {"error": True, "message": "Server is unavailable now"} },
|
||||
"is_error_tool": True
|
||||
},
|
||||
]
|
||||
```
|
||||
|
||||
*prompt with generation*
|
||||
```
|
||||
<|im_start|>system
|
||||
...grounded_system_prompt...
|
||||
|
||||
<|im_end|>
|
||||
<|im_start|>user
|
||||
Hey dude, what can you do?<|im_end|>
|
||||
<|im_start|>assistant
|
||||
<|start_response|>I can provide weather information for a given city and also provide the sunrise and sunset times for a given city.<|end_response|><|im_end|>
|
||||
<|im_start|>user
|
||||
Thats great! Okey, can you provide weather in Krasnodar, Moscow and only the sunrise time in Krasnoyarsk for me please.<|im_end|>
|
||||
<|im_start|>assistant
|
||||
<|start_thinking|>The user has requested weather information for three cities and only the sunrise time for one city. I will first retrieve the weather information for Krasnodar and Moscow, and then retrieve the sunrise time for Krasnoyarsk.<|end_thinking|><tool_call>[
|
||||
{"tool_call_id": "0", "tool_name": "get_weather", "parameters": {"city": "Krasnodar"}},
|
||||
{"tool_call_id": "1", "tool_name": "get_weather", "parameters": {"city": "Moscow"}},
|
||||
{"tool_call_id": "2", "tool_name": "get_sunrise_sunset_times", "parameters": {"city": "Krasnoyarsk"}}
|
||||
]</tool_call><|im_end|>
|
||||
<|im_start|>system
|
||||
<tool_response>[
|
||||
{
|
||||
"tool_call_id": "0",
|
||||
"results": {
|
||||
"0": {"get_weather_returns": "sunny"}
|
||||
},
|
||||
"is_error_tool": False
|
||||
},
|
||||
{
|
||||
"tool_call_id": "1",
|
||||
"results": {
|
||||
"0": {"get_weather_returns": "sunny"}
|
||||
},
|
||||
"is_error_tool": False
|
||||
},
|
||||
{
|
||||
"tool_call_id": "2",
|
||||
"results": {
|
||||
"0": {"get_sunrise_sunset_times_returns": {"error": true, "message": "Server is unavailable now"}}
|
||||
},
|
||||
"is_error_tool": True
|
||||
}
|
||||
]</tool_response><|im_end|>
|
||||
<|im_start|>assistant
|
||||
<|start_response|>The weather in Krasnodar and Moscow is sunny. Unfortunately, the server is currently unavailable, so I cannot provide the sunrise time for Krasnoyarsk.<|end_response|><|im_end|>
|
||||
```
|
||||
|
||||
## Limitations <a name="lim"></a>
|
||||
|
||||
This is the experimental checkpoint and some hallucinations are possible. If you find something interesting in model behavior, please create [issue and lets discuss it!](https://huggingface.co/Vikhrmodels/Qwen2.5-7B-Instruct-Tool-Planning/discussions)
|
||||
|
||||
* The model the most stability works in `greedy search` or low `temperature(about < 0.5)`
|
||||
* The model can feel some problems with long user plan. It confuses the trajectory of calls and changes the order in which related tasks are performed. In fact, this is not a mistake, but a violation of the user's requirement.
|
||||
* The model can solve very easy tasks on the fly, right in the process of calls (for example, basic arithmetic).
|
||||
|
||||
|
||||
## Evaluation <a name="eval"></a>
|
||||
|
||||
| Task | Acc(%) |
|
||||
|---------------------------|----------|
|
||||
| Simple | 73.25 |
|
||||
| Multiple | 93.00 |
|
||||
| Parallel | 90.00 |
|
||||
| Parallel Multiple | 81.00 |
|
||||
| Relevance Detection | 64.71 |
|
||||
| Irrelevance Detection | 85.72 |
|
||||
|
||||
## Authors
|
||||
|
||||
- [Dmitry Tishencko](https://huggingface.co/DiTy), [Vikhr Team](https://t.me/vikhrlabs)
|
||||
30
added_tokens.json
Normal file
30
added_tokens.json
Normal file
@@ -0,0 +1,30 @@
|
||||
{
|
||||
"</tool_call>": 151658,
|
||||
"</tool_response>": 151668,
|
||||
"<tool_call>": 151657,
|
||||
"<tool_response>": 151667,
|
||||
"<|box_end|>": 151649,
|
||||
"<|box_start|>": 151648,
|
||||
"<|end_response|>": 151670,
|
||||
"<|end_thinking|>": 151666,
|
||||
"<|endoftext|>": 151643,
|
||||
"<|file_sep|>": 151664,
|
||||
"<|fim_middle|>": 151660,
|
||||
"<|fim_pad|>": 151662,
|
||||
"<|fim_prefix|>": 151659,
|
||||
"<|fim_suffix|>": 151661,
|
||||
"<|im_end|>": 151645,
|
||||
"<|im_start|>": 151644,
|
||||
"<|image_pad|>": 151655,
|
||||
"<|object_ref_end|>": 151647,
|
||||
"<|object_ref_start|>": 151646,
|
||||
"<|quad_end|>": 151651,
|
||||
"<|quad_start|>": 151650,
|
||||
"<|repo_name|>": 151663,
|
||||
"<|start_response|>": 151669,
|
||||
"<|start_thinking|>": 151665,
|
||||
"<|video_pad|>": 151656,
|
||||
"<|vision_end|>": 151653,
|
||||
"<|vision_pad|>": 151654,
|
||||
"<|vision_start|>": 151652
|
||||
}
|
||||
129
chat_template.jinja
Normal file
129
chat_template.jinja
Normal file
@@ -0,0 +1,129 @@
|
||||
{%- macro tool_call_id_to_int(messages, tool_call_id) %}
|
||||
{%- set counter = namespace(value=0) %}
|
||||
{%- set tool_call_id_seen = namespace(value=false) %}
|
||||
{%- for msg in messages %}
|
||||
{%- if msg.tool_calls %}
|
||||
{%- for tool_call in msg.tool_calls %}
|
||||
{%- if tool_call.id == tool_call_id and not tool_call_id_seen.value -%}
|
||||
{{ counter.value }}
|
||||
{%- set tool_call_id_seen.value = true %}
|
||||
{%- endif %}
|
||||
{%- set counter.value = counter.value + 1 %}
|
||||
{%- endfor %}
|
||||
{%- endif %}
|
||||
{%- endfor %}
|
||||
{%- endmacro %}
|
||||
|
||||
{%- macro check_is_error_tool(tool_msg) -%}
|
||||
{%- if tool_msg.is_error_tool -%}
|
||||
True
|
||||
{%- else -%}
|
||||
False
|
||||
{%- endif -%}
|
||||
{%- endmacro -%}
|
||||
|
||||
{%- macro format_tool_message(messages, tool_msg) -%}
|
||||
{# format tool message #}
|
||||
{
|
||||
"tool_call_id": "{{ tool_msg.tool_call_id }}",
|
||||
"results": {
|
||||
"0": {{ tool_msg.content|tojson }}
|
||||
},
|
||||
"is_error_tool": {{ check_is_error_tool(tool_msg) }}
|
||||
}
|
||||
{%- endmacro -%}
|
||||
|
||||
{%- if messages and messages[0]['role']|lower == 'system' %}{%- set developer_preamble = messages[0]['content'] %}{% endif %}
|
||||
{%- set tool_idx = namespace(value=0) %}
|
||||
{%- set tool_ids_seen = namespace(value=[]) %}
|
||||
{{- "<|im_start|>system
|
||||
" -}}
|
||||
{% if tools %}
|
||||
You have been trained to have advanced reasoning and tool-use capabilities and you should make best use of these skills to serve user's requests.
|
||||
|
||||
# Tool Use
|
||||
Think about how you can make best use of the provided tools to help with the task and come up with a high level plan that you will execute first.
|
||||
|
||||
0. Start by writing <|start_thinking|> followed by a detailed step by step plan of how you will solve the problem. For each step explain your thinking fully and give details of required tool calls (if needed). Unless specified otherwise, you write your plan in natural language. When you finish, close it out with <|end_thinking|>.
|
||||
You can optionally choose to skip this step when the user request is so straightforward to address that only a trivial plan would be needed.
|
||||
NOTE: You MUST skip this step when you are directly responding to the user's request without using any tools.
|
||||
|
||||
Then carry out your plan by repeatedly executing the following steps.
|
||||
1. Action: write <tool_call> followed by a list of JSON-formatted tool calls, with each one containing "tool_name" and "parameters" fields.
|
||||
When there are multiple tool calls which are completely independent of each other (i.e. they can be executed in parallel), you should list them out all together in one step. When you finish, close it out with </tool_call>.
|
||||
2. Observation: you will then receive results of those tool calls in JSON format in the very next turn, wrapped around by <tool_response> and </tool_response>. Carefully observe those results and think about what to do next. Note that these results will be provided to you in a separate turn. NEVER hallucinate results.
|
||||
Every tool call produces a list of results (when a tool call produces no result or a single result, it'll still get wrapped inside a list). Each result is clearly linked to its originating tool call via its "tool_call_id".
|
||||
3. Reflection: start the next turn by writing <|start_thinking|> followed by what you've figured out so far, any changes you need to make to your plan, and what you will do next. When you finish, close it out with <|end_thinking|>.
|
||||
You can optionally choose to skip this step when everything is going according to plan and no special pieces of information or reasoning chains need to be recorded.
|
||||
NOTE: You MUST skip this step when you are done with tool-use actions and are ready to respond to the user.
|
||||
|
||||
You can repeat the above 3 steps multiple times (could be 0 times too if no suitable tool calls are available or needed), until you decide it's time to finally respond to the user.
|
||||
|
||||
4. Response: then break out of the loop and write <|start_response|> followed by a piece of text which serves as a response to the user's last request. Use all previous tool calls and results to help you when formulating your response. When you finish, close it out with <|end_response|>.
|
||||
|
||||
# Available Tools
|
||||
Here is the list of tools that you have available to you.
|
||||
You can ONLY use the tools listed here. When a tool is not listed below, it is NOT available and you should NEVER attempt to use it.
|
||||
Each tool is represented as a JSON object with fields like "name", "description", "parameters" (per JSON Schema), and optionally, "responses" (per JSON Schema).
|
||||
|
||||
```json
|
||||
[
|
||||
{% for tool in tools %}
|
||||
{"name": "{{ tool['function']['name'] }}", "description": "{{tool['function']['description']}}", "parameters": {{ tool['function']['parameters']|tojson }}, "responses": null}{%- if not loop.last %},{% endif %}
|
||||
|
||||
{% endfor %}
|
||||
]
|
||||
```
|
||||
|
||||
{% endif %}
|
||||
{%- if developer_preamble %}
|
||||
{{ developer_preamble }}
|
||||
{%- endif -%}
|
||||
{{- "<|im_end|>" -}}
|
||||
{%- for message in messages %}
|
||||
{%- if message.role|lower == 'system' and not (loop.first and developer_preamble)%}
|
||||
{{- "
|
||||
<|im_start|>system
|
||||
" -}}
|
||||
{{- message.content + "<|im_end|>" -}}
|
||||
{%- elif message.role|lower == 'user' -%}
|
||||
{{- "
|
||||
<|im_start|>user
|
||||
" -}}
|
||||
{{- message.content + "<|im_end|>" -}}
|
||||
{%- elif message.role|lower == 'assistant' %}
|
||||
{{- "
|
||||
<|im_start|>assistant
|
||||
" -}}
|
||||
{% if message.tool_calls %}<|start_thinking|>{{message.tool_plan}}<|end_thinking|><tool_call>[
|
||||
{% for tc in message.tool_calls %}
|
||||
{"tool_call_id": "{{ tc.id }}", "tool_name": "{{ tc['function']['name'] }}", "parameters": {{ tc['function']['arguments']|tojson }}}{% if not loop.last %},{% endif %}
|
||||
|
||||
{% set tool_idx.value = tool_idx.value + 1 %}
|
||||
{% endfor %}
|
||||
]</tool_call>{{- "<|im_end|>" -}}
|
||||
{%- else -%}<|start_response|>{{message.content}}<|end_response|>{{- "<|im_end|>" -}}
|
||||
{% endif %}
|
||||
{% elif message.role|lower == 'tool' and message.tool_call_id not in tool_ids_seen.value %}
|
||||
{{- "
|
||||
<|im_start|>system
|
||||
<tool_response>[
|
||||
" -}}
|
||||
{{ format_tool_message(messages, message) }}
|
||||
{%- for msg in messages[loop.index0 + 1:] %}
|
||||
{%- if msg.role|lower == 'tool' %},
|
||||
{{ format_tool_message(messages, msg) }}
|
||||
{%- set tool_ids_seen.value = tool_ids_seen.value + [msg.tool_call_id] %}
|
||||
{%- else %}
|
||||
{%- break %}
|
||||
{%- endif %}
|
||||
{%- endfor %}
|
||||
{{- "
|
||||
]</tool_response><|im_end|>" -}}
|
||||
{%- endif -%}
|
||||
{%- endfor -%}
|
||||
{%- if add_generation_prompt -%}
|
||||
{{- "
|
||||
<|im_start|>assistant
|
||||
" -}}
|
||||
{%- endif -%}
|
||||
29
config.json
Normal file
29
config.json
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"_name_or_path": "DiTy/Qwen2.5-7B-Instruct-Tool-Planning",
|
||||
"architectures": [
|
||||
"Qwen2ForCausalLM"
|
||||
],
|
||||
"attention_dropout": 0.0,
|
||||
"bos_token_id": 151643,
|
||||
"eos_token_id": 151645,
|
||||
"hidden_act": "silu",
|
||||
"hidden_size": 3584,
|
||||
"initializer_range": 0.02,
|
||||
"intermediate_size": 18944,
|
||||
"max_position_embeddings": 32768,
|
||||
"max_window_layers": 28,
|
||||
"model_type": "qwen2",
|
||||
"num_attention_heads": 28,
|
||||
"num_hidden_layers": 28,
|
||||
"num_key_value_heads": 4,
|
||||
"rms_norm_eps": 1e-06,
|
||||
"rope_scaling": null,
|
||||
"rope_theta": 1000000.0,
|
||||
"sliding_window": null,
|
||||
"tie_word_embeddings": false,
|
||||
"torch_dtype": "bfloat16",
|
||||
"transformers_version": "4.48.3",
|
||||
"use_cache": true,
|
||||
"use_sliding_window": false,
|
||||
"vocab_size": 152064
|
||||
}
|
||||
1
configuration.json
Normal file
1
configuration.json
Normal file
@@ -0,0 +1 @@
|
||||
{"framework": "pytorch", "task": "text-generation", "allow_remote": true}
|
||||
14
generation_config.json
Normal file
14
generation_config.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"bos_token_id": 151643,
|
||||
"do_sample": true,
|
||||
"eos_token_id": [
|
||||
151645,
|
||||
151643
|
||||
],
|
||||
"pad_token_id": 151643,
|
||||
"repetition_penalty": 1.05,
|
||||
"temperature": 0.7,
|
||||
"top_k": 20,
|
||||
"top_p": 0.8,
|
||||
"transformers_version": "4.48.3"
|
||||
}
|
||||
BIN
merges.txt
(Stored with Git LFS)
Normal file
BIN
merges.txt
(Stored with Git LFS)
Normal file
Binary file not shown.
3
model-00001-of-00004.safetensors
Normal file
3
model-00001-of-00004.safetensors
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:8b3dd888e1a1e0e1df2e27c72ecddba53aff90ed4205f99b8243c072b1954e55
|
||||
size 4877660776
|
||||
3
model-00002-of-00004.safetensors
Normal file
3
model-00002-of-00004.safetensors
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:ecf314b8a0e31670a43f227e05a85a45e3dcc7786a08ae037fde7ba9d1c9b213
|
||||
size 4932751008
|
||||
3
model-00003-of-00004.safetensors
Normal file
3
model-00003-of-00004.safetensors
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:802a8e1cfd00de6eed771b698209dc6be951e25d18e84ee443179b1d8a6ec083
|
||||
size 4330865200
|
||||
3
model-00004-of-00004.safetensors
Normal file
3
model-00004-of-00004.safetensors
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:a62940a902a311922efa8cda4a38d6f01071febb6db2836172f2379700621d7e
|
||||
size 1089994880
|
||||
346
model.safetensors.index.json
Normal file
346
model.safetensors.index.json
Normal file
@@ -0,0 +1,346 @@
|
||||
{
|
||||
"metadata": {
|
||||
"total_size": 15231233024
|
||||
},
|
||||
"weight_map": {
|
||||
"lm_head.weight": "model-00004-of-00004.safetensors",
|
||||
"model.embed_tokens.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.0.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.0.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.0.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.0.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.0.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.0.self_attn.k_proj.bias": "model-00001-of-00004.safetensors",
|
||||
"model.layers.0.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.0.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.0.self_attn.q_proj.bias": "model-00001-of-00004.safetensors",
|
||||
"model.layers.0.self_attn.q_proj.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.0.self_attn.v_proj.bias": "model-00001-of-00004.safetensors",
|
||||
"model.layers.0.self_attn.v_proj.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.1.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.1.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.1.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.1.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.1.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.1.self_attn.k_proj.bias": "model-00001-of-00004.safetensors",
|
||||
"model.layers.1.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.1.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.1.self_attn.q_proj.bias": "model-00001-of-00004.safetensors",
|
||||
"model.layers.1.self_attn.q_proj.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.1.self_attn.v_proj.bias": "model-00001-of-00004.safetensors",
|
||||
"model.layers.1.self_attn.v_proj.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.10.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.10.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.10.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.10.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.10.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.10.self_attn.k_proj.bias": "model-00002-of-00004.safetensors",
|
||||
"model.layers.10.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.10.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.10.self_attn.q_proj.bias": "model-00002-of-00004.safetensors",
|
||||
"model.layers.10.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.10.self_attn.v_proj.bias": "model-00002-of-00004.safetensors",
|
||||
"model.layers.10.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.11.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.11.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.11.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.11.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.11.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.11.self_attn.k_proj.bias": "model-00002-of-00004.safetensors",
|
||||
"model.layers.11.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.11.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.11.self_attn.q_proj.bias": "model-00002-of-00004.safetensors",
|
||||
"model.layers.11.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.11.self_attn.v_proj.bias": "model-00002-of-00004.safetensors",
|
||||
"model.layers.11.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.12.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.12.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.12.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.12.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.12.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.12.self_attn.k_proj.bias": "model-00002-of-00004.safetensors",
|
||||
"model.layers.12.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.12.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.12.self_attn.q_proj.bias": "model-00002-of-00004.safetensors",
|
||||
"model.layers.12.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.12.self_attn.v_proj.bias": "model-00002-of-00004.safetensors",
|
||||
"model.layers.12.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.13.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.13.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.13.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.13.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.13.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.13.self_attn.k_proj.bias": "model-00002-of-00004.safetensors",
|
||||
"model.layers.13.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.13.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.13.self_attn.q_proj.bias": "model-00002-of-00004.safetensors",
|
||||
"model.layers.13.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.13.self_attn.v_proj.bias": "model-00002-of-00004.safetensors",
|
||||
"model.layers.13.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.14.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.14.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.14.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.14.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.14.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.14.self_attn.k_proj.bias": "model-00002-of-00004.safetensors",
|
||||
"model.layers.14.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.14.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.14.self_attn.q_proj.bias": "model-00002-of-00004.safetensors",
|
||||
"model.layers.14.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.14.self_attn.v_proj.bias": "model-00002-of-00004.safetensors",
|
||||
"model.layers.14.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.15.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.15.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.15.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.15.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.15.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.15.self_attn.k_proj.bias": "model-00002-of-00004.safetensors",
|
||||
"model.layers.15.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.15.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.15.self_attn.q_proj.bias": "model-00002-of-00004.safetensors",
|
||||
"model.layers.15.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.15.self_attn.v_proj.bias": "model-00002-of-00004.safetensors",
|
||||
"model.layers.15.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.16.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.16.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.16.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.16.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.16.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.16.self_attn.k_proj.bias": "model-00002-of-00004.safetensors",
|
||||
"model.layers.16.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.16.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.16.self_attn.q_proj.bias": "model-00002-of-00004.safetensors",
|
||||
"model.layers.16.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.16.self_attn.v_proj.bias": "model-00002-of-00004.safetensors",
|
||||
"model.layers.16.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.17.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.17.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.17.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.17.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.17.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.17.self_attn.k_proj.bias": "model-00002-of-00004.safetensors",
|
||||
"model.layers.17.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.17.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.17.self_attn.q_proj.bias": "model-00002-of-00004.safetensors",
|
||||
"model.layers.17.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.17.self_attn.v_proj.bias": "model-00002-of-00004.safetensors",
|
||||
"model.layers.17.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.18.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.18.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.18.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.18.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.18.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.18.self_attn.k_proj.bias": "model-00002-of-00004.safetensors",
|
||||
"model.layers.18.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.18.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.18.self_attn.q_proj.bias": "model-00002-of-00004.safetensors",
|
||||
"model.layers.18.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.18.self_attn.v_proj.bias": "model-00002-of-00004.safetensors",
|
||||
"model.layers.18.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.19.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.19.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.19.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.19.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.19.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.19.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
|
||||
"model.layers.19.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.19.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.19.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
|
||||
"model.layers.19.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.19.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
|
||||
"model.layers.19.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.2.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.2.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.2.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.2.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.2.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.2.self_attn.k_proj.bias": "model-00001-of-00004.safetensors",
|
||||
"model.layers.2.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.2.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.2.self_attn.q_proj.bias": "model-00001-of-00004.safetensors",
|
||||
"model.layers.2.self_attn.q_proj.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.2.self_attn.v_proj.bias": "model-00001-of-00004.safetensors",
|
||||
"model.layers.2.self_attn.v_proj.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.20.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.20.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.20.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.20.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.20.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.20.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
|
||||
"model.layers.20.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.20.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.20.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
|
||||
"model.layers.20.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.20.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
|
||||
"model.layers.20.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.21.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.21.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.21.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.21.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.21.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.21.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
|
||||
"model.layers.21.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.21.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.21.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
|
||||
"model.layers.21.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.21.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
|
||||
"model.layers.21.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.22.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.22.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.22.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.22.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.22.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.22.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
|
||||
"model.layers.22.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.22.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.22.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
|
||||
"model.layers.22.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.22.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
|
||||
"model.layers.22.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.23.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.23.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.23.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.23.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.23.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.23.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
|
||||
"model.layers.23.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.23.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.23.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
|
||||
"model.layers.23.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.23.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
|
||||
"model.layers.23.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.24.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.24.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.24.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.24.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.24.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.24.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
|
||||
"model.layers.24.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.24.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.24.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
|
||||
"model.layers.24.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.24.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
|
||||
"model.layers.24.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.25.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.25.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.25.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.25.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.25.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.25.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
|
||||
"model.layers.25.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.25.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.25.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
|
||||
"model.layers.25.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.25.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
|
||||
"model.layers.25.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.26.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.26.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.26.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.26.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.26.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.26.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
|
||||
"model.layers.26.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.26.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.26.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
|
||||
"model.layers.26.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.26.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
|
||||
"model.layers.26.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.27.input_layernorm.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.27.mlp.down_proj.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.27.mlp.gate_proj.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.27.mlp.up_proj.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.27.post_attention_layernorm.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.27.self_attn.k_proj.bias": "model-00003-of-00004.safetensors",
|
||||
"model.layers.27.self_attn.k_proj.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.27.self_attn.o_proj.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.27.self_attn.q_proj.bias": "model-00003-of-00004.safetensors",
|
||||
"model.layers.27.self_attn.q_proj.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.27.self_attn.v_proj.bias": "model-00003-of-00004.safetensors",
|
||||
"model.layers.27.self_attn.v_proj.weight": "model-00003-of-00004.safetensors",
|
||||
"model.layers.3.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.3.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.3.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.3.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.3.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.3.self_attn.k_proj.bias": "model-00001-of-00004.safetensors",
|
||||
"model.layers.3.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.3.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.3.self_attn.q_proj.bias": "model-00001-of-00004.safetensors",
|
||||
"model.layers.3.self_attn.q_proj.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.3.self_attn.v_proj.bias": "model-00001-of-00004.safetensors",
|
||||
"model.layers.3.self_attn.v_proj.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.4.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.4.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.4.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.4.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.4.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.4.self_attn.k_proj.bias": "model-00001-of-00004.safetensors",
|
||||
"model.layers.4.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.4.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.4.self_attn.q_proj.bias": "model-00001-of-00004.safetensors",
|
||||
"model.layers.4.self_attn.q_proj.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.4.self_attn.v_proj.bias": "model-00001-of-00004.safetensors",
|
||||
"model.layers.4.self_attn.v_proj.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.5.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.5.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.5.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.5.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.5.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.5.self_attn.k_proj.bias": "model-00001-of-00004.safetensors",
|
||||
"model.layers.5.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.5.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.5.self_attn.q_proj.bias": "model-00001-of-00004.safetensors",
|
||||
"model.layers.5.self_attn.q_proj.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.5.self_attn.v_proj.bias": "model-00001-of-00004.safetensors",
|
||||
"model.layers.5.self_attn.v_proj.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.6.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.6.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.6.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.6.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.6.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.6.self_attn.k_proj.bias": "model-00001-of-00004.safetensors",
|
||||
"model.layers.6.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.6.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.6.self_attn.q_proj.bias": "model-00001-of-00004.safetensors",
|
||||
"model.layers.6.self_attn.q_proj.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.6.self_attn.v_proj.bias": "model-00001-of-00004.safetensors",
|
||||
"model.layers.6.self_attn.v_proj.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.7.input_layernorm.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.7.mlp.down_proj.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.7.mlp.gate_proj.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.7.mlp.up_proj.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.7.post_attention_layernorm.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.7.self_attn.k_proj.bias": "model-00001-of-00004.safetensors",
|
||||
"model.layers.7.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.7.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.7.self_attn.q_proj.bias": "model-00001-of-00004.safetensors",
|
||||
"model.layers.7.self_attn.q_proj.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.7.self_attn.v_proj.bias": "model-00001-of-00004.safetensors",
|
||||
"model.layers.7.self_attn.v_proj.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.8.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.8.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.8.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.8.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.8.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.8.self_attn.k_proj.bias": "model-00001-of-00004.safetensors",
|
||||
"model.layers.8.self_attn.k_proj.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.8.self_attn.o_proj.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.8.self_attn.q_proj.bias": "model-00001-of-00004.safetensors",
|
||||
"model.layers.8.self_attn.q_proj.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.8.self_attn.v_proj.bias": "model-00001-of-00004.safetensors",
|
||||
"model.layers.8.self_attn.v_proj.weight": "model-00001-of-00004.safetensors",
|
||||
"model.layers.9.input_layernorm.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.9.mlp.down_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.9.mlp.gate_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.9.mlp.up_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.9.post_attention_layernorm.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.9.self_attn.k_proj.bias": "model-00002-of-00004.safetensors",
|
||||
"model.layers.9.self_attn.k_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.9.self_attn.o_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.9.self_attn.q_proj.bias": "model-00002-of-00004.safetensors",
|
||||
"model.layers.9.self_attn.q_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.layers.9.self_attn.v_proj.bias": "model-00002-of-00004.safetensors",
|
||||
"model.layers.9.self_attn.v_proj.weight": "model-00002-of-00004.safetensors",
|
||||
"model.norm.weight": "model-00003-of-00004.safetensors"
|
||||
}
|
||||
}
|
||||
122
qwen2_tool_parser.py
Normal file
122
qwen2_tool_parser.py
Normal file
@@ -0,0 +1,122 @@
|
||||
import json
|
||||
import re
|
||||
from typing import Dict, List, Sequence, Union
|
||||
|
||||
import partial_json_parser
|
||||
from partial_json_parser.core.options import Allow
|
||||
|
||||
from vllm.entrypoints.openai.protocol import (ChatCompletionRequest,
|
||||
DeltaFunctionCall, DeltaMessage,
|
||||
DeltaToolCall,
|
||||
ExtractedToolCallInformation,
|
||||
FunctionCall, ToolCall)
|
||||
from vllm.entrypoints.openai.tool_parsers.abstract_tool_parser import (
|
||||
ToolParser, ToolParserManager)
|
||||
from vllm.logger import init_logger
|
||||
from vllm.transformers_utils.tokenizer import AnyTokenizer, MistralTokenizer
|
||||
from vllm.utils import random_uuid
|
||||
|
||||
logger = init_logger(__name__)
|
||||
|
||||
|
||||
@ToolParserManager.register_module("qwen2")
|
||||
class Qwen2ToolParser(ToolParser):
|
||||
|
||||
def __init__(self, tokenizer: AnyTokenizer):
|
||||
super().__init__(tokenizer)
|
||||
|
||||
if isinstance(self.model_tokenizer, MistralTokenizer):
|
||||
logger.error(
|
||||
"Detected Mistral tokenizer when using a Qwen2.5 model")
|
||||
self.model_tokenizer = self.model_tokenizer.tokenizer
|
||||
|
||||
self.current_tool_name_sent: bool = False
|
||||
self.prev_tool_call_arr: List[Dict] = []
|
||||
self.current_tool_id: int = -1
|
||||
self.streamed_args_for_tool: List[str] = [
|
||||
] # map what has been streamed for each tool so far to a list
|
||||
|
||||
self.tool_call_start_token: str = "<tool_call>"
|
||||
self.tool_call_end_token: str = "</tool_call>"
|
||||
|
||||
self.tool_call_regex = re.compile(
|
||||
r"<tool_call>(.*?)</tool_call>", re.DOTALL)
|
||||
self.scratch_pad_regex = re.compile(
|
||||
r"<scratch_pad>(.*?)</scratch_pad>", re.DOTALL)
|
||||
|
||||
if not self.model_tokenizer:
|
||||
raise ValueError(
|
||||
"The model tokenizer must be passed to the ToolParser "
|
||||
"constructor during construction.")
|
||||
self.tool_call_start_token_id = self.vocab.get(
|
||||
self.tool_call_start_token)
|
||||
self.tool_call_end_token_id = self.vocab.get(self.tool_call_end_token)
|
||||
if (self.tool_call_start_token_id is None
|
||||
or self.tool_call_end_token_id is None):
|
||||
raise RuntimeError(
|
||||
"Qwen2.5 Tool parser could not locate tool call start/end "
|
||||
"tokens in the tokenizer!")
|
||||
|
||||
def extract_tool_calls(
|
||||
self,
|
||||
model_output: str,
|
||||
request: ChatCompletionRequest,
|
||||
) -> ExtractedToolCallInformation:
|
||||
|
||||
# sanity check; avoid unnecessary processing
|
||||
if self.tool_call_start_token not in model_output:
|
||||
return ExtractedToolCallInformation(tools_called=False,
|
||||
tool_calls=[],
|
||||
content=model_output)
|
||||
|
||||
else:
|
||||
|
||||
try:
|
||||
# find all tool calls between "<tool_call>" and "</tool_call>"
|
||||
# the other is None
|
||||
function_call_strs = (
|
||||
self.tool_call_regex.findall(model_output))
|
||||
|
||||
# load the JSON, and then use it to build the Function and
|
||||
# Tool Call
|
||||
raw_function_calls = json.loads(function_call_strs[0])
|
||||
|
||||
tool_calls = [
|
||||
ToolCall(
|
||||
type="function",
|
||||
function=FunctionCall(
|
||||
name=function_call["tool_name"],
|
||||
# function call args are JSON but as a string
|
||||
arguments=json.dumps(function_call["parameters"], ensure_ascii=False)
|
||||
)
|
||||
)
|
||||
for function_call in raw_function_calls
|
||||
]
|
||||
|
||||
content = model_output[:model_output.
|
||||
find(self.tool_call_start_token)]
|
||||
return ExtractedToolCallInformation(
|
||||
tools_called=True,
|
||||
tool_calls=tool_calls,
|
||||
content=content if content else None)
|
||||
|
||||
except Exception:
|
||||
logger.exception(
|
||||
"Error in extracting tool call from response.")
|
||||
return ExtractedToolCallInformation(tools_called=False,
|
||||
tool_calls=[],
|
||||
content=model_output)
|
||||
|
||||
# for streamed parsing
|
||||
def extract_tool_calls_streaming(
|
||||
self,
|
||||
previous_text: str,
|
||||
current_text: str,
|
||||
delta_text: str,
|
||||
previous_token_ids: Sequence[int],
|
||||
current_token_ids: Sequence[int],
|
||||
delta_token_ids: Sequence[int],
|
||||
request: ChatCompletionRequest,
|
||||
) -> Union[DeltaMessage, None]:
|
||||
|
||||
pass
|
||||
31
special_tokens_map.json
Normal file
31
special_tokens_map.json
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"additional_special_tokens": [
|
||||
"<|im_start|>",
|
||||
"<|im_end|>",
|
||||
"<|object_ref_start|>",
|
||||
"<|object_ref_end|>",
|
||||
"<|box_start|>",
|
||||
"<|box_end|>",
|
||||
"<|quad_start|>",
|
||||
"<|quad_end|>",
|
||||
"<|vision_start|>",
|
||||
"<|vision_end|>",
|
||||
"<|vision_pad|>",
|
||||
"<|image_pad|>",
|
||||
"<|video_pad|>"
|
||||
],
|
||||
"eos_token": {
|
||||
"content": "<|im_end|>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false
|
||||
},
|
||||
"pad_token": {
|
||||
"content": "<|endoftext|>",
|
||||
"lstrip": false,
|
||||
"normalized": false,
|
||||
"rstrip": false,
|
||||
"single_word": false
|
||||
}
|
||||
}
|
||||
3
tokenizer.json
Normal file
3
tokenizer.json
Normal file
@@ -0,0 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:7d2130c93e3748f162dd044ecc8a858f37f598282a1df036a56ee52c64b7c29f
|
||||
size 11423063
|
||||
256
tokenizer_config.json
Normal file
256
tokenizer_config.json
Normal file
File diff suppressed because one or more lines are too long
BIN
vocab.json
(Stored with Git LFS)
Normal file
BIN
vocab.json
(Stored with Git LFS)
Normal file
Binary file not shown.
Reference in New Issue
Block a user