PEFT
Safetensors
File size: 2,396 Bytes
a32bb29
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
{{- bos_token }}
    {%- if not tools is defined %}
        {%- set tools = none %}
    {%- endif %}
    {#- This block extracts the system/developer message, so we can slot it into the right place. #}
    {%- if messages[0]['role'] in ['system', 'developer'] %}
        {%- set system_message = messages[0]['content']|trim %}
        {%- set messages = messages[1:] %}
    {%- else %}
        {%- set system_message = "" %}
    {%- endif %}
    {#- System message #}
    {{- "<|start_header_id|>system<|end_header_id|>

" }}
    {%- if tools is not none and tools|length > 0 %}
        {{- "Environment: ipython
" }}
        {{- "You have access to the following functions. To call a function, please respond with JSON for a function call." }}
        {{- 'Respond in the format {"name": function name, "parameters": dictionary of argument name and its value}.' }}
        {{- "Do not use variables.

" }}
        {%- for t in tools %}
            {{- t | tojson }}
            {{- "

" }}
        {%- endfor %}
    {%- endif %}
    {{- system_message }}
    {{- "<|eot_id|>" }}
    {%- for message in messages %}
        {%- if not (message.role == 'tool' or 'tool_calls' in message) %}
            {{- '<|start_header_id|>' + message['role'] + '<|end_header_id|>

'+ message['content'] | trim + '<|eot_id|>' }}
        {%- elif 'tool_calls' in message %}
            {{- '<|start_header_id|>assistant<|end_header_id|>

' -}}
            {%- for tool_call in message.tool_calls -%}
                {{- '<|start_tool_call|>' }}
                {{- '{"name": "' + tool_call.function.name + '", ' }}
                {{- '"parameters": ' }}
                {{- tool_call.function.arguments | tojson }}
                {{- "}" }}
                {{- '<|end_tool_call|>' }}
                {%- if not loop.last %}, {% endif %}
            {%- endfor -%}
            {{- "<|eot_id|>" }}
        {%- elif message.role == "tool" %}
            {{- "<|start_header_id|>ipython<|end_header_id|>

" }}
            {%- if message.content is mapping or message.content is iterable %}
                {{- message.content | tojson }}
            {%- else %}
                {{- message.content }}
            {%- endif %}
            {{- "<|eot_id|>" }}
        {%- endif %}
    {%- endfor %}
    {%- if add_generation_prompt %}
        {{- '<|start_header_id|>assistant<|end_header_id|>

' }}
    {%- endif %}