Upload folder using huggingface_hub
Browse files- .gitattributes +1 -0
- README.md +187 -0
- chat_template.jinja +122 -0
- config.json +54 -0
- generation_config.json +7 -0
- model.safetensors +3 -0
- preprocessor_config.json +27 -0
- processor_config.json +8 -0
- special_tokens_map.json +30 -0
- tokenizer.json +3 -0
- tokenizer_config.json +0 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
README.md
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
library_name: transformers
|
| 3 |
+
pipeline_tag: image-text-to-text
|
| 4 |
+
inference: true
|
| 5 |
+
widget:
|
| 6 |
+
- text: Hello!
|
| 7 |
+
example_title: Hello world
|
| 8 |
+
group: Python
|
| 9 |
+
base_model:
|
| 10 |
+
- ServiceNow-AI/Apriel-1.5-15b-Thinker
|
| 11 |
+
---
|
| 12 |
+
|
| 13 |
+
This tiny model is intended for debugging. It is randomly initialized using the configuration adapted from [ServiceNow-AI/Apriel-1.5-15b-Thinker](https://huggingface.co/ServiceNow-AI/Apriel-1.5-15b-Thinker).
|
| 14 |
+
|
| 15 |
+
### Example usage:
|
| 16 |
+
|
| 17 |
+
```python
|
| 18 |
+
import re
|
| 19 |
+
import requests
|
| 20 |
+
import torch
|
| 21 |
+
from PIL import Image
|
| 22 |
+
from transformers import AutoProcessor, AutoModelForImageTextToText
|
| 23 |
+
|
| 24 |
+
# Load model
|
| 25 |
+
model_id = "tiny-random/apriel-1.5"
|
| 26 |
+
model = AutoModelForImageTextToText.from_pretrained(
|
| 27 |
+
model_id,
|
| 28 |
+
dtype=torch.bfloat16,
|
| 29 |
+
device_map="auto"
|
| 30 |
+
)
|
| 31 |
+
processor = AutoProcessor.from_pretrained(model_id)
|
| 32 |
+
url = "https://picsum.photos/id/237/200/300"
|
| 33 |
+
image = Image.open(requests.get(url, stream=True).raw).convert("RGB")
|
| 34 |
+
|
| 35 |
+
chat = [
|
| 36 |
+
{
|
| 37 |
+
"role": "user",
|
| 38 |
+
"content": [
|
| 39 |
+
{"type": "text", "text": "Which animal is this?"},
|
| 40 |
+
{"type": "image"},
|
| 41 |
+
],
|
| 42 |
+
}
|
| 43 |
+
]
|
| 44 |
+
prompt = processor.apply_chat_template(chat, add_generation_prompt=True, tokenize=False)
|
| 45 |
+
inputs = processor(text=prompt, images=[image], return_tensors="pt").to(model.device)
|
| 46 |
+
inputs.pop("token_type_ids", None)
|
| 47 |
+
inputs['pixel_values'] = inputs['pixel_values'].to(model.dtype)
|
| 48 |
+
|
| 49 |
+
with torch.no_grad():
|
| 50 |
+
output_ids = model.generate(**inputs, max_new_tokens=128, do_sample=True, temperature=0.6)
|
| 51 |
+
|
| 52 |
+
generated_ids = output_ids[:, inputs['input_ids'].shape[1]:]
|
| 53 |
+
output = processor.decode(generated_ids[0], skip_special_tokens=False)
|
| 54 |
+
print("Image Response:", output)
|
| 55 |
+
```
|
| 56 |
+
|
| 57 |
+
### Codes to create this repo:
|
| 58 |
+
|
| 59 |
+
```python
|
| 60 |
+
import json
|
| 61 |
+
from pathlib import Path
|
| 62 |
+
|
| 63 |
+
import accelerate
|
| 64 |
+
import torch
|
| 65 |
+
from huggingface_hub import file_exists, hf_hub_download
|
| 66 |
+
from transformers import (
|
| 67 |
+
AutoConfig,
|
| 68 |
+
AutoModelForCausalLM,
|
| 69 |
+
AutoProcessor,
|
| 70 |
+
GenerationConfig,
|
| 71 |
+
AutoModelForImageTextToText,
|
| 72 |
+
set_seed,
|
| 73 |
+
)
|
| 74 |
+
|
| 75 |
+
source_model_id = "ServiceNow-AI/Apriel-1.5-15b-Thinker"
|
| 76 |
+
save_folder = "/tmp/tiny-random/apriel-1.5"
|
| 77 |
+
|
| 78 |
+
processor = AutoProcessor.from_pretrained(source_model_id, trust_remote_code=True)
|
| 79 |
+
processor.save_pretrained(save_folder)
|
| 80 |
+
|
| 81 |
+
with open(hf_hub_download(source_model_id, filename='config.json', repo_type='model'), 'r', encoding='utf-8') as f:
|
| 82 |
+
config_json = json.load(f)
|
| 83 |
+
|
| 84 |
+
config_json['text_config'].update({
|
| 85 |
+
'head_dim': 32,
|
| 86 |
+
'hidden_size': 8,
|
| 87 |
+
'intermediate_size': 64,
|
| 88 |
+
'num_hidden_layers': 2,
|
| 89 |
+
'num_attention_heads': 8,
|
| 90 |
+
'num_key_value_heads': 4,
|
| 91 |
+
})
|
| 92 |
+
config_json['vision_config'].update(
|
| 93 |
+
{
|
| 94 |
+
'head_dim': 32,
|
| 95 |
+
'intermediate_size': 256,
|
| 96 |
+
'hidden_size': 32 * 4,
|
| 97 |
+
'num_attention_heads': 4,
|
| 98 |
+
'num_hidden_layers': 2,
|
| 99 |
+
}
|
| 100 |
+
)
|
| 101 |
+
with open(f"{save_folder}/config.json", "w", encoding='utf-8') as f:
|
| 102 |
+
json.dump(config_json, f, indent=2)
|
| 103 |
+
|
| 104 |
+
config = AutoConfig.from_pretrained(
|
| 105 |
+
save_folder,
|
| 106 |
+
trust_remote_code=True,
|
| 107 |
+
)
|
| 108 |
+
print(config)
|
| 109 |
+
torch.set_default_dtype(torch.bfloat16)
|
| 110 |
+
model = AutoModelForImageTextToText.from_config(config, trust_remote_code=True).to(torch.bfloat16)
|
| 111 |
+
torch.set_default_dtype(torch.float32)
|
| 112 |
+
if file_exists(filename="generation_config.json", repo_id=source_model_id, repo_type='model'):
|
| 113 |
+
model.generation_config = GenerationConfig.from_pretrained(
|
| 114 |
+
source_model_id, trust_remote_code=True,
|
| 115 |
+
)
|
| 116 |
+
model.generation_config.do_sample = True
|
| 117 |
+
print(model.generation_config)
|
| 118 |
+
model = model.cpu()
|
| 119 |
+
with torch.no_grad():
|
| 120 |
+
for name, p in sorted(model.named_parameters()):
|
| 121 |
+
torch.nn.init.normal_(p, 0, 0.1)
|
| 122 |
+
print(name, p.shape)
|
| 123 |
+
model.save_pretrained(save_folder)
|
| 124 |
+
```
|
| 125 |
+
|
| 126 |
+
### Printing the model:
|
| 127 |
+
|
| 128 |
+
```text
|
| 129 |
+
LlavaForConditionalGeneration(
|
| 130 |
+
(model): LlavaModel(
|
| 131 |
+
(vision_tower): PixtralVisionModel(
|
| 132 |
+
(patch_conv): Conv2d(3, 128, kernel_size=(16, 16), stride=(16, 16), bias=False)
|
| 133 |
+
(ln_pre): PixtralRMSNorm((128,), eps=1e-05)
|
| 134 |
+
(transformer): PixtralTransformer(
|
| 135 |
+
(layers): ModuleList(
|
| 136 |
+
(0-1): 2 x PixtralAttentionLayer(
|
| 137 |
+
(attention_norm): PixtralRMSNorm((128,), eps=1e-05)
|
| 138 |
+
(feed_forward): PixtralMLP(
|
| 139 |
+
(gate_proj): Linear(in_features=128, out_features=256, bias=False)
|
| 140 |
+
(up_proj): Linear(in_features=128, out_features=256, bias=False)
|
| 141 |
+
(down_proj): Linear(in_features=256, out_features=128, bias=False)
|
| 142 |
+
(act_fn): SiLU()
|
| 143 |
+
)
|
| 144 |
+
(attention): PixtralAttention(
|
| 145 |
+
(k_proj): Linear(in_features=128, out_features=128, bias=False)
|
| 146 |
+
(v_proj): Linear(in_features=128, out_features=128, bias=False)
|
| 147 |
+
(q_proj): Linear(in_features=128, out_features=128, bias=False)
|
| 148 |
+
(o_proj): Linear(in_features=128, out_features=128, bias=False)
|
| 149 |
+
)
|
| 150 |
+
(ffn_norm): PixtralRMSNorm((128,), eps=1e-05)
|
| 151 |
+
)
|
| 152 |
+
)
|
| 153 |
+
)
|
| 154 |
+
(patch_positional_embedding): PixtralRotaryEmbedding()
|
| 155 |
+
)
|
| 156 |
+
(multi_modal_projector): LlavaMultiModalProjector(
|
| 157 |
+
(linear_1): Linear(in_features=128, out_features=8, bias=True)
|
| 158 |
+
(act): GELUActivation()
|
| 159 |
+
(linear_2): Linear(in_features=8, out_features=8, bias=True)
|
| 160 |
+
)
|
| 161 |
+
(language_model): MistralModel(
|
| 162 |
+
(embed_tokens): Embedding(131072, 8)
|
| 163 |
+
(layers): ModuleList(
|
| 164 |
+
(0-1): 2 x MistralDecoderLayer(
|
| 165 |
+
(self_attn): MistralAttention(
|
| 166 |
+
(q_proj): Linear(in_features=8, out_features=256, bias=False)
|
| 167 |
+
(k_proj): Linear(in_features=8, out_features=128, bias=False)
|
| 168 |
+
(v_proj): Linear(in_features=8, out_features=128, bias=False)
|
| 169 |
+
(o_proj): Linear(in_features=256, out_features=8, bias=False)
|
| 170 |
+
)
|
| 171 |
+
(mlp): MistralMLP(
|
| 172 |
+
(gate_proj): Linear(in_features=8, out_features=64, bias=False)
|
| 173 |
+
(up_proj): Linear(in_features=8, out_features=64, bias=False)
|
| 174 |
+
(down_proj): Linear(in_features=64, out_features=8, bias=False)
|
| 175 |
+
(act_fn): SiLU()
|
| 176 |
+
)
|
| 177 |
+
(input_layernorm): MistralRMSNorm((8,), eps=1e-05)
|
| 178 |
+
(post_attention_layernorm): MistralRMSNorm((8,), eps=1e-05)
|
| 179 |
+
)
|
| 180 |
+
)
|
| 181 |
+
(norm): MistralRMSNorm((8,), eps=1e-05)
|
| 182 |
+
(rotary_emb): MistralRotaryEmbedding()
|
| 183 |
+
)
|
| 184 |
+
)
|
| 185 |
+
(lm_head): Linear(in_features=8, out_features=131072, bias=False)
|
| 186 |
+
)
|
| 187 |
+
```
|
chat_template.jinja
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{%- set available_tools_string, thought_instructions, add_tool_id, tool_output_format = '', '', true, "default" -%}
|
| 2 |
+
|
| 3 |
+
{%- if tools is not none and tools|length > 0 -%}
|
| 4 |
+
{%- set available_tools_string -%}
|
| 5 |
+
You are provided with function signatures within <available_tools></available_tools> XML tags. You may call one or more functions to assist with the user query. Don't make assumptions about the arguments. You should infer the argument values from previous user responses and the system message. Here are the available tools:
|
| 6 |
+
<available_tools>
|
| 7 |
+
{% for tool in tools %}
|
| 8 |
+
{{ tool|string }}
|
| 9 |
+
{% endfor %}
|
| 10 |
+
</available_tools>
|
| 11 |
+
{%- endset -%}
|
| 12 |
+
{%- endif -%}
|
| 13 |
+
{%- if tool_output_format is none or tool_output_format == "default" -%}
|
| 14 |
+
{%- set tool_output_instructions -%}
|
| 15 |
+
Return all function calls as a list of json objects within <tool_call></tool_call> XML tags. Each json object should contain a function name and arguments as follows:
|
| 16 |
+
<tool_calls>[{"name": <function-name-1>, "arguments": <args-dict-1>}, {"name": <function-name-2>, "arguments": <args-dict-2>},...]</tool_calls>
|
| 17 |
+
{%- endset -%}
|
| 18 |
+
{%- elif tool_output_format == "yaml" -%}
|
| 19 |
+
{%- set tool_output_instructions -%}
|
| 20 |
+
Return all function calls as a list of yaml objects within <tool_call></tool_call> XML tags. Each yaml object should contain a function name and arguments as follows:
|
| 21 |
+
<tool_calls>
|
| 22 |
+
- name: <function-name-1>
|
| 23 |
+
arguments: <args-dict-1>
|
| 24 |
+
- name: <function-name-2>
|
| 25 |
+
arguments: <args-dict-2>
|
| 26 |
+
...
|
| 27 |
+
</tool_calls>
|
| 28 |
+
{%- endset -%}
|
| 29 |
+
{%- endif -%}
|
| 30 |
+
{%- if add_thoughts -%}
|
| 31 |
+
{%- set thought_instructions -%}
|
| 32 |
+
Prior to generating the function calls, you should generate the reasoning for why you're calling the function. Please generate these reasoning thoughts between <thinking> and </thinking> XML tags.
|
| 33 |
+
{%- endset -%}
|
| 34 |
+
{%- endif -%}
|
| 35 |
+
{{- bos_token -}}
|
| 36 |
+
{%- set reasoning_prompt='You are a thoughtful and systematic AI assistant built by ServiceNow Language Models (SLAM) lab. Before providing an answer, analyze the problem carefully and present your reasoning step by step. After explaining your thought process, provide the final solution in the following format: [BEGIN FINAL RESPONSE] ... [END FINAL RESPONSE].' -%}
|
| 37 |
+
{%- if messages[0]['role'] != 'system' and tools is not none and tools|length > 0 -%}
|
| 38 |
+
{{- '<|system|>\n' + reasoning_prompt + available_tools_string + "\n" + tool_output_instructions + '\n<|end|>\n' -}}
|
| 39 |
+
{%- endif -%}
|
| 40 |
+
{%- if messages|selectattr('role', 'equalto', 'system')|list|length == 0 -%}
|
| 41 |
+
{{- '<|system|>\n' + reasoning_prompt + '\n<|end|>\n' -}}
|
| 42 |
+
{%- endif -%}
|
| 43 |
+
{%- for message in messages -%}
|
| 44 |
+
{%- if message['role'] == 'user' -%}
|
| 45 |
+
{{- '<|user|>\n' }}
|
| 46 |
+
{%- if message['content'] is not string %}
|
| 47 |
+
{%- for chunk in message['content'] %}
|
| 48 |
+
{%- if chunk['type'] == 'text' %}
|
| 49 |
+
{{- chunk['text'] }}
|
| 50 |
+
{%- elif chunk['type'] == 'image' or chunk['type'] == 'image_url'%}
|
| 51 |
+
{{- '[IMG]' }}
|
| 52 |
+
{%- else %}
|
| 53 |
+
{{- raise_exception('Unrecognized content type!') }}
|
| 54 |
+
{%- endif %}
|
| 55 |
+
{%- endfor %}
|
| 56 |
+
{%- else %}
|
| 57 |
+
{{- message['content'] }}
|
| 58 |
+
{%- endif %}
|
| 59 |
+
{{- '\n<|end|>\n' }}
|
| 60 |
+
{%- elif message['role'] == 'content' -%}
|
| 61 |
+
{%- if message['content'] is not string %}
|
| 62 |
+
{{- '<|content|>\n' + message['content'][0]['text'] + '\n<|end|>\n' -}}
|
| 63 |
+
{%- else %}
|
| 64 |
+
{{- '<|content|>\n' + message['content'] + '\n<|end|>\n' -}}
|
| 65 |
+
{%- endif -%}
|
| 66 |
+
{%- elif message['role'] == 'system' -%}
|
| 67 |
+
{%- if message['content'] is not none and message['content']|length > 0 %}
|
| 68 |
+
{%- if message['content'] is string %}
|
| 69 |
+
{%- set system_message = message['content'] %}
|
| 70 |
+
{%- else %}
|
| 71 |
+
{%- set system_message = message['content'][0]['text'] %}
|
| 72 |
+
{%- endif %}
|
| 73 |
+
{%- else %}
|
| 74 |
+
{%- set system_message = '' %}
|
| 75 |
+
{%- endif %}
|
| 76 |
+
{%- if tools is not none and tools|length > 0 -%}
|
| 77 |
+
{{- '<|system|>\n' + reasoning_prompt + system_message + '\n' + available_tools_string + '\n<|end|>\n' -}}
|
| 78 |
+
{%- else -%}
|
| 79 |
+
{{- '<|system|>\n' + reasoning_prompt + system_message + '\n<|end|>\n' -}}
|
| 80 |
+
{%- endif -%}
|
| 81 |
+
{%- elif message['role'] == 'assistant' -%}
|
| 82 |
+
{%- if loop.last -%}
|
| 83 |
+
{%- set add_tool_id = false -%}
|
| 84 |
+
{%- endif -%}
|
| 85 |
+
{{- '<|assistant|>\n' -}}
|
| 86 |
+
{%- if message['content'] is not none and message['content']|length > 0 -%}
|
| 87 |
+
{%- if message['content'] is not string and message['content'][0]['text'] is not none %}
|
| 88 |
+
{{- message['content'][0]['text'] }}
|
| 89 |
+
{%- else %}
|
| 90 |
+
{{- message['content'] -}}
|
| 91 |
+
{%- endif -%}
|
| 92 |
+
{%- elif message['chosen'] is not none and message['chosen']|length > 0 -%}
|
| 93 |
+
{{- message['chosen'][0] -}}
|
| 94 |
+
{%- endif -%}
|
| 95 |
+
{%- if add_thoughts and 'thought' in message and message['thought'] is not none -%}
|
| 96 |
+
{{- '<thinking>' + message['thought'] + '</thinking>' -}}
|
| 97 |
+
{%- endif -%}
|
| 98 |
+
{%- if message['tool_calls'] is not none and message['tool_calls']|length > 0 -%}
|
| 99 |
+
{{- '\n<tool_calls>[' -}}
|
| 100 |
+
{%- for tool_call in message["tool_calls"] -%}
|
| 101 |
+
{{- '{"name": "' + tool_call['function']['name'] + '", "arguments": ' + tool_call['function']['arguments']|string -}}
|
| 102 |
+
{%- if add_tool_id == true -%}
|
| 103 |
+
{{- ', "id": "' + tool_call['id'] + '"' -}}
|
| 104 |
+
{%- endif -%}
|
| 105 |
+
{{- '}' -}}
|
| 106 |
+
{%- if not loop.last -%}{{- ', ' -}}{%- endif -%}
|
| 107 |
+
{%- endfor -%}
|
| 108 |
+
{{- ']</tool_calls>' -}}
|
| 109 |
+
{%- endif -%}
|
| 110 |
+
{{- '\n<|end|>\n' + eos_token -}}
|
| 111 |
+
{%- elif message['role'] == 'tool' -%}
|
| 112 |
+
{%- if message['content'] is string %}
|
| 113 |
+
{%- set tool_message = message['content'] %}
|
| 114 |
+
{%- else %}
|
| 115 |
+
{%- set tool_message = message['content'][0]['text'] %}
|
| 116 |
+
{%- endif -%}
|
| 117 |
+
{{- '<|tool_result|>\n' + tool_message|string + '\n<|end|>\n' -}}
|
| 118 |
+
{%- endif -%}
|
| 119 |
+
{%- if loop.last and add_generation_prompt and message['role'] != 'assistant' -%}
|
| 120 |
+
{{- '<|assistant|>\n' -}}
|
| 121 |
+
{%- endif -%}
|
| 122 |
+
{%- endfor -%}
|
config.json
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"LlavaForConditionalGeneration"
|
| 4 |
+
],
|
| 5 |
+
"dtype": "bfloat16",
|
| 6 |
+
"ignore_index": -100,
|
| 7 |
+
"image_seq_length": 1,
|
| 8 |
+
"image_token_index": 10,
|
| 9 |
+
"model_type": "llava",
|
| 10 |
+
"multimodal_projector_bias": true,
|
| 11 |
+
"projector_hidden_act": "gelu",
|
| 12 |
+
"text_config": {
|
| 13 |
+
"_attn_implementation_autoset": false,
|
| 14 |
+
"attention_dropout": 0.0,
|
| 15 |
+
"head_dim": 32,
|
| 16 |
+
"hidden_act": "silu",
|
| 17 |
+
"hidden_size": 8,
|
| 18 |
+
"initializer_range": 0.02,
|
| 19 |
+
"intermediate_size": 64,
|
| 20 |
+
"max_position_embeddings": 262400,
|
| 21 |
+
"model_type": "mistral",
|
| 22 |
+
"num_attention_heads": 8,
|
| 23 |
+
"num_hidden_layers": 2,
|
| 24 |
+
"num_key_value_heads": 4,
|
| 25 |
+
"rms_norm_eps": 1e-05,
|
| 26 |
+
"rope_theta": 1000000000.0,
|
| 27 |
+
"sliding_window": null,
|
| 28 |
+
"tf_legacy_loss": false,
|
| 29 |
+
"use_bfloat16": false,
|
| 30 |
+
"use_cache": true,
|
| 31 |
+
"vocab_size": 131072
|
| 32 |
+
},
|
| 33 |
+
"transformers_version": "4.57.0.dev0",
|
| 34 |
+
"vision_config": {
|
| 35 |
+
"_attn_implementation_autoset": false,
|
| 36 |
+
"attention_dropout": 0.0,
|
| 37 |
+
"head_dim": 32,
|
| 38 |
+
"hidden_act": "silu",
|
| 39 |
+
"hidden_size": 128,
|
| 40 |
+
"image_size": 1024,
|
| 41 |
+
"initializer_range": 0.02,
|
| 42 |
+
"intermediate_size": 256,
|
| 43 |
+
"model_type": "pixtral",
|
| 44 |
+
"num_attention_heads": 4,
|
| 45 |
+
"num_channels": 3,
|
| 46 |
+
"num_hidden_layers": 2,
|
| 47 |
+
"patch_size": 16,
|
| 48 |
+
"rope_theta": 10000.0,
|
| 49 |
+
"tf_legacy_loss": false,
|
| 50 |
+
"use_bfloat16": false
|
| 51 |
+
},
|
| 52 |
+
"vision_feature_layer": -1,
|
| 53 |
+
"vision_feature_select_strategy": "full"
|
| 54 |
+
}
|
generation_config.json
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_from_model_config": true,
|
| 3 |
+
"bos_token_id": 1,
|
| 4 |
+
"do_sample": true,
|
| 5 |
+
"eos_token_id": 2,
|
| 6 |
+
"transformers_version": "4.57.0.dev0"
|
| 7 |
+
}
|
model.safetensors
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:88b138e76f9bb1b8ebd1ac83c81bdebafb60efb3871e8a32ea4309d6da1bd1a1
|
| 3 |
+
size 5085984
|
preprocessor_config.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"do_convert_rgb": true,
|
| 3 |
+
"do_normalize": true,
|
| 4 |
+
"do_rescale": true,
|
| 5 |
+
"do_resize": true,
|
| 6 |
+
"image_mean": [
|
| 7 |
+
0.48145466,
|
| 8 |
+
0.4578275,
|
| 9 |
+
0.40821073
|
| 10 |
+
],
|
| 11 |
+
"image_processor_type": "PixtralImageProcessor",
|
| 12 |
+
"image_std": [
|
| 13 |
+
0.26862954,
|
| 14 |
+
0.26130258,
|
| 15 |
+
0.27577711
|
| 16 |
+
],
|
| 17 |
+
"patch_size": {
|
| 18 |
+
"height": 16,
|
| 19 |
+
"width": 16
|
| 20 |
+
},
|
| 21 |
+
"processor_class": "PixtralProcessor",
|
| 22 |
+
"resample": 3,
|
| 23 |
+
"rescale_factor": 0.00392156862745098,
|
| 24 |
+
"size": {
|
| 25 |
+
"longest_edge": 1024
|
| 26 |
+
}
|
| 27 |
+
}
|
processor_config.json
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"image_break_token": "[IMG_BREAK]",
|
| 3 |
+
"image_end_token": "[IMG_END]",
|
| 4 |
+
"image_token": "[IMG]",
|
| 5 |
+
"patch_size": 16,
|
| 6 |
+
"processor_class": "PixtralProcessor",
|
| 7 |
+
"spatial_merge_size": 1
|
| 8 |
+
}
|
special_tokens_map.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"bos_token": {
|
| 3 |
+
"content": "<s>",
|
| 4 |
+
"lstrip": false,
|
| 5 |
+
"normalized": false,
|
| 6 |
+
"rstrip": false,
|
| 7 |
+
"single_word": false
|
| 8 |
+
},
|
| 9 |
+
"eos_token": {
|
| 10 |
+
"content": "</s>",
|
| 11 |
+
"lstrip": false,
|
| 12 |
+
"normalized": false,
|
| 13 |
+
"rstrip": false,
|
| 14 |
+
"single_word": false
|
| 15 |
+
},
|
| 16 |
+
"pad_token": {
|
| 17 |
+
"content": "<pad>",
|
| 18 |
+
"lstrip": false,
|
| 19 |
+
"normalized": false,
|
| 20 |
+
"rstrip": false,
|
| 21 |
+
"single_word": false
|
| 22 |
+
},
|
| 23 |
+
"unk_token": {
|
| 24 |
+
"content": "<unk>",
|
| 25 |
+
"lstrip": false,
|
| 26 |
+
"normalized": false,
|
| 27 |
+
"rstrip": false,
|
| 28 |
+
"single_word": false
|
| 29 |
+
}
|
| 30 |
+
}
|
tokenizer.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:84f33e6f52b2833e8cc17229af8eea363f640a898f19a48184a2c7f6f5a88337
|
| 3 |
+
size 17077329
|
tokenizer_config.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|