Instructions to use AXERA-TECH/LocateAnything-3B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use AXERA-TECH/LocateAnything-3B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("zero-shot-object-detection", model="AXERA-TECH/LocateAnything-3B")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("AXERA-TECH/LocateAnything-3B", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Upload folder using huggingface_hub
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .gitattributes +44 -0
- README.md +165 -1
- assert/ocr.jpg +3 -0
- assert/person.jpg +3 -0
- assert/phrase_grounding.jpg +3 -0
- config.json +16 -0
- gradio_locateanything_axengine.py +477 -0
- image_encoder_mlp.axmodel +3 -0
- infer_locateanything_axengine.py +997 -0
- model.embed_tokens.weight.bfloat16.bin +3 -0
- post_config.json +14 -0
- qwen2.5_tokenizer/README.md +3 -0
- qwen2.5_tokenizer/added_tokens.json +1040 -0
- qwen2.5_tokenizer/chat_template.jinja +54 -0
- qwen2.5_tokenizer/chat_template.json +4 -0
- qwen2.5_tokenizer/config.json +125 -0
- qwen2.5_tokenizer/configuration_qwen2.py +148 -0
- qwen2.5_tokenizer/generation_config.json +7 -0
- qwen2.5_tokenizer/mask_magi_utils.py +101 -0
- qwen2.5_tokenizer/mask_sdpa_utils.py +232 -0
- qwen2.5_tokenizer/merges.txt +0 -0
- qwen2.5_tokenizer/model.safetensors.index.json +442 -0
- qwen2.5_tokenizer/model.safetensors.index.json.bak +442 -0
- qwen2.5_tokenizer/modeling_qwen2.py +1738 -0
- qwen2.5_tokenizer/quant_log.csv +253 -0
- qwen2.5_tokenizer/quantize_config.json +47 -0
- qwen2.5_tokenizer/qwen2_5_tokenizer.txt +0 -0
- qwen2.5_tokenizer/special_tokens_map.json +1053 -0
- qwen2.5_tokenizer/tokenizer.json +3 -0
- qwen2.5_tokenizer/tokenizer_config.json +20 -0
- qwen2.5_tokenizer/vocab.json +0 -0
- qwen2_5_tokenizer.txt +0 -0
- qwen2_p128_l0_together.axmodel +3 -0
- qwen2_p128_l10_together.axmodel +3 -0
- qwen2_p128_l11_together.axmodel +3 -0
- qwen2_p128_l12_together.axmodel +3 -0
- qwen2_p128_l13_together.axmodel +3 -0
- qwen2_p128_l14_together.axmodel +3 -0
- qwen2_p128_l15_together.axmodel +3 -0
- qwen2_p128_l16_together.axmodel +3 -0
- qwen2_p128_l17_together.axmodel +3 -0
- qwen2_p128_l18_together.axmodel +3 -0
- qwen2_p128_l19_together.axmodel +3 -0
- qwen2_p128_l1_together.axmodel +3 -0
- qwen2_p128_l20_together.axmodel +3 -0
- qwen2_p128_l21_together.axmodel +3 -0
- qwen2_p128_l22_together.axmodel +3 -0
- qwen2_p128_l23_together.axmodel +3 -0
- qwen2_p128_l24_together.axmodel +3 -0
- qwen2_p128_l25_together.axmodel +3 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,47 @@ 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 |
+
assert/ocr.jpg filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
assert/person.jpg filter=lfs diff=lfs merge=lfs -text
|
| 38 |
+
assert/phrase_grounding.jpg filter=lfs diff=lfs merge=lfs -text
|
| 39 |
+
image_encoder_mlp.axmodel filter=lfs diff=lfs merge=lfs -text
|
| 40 |
+
qwen2.5_tokenizer/tokenizer.json filter=lfs diff=lfs merge=lfs -text
|
| 41 |
+
qwen2_p128_l0_together.axmodel filter=lfs diff=lfs merge=lfs -text
|
| 42 |
+
qwen2_p128_l10_together.axmodel filter=lfs diff=lfs merge=lfs -text
|
| 43 |
+
qwen2_p128_l11_together.axmodel filter=lfs diff=lfs merge=lfs -text
|
| 44 |
+
qwen2_p128_l12_together.axmodel filter=lfs diff=lfs merge=lfs -text
|
| 45 |
+
qwen2_p128_l13_together.axmodel filter=lfs diff=lfs merge=lfs -text
|
| 46 |
+
qwen2_p128_l14_together.axmodel filter=lfs diff=lfs merge=lfs -text
|
| 47 |
+
qwen2_p128_l15_together.axmodel filter=lfs diff=lfs merge=lfs -text
|
| 48 |
+
qwen2_p128_l16_together.axmodel filter=lfs diff=lfs merge=lfs -text
|
| 49 |
+
qwen2_p128_l17_together.axmodel filter=lfs diff=lfs merge=lfs -text
|
| 50 |
+
qwen2_p128_l18_together.axmodel filter=lfs diff=lfs merge=lfs -text
|
| 51 |
+
qwen2_p128_l19_together.axmodel filter=lfs diff=lfs merge=lfs -text
|
| 52 |
+
qwen2_p128_l1_together.axmodel filter=lfs diff=lfs merge=lfs -text
|
| 53 |
+
qwen2_p128_l20_together.axmodel filter=lfs diff=lfs merge=lfs -text
|
| 54 |
+
qwen2_p128_l21_together.axmodel filter=lfs diff=lfs merge=lfs -text
|
| 55 |
+
qwen2_p128_l22_together.axmodel filter=lfs diff=lfs merge=lfs -text
|
| 56 |
+
qwen2_p128_l23_together.axmodel filter=lfs diff=lfs merge=lfs -text
|
| 57 |
+
qwen2_p128_l24_together.axmodel filter=lfs diff=lfs merge=lfs -text
|
| 58 |
+
qwen2_p128_l25_together.axmodel filter=lfs diff=lfs merge=lfs -text
|
| 59 |
+
qwen2_p128_l26_together.axmodel filter=lfs diff=lfs merge=lfs -text
|
| 60 |
+
qwen2_p128_l27_together.axmodel filter=lfs diff=lfs merge=lfs -text
|
| 61 |
+
qwen2_p128_l28_together.axmodel filter=lfs diff=lfs merge=lfs -text
|
| 62 |
+
qwen2_p128_l29_together.axmodel filter=lfs diff=lfs merge=lfs -text
|
| 63 |
+
qwen2_p128_l2_together.axmodel filter=lfs diff=lfs merge=lfs -text
|
| 64 |
+
qwen2_p128_l30_together.axmodel filter=lfs diff=lfs merge=lfs -text
|
| 65 |
+
qwen2_p128_l31_together.axmodel filter=lfs diff=lfs merge=lfs -text
|
| 66 |
+
qwen2_p128_l32_together.axmodel filter=lfs diff=lfs merge=lfs -text
|
| 67 |
+
qwen2_p128_l33_together.axmodel filter=lfs diff=lfs merge=lfs -text
|
| 68 |
+
qwen2_p128_l34_together.axmodel filter=lfs diff=lfs merge=lfs -text
|
| 69 |
+
qwen2_p128_l35_together.axmodel filter=lfs diff=lfs merge=lfs -text
|
| 70 |
+
qwen2_p128_l3_together.axmodel filter=lfs diff=lfs merge=lfs -text
|
| 71 |
+
qwen2_p128_l4_together.axmodel filter=lfs diff=lfs merge=lfs -text
|
| 72 |
+
qwen2_p128_l5_together.axmodel filter=lfs diff=lfs merge=lfs -text
|
| 73 |
+
qwen2_p128_l6_together.axmodel filter=lfs diff=lfs merge=lfs -text
|
| 74 |
+
qwen2_p128_l7_together.axmodel filter=lfs diff=lfs merge=lfs -text
|
| 75 |
+
qwen2_p128_l8_together.axmodel filter=lfs diff=lfs merge=lfs -text
|
| 76 |
+
qwen2_p128_l9_together.axmodel filter=lfs diff=lfs merge=lfs -text
|
| 77 |
+
qwen2_post.axmodel filter=lfs diff=lfs merge=lfs -text
|
| 78 |
+
test_data/ocr.jpg filter=lfs diff=lfs merge=lfs -text
|
| 79 |
+
test_data/person.jpg filter=lfs diff=lfs merge=lfs -text
|
README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|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
license: mit
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
+
- zh
|
| 6 |
+
base_model:
|
| 7 |
+
- nvidia/LocateAnything-3B
|
| 8 |
+
pipeline_tag: detection, VLM
|
| 9 |
+
library_name: transformers
|
| 10 |
+
tags:
|
| 11 |
+
- LocateAnything-3B
|
| 12 |
+
- Int4
|
| 13 |
+
- VLM
|
| 14 |
+
- GPTQ
|
| 15 |
---
|
| 16 |
+
|
| 17 |
+
# LocateAnything-3B
|
| 18 |
+
|
| 19 |
+
This version of LocateAnything-3B have been converted to run on the Axera NPU using **w4a16** quantization.
|
| 20 |
+
|
| 21 |
+
Compatible with Pulsar2 version: 6.0
|
| 22 |
+
|
| 23 |
+
## Convert tools links:
|
| 24 |
+
|
| 25 |
+
For those who are interested in model conversion, you can try to export axmodel through the original repo :
|
| 26 |
+
|
| 27 |
+
- https://huggingface.co/nvidia/LocateAnything-3B
|
| 28 |
+
|
| 29 |
+
[Pulsar2 Link, How to Convert LLM from Huggingface to axmodel](https://pulsar2-docs.readthedocs.io/en/latest/appendix/build_llm.html)
|
| 30 |
+
|
| 31 |
+
[AXera NPU HOST LLM Runtime](TODO)
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
## Support Platform
|
| 35 |
+
|
| 36 |
+
- AX650
|
| 37 |
+
- AX650N DEMO Board
|
| 38 |
+
- [M4N-Dock(爱芯派Pro)](https://wiki.sipeed.com/hardware/zh/maixIV/m4ndock/m4ndock.html)
|
| 39 |
+
- [M.2 Accelerator card](https://docs.m5stack.com/zh_CN/ai_hardware/LLM-8850_Card)
|
| 40 |
+
|
| 41 |
+
**Image Process**
|
| 42 |
+
|Chips| input size | image num | image encoder | ttft(493 tokens) | w4a16 | CMM | Flash |
|
| 43 |
+
|--|--|--|--|--|--|--|--|
|
| 44 |
+
|AX650| 560*560 | 1 | 1152.583 ms | 2072.06 ms | 10.61 tokens/sec| 2.9GiB | 3.2GiB |
|
| 45 |
+
|
| 46 |
+
The DDR capacity refers to the CMM memory that needs to be consumed. Ensure that the CMM memory allocation on the development board is greater than this value.
|
| 47 |
+
|
| 48 |
+
## How to use
|
| 49 |
+
|
| 50 |
+
## 安装 axllm
|
| 51 |
+
方式一:克隆仓库后执行安装脚本:
|
| 52 |
+
|
| 53 |
+
```shell
|
| 54 |
+
git clone -b axllm https://github.com/AXERA-TECH/ax-llm.git
|
| 55 |
+
cd ax-llm
|
| 56 |
+
./install.sh
|
| 57 |
+
```
|
| 58 |
+
|
| 59 |
+
方式二:一行命令安装(默认分支 `axllm`):
|
| 60 |
+
|
| 61 |
+
```shell
|
| 62 |
+
curl -fsSL https://raw.githubusercontent.com/AXERA-TECH/ax-llm/axllm/install.sh | bash
|
| 63 |
+
```
|
| 64 |
+
|
| 65 |
+
方式三:下载Github Actions CI 导出的可执行程序(适合没有编译环境的用户):
|
| 66 |
+
|
| 67 |
+
如果没有编译环境,请到:
|
| 68 |
+
`https://github.com/AXERA-TECH/ax-llm/actions?query=branch%3Aaxllm`
|
| 69 |
+
下载 **最新 CI 导出的可执行程序**(`axllm`),然后:
|
| 70 |
+
|
| 71 |
+
```shell
|
| 72 |
+
chmod +x axllm
|
| 73 |
+
sudo mv axllm /usr/bin/axllm
|
| 74 |
+
```
|
| 75 |
+
|
| 76 |
+
## 模型下载(Hugging Face)
|
| 77 |
+
先创建模型目录并进入,然后下载到该目录:
|
| 78 |
+
|
| 79 |
+
```shell
|
| 80 |
+
mkdir -p AXERA-TECH/LocateAnything-3B
|
| 81 |
+
cd AXERA-TECH/LocateAnything-3B
|
| 82 |
+
hf download AXERA-TECH/LocateAnything-3B --local-dir .
|
| 83 |
+
|
| 84 |
+
# structure of the downloaded files
|
| 85 |
+
tree -L 3
|
| 86 |
+
.
|
| 87 |
+
└── AXERA-TECH
|
| 88 |
+
└── LocateAnything-3B
|
| 89 |
+
|-- assert
|
| 90 |
+
|-- config.json
|
| 91 |
+
|-- gradio_locateanything_axengine.py
|
| 92 |
+
|-- image_encoder_mlp.axmodel
|
| 93 |
+
|-- infer_locateanything_axengine.py
|
| 94 |
+
|-- model.embed_tokens.weight.bfloat16.bin
|
| 95 |
+
|-- post_config.json
|
| 96 |
+
|-- qwen2.5_tokenizer
|
| 97 |
+
|-- qwen2_5_tokenizer.txt
|
| 98 |
+
|-- qwen2_p128_l0_together.axmodel
|
| 99 |
+
|-- qwen2_p128_l10_together.axmodel
|
| 100 |
+
|-- qwen2_p128_l11_together.axmodel
|
| 101 |
+
|-- qwen2_p128_l12_together.axmodel
|
| 102 |
+
|-- qwen2_p128_l13_together.axmodel
|
| 103 |
+
|-- qwen2_p128_l14_together.axmodel
|
| 104 |
+
|-- qwen2_p128_l15_together.axmodel
|
| 105 |
+
|-- qwen2_p128_l16_together.axmodel
|
| 106 |
+
|-- qwen2_p128_l17_together.axmodel
|
| 107 |
+
|-- qwen2_p128_l18_together.axmodel
|
| 108 |
+
|-- qwen2_p128_l19_together.axmodel
|
| 109 |
+
|-- qwen2_p128_l1_together.axmodel
|
| 110 |
+
|-- qwen2_p128_l20_together.axmodel
|
| 111 |
+
|-- qwen2_p128_l21_together.axmodel
|
| 112 |
+
|-- qwen2_p128_l22_together.axmodel
|
| 113 |
+
|-- qwen2_p128_l23_together.axmodel
|
| 114 |
+
|-- qwen2_p128_l24_together.axmodel
|
| 115 |
+
|-- qwen2_p128_l25_together.axmodel
|
| 116 |
+
|-- qwen2_p128_l26_together.axmodel
|
| 117 |
+
|-- qwen2_p128_l27_together.axmodel
|
| 118 |
+
|-- qwen2_p128_l28_together.axmodel
|
| 119 |
+
|-- qwen2_p128_l29_together.axmodel
|
| 120 |
+
|-- qwen2_p128_l2_together.axmodel
|
| 121 |
+
|-- qwen2_p128_l30_together.axmodel
|
| 122 |
+
|-- qwen2_p128_l31_together.axmodel
|
| 123 |
+
|-- qwen2_p128_l32_together.axmodel
|
| 124 |
+
|-- qwen2_p128_l33_together.axmodel
|
| 125 |
+
|-- qwen2_p128_l34_together.axmodel
|
| 126 |
+
|-- qwen2_p128_l35_together.axmodel
|
| 127 |
+
|-- qwen2_p128_l3_together.axmodel
|
| 128 |
+
|-- qwen2_p128_l4_together.axmodel
|
| 129 |
+
|-- qwen2_p128_l5_together.axmodel
|
| 130 |
+
|-- qwen2_p128_l6_together.axmodel
|
| 131 |
+
|-- qwen2_p128_l7_together.axmodel
|
| 132 |
+
|-- qwen2_p128_l8_together.axmodel
|
| 133 |
+
|-- qwen2_p128_l9_together.axmodel
|
| 134 |
+
|-- qwen2_post.axmodel
|
| 135 |
+
|-- results
|
| 136 |
+
`-- test_data
|
| 137 |
+
|
| 138 |
+
4 directories, 44 files
|
| 139 |
+
```
|
| 140 |
+
|
| 141 |
+
## Inference with AX650 Host, such as M4N-Dock(爱芯派Pro) or AX650N DEMO Board
|
| 142 |
+
|
| 143 |
+
### Gradio Demo
|
| 144 |
+
|
| 145 |
+
```shell
|
| 146 |
+
(base) root@ax650:~/LocateAnything# python gradio_locateanything_axengine.py
|
| 147 |
+
[INFO] Available providers: ['AxEngineExecutionProvider', 'AXCLRTExecutionProvider']
|
| 148 |
+
[Gradio] starting LocateAnything UI
|
| 149 |
+
[Gradio] local: http://127.0.0.1:7860
|
| 150 |
+
[Gradio] LAN: http://10.126.29.50:7860
|
| 151 |
+
[Gradio] LAN: http://10.126.29.68:7860
|
| 152 |
+
[Gradio] LAN: http://172.17.0.1:7860
|
| 153 |
+
[Gradio] Use another computer in the same LAN to open the LAN URL.
|
| 154 |
+
* Running on local URL: http://0.0.0.0:7860
|
| 155 |
+
* To create a public link, set `share=True` in `launch()`.
|
| 156 |
+
```
|
| 157 |
+
|
| 158 |
+
Output:
|
| 159 |
+
|
| 160 |
+
detection:
|
| 161 |
+

|
| 162 |
+
|
| 163 |
+
ocr:
|
| 164 |
+

|
| 165 |
+
|
| 166 |
+
phrase grounding:
|
| 167 |
+

|
assert/ocr.jpg
ADDED
|
Git LFS Details
|
assert/person.jpg
ADDED
|
Git LFS Details
|
assert/phrase_grounding.jpg
ADDED
|
Git LFS Details
|
config.json
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"system_prompt": "you are a helpful assistant.",
|
| 3 |
+
"model_name": "AXERA-TECH/Qwen2.5-locateanything",
|
| 4 |
+
"url_tokenizer_model": "qwen2_5_tokenizer.txt",
|
| 5 |
+
"tokenizer_type": "Qwen2_5",
|
| 6 |
+
"post_config_path": "post_config.json",
|
| 7 |
+
"template_filename_axmodel": "qwen2_p128_l%d_together.axmodel",
|
| 8 |
+
"axmodel_num": 36,
|
| 9 |
+
"filename_post_axmodel": "qwen2_post.axmodel",
|
| 10 |
+
"filename_tokens_embed": "model.embed_tokens.weight.bfloat16.bin",
|
| 11 |
+
"tokens_embed_num": 152681,
|
| 12 |
+
"tokens_embed_size": 2048,
|
| 13 |
+
"use_mmap_load_embed": true,
|
| 14 |
+
"use_mmap_load_layer": true,
|
| 15 |
+
"devices": [0]
|
| 16 |
+
}
|
gradio_locateanything_axengine.py
ADDED
|
@@ -0,0 +1,477 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Gradio UI for LocateAnything axengine inference.
|
| 3 |
+
|
| 4 |
+
The UI reuses infer_locateanything_axengine.py and keeps the same pure
|
| 5 |
+
axengine path: image encoder + AR LLM decode + strict streaming geometry
|
| 6 |
+
decode. Gradio is intentionally imported lazily so the script can print a
|
| 7 |
+
clear dependency error on boards where it is not preinstalled.
|
| 8 |
+
"""
|
| 9 |
+
|
| 10 |
+
from __future__ import annotations
|
| 11 |
+
|
| 12 |
+
import argparse
|
| 13 |
+
import json
|
| 14 |
+
import os
|
| 15 |
+
import queue
|
| 16 |
+
import re
|
| 17 |
+
import subprocess
|
| 18 |
+
import socket
|
| 19 |
+
import threading
|
| 20 |
+
import time
|
| 21 |
+
from pathlib import Path
|
| 22 |
+
from types import SimpleNamespace
|
| 23 |
+
|
| 24 |
+
from PIL import Image, UnidentifiedImageError
|
| 25 |
+
|
| 26 |
+
from infer_locateanything_axengine import (
|
| 27 |
+
DEFAULT_IMAGE_ENCODER,
|
| 28 |
+
DEFAULT_LLM_DIR,
|
| 29 |
+
DEFAULT_SYSTEM_PROMPT,
|
| 30 |
+
DEFAULT_TARGET,
|
| 31 |
+
DEFAULT_TOKENIZER,
|
| 32 |
+
LocateAnythingAxEngineRunner,
|
| 33 |
+
GeometryImageDrawer,
|
| 34 |
+
PROMPT_SPECS,
|
| 35 |
+
Point,
|
| 36 |
+
Box,
|
| 37 |
+
StreamingGeometryDecoder,
|
| 38 |
+
build_task_prompt,
|
| 39 |
+
time_geometry_decode,
|
| 40 |
+
)
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
SCRIPT_DIR = Path(__file__).resolve().parent
|
| 44 |
+
UI_DIR = SCRIPT_DIR / "results" / "gradio"
|
| 45 |
+
INPUT_DIR = UI_DIR / "inputs"
|
| 46 |
+
OUTPUT_DIR = UI_DIR / "outputs"
|
| 47 |
+
|
| 48 |
+
UI_TASKS = {
|
| 49 |
+
"Object Detection": "object_detection",
|
| 50 |
+
"Phrase Grounding (Single Box)": "phrase_grounding_single",
|
| 51 |
+
"Phrase Grounding (Multiple Boxes)": "phrase_grounding_multi",
|
| 52 |
+
"Text Grounding": "text_grounding",
|
| 53 |
+
"Scene Text Detection (OCR)": "scene_text_detection",
|
| 54 |
+
"Document Layout Analysis": "document_layout",
|
| 55 |
+
"GUI Grounding (Box)": "gui_grounding_box",
|
| 56 |
+
"GUI Grounding (Point)": "gui_grounding_point",
|
| 57 |
+
"Pointing": "pointing",
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
gr = None
|
| 61 |
+
|
| 62 |
+
|
| 63 |
+
def ensure_gradio() -> None:
|
| 64 |
+
global gr
|
| 65 |
+
if gr is not None:
|
| 66 |
+
return
|
| 67 |
+
try:
|
| 68 |
+
import gradio as gradio_module
|
| 69 |
+
except ModuleNotFoundError:
|
| 70 |
+
print("[ERROR] gradio is not installed.")
|
| 71 |
+
print("Install it first, for example: python3 -m pip install gradio")
|
| 72 |
+
raise SystemExit(1)
|
| 73 |
+
gr = gradio_module
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
class RunnerState:
|
| 77 |
+
def __init__(self, tokenizer: str, llm_dir: str, image_encoder: str):
|
| 78 |
+
self.tokenizer = tokenizer
|
| 79 |
+
self.llm_dir = llm_dir
|
| 80 |
+
self.image_encoder = image_encoder
|
| 81 |
+
self.runner: LocateAnythingAxEngineRunner | None = None
|
| 82 |
+
self.lock = threading.Lock()
|
| 83 |
+
|
| 84 |
+
def get_runner(self) -> LocateAnythingAxEngineRunner:
|
| 85 |
+
if self.runner is None:
|
| 86 |
+
self.runner = LocateAnythingAxEngineRunner(self.tokenizer, self.llm_dir, self.image_encoder)
|
| 87 |
+
return self.runner
|
| 88 |
+
|
| 89 |
+
def close(self) -> None:
|
| 90 |
+
if self.runner is not None:
|
| 91 |
+
self.runner.close()
|
| 92 |
+
self.runner = None
|
| 93 |
+
|
| 94 |
+
|
| 95 |
+
def get_lan_ips() -> list[str]:
|
| 96 |
+
ips = set()
|
| 97 |
+
try:
|
| 98 |
+
output = subprocess.check_output(["hostname", "-I"], text=True, timeout=2)
|
| 99 |
+
for item in output.split():
|
| 100 |
+
if item and not item.startswith("127.") and ":" not in item:
|
| 101 |
+
ips.add(item)
|
| 102 |
+
except (OSError, subprocess.SubprocessError):
|
| 103 |
+
pass
|
| 104 |
+
|
| 105 |
+
try:
|
| 106 |
+
output = subprocess.check_output(["ip", "-4", "addr", "show"], text=True, timeout=2)
|
| 107 |
+
for line in output.splitlines():
|
| 108 |
+
line = line.strip()
|
| 109 |
+
if not line.startswith("inet "):
|
| 110 |
+
continue
|
| 111 |
+
item = line.split()[1].split("/")[0]
|
| 112 |
+
if item and not item.startswith("127."):
|
| 113 |
+
ips.add(item)
|
| 114 |
+
except (OSError, subprocess.SubprocessError):
|
| 115 |
+
pass
|
| 116 |
+
|
| 117 |
+
try:
|
| 118 |
+
hostname = socket.gethostname()
|
| 119 |
+
for item in socket.gethostbyname_ex(hostname)[2]:
|
| 120 |
+
if item and not item.startswith("127."):
|
| 121 |
+
ips.add(item)
|
| 122 |
+
except OSError:
|
| 123 |
+
pass
|
| 124 |
+
|
| 125 |
+
try:
|
| 126 |
+
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
| 127 |
+
sock.connect(("8.8.8.8", 80))
|
| 128 |
+
ip = sock.getsockname()[0]
|
| 129 |
+
if ip and not ip.startswith("127."):
|
| 130 |
+
ips.add(ip)
|
| 131 |
+
sock.close()
|
| 132 |
+
except OSError:
|
| 133 |
+
pass
|
| 134 |
+
|
| 135 |
+
return sorted(ips) or ["127.0.0.1"]
|
| 136 |
+
|
| 137 |
+
|
| 138 |
+
def find_available_port(start_port: int, retries: int) -> int:
|
| 139 |
+
for port in range(start_port, start_port + retries + 1):
|
| 140 |
+
try:
|
| 141 |
+
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
|
| 142 |
+
sock.bind(("127.0.0.1", port))
|
| 143 |
+
return port
|
| 144 |
+
except OSError:
|
| 145 |
+
continue
|
| 146 |
+
raise OSError(f"Cannot find empty port in range: {start_port}-{start_port + retries}")
|
| 147 |
+
|
| 148 |
+
|
| 149 |
+
def save_uploaded_image(image: Image.Image) -> str:
|
| 150 |
+
INPUT_DIR.mkdir(parents=True, exist_ok=True)
|
| 151 |
+
ts = time.strftime("%Y%m%d_%H%M%S")
|
| 152 |
+
path = INPUT_DIR / f"upload_{ts}_{int(time.time() * 1000) % 1000:03d}.jpg"
|
| 153 |
+
image.convert("RGB").save(path)
|
| 154 |
+
return str(path)
|
| 155 |
+
|
| 156 |
+
|
| 157 |
+
def load_ui_image(path: str) -> Image.Image | None:
|
| 158 |
+
if not path or not os.path.exists(path):
|
| 159 |
+
return None
|
| 160 |
+
for _ in range(5):
|
| 161 |
+
try:
|
| 162 |
+
with Image.open(path) as image:
|
| 163 |
+
return image.convert("RGB").copy()
|
| 164 |
+
except (OSError, UnidentifiedImageError):
|
| 165 |
+
time.sleep(0.05)
|
| 166 |
+
return None
|
| 167 |
+
|
| 168 |
+
|
| 169 |
+
def drain_update_queue(update_queue: queue.Queue) -> None:
|
| 170 |
+
while True:
|
| 171 |
+
try:
|
| 172 |
+
update_queue.get_nowait()
|
| 173 |
+
except queue.Empty:
|
| 174 |
+
return
|
| 175 |
+
|
| 176 |
+
|
| 177 |
+
def build_prompt(ui_task: str, target_text: str, custom_prompt: str) -> tuple[str, str, str, str]:
|
| 178 |
+
task = UI_TASKS[ui_task]
|
| 179 |
+
if custom_prompt.strip():
|
| 180 |
+
ns = SimpleNamespace(prompt=custom_prompt.strip(), task=task, target=target_text.strip(), categories=None, phrase=None)
|
| 181 |
+
return build_task_prompt(ns)
|
| 182 |
+
|
| 183 |
+
target = target_text.strip() or DEFAULT_TARGET
|
| 184 |
+
spec = PROMPT_SPECS[task]
|
| 185 |
+
categories = target if spec.target_kind == "categories" else None
|
| 186 |
+
phrase = target if spec.target_kind == "phrase" else None
|
| 187 |
+
ns = SimpleNamespace(prompt=None, task=task, target=target, categories=categories, phrase=phrase)
|
| 188 |
+
return build_task_prompt(ns)
|
| 189 |
+
|
| 190 |
+
|
| 191 |
+
def box_to_dict(box: Box) -> dict[str, float]:
|
| 192 |
+
return {"x1": box.x1, "y1": box.y1, "x2": box.x2, "y2": box.y2}
|
| 193 |
+
|
| 194 |
+
|
| 195 |
+
def point_to_dict(point: Point) -> dict[str, float]:
|
| 196 |
+
return {"x": point.x, "y": point.y}
|
| 197 |
+
|
| 198 |
+
|
| 199 |
+
def format_coord(value: float) -> int:
|
| 200 |
+
return int(round(value))
|
| 201 |
+
|
| 202 |
+
|
| 203 |
+
def extract_ref_labels(text: str) -> list[str]:
|
| 204 |
+
refs = re.findall(r"<ref>(.*?)</ref>\s*<box>", text, flags=re.DOTALL)
|
| 205 |
+
return [ref.strip() for ref in refs]
|
| 206 |
+
|
| 207 |
+
|
| 208 |
+
def format_detection_results(
|
| 209 |
+
label: str,
|
| 210 |
+
boxes: list[Box],
|
| 211 |
+
points: list[Point],
|
| 212 |
+
ref_labels: list[str] | None = None,
|
| 213 |
+
) -> str:
|
| 214 |
+
fallback_ref = label or "text"
|
| 215 |
+
lines = []
|
| 216 |
+
ref_labels = ref_labels or []
|
| 217 |
+
for index, box in enumerate(boxes):
|
| 218 |
+
ref = ref_labels[index] if index < len(ref_labels) and ref_labels[index] else fallback_ref
|
| 219 |
+
box_value = [format_coord(box.x1), format_coord(box.y1), format_coord(box.x2), format_coord(box.y2)]
|
| 220 |
+
lines.append(json.dumps([ref, {"box": box_value}], ensure_ascii=False))
|
| 221 |
+
for point in points:
|
| 222 |
+
point_value = [format_coord(point.x), format_coord(point.y)]
|
| 223 |
+
lines.append(json.dumps([fallback_ref, {"point": point_value}], ensure_ascii=False))
|
| 224 |
+
return "\n".join(lines) if lines else "[]"
|
| 225 |
+
|
| 226 |
+
|
| 227 |
+
def make_json_result(
|
| 228 |
+
*,
|
| 229 |
+
task: str,
|
| 230 |
+
output_type: str,
|
| 231 |
+
target: str,
|
| 232 |
+
prompt: str,
|
| 233 |
+
token_ids: list[int],
|
| 234 |
+
text: str,
|
| 235 |
+
boxes: list[Box],
|
| 236 |
+
points: list[Point],
|
| 237 |
+
stream_boxes: list[dict],
|
| 238 |
+
stream_points: list[dict],
|
| 239 |
+
stream_consistent: bool,
|
| 240 |
+
stream_points_consistent: bool,
|
| 241 |
+
timings: dict,
|
| 242 |
+
output_image: str,
|
| 243 |
+
) -> dict:
|
| 244 |
+
return {
|
| 245 |
+
"task": task,
|
| 246 |
+
"task_output_type": output_type,
|
| 247 |
+
"target": target,
|
| 248 |
+
"prompt": prompt,
|
| 249 |
+
"token_ids": token_ids,
|
| 250 |
+
"text": text,
|
| 251 |
+
"boxes": [box_to_dict(box) for box in boxes],
|
| 252 |
+
"points": [point_to_dict(point) for point in points],
|
| 253 |
+
"stream_boxes": stream_boxes,
|
| 254 |
+
"stream_points": stream_points,
|
| 255 |
+
"stream_consistent": stream_consistent,
|
| 256 |
+
"stream_points_consistent": stream_points_consistent,
|
| 257 |
+
"timings": timings,
|
| 258 |
+
"output_image": output_image,
|
| 259 |
+
}
|
| 260 |
+
|
| 261 |
+
|
| 262 |
+
def create_infer_fn(state: RunnerState, args: argparse.Namespace):
|
| 263 |
+
def infer(
|
| 264 |
+
image: Image.Image | None,
|
| 265 |
+
ui_task: str,
|
| 266 |
+
target_text: str,
|
| 267 |
+
custom_prompt: str,
|
| 268 |
+
max_new_tokens: int,
|
| 269 |
+
temperature: float,
|
| 270 |
+
top_p: float,
|
| 271 |
+
repetition_penalty: float,
|
| 272 |
+
seed: int,
|
| 273 |
+
):
|
| 274 |
+
if image is None:
|
| 275 |
+
yield "请先上传图片。", None, None
|
| 276 |
+
return
|
| 277 |
+
|
| 278 |
+
OUTPUT_DIR.mkdir(parents=True, exist_ok=True)
|
| 279 |
+
image_path = save_uploaded_image(image)
|
| 280 |
+
ts = time.strftime("%Y%m%d_%H%M%S")
|
| 281 |
+
stem = f"{UI_TASKS[ui_task]}_{ts}_{int(time.time() * 1000) % 1000:03d}"
|
| 282 |
+
output_image = str(OUTPUT_DIR / f"{stem}.jpg")
|
| 283 |
+
output_json = str(OUTPUT_DIR / f"{stem}.json")
|
| 284 |
+
image.convert("RGB").save(output_image)
|
| 285 |
+
|
| 286 |
+
prompt, task, output_type, target = build_prompt(ui_task, target_text, custom_prompt)
|
| 287 |
+
image_size = Image.open(image_path).size
|
| 288 |
+
stream_decoder = StreamingGeometryDecoder(image_size)
|
| 289 |
+
stream_drawer = GeometryImageDrawer(image_path, output_image)
|
| 290 |
+
stream_boxes: list[dict] = []
|
| 291 |
+
stream_points: list[dict] = []
|
| 292 |
+
update_queue: queue.Queue = queue.Queue()
|
| 293 |
+
|
| 294 |
+
yield "", load_ui_image(output_image), None
|
| 295 |
+
|
| 296 |
+
def on_token(token_id: int, step: int, piece: str, elapsed_s: float) -> None:
|
| 297 |
+
geometry = stream_decoder.push(token_id)
|
| 298 |
+
if geometry is None:
|
| 299 |
+
return
|
| 300 |
+
kind, value = geometry
|
| 301 |
+
if kind == "box":
|
| 302 |
+
assert isinstance(value, Box)
|
| 303 |
+
index = len(stream_boxes) + 1
|
| 304 |
+
stream_drawer.add_box(value, index)
|
| 305 |
+
stream_boxes.append(
|
| 306 |
+
{
|
| 307 |
+
"index": index,
|
| 308 |
+
"token_step": step,
|
| 309 |
+
"elapsed_s": elapsed_s,
|
| 310 |
+
"box": box_to_dict(value),
|
| 311 |
+
}
|
| 312 |
+
)
|
| 313 |
+
update_queue.put(("update", None, output_image, None))
|
| 314 |
+
else:
|
| 315 |
+
assert isinstance(value, Point)
|
| 316 |
+
index = len(stream_points) + 1
|
| 317 |
+
stream_drawer.add_point(value, index)
|
| 318 |
+
stream_points.append(
|
| 319 |
+
{
|
| 320 |
+
"index": index,
|
| 321 |
+
"token_step": step,
|
| 322 |
+
"elapsed_s": elapsed_s,
|
| 323 |
+
"point": point_to_dict(value),
|
| 324 |
+
}
|
| 325 |
+
)
|
| 326 |
+
update_queue.put(("update", None, output_image, None))
|
| 327 |
+
|
| 328 |
+
def worker() -> None:
|
| 329 |
+
try:
|
| 330 |
+
with state.lock:
|
| 331 |
+
runner = state.get_runner()
|
| 332 |
+
token_ids, text, decoded_image_size, used_seed, timings = runner.generate(
|
| 333 |
+
prompt=prompt,
|
| 334 |
+
image_path=image_path,
|
| 335 |
+
max_new_tokens=int(max_new_tokens),
|
| 336 |
+
system_prompt=args.system_prompt,
|
| 337 |
+
temperature=float(temperature),
|
| 338 |
+
top_p=float(top_p),
|
| 339 |
+
repetition_penalty=float(repetition_penalty),
|
| 340 |
+
seed=int(seed),
|
| 341 |
+
on_token=on_token,
|
| 342 |
+
)
|
| 343 |
+
|
| 344 |
+
boxes, points, geometry_decode_s = time_geometry_decode(token_ids, decoded_image_size)
|
| 345 |
+
timings["geometry_decode_s"] = geometry_decode_s
|
| 346 |
+
stream_consistent = [item["box"] for item in stream_boxes] == [box_to_dict(box) for box in boxes]
|
| 347 |
+
stream_points_consistent = [item["point"] for item in stream_points] == [
|
| 348 |
+
point_to_dict(point) for point in points
|
| 349 |
+
]
|
| 350 |
+
|
| 351 |
+
if not stream_consistent or not stream_points_consistent:
|
| 352 |
+
from infer_locateanything_axengine import draw_geometries
|
| 353 |
+
|
| 354 |
+
draw_geometries(image_path, boxes, points, output_image)
|
| 355 |
+
|
| 356 |
+
result = make_json_result(
|
| 357 |
+
task=task,
|
| 358 |
+
output_type=output_type,
|
| 359 |
+
target=target,
|
| 360 |
+
prompt=prompt,
|
| 361 |
+
token_ids=token_ids,
|
| 362 |
+
text=text,
|
| 363 |
+
boxes=boxes,
|
| 364 |
+
points=points,
|
| 365 |
+
stream_boxes=stream_boxes,
|
| 366 |
+
stream_points=stream_points,
|
| 367 |
+
stream_consistent=stream_consistent,
|
| 368 |
+
stream_points_consistent=stream_points_consistent,
|
| 369 |
+
timings=timings,
|
| 370 |
+
output_image=output_image,
|
| 371 |
+
)
|
| 372 |
+
with open(output_json, "w", encoding="utf-8") as f:
|
| 373 |
+
json.dump(result, f, ensure_ascii=False, indent=2)
|
| 374 |
+
|
| 375 |
+
ref_labels = extract_ref_labels(text) if task == "scene_text_detection" else None
|
| 376 |
+
result_text = format_detection_results(target, boxes, points, ref_labels)
|
| 377 |
+
drain_update_queue(update_queue)
|
| 378 |
+
update_queue.put(("final", result_text, output_image, output_json))
|
| 379 |
+
except Exception as exc:
|
| 380 |
+
drain_update_queue(update_queue)
|
| 381 |
+
update_queue.put(("error", f"[ERROR] {type(exc).__name__}: {exc}", output_image, None))
|
| 382 |
+
finally:
|
| 383 |
+
update_queue.put(("done", None, None, None))
|
| 384 |
+
|
| 385 |
+
thread = threading.Thread(target=worker, daemon=True)
|
| 386 |
+
thread.start()
|
| 387 |
+
|
| 388 |
+
while True:
|
| 389 |
+
kind, log_value, image_value, file_value = update_queue.get()
|
| 390 |
+
if kind == "done":
|
| 391 |
+
break
|
| 392 |
+
if kind == "update":
|
| 393 |
+
yield gr.update(), load_ui_image(image_value), gr.update()
|
| 394 |
+
else:
|
| 395 |
+
yield log_value, load_ui_image(image_value), file_value
|
| 396 |
+
|
| 397 |
+
return infer
|
| 398 |
+
|
| 399 |
+
|
| 400 |
+
def build_ui(state: RunnerState, args: argparse.Namespace):
|
| 401 |
+
infer_fn = create_infer_fn(state, args)
|
| 402 |
+
with gr.Blocks(title="LocateAnything") as demo:
|
| 403 |
+
gr.Markdown("# LocateAnything Gradio UI")
|
| 404 |
+
gr.Markdown(
|
| 405 |
+
"上传图片,选择任务类型,输入类别、category set 或 phrase 后开始推理。OCR 任务可留空;box/point 会在生成过程中逐个写入输出图。"
|
| 406 |
+
)
|
| 407 |
+
with gr.Row():
|
| 408 |
+
with gr.Column(scale=1):
|
| 409 |
+
image = gr.Image(label="图片上传", type="pil")
|
| 410 |
+
task = gr.Dropdown(
|
| 411 |
+
label="任务类别",
|
| 412 |
+
choices=list(UI_TASKS),
|
| 413 |
+
value="Object Detection",
|
| 414 |
+
)
|
| 415 |
+
target = gr.Textbox(label="类别 / category set / phrase(OCR 可留空)", value=DEFAULT_TARGET)
|
| 416 |
+
custom_prompt = gr.Textbox(label="自定义 prompt(可选,填写后覆盖任务模板)", value="")
|
| 417 |
+
with gr.Accordion("生成参数", open=False):
|
| 418 |
+
max_new_tokens = gr.Slider(32, 512, value=512, step=1, label="max_new_tokens")
|
| 419 |
+
temperature = gr.Slider(0.0, 2.0, value=0.7, step=0.05, label="temperature")
|
| 420 |
+
top_p = gr.Slider(0.1, 1.0, value=0.9, step=0.01, label="top_p")
|
| 421 |
+
repetition_penalty = gr.Slider(1.0, 2.0, value=1.1, step=0.05, label="repetition_penalty")
|
| 422 |
+
seed = gr.Number(value=42, precision=0, label="seed")
|
| 423 |
+
run_btn = gr.Button("开始推理", variant="primary")
|
| 424 |
+
with gr.Column(scale=1):
|
| 425 |
+
output_image = gr.Image(label="原图结果流式可视化", type="pil")
|
| 426 |
+
log = gr.Textbox(label="最终检测结果 [ref, box]", lines=24)
|
| 427 |
+
json_file = gr.File(label="标准 JSON 结果下载")
|
| 428 |
+
|
| 429 |
+
run_btn.click(
|
| 430 |
+
infer_fn,
|
| 431 |
+
inputs=[image, task, target, custom_prompt, max_new_tokens, temperature, top_p, repetition_penalty, seed],
|
| 432 |
+
outputs=[log, output_image, json_file],
|
| 433 |
+
)
|
| 434 |
+
return demo
|
| 435 |
+
|
| 436 |
+
|
| 437 |
+
def parse_args() -> argparse.Namespace:
|
| 438 |
+
parser = argparse.ArgumentParser(description="LocateAnything Gradio UI")
|
| 439 |
+
parser.add_argument("--tokenizer", default=DEFAULT_TOKENIZER)
|
| 440 |
+
parser.add_argument("--llm-dir", default=DEFAULT_LLM_DIR)
|
| 441 |
+
parser.add_argument("--image-encoder", default=DEFAULT_IMAGE_ENCODER)
|
| 442 |
+
parser.add_argument("--system-prompt", default=DEFAULT_SYSTEM_PROMPT)
|
| 443 |
+
parser.add_argument("--host", default="0.0.0.0")
|
| 444 |
+
parser.add_argument("--port", type=int, default=7860)
|
| 445 |
+
parser.add_argument("--port-retries", type=int, default=20, help="Try following ports when --port is occupied.")
|
| 446 |
+
parser.add_argument("--share", action="store_true")
|
| 447 |
+
return parser.parse_args()
|
| 448 |
+
|
| 449 |
+
|
| 450 |
+
def main() -> None:
|
| 451 |
+
args = parse_args()
|
| 452 |
+
ensure_gradio()
|
| 453 |
+
UI_DIR.mkdir(parents=True, exist_ok=True)
|
| 454 |
+
state = RunnerState(args.tokenizer, args.llm_dir, args.image_encoder)
|
| 455 |
+
demo = build_ui(state, args)
|
| 456 |
+
selected_port = find_available_port(args.port, args.port_retries)
|
| 457 |
+
if selected_port != args.port:
|
| 458 |
+
print(f"[Gradio] port {args.port} is occupied, fallback to {selected_port}", flush=True)
|
| 459 |
+
|
| 460 |
+
print("[Gradio] starting LocateAnything UI", flush=True)
|
| 461 |
+
print(f"[Gradio] local: http://127.0.0.1:{selected_port}", flush=True)
|
| 462 |
+
for ip in get_lan_ips():
|
| 463 |
+
print(f"[Gradio] LAN: http://{ip}:{selected_port}", flush=True)
|
| 464 |
+
print("[Gradio] Use another computer in the same LAN to open the LAN URL.", flush=True)
|
| 465 |
+
|
| 466 |
+
try:
|
| 467 |
+
demo.queue(default_concurrency_limit=1).launch(
|
| 468 |
+
server_name=args.host,
|
| 469 |
+
server_port=selected_port,
|
| 470 |
+
share=args.share,
|
| 471 |
+
)
|
| 472 |
+
finally:
|
| 473 |
+
state.close()
|
| 474 |
+
|
| 475 |
+
|
| 476 |
+
if __name__ == "__main__":
|
| 477 |
+
main()
|
image_encoder_mlp.axmodel
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6f72727633e605bf7eda5eb0fd478a425297e065b161b9029f027c89cb545f93
|
| 3 |
+
size 592696349
|
infer_locateanything_axengine.py
ADDED
|
@@ -0,0 +1,997 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Pure Python LocateAnything inference with axengine.
|
| 3 |
+
|
| 4 |
+
This runner does not use axllm serve or OpenAI-compatible HTTP APIs. It runs:
|
| 5 |
+
1. image_encoder_mlp.axmodel
|
| 6 |
+
2. llm-4bit-650/qwen2_p128_l*_together.axmodel
|
| 7 |
+
3. llm-4bit-650/qwen2_post.axmodel
|
| 8 |
+
|
| 9 |
+
The implementation mirrors infer_axmodel.py's prefill/decode/post flow and
|
| 10 |
+
injects image encoder embeddings at LocateAnything's <IMG_CONTEXT> positions.
|
| 11 |
+
"""
|
| 12 |
+
|
| 13 |
+
from __future__ import annotations
|
| 14 |
+
|
| 15 |
+
import argparse
|
| 16 |
+
import atexit
|
| 17 |
+
import json
|
| 18 |
+
import os
|
| 19 |
+
import time
|
| 20 |
+
from dataclasses import dataclass
|
| 21 |
+
from typing import Sequence
|
| 22 |
+
|
| 23 |
+
import numpy as np
|
| 24 |
+
from axengine import InferenceSession
|
| 25 |
+
from ml_dtypes import bfloat16
|
| 26 |
+
from PIL import Image, ImageDraw, ImageFont
|
| 27 |
+
from tokenizers import Tokenizer
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
|
| 31 |
+
DEFAULT_TOKENIZER = os.path.join(SCRIPT_DIR, "qwen2.5_tokenizer", "tokenizer.json")
|
| 32 |
+
DEFAULT_LLM_DIR = os.path.join(SCRIPT_DIR)
|
| 33 |
+
DEFAULT_IMAGE_ENCODER = os.path.join(SCRIPT_DIR, "image_encoder_mlp.axmodel")
|
| 34 |
+
DEFAULT_IMAGE = os.path.join(SCRIPT_DIR, "test_data", "person.jpg")
|
| 35 |
+
DEFAULT_SYSTEM_PROMPT = "You are a helpful assistant."
|
| 36 |
+
DEFAULT_TASK = "object_detection"
|
| 37 |
+
DEFAULT_TARGET = "person"
|
| 38 |
+
|
| 39 |
+
PATCH_SIZE = 14
|
| 40 |
+
VISION_SIZE = 560
|
| 41 |
+
VISION_TOKENS = 400
|
| 42 |
+
HIDDEN_SIZE = 2048
|
| 43 |
+
VOCAB_SIZE = 152681
|
| 44 |
+
KV_CACHE_LEN = 1024
|
| 45 |
+
|
| 46 |
+
TOK_BOX_START = 151668
|
| 47 |
+
TOK_BOX_END = 151669
|
| 48 |
+
TOK_COORD_START = 151677
|
| 49 |
+
TOK_COORD_END = 152677
|
| 50 |
+
TOK_IMG_CONTEXT = 151665
|
| 51 |
+
TOK_EOS = 151645
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
@dataclass
|
| 55 |
+
class Box:
|
| 56 |
+
x1: float
|
| 57 |
+
y1: float
|
| 58 |
+
x2: float
|
| 59 |
+
y2: float
|
| 60 |
+
|
| 61 |
+
|
| 62 |
+
@dataclass
|
| 63 |
+
class Point:
|
| 64 |
+
x: float
|
| 65 |
+
y: float
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
@dataclass
|
| 69 |
+
class StreamBox:
|
| 70 |
+
index: int
|
| 71 |
+
token_step: int
|
| 72 |
+
elapsed_s: float
|
| 73 |
+
box: Box
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
@dataclass
|
| 77 |
+
class StreamPoint:
|
| 78 |
+
index: int
|
| 79 |
+
token_step: int
|
| 80 |
+
elapsed_s: float
|
| 81 |
+
point: Point
|
| 82 |
+
|
| 83 |
+
|
| 84 |
+
@dataclass
|
| 85 |
+
class LayerFiles:
|
| 86 |
+
layer_paths: list[str]
|
| 87 |
+
post_path: str
|
| 88 |
+
embed_path: str
|
| 89 |
+
|
| 90 |
+
|
| 91 |
+
@dataclass(frozen=True)
|
| 92 |
+
class PromptSpec:
|
| 93 |
+
output_type: str
|
| 94 |
+
target_kind: str | None
|
| 95 |
+
template: str
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
PROMPT_SPECS = {
|
| 99 |
+
"object_detection": PromptSpec(
|
| 100 |
+
"box",
|
| 101 |
+
"categories",
|
| 102 |
+
"Locate all the instances that matches the following description:{target}",
|
| 103 |
+
),
|
| 104 |
+
"phrase_grounding_single": PromptSpec(
|
| 105 |
+
"box",
|
| 106 |
+
"phrase",
|
| 107 |
+
"Locate a single instance that matches the following description: {target}.",
|
| 108 |
+
),
|
| 109 |
+
"phrase_grounding_multi": PromptSpec(
|
| 110 |
+
"box",
|
| 111 |
+
"phrase",
|
| 112 |
+
"Locate all the instances that match the following description: {target}.",
|
| 113 |
+
),
|
| 114 |
+
"text_grounding": PromptSpec("box", "phrase", "Please locate the text referred as {target}."),
|
| 115 |
+
"scene_text_detection": PromptSpec("box", None, "Detect all the text in box format."),
|
| 116 |
+
"document_layout": PromptSpec(
|
| 117 |
+
"box",
|
| 118 |
+
"categories",
|
| 119 |
+
"Detect all the objects in the image that belong to the category set: {target}.",
|
| 120 |
+
),
|
| 121 |
+
"gui_grounding_box": PromptSpec(
|
| 122 |
+
"box",
|
| 123 |
+
"phrase",
|
| 124 |
+
"Locate the region that matches the following description: {target}.",
|
| 125 |
+
),
|
| 126 |
+
"gui_grounding_point": PromptSpec("point", "phrase", "Point to: {target}."),
|
| 127 |
+
"pointing": PromptSpec("point", "phrase", "Point to: {target}."),
|
| 128 |
+
}
|
| 129 |
+
|
| 130 |
+
|
| 131 |
+
def release_ax_inference_session(session) -> None:
|
| 132 |
+
inner = getattr(session, "_sess", None)
|
| 133 |
+
unload = getattr(inner, "_unload", None)
|
| 134 |
+
if not callable(unload):
|
| 135 |
+
return
|
| 136 |
+
try:
|
| 137 |
+
unload()
|
| 138 |
+
except Exception as exc:
|
| 139 |
+
print(f"[WARN] Failed to unload axengine session cleanly: {exc}")
|
| 140 |
+
finally:
|
| 141 |
+
try:
|
| 142 |
+
inner._unload = lambda: None
|
| 143 |
+
except Exception:
|
| 144 |
+
pass
|
| 145 |
+
|
| 146 |
+
|
| 147 |
+
def dtype_from_axengine(dtype) -> np.dtype:
|
| 148 |
+
name = str(dtype).lower()
|
| 149 |
+
if "bfloat16" in name or "bf16" in name:
|
| 150 |
+
return bfloat16
|
| 151 |
+
if "float32" in name or "fp32" in name:
|
| 152 |
+
return np.float32
|
| 153 |
+
if "float16" in name or "fp16" in name:
|
| 154 |
+
return np.float16
|
| 155 |
+
if "uint32" in name or "u32" in name:
|
| 156 |
+
return np.uint32
|
| 157 |
+
raise ValueError(f"Unsupported axengine dtype: {dtype}")
|
| 158 |
+
|
| 159 |
+
|
| 160 |
+
def ensure_finite(name: str, arr: np.ndarray) -> None:
|
| 161 |
+
arr32 = np.asarray(arr, dtype=np.float32)
|
| 162 |
+
if not np.isfinite(arr32).all():
|
| 163 |
+
raise RuntimeError(f"{name} contains NaN/Inf")
|
| 164 |
+
|
| 165 |
+
|
| 166 |
+
def resolve_model_files(llm_dir: str) -> LayerFiles:
|
| 167 |
+
cfg_path = os.path.join(llm_dir, "config.json")
|
| 168 |
+
with open(cfg_path, "r", encoding="utf-8") as f:
|
| 169 |
+
cfg = json.load(f)
|
| 170 |
+
|
| 171 |
+
template = cfg.get("template_filename_axmodel", "qwen2_p128_l%d_together.axmodel")
|
| 172 |
+
num_layers = int(cfg.get("axmodel_num", 36))
|
| 173 |
+
layer_paths = [os.path.join(llm_dir, template % i) for i in range(num_layers)]
|
| 174 |
+
missing = [p for p in layer_paths if not os.path.exists(p)]
|
| 175 |
+
if missing:
|
| 176 |
+
raise FileNotFoundError(f"Missing layer axmodel: {missing[0]}")
|
| 177 |
+
|
| 178 |
+
post_path = os.path.join(llm_dir, cfg.get("filename_post_axmodel", "qwen2_post.axmodel"))
|
| 179 |
+
embed_path = os.path.join(llm_dir, cfg.get("filename_tokens_embed", "model.embed_tokens.weight.bfloat16.bin"))
|
| 180 |
+
if not os.path.exists(post_path):
|
| 181 |
+
raise FileNotFoundError(post_path)
|
| 182 |
+
if not os.path.exists(embed_path):
|
| 183 |
+
raise FileNotFoundError(embed_path)
|
| 184 |
+
return LayerFiles(layer_paths=layer_paths, post_path=post_path, embed_path=embed_path)
|
| 185 |
+
|
| 186 |
+
|
| 187 |
+
def image_to_patches(image_path: str) -> tuple[np.ndarray, tuple[int, int]]:
|
| 188 |
+
image = Image.open(image_path).convert("RGB")
|
| 189 |
+
original_size = image.size
|
| 190 |
+
if image.size != (VISION_SIZE, VISION_SIZE):
|
| 191 |
+
image = image.resize((VISION_SIZE, VISION_SIZE), Image.Resampling.BICUBIC)
|
| 192 |
+
|
| 193 |
+
# Match C++ LocateAnythingImageProcessor: uint8 RGB after Pillow-like
|
| 194 |
+
# resize, then normalize each pixel as v / 127.5 - 1.0.
|
| 195 |
+
arr = np.asarray(image, dtype=np.uint8).astype(np.float32)
|
| 196 |
+
arr = arr / 127.5 - 1.0
|
| 197 |
+
arr = arr.transpose(2, 0, 1)
|
| 198 |
+
|
| 199 |
+
c, h, w = arr.shape
|
| 200 |
+
h_grid = h // PATCH_SIZE
|
| 201 |
+
w_grid = w // PATCH_SIZE
|
| 202 |
+
patches = arr.reshape(c, h_grid, PATCH_SIZE, w_grid, PATCH_SIZE)
|
| 203 |
+
patches = patches.transpose(1, 3, 0, 2, 4)
|
| 204 |
+
patches = np.ascontiguousarray(patches.reshape(-1, c, PATCH_SIZE, PATCH_SIZE), dtype=np.float32)
|
| 205 |
+
return patches, original_size
|
| 206 |
+
|
| 207 |
+
|
| 208 |
+
def build_locateanything_prompt(
|
| 209 |
+
system_prompt: str,
|
| 210 |
+
prompt: str,
|
| 211 |
+
image_tokens: int = VISION_TOKENS,
|
| 212 |
+
) -> str:
|
| 213 |
+
media = "<image 1><img>" + "<IMG_CONTEXT>" * image_tokens + "</img>"
|
| 214 |
+
return (
|
| 215 |
+
f"<|im_start|>system\n{system_prompt}\n<|im_end|>\n"
|
| 216 |
+
"<|im_start|>user\n"
|
| 217 |
+
+ media
|
| 218 |
+
+ prompt
|
| 219 |
+
+ "<|im_end|>\n<|im_start|>assistant\n"
|
| 220 |
+
)
|
| 221 |
+
|
| 222 |
+
|
| 223 |
+
def make_feed(shapes: dict[str, tuple[int, ...]], values: dict[str, np.ndarray]) -> dict[str, np.ndarray]:
|
| 224 |
+
return {name: value for name, value in values.items() if name in shapes}
|
| 225 |
+
|
| 226 |
+
|
| 227 |
+
def build_task_prompt(args: argparse.Namespace) -> tuple[str, str, str, str]:
|
| 228 |
+
if args.prompt:
|
| 229 |
+
return args.prompt, "custom", "unknown", "custom"
|
| 230 |
+
|
| 231 |
+
spec = PROMPT_SPECS[args.task]
|
| 232 |
+
if spec.target_kind == "categories":
|
| 233 |
+
target = args.categories or args.target
|
| 234 |
+
elif spec.target_kind == "phrase":
|
| 235 |
+
target = args.phrase or args.target
|
| 236 |
+
else:
|
| 237 |
+
target = ""
|
| 238 |
+
|
| 239 |
+
if spec.target_kind is not None and not target:
|
| 240 |
+
raise ValueError(f"--task {args.task} requires --target, --categories, or --phrase")
|
| 241 |
+
|
| 242 |
+
prompt = spec.template.format(target=target)
|
| 243 |
+
return prompt, args.task, spec.output_type, target
|
| 244 |
+
|
| 245 |
+
|
| 246 |
+
class LocateAnythingAxEngineRunner:
|
| 247 |
+
def __init__(self, tokenizer_path: str, llm_dir: str, image_encoder_path: str):
|
| 248 |
+
self.tokenizer = Tokenizer.from_file(tokenizer_path)
|
| 249 |
+
self.files = resolve_model_files(llm_dir)
|
| 250 |
+
self.embed_matrix = np.memmap(self.files.embed_path, mode="r", dtype=np.uint16).view(bfloat16).reshape(
|
| 251 |
+
VOCAB_SIZE, HIDDEN_SIZE
|
| 252 |
+
)
|
| 253 |
+
|
| 254 |
+
self.image_encoder = InferenceSession(image_encoder_path)
|
| 255 |
+
self.layer_sessions = [InferenceSession(path) for path in self.files.layer_paths]
|
| 256 |
+
self.post_session = InferenceSession(self.files.post_path)
|
| 257 |
+
self._closed = False
|
| 258 |
+
atexit.register(self.close)
|
| 259 |
+
|
| 260 |
+
self.layer_decode_input_shapes: list[dict[str, tuple[int, ...]]] = []
|
| 261 |
+
self.layer_decode_input_dtypes: list[dict[str, np.dtype]] = []
|
| 262 |
+
self.layer_decode_output_names: list[list[str]] = []
|
| 263 |
+
self.layer_prefill_input_shapes: list[list[dict[str, tuple[int, ...]]]] = []
|
| 264 |
+
self.layer_prefill_input_dtypes: list[list[dict[str, np.dtype]]] = []
|
| 265 |
+
self.layer_prefill_output_names: list[list[list[str]]] = []
|
| 266 |
+
|
| 267 |
+
for session in self.layer_sessions:
|
| 268 |
+
decode_inputs = session.get_inputs(shape_group=0)
|
| 269 |
+
self.layer_decode_input_shapes.append({x.name: tuple(x.shape) for x in decode_inputs})
|
| 270 |
+
self.layer_decode_input_dtypes.append({x.name: dtype_from_axengine(x.dtype) for x in decode_inputs})
|
| 271 |
+
self.layer_decode_output_names.append([x.name for x in session.get_outputs(shape_group=0)])
|
| 272 |
+
|
| 273 |
+
group_shapes = []
|
| 274 |
+
group_dtypes = []
|
| 275 |
+
group_outputs = []
|
| 276 |
+
for shape_group in range(1, 64):
|
| 277 |
+
try:
|
| 278 |
+
inputs = session.get_inputs(shape_group=shape_group)
|
| 279 |
+
outputs = session.get_outputs(shape_group=shape_group)
|
| 280 |
+
except Exception:
|
| 281 |
+
break
|
| 282 |
+
group_shapes.append({x.name: tuple(x.shape) for x in inputs})
|
| 283 |
+
group_dtypes.append({x.name: dtype_from_axengine(x.dtype) for x in inputs})
|
| 284 |
+
group_outputs.append([x.name for x in outputs])
|
| 285 |
+
self.layer_prefill_input_shapes.append(group_shapes)
|
| 286 |
+
self.layer_prefill_input_dtypes.append(group_dtypes)
|
| 287 |
+
self.layer_prefill_output_names.append(group_outputs)
|
| 288 |
+
|
| 289 |
+
self.prefill_len = int(self.layer_prefill_input_shapes[0][0]["input"][1])
|
| 290 |
+
self.hidden_dtype = self.layer_decode_input_dtypes[0]["input"]
|
| 291 |
+
|
| 292 |
+
def close(self) -> None:
|
| 293 |
+
if self._closed:
|
| 294 |
+
return
|
| 295 |
+
release_ax_inference_session(self.image_encoder)
|
| 296 |
+
for session in self.layer_sessions:
|
| 297 |
+
release_ax_inference_session(session)
|
| 298 |
+
release_ax_inference_session(self.post_session)
|
| 299 |
+
self._closed = True
|
| 300 |
+
|
| 301 |
+
def encode_text(self, text: str) -> list[int]:
|
| 302 |
+
return self.tokenizer.encode(text, add_special_tokens=False).ids
|
| 303 |
+
|
| 304 |
+
def decode_text(self, token_ids: Sequence[int]) -> str:
|
| 305 |
+
return self.tokenizer.decode(list(token_ids), skip_special_tokens=False)
|
| 306 |
+
|
| 307 |
+
def embed_token(self, token_id: int) -> np.ndarray:
|
| 308 |
+
return np.asarray(self.embed_matrix[int(token_id)], dtype=self.hidden_dtype).reshape(1, 1, HIDDEN_SIZE)
|
| 309 |
+
|
| 310 |
+
def alloc_layer_states(self) -> tuple[list[np.ndarray], list[np.ndarray]]:
|
| 311 |
+
k_states = []
|
| 312 |
+
v_states = []
|
| 313 |
+
for shapes, dtypes in zip(self.layer_decode_input_shapes, self.layer_decode_input_dtypes):
|
| 314 |
+
k_states.append(np.zeros(shapes["K_cache"], dtype=dtypes["K_cache"]))
|
| 315 |
+
v_states.append(np.zeros(shapes["V_cache"], dtype=dtypes["V_cache"]))
|
| 316 |
+
return k_states, v_states
|
| 317 |
+
|
| 318 |
+
def encode_image(self, image_path: str) -> tuple[np.ndarray, tuple[int, int], dict[str, float]]:
|
| 319 |
+
t0 = time.perf_counter()
|
| 320 |
+
patches, original_size = image_to_patches(image_path)
|
| 321 |
+
preprocess_s = time.perf_counter() - t0
|
| 322 |
+
|
| 323 |
+
t1 = time.perf_counter()
|
| 324 |
+
input_name = self.image_encoder.get_inputs()[0].name
|
| 325 |
+
output = self.image_encoder.run(None, {input_name: patches})[0]
|
| 326 |
+
image_encoder_s = time.perf_counter() - t1
|
| 327 |
+
|
| 328 |
+
output = np.asarray(output, dtype=np.float32)
|
| 329 |
+
if output.shape != (VISION_TOKENS, HIDDEN_SIZE):
|
| 330 |
+
raise RuntimeError(f"Unexpected image encoder output shape: {output.shape}")
|
| 331 |
+
ensure_finite("image encoder output", output)
|
| 332 |
+
timings = {
|
| 333 |
+
"image_preprocess_s": preprocess_s,
|
| 334 |
+
"image_encoder_s": image_encoder_s,
|
| 335 |
+
"image_total_s": preprocess_s + image_encoder_s,
|
| 336 |
+
}
|
| 337 |
+
return output.astype(self.hidden_dtype), original_size, timings
|
| 338 |
+
|
| 339 |
+
def build_prompt_embeddings(
|
| 340 |
+
self,
|
| 341 |
+
prompt: str,
|
| 342 |
+
image_embeds: np.ndarray,
|
| 343 |
+
system_prompt: str,
|
| 344 |
+
) -> tuple[list[int], np.ndarray]:
|
| 345 |
+
text = build_locateanything_prompt(
|
| 346 |
+
system_prompt,
|
| 347 |
+
prompt,
|
| 348 |
+
image_tokens=image_embeds.shape[0],
|
| 349 |
+
)
|
| 350 |
+
token_ids = self.encode_text(text)
|
| 351 |
+
image_positions = [i for i, token_id in enumerate(token_ids) if token_id == TOK_IMG_CONTEXT]
|
| 352 |
+
if len(image_positions) != image_embeds.shape[0]:
|
| 353 |
+
raise RuntimeError(
|
| 354 |
+
f"image placeholder count mismatch: prompt={len(image_positions)} image_embeds={image_embeds.shape[0]}"
|
| 355 |
+
)
|
| 356 |
+
|
| 357 |
+
embeds = np.asarray(self.embed_matrix[np.asarray(token_ids, dtype=np.int64)], dtype=self.hidden_dtype)
|
| 358 |
+
embeds[image_positions, :] = image_embeds
|
| 359 |
+
return token_ids, embeds
|
| 360 |
+
|
| 361 |
+
@staticmethod
|
| 362 |
+
def prefill_history_capacity(shapes: dict[str, tuple[int, ...]]) -> int:
|
| 363 |
+
input_len = int(shapes.get("input", (1, 128))[1])
|
| 364 |
+
mask_shape = shapes.get("mask")
|
| 365 |
+
if mask_shape is not None and len(mask_shape) == 3:
|
| 366 |
+
return max(0, int(mask_shape[-1]) - input_len)
|
| 367 |
+
k_shape = shapes.get("K_cache")
|
| 368 |
+
if k_shape is not None and len(k_shape) >= 2:
|
| 369 |
+
return int(k_shape[1])
|
| 370 |
+
return 0
|
| 371 |
+
|
| 372 |
+
def select_prefill_shape_group(self, layer_idx: int, history_len: int) -> int:
|
| 373 |
+
groups = self.layer_prefill_input_shapes[layer_idx]
|
| 374 |
+
candidates = []
|
| 375 |
+
for offset, shapes in enumerate(groups):
|
| 376 |
+
cap = self.prefill_history_capacity(shapes)
|
| 377 |
+
if cap >= history_len:
|
| 378 |
+
candidates.append((cap, offset + 1))
|
| 379 |
+
if candidates:
|
| 380 |
+
return min(candidates)[1]
|
| 381 |
+
return max(range(1, len(groups) + 1), key=lambda gid: self.prefill_history_capacity(groups[gid - 1]))
|
| 382 |
+
|
| 383 |
+
def run_prefill(self, prompt_embeds: np.ndarray):
|
| 384 |
+
k_states, v_states = self.alloc_layer_states()
|
| 385 |
+
last_hidden = None
|
| 386 |
+
total_len = int(prompt_embeds.shape[0])
|
| 387 |
+
|
| 388 |
+
for start in range(0, total_len, self.prefill_len):
|
| 389 |
+
chunk = prompt_embeds[start : start + self.prefill_len]
|
| 390 |
+
chunk_len = int(chunk.shape[0])
|
| 391 |
+
data = np.zeros((1, self.prefill_len, HIDDEN_SIZE), dtype=self.hidden_dtype)
|
| 392 |
+
data[0, :chunk_len, :] = chunk
|
| 393 |
+
|
| 394 |
+
for layer_idx, session in enumerate(self.layer_sessions):
|
| 395 |
+
shape_group = self.select_prefill_shape_group(layer_idx, start)
|
| 396 |
+
layer_shapes = self.layer_prefill_input_shapes[layer_idx][shape_group - 1]
|
| 397 |
+
layer_dtypes = self.layer_prefill_input_dtypes[layer_idx][shape_group - 1]
|
| 398 |
+
history_cap = self.prefill_history_capacity(layer_shapes)
|
| 399 |
+
history_len = min(start, history_cap)
|
| 400 |
+
|
| 401 |
+
indices = np.zeros(layer_shapes["indices"], dtype=layer_dtypes["indices"])
|
| 402 |
+
indices.reshape(-1)[:chunk_len] = np.arange(start, start + chunk_len, dtype=np.uint32)
|
| 403 |
+
|
| 404 |
+
mask = np.full(layer_shapes["mask"], -65536.0, dtype=np.float32)
|
| 405 |
+
for q in range(chunk_len):
|
| 406 |
+
mask[:, q, : history_len + q + 1] = 0.0
|
| 407 |
+
mask = mask.astype(layer_dtypes["mask"])
|
| 408 |
+
|
| 409 |
+
k_feed = np.zeros(layer_shapes["K_cache"], dtype=layer_dtypes["K_cache"])
|
| 410 |
+
v_feed = np.zeros(layer_shapes["V_cache"], dtype=layer_dtypes["V_cache"])
|
| 411 |
+
if history_len > 0:
|
| 412 |
+
k_feed[:, :history_len, :] = k_states[layer_idx][:, :history_len, :]
|
| 413 |
+
v_feed[:, :history_len, :] = v_states[layer_idx][:, :history_len, :]
|
| 414 |
+
|
| 415 |
+
outputs = session.run(
|
| 416 |
+
None,
|
| 417 |
+
make_feed(
|
| 418 |
+
layer_shapes,
|
| 419 |
+
{
|
| 420 |
+
"K_cache": k_feed,
|
| 421 |
+
"V_cache": v_feed,
|
| 422 |
+
"indices": indices,
|
| 423 |
+
"input": data.astype(layer_dtypes["input"], copy=False),
|
| 424 |
+
"mask": mask,
|
| 425 |
+
},
|
| 426 |
+
),
|
| 427 |
+
shape_group=shape_group,
|
| 428 |
+
)
|
| 429 |
+
output_map = dict(zip(self.layer_prefill_output_names[layer_idx][shape_group - 1], outputs))
|
| 430 |
+
k_out = output_map.get("K_cache_out")
|
| 431 |
+
if k_out is not None:
|
| 432 |
+
k_states[layer_idx][:, start : start + chunk_len, :] = k_out[:, :chunk_len, :]
|
| 433 |
+
v_out = output_map.get("V_cache_out")
|
| 434 |
+
if v_out is not None:
|
| 435 |
+
v_states[layer_idx][:, start : start + chunk_len, :] = v_out[:, :chunk_len, :]
|
| 436 |
+
data = output_map["output"]
|
| 437 |
+
ensure_finite(f"prefill layer {layer_idx}", data)
|
| 438 |
+
|
| 439 |
+
last_hidden = data[:, chunk_len - 1 : chunk_len, :]
|
| 440 |
+
return k_states, v_states, last_hidden
|
| 441 |
+
|
| 442 |
+
def run_decode_step(
|
| 443 |
+
self,
|
| 444 |
+
hidden: np.ndarray,
|
| 445 |
+
position: int,
|
| 446 |
+
k_states: list[np.ndarray],
|
| 447 |
+
v_states: list[np.ndarray],
|
| 448 |
+
) -> np.ndarray:
|
| 449 |
+
data = hidden
|
| 450 |
+
for layer_idx, session in enumerate(self.layer_sessions):
|
| 451 |
+
layer_shapes = self.layer_decode_input_shapes[layer_idx]
|
| 452 |
+
layer_dtypes = self.layer_decode_input_dtypes[layer_idx]
|
| 453 |
+
|
| 454 |
+
indices = np.zeros(layer_shapes["indices"], dtype=layer_dtypes["indices"])
|
| 455 |
+
indices.reshape(-1)[0] = position
|
| 456 |
+
|
| 457 |
+
mask = np.full(layer_shapes["mask"], -65536.0, dtype=np.float32)
|
| 458 |
+
valid_past = min(position, layer_shapes["mask"][-1] - 1)
|
| 459 |
+
if valid_past > 0:
|
| 460 |
+
mask[:, :, :valid_past] = 0.0
|
| 461 |
+
mask[:, :, -1:] = 0.0
|
| 462 |
+
mask = mask.astype(layer_dtypes["mask"])
|
| 463 |
+
|
| 464 |
+
outputs = session.run(
|
| 465 |
+
None,
|
| 466 |
+
make_feed(
|
| 467 |
+
layer_shapes,
|
| 468 |
+
{
|
| 469 |
+
"K_cache": k_states[layer_idx],
|
| 470 |
+
"V_cache": v_states[layer_idx],
|
| 471 |
+
"indices": indices,
|
| 472 |
+
"input": data.astype(layer_dtypes["input"], copy=False),
|
| 473 |
+
"mask": mask,
|
| 474 |
+
},
|
| 475 |
+
),
|
| 476 |
+
shape_group=0,
|
| 477 |
+
)
|
| 478 |
+
output_map = dict(zip(self.layer_decode_output_names[layer_idx], outputs))
|
| 479 |
+
k_out = output_map.get("K_cache_out")
|
| 480 |
+
if k_out is not None:
|
| 481 |
+
pos_end = position + k_out.shape[1]
|
| 482 |
+
k_states[layer_idx][:, position:pos_end, :] = k_out
|
| 483 |
+
v_out = output_map.get("V_cache_out")
|
| 484 |
+
if v_out is not None:
|
| 485 |
+
pos_end = position + v_out.shape[1]
|
| 486 |
+
v_states[layer_idx][:, position:pos_end, :] = v_out
|
| 487 |
+
data = output_map["output"]
|
| 488 |
+
ensure_finite(f"decode layer {layer_idx}", data)
|
| 489 |
+
return data
|
| 490 |
+
|
| 491 |
+
def run_post(self, hidden: np.ndarray) -> np.ndarray:
|
| 492 |
+
logits = self.post_session.run(None, {"input": hidden.astype(self.hidden_dtype, copy=False)})[0]
|
| 493 |
+
ensure_finite("post logits", logits)
|
| 494 |
+
return np.asarray(logits, dtype=np.float32).reshape(-1)
|
| 495 |
+
|
| 496 |
+
@staticmethod
|
| 497 |
+
def sample_next_token(
|
| 498 |
+
logits: np.ndarray,
|
| 499 |
+
rng: np.random.Generator | None,
|
| 500 |
+
temperature: float,
|
| 501 |
+
top_p: float,
|
| 502 |
+
repetition_penalty: float,
|
| 503 |
+
generated_history: Sequence[int],
|
| 504 |
+
) -> int:
|
| 505 |
+
scores = logits.astype(np.float64)
|
| 506 |
+
if repetition_penalty != 1.0 and generated_history:
|
| 507 |
+
for token_id in set(int(x) for x in generated_history if 0 <= int(x) < scores.shape[0]):
|
| 508 |
+
if scores[token_id] > 0:
|
| 509 |
+
scores[token_id] /= repetition_penalty
|
| 510 |
+
else:
|
| 511 |
+
scores[token_id] *= repetition_penalty
|
| 512 |
+
|
| 513 |
+
if temperature > 0.0:
|
| 514 |
+
scores = scores / float(temperature)
|
| 515 |
+
if top_p is not None and top_p < 1.0:
|
| 516 |
+
order = np.argsort(scores)[::-1]
|
| 517 |
+
sorted_scores = scores[order]
|
| 518 |
+
stable_scores = sorted_scores - np.max(sorted_scores)
|
| 519 |
+
sorted_probs = np.exp(stable_scores)
|
| 520 |
+
sorted_probs /= np.sum(sorted_probs)
|
| 521 |
+
cumulative = np.cumsum(sorted_probs)
|
| 522 |
+
remove = cumulative > top_p
|
| 523 |
+
if remove.shape[0] > 1:
|
| 524 |
+
remove[1:] = remove[:-1]
|
| 525 |
+
remove[0] = False
|
| 526 |
+
scores[order[remove]] = -np.inf
|
| 527 |
+
|
| 528 |
+
if temperature <= 0.0:
|
| 529 |
+
return int(np.argmax(scores))
|
| 530 |
+
|
| 531 |
+
scores -= np.max(scores)
|
| 532 |
+
probs = np.exp(scores)
|
| 533 |
+
probs_sum = float(np.sum(probs))
|
| 534 |
+
if not np.isfinite(probs_sum) or probs_sum <= 0.0:
|
| 535 |
+
return int(np.argmax(logits))
|
| 536 |
+
probs /= probs_sum
|
| 537 |
+
|
| 538 |
+
assert rng is not None
|
| 539 |
+
return int(rng.choice(np.arange(probs.shape[0]), p=probs))
|
| 540 |
+
|
| 541 |
+
def generate_from_state(
|
| 542 |
+
self,
|
| 543 |
+
prompt_len: int,
|
| 544 |
+
k_states: list[np.ndarray],
|
| 545 |
+
v_states: list[np.ndarray],
|
| 546 |
+
last_hidden: np.ndarray,
|
| 547 |
+
max_new_tokens: int,
|
| 548 |
+
temperature: float,
|
| 549 |
+
top_p: float,
|
| 550 |
+
repetition_penalty: float,
|
| 551 |
+
seed: int,
|
| 552 |
+
prompt_token_ids: Sequence[int],
|
| 553 |
+
on_token=None,
|
| 554 |
+
) -> list[int]:
|
| 555 |
+
rng = None if temperature <= 0.0 else np.random.default_rng(seed)
|
| 556 |
+
generated: list[int] = []
|
| 557 |
+
generated_history = list(prompt_token_ids)
|
| 558 |
+
decode_start = time.perf_counter()
|
| 559 |
+
for step in range(max_new_tokens):
|
| 560 |
+
next_token = self.sample_next_token(
|
| 561 |
+
self.run_post(last_hidden),
|
| 562 |
+
rng,
|
| 563 |
+
temperature,
|
| 564 |
+
top_p,
|
| 565 |
+
repetition_penalty,
|
| 566 |
+
generated_history,
|
| 567 |
+
)
|
| 568 |
+
generated.append(next_token)
|
| 569 |
+
generated_history.append(next_token)
|
| 570 |
+
if on_token is not None:
|
| 571 |
+
on_token(
|
| 572 |
+
next_token,
|
| 573 |
+
step,
|
| 574 |
+
self.decode_text([next_token]),
|
| 575 |
+
time.perf_counter() - decode_start,
|
| 576 |
+
)
|
| 577 |
+
if next_token == TOK_EOS:
|
| 578 |
+
break
|
| 579 |
+
last_hidden = self.run_decode_step(
|
| 580 |
+
self.embed_token(next_token),
|
| 581 |
+
prompt_len + step,
|
| 582 |
+
k_states,
|
| 583 |
+
v_states,
|
| 584 |
+
)
|
| 585 |
+
return generated
|
| 586 |
+
|
| 587 |
+
def generate(
|
| 588 |
+
self,
|
| 589 |
+
prompt: str,
|
| 590 |
+
image_path: str,
|
| 591 |
+
max_new_tokens: int,
|
| 592 |
+
system_prompt: str,
|
| 593 |
+
temperature: float,
|
| 594 |
+
top_p: float,
|
| 595 |
+
repetition_penalty: float,
|
| 596 |
+
seed: int,
|
| 597 |
+
on_token=None,
|
| 598 |
+
) -> tuple[list[int], str, tuple[int, int], int, dict[str, float]]:
|
| 599 |
+
image_embeds, image_size, timings = self.encode_image(image_path)
|
| 600 |
+
print(
|
| 601 |
+
f"[Image] encoded {image_path}, embeds={image_embeds.shape}, "
|
| 602 |
+
f"preprocess={timings['image_preprocess_s']:.3f}s "
|
| 603 |
+
f"encoder={timings['image_encoder_s']:.3f}s "
|
| 604 |
+
f"total={timings['image_total_s']:.3f}s"
|
| 605 |
+
)
|
| 606 |
+
|
| 607 |
+
t_prompt = time.perf_counter()
|
| 608 |
+
token_ids, prompt_embeds = self.build_prompt_embeddings(prompt, image_embeds, system_prompt)
|
| 609 |
+
timings["prompt_build_s"] = time.perf_counter() - t_prompt
|
| 610 |
+
print(f"[Prompt] tokens={len(token_ids)}, image_tokens={token_ids.count(TOK_IMG_CONTEXT)} style=original")
|
| 611 |
+
if len(token_ids) + max_new_tokens >= KV_CACHE_LEN:
|
| 612 |
+
raise RuntimeError(f"prompt + max_new_tokens exceeds KV cache: {len(token_ids)} + {max_new_tokens} >= {KV_CACHE_LEN}")
|
| 613 |
+
|
| 614 |
+
t1 = time.perf_counter()
|
| 615 |
+
k_states, v_states, last_hidden = self.run_prefill(prompt_embeds)
|
| 616 |
+
timings["llm_prefill_s"] = time.perf_counter() - t1
|
| 617 |
+
print(f"[Prefill] cost={timings['llm_prefill_s']:.3f}s")
|
| 618 |
+
|
| 619 |
+
t2 = time.perf_counter()
|
| 620 |
+
print(
|
| 621 |
+
f"[LLM Decode] seed={seed} temperature={temperature} "
|
| 622 |
+
f"top_p={top_p} repetition_penalty={repetition_penalty}"
|
| 623 |
+
)
|
| 624 |
+
generated = self.generate_from_state(
|
| 625 |
+
len(token_ids),
|
| 626 |
+
k_states,
|
| 627 |
+
v_states,
|
| 628 |
+
last_hidden,
|
| 629 |
+
max_new_tokens,
|
| 630 |
+
temperature,
|
| 631 |
+
top_p,
|
| 632 |
+
repetition_penalty,
|
| 633 |
+
seed,
|
| 634 |
+
token_ids,
|
| 635 |
+
on_token=on_token,
|
| 636 |
+
)
|
| 637 |
+
timings["llm_generate_s"] = time.perf_counter() - t2
|
| 638 |
+
timings["llm_total_s"] = timings["llm_prefill_s"] + timings["llm_generate_s"]
|
| 639 |
+
print(f"[LLM Decode] generated={len(generated)} cost={timings['llm_generate_s']:.3f}s")
|
| 640 |
+
print(f"[Timing] llm_total={timings['llm_total_s']:.3f}s")
|
| 641 |
+
return generated, self.decode_text(generated), image_size, seed, timings
|
| 642 |
+
|
| 643 |
+
|
| 644 |
+
def token_to_coord(token_id: int) -> int | None:
|
| 645 |
+
if TOK_COORD_START <= token_id <= TOK_COORD_END:
|
| 646 |
+
return token_id - TOK_COORD_START
|
| 647 |
+
return None
|
| 648 |
+
|
| 649 |
+
|
| 650 |
+
def coord_to_pixel(coord: int, dim: int) -> float:
|
| 651 |
+
return coord / 1000 * dim
|
| 652 |
+
|
| 653 |
+
|
| 654 |
+
def make_box(coords: Sequence[int], image_size: tuple[int, int]) -> Box:
|
| 655 |
+
iw, ih = image_size
|
| 656 |
+
x1, y1, x2, y2 = [int(v) for v in coords]
|
| 657 |
+
return Box(
|
| 658 |
+
coord_to_pixel(x1, iw),
|
| 659 |
+
coord_to_pixel(y1, ih),
|
| 660 |
+
coord_to_pixel(x2, iw),
|
| 661 |
+
coord_to_pixel(y2, ih),
|
| 662 |
+
)
|
| 663 |
+
|
| 664 |
+
|
| 665 |
+
def make_point(coords: Sequence[int], image_size: tuple[int, int]) -> Point:
|
| 666 |
+
iw, ih = image_size
|
| 667 |
+
x, y = [int(v) for v in coords]
|
| 668 |
+
return Point(coord_to_pixel(x, iw), coord_to_pixel(y, ih))
|
| 669 |
+
|
| 670 |
+
|
| 671 |
+
def decode_boxes_strict(token_ids: Sequence[int], image_size: tuple[int, int]) -> list[Box]:
|
| 672 |
+
"""Decode exact <box><x1><y1><x2><y2></box> token sequences."""
|
| 673 |
+
boxes: list[Box] = []
|
| 674 |
+
i = 0
|
| 675 |
+
while i <= len(token_ids) - 6:
|
| 676 |
+
if token_ids[i] != TOK_BOX_START:
|
| 677 |
+
i += 1
|
| 678 |
+
continue
|
| 679 |
+
coords = [token_to_coord(token_ids[i + j]) for j in range(1, 5)]
|
| 680 |
+
if None not in coords and token_ids[i + 5] == TOK_BOX_END:
|
| 681 |
+
boxes.append(make_box([int(v) for v in coords], image_size))
|
| 682 |
+
i += 6
|
| 683 |
+
else:
|
| 684 |
+
i += 1
|
| 685 |
+
return boxes
|
| 686 |
+
|
| 687 |
+
|
| 688 |
+
def decode_points_strict(token_ids: Sequence[int], image_size: tuple[int, int]) -> list[Point]:
|
| 689 |
+
"""Decode exact <box><x><y></box> point token sequences."""
|
| 690 |
+
points: list[Point] = []
|
| 691 |
+
i = 0
|
| 692 |
+
while i <= len(token_ids) - 4:
|
| 693 |
+
if token_ids[i] != TOK_BOX_START:
|
| 694 |
+
i += 1
|
| 695 |
+
continue
|
| 696 |
+
coords = [token_to_coord(token_ids[i + 1]), token_to_coord(token_ids[i + 2])]
|
| 697 |
+
if None not in coords and token_ids[i + 3] == TOK_BOX_END:
|
| 698 |
+
points.append(make_point([int(v) for v in coords], image_size))
|
| 699 |
+
i += 4
|
| 700 |
+
else:
|
| 701 |
+
i += 1
|
| 702 |
+
return points
|
| 703 |
+
|
| 704 |
+
|
| 705 |
+
class StreamingGeometryDecoder:
|
| 706 |
+
"""Incrementally decode strict box and point token sequences."""
|
| 707 |
+
|
| 708 |
+
def __init__(self, image_size: tuple[int, int]):
|
| 709 |
+
self.image_size = image_size
|
| 710 |
+
self._state = "search"
|
| 711 |
+
self._coords: list[int] = []
|
| 712 |
+
|
| 713 |
+
def push(self, token_id: int) -> tuple[str, Box | Point] | None:
|
| 714 |
+
if self._state == "search":
|
| 715 |
+
if token_id == TOK_BOX_START:
|
| 716 |
+
self._coords = []
|
| 717 |
+
self._state = "coords"
|
| 718 |
+
return None
|
| 719 |
+
|
| 720 |
+
if self._state == "coords":
|
| 721 |
+
coord = token_to_coord(token_id)
|
| 722 |
+
if coord is not None:
|
| 723 |
+
self._coords.append(coord)
|
| 724 |
+
if len(self._coords) == 4:
|
| 725 |
+
self._state = "end"
|
| 726 |
+
return None
|
| 727 |
+
if token_id == TOK_BOX_END and len(self._coords) == 2:
|
| 728 |
+
point = make_point(self._coords, self.image_size)
|
| 729 |
+
self._state = "search"
|
| 730 |
+
self._coords = []
|
| 731 |
+
return "point", point
|
| 732 |
+
self._reset(token_id)
|
| 733 |
+
return None
|
| 734 |
+
|
| 735 |
+
if self._state == "end":
|
| 736 |
+
if token_id == TOK_BOX_END:
|
| 737 |
+
box = make_box(self._coords, self.image_size)
|
| 738 |
+
self._state = "search"
|
| 739 |
+
self._coords = []
|
| 740 |
+
return "box", box
|
| 741 |
+
self._reset(token_id)
|
| 742 |
+
return None
|
| 743 |
+
|
| 744 |
+
def _reset(self, token_id: int) -> None:
|
| 745 |
+
if token_id == TOK_BOX_START:
|
| 746 |
+
self._coords = []
|
| 747 |
+
self._state = "coords"
|
| 748 |
+
else:
|
| 749 |
+
self._coords = []
|
| 750 |
+
self._state = "search"
|
| 751 |
+
|
| 752 |
+
|
| 753 |
+
def time_geometry_decode(
|
| 754 |
+
token_ids: Sequence[int],
|
| 755 |
+
image_size: tuple[int, int],
|
| 756 |
+
) -> tuple[list[Box], list[Point], float]:
|
| 757 |
+
t0 = time.perf_counter()
|
| 758 |
+
boxes = decode_boxes_strict(token_ids, image_size)
|
| 759 |
+
points = decode_points_strict(token_ids, image_size)
|
| 760 |
+
return boxes, points, time.perf_counter() - t0
|
| 761 |
+
|
| 762 |
+
|
| 763 |
+
BOX_COLORS = ["#00FF00", "#FF0000", "#0000FF", "#FFFF00", "#FF00FF", "#00FFFF", "#FFA500"]
|
| 764 |
+
|
| 765 |
+
|
| 766 |
+
def load_box_font():
|
| 767 |
+
try:
|
| 768 |
+
return ImageFont.truetype("/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf", 16)
|
| 769 |
+
except OSError:
|
| 770 |
+
return ImageFont.load_default()
|
| 771 |
+
|
| 772 |
+
|
| 773 |
+
def draw_one_box(draw: ImageDraw.ImageDraw, font, box: Box, idx: int) -> None:
|
| 774 |
+
color = BOX_COLORS[(idx - 1) % len(BOX_COLORS)]
|
| 775 |
+
rect = [round(box.x1), round(box.y1), round(box.x2), round(box.y2)]
|
| 776 |
+
draw.rectangle(rect, outline=color, width=3)
|
| 777 |
+
label = str(idx)
|
| 778 |
+
label_pos = (rect[0], max(0, rect[1] - 18))
|
| 779 |
+
tb = draw.textbbox(label_pos, label, font=font)
|
| 780 |
+
draw.rectangle(tb, fill=color)
|
| 781 |
+
draw.text(label_pos, label, fill="black", font=font)
|
| 782 |
+
|
| 783 |
+
|
| 784 |
+
def draw_one_point(draw: ImageDraw.ImageDraw, font, point: Point, idx: int) -> None:
|
| 785 |
+
color = BOX_COLORS[(idx - 1) % len(BOX_COLORS)]
|
| 786 |
+
x = round(point.x)
|
| 787 |
+
y = round(point.y)
|
| 788 |
+
radius = 8
|
| 789 |
+
draw.ellipse([x - radius, y - radius, x + radius, y + radius], outline=color, fill=color, width=3)
|
| 790 |
+
label = str(idx)
|
| 791 |
+
label_pos = (x + radius + 2, max(0, y - radius))
|
| 792 |
+
tb = draw.textbbox(label_pos, label, font=font)
|
| 793 |
+
draw.rectangle(tb, fill=color)
|
| 794 |
+
draw.text(label_pos, label, fill="black", font=font)
|
| 795 |
+
|
| 796 |
+
|
| 797 |
+
def draw_geometries(image_path: str, boxes: list[Box], points: list[Point], output: str) -> None:
|
| 798 |
+
image = Image.open(image_path).convert("RGB")
|
| 799 |
+
draw = ImageDraw.Draw(image)
|
| 800 |
+
font = load_box_font()
|
| 801 |
+
for idx, box in enumerate(boxes, start=1):
|
| 802 |
+
draw_one_box(draw, font, box, idx)
|
| 803 |
+
for idx, point in enumerate(points, start=1):
|
| 804 |
+
draw_one_point(draw, font, point, idx)
|
| 805 |
+
save_image_atomic(image, output)
|
| 806 |
+
|
| 807 |
+
|
| 808 |
+
def save_image_atomic(image: Image.Image, output: str) -> None:
|
| 809 |
+
output_dir = os.path.dirname(os.path.abspath(output))
|
| 810 |
+
os.makedirs(output_dir, exist_ok=True)
|
| 811 |
+
root, ext = os.path.splitext(output)
|
| 812 |
+
tmp_output = f"{root}.tmp.{os.getpid()}.{time.time_ns()}{ext or '.png'}"
|
| 813 |
+
try:
|
| 814 |
+
image.save(tmp_output)
|
| 815 |
+
os.replace(tmp_output, output)
|
| 816 |
+
finally:
|
| 817 |
+
if os.path.exists(tmp_output):
|
| 818 |
+
os.unlink(tmp_output)
|
| 819 |
+
|
| 820 |
+
|
| 821 |
+
class GeometryImageDrawer:
|
| 822 |
+
def __init__(self, image_path: str, output: str):
|
| 823 |
+
self.output = output
|
| 824 |
+
output_dir = os.path.dirname(os.path.abspath(output))
|
| 825 |
+
os.makedirs(output_dir, exist_ok=True)
|
| 826 |
+
self.image = Image.open(image_path).convert("RGB")
|
| 827 |
+
self.draw = ImageDraw.Draw(self.image)
|
| 828 |
+
self.font = load_box_font()
|
| 829 |
+
|
| 830 |
+
def add_box(self, box: Box, idx: int) -> None:
|
| 831 |
+
draw_one_box(self.draw, self.font, box, idx)
|
| 832 |
+
save_image_atomic(self.image, self.output)
|
| 833 |
+
|
| 834 |
+
def add_point(self, point: Point, idx: int) -> None:
|
| 835 |
+
draw_one_point(self.draw, self.font, point, idx)
|
| 836 |
+
save_image_atomic(self.image, self.output)
|
| 837 |
+
|
| 838 |
+
|
| 839 |
+
def parse_args() -> argparse.Namespace:
|
| 840 |
+
parser = argparse.ArgumentParser(description="LocateAnything pure axengine Python inference")
|
| 841 |
+
parser.add_argument("--tokenizer", default=DEFAULT_TOKENIZER)
|
| 842 |
+
parser.add_argument("--llm-dir", default=DEFAULT_LLM_DIR)
|
| 843 |
+
parser.add_argument("--image-encoder", default=DEFAULT_IMAGE_ENCODER)
|
| 844 |
+
parser.add_argument("--image", default=DEFAULT_IMAGE)
|
| 845 |
+
parser.add_argument("--prompt", default=None, help="Custom prompt. Overrides --task prompt templates.")
|
| 846 |
+
parser.add_argument("--task", choices=sorted(PROMPT_SPECS), default=DEFAULT_TASK)
|
| 847 |
+
parser.add_argument("--target", default=DEFAULT_TARGET, help="Fallback target text for prompt templates.")
|
| 848 |
+
parser.add_argument("--categories", default=None, help="Comma-separated category names for category tasks.")
|
| 849 |
+
parser.add_argument("--phrase", default=None, help="Free-form phrase for grounding/pointing tasks.")
|
| 850 |
+
parser.add_argument("--system-prompt", default=DEFAULT_SYSTEM_PROMPT)
|
| 851 |
+
parser.add_argument("--output", default="output_locateanything_axengine.jpg")
|
| 852 |
+
parser.add_argument("--max-new-tokens", type=int, default=512)
|
| 853 |
+
parser.add_argument("--temperature", type=float, default=0.7)
|
| 854 |
+
parser.add_argument("--top-p", type=float, default=0.9)
|
| 855 |
+
parser.add_argument("--repetition-penalty", type=float, default=1.1)
|
| 856 |
+
parser.add_argument("--seed", type=int, default=42)
|
| 857 |
+
parser.add_argument("--save-response", default=None)
|
| 858 |
+
return parser.parse_args()
|
| 859 |
+
|
| 860 |
+
|
| 861 |
+
def main() -> None:
|
| 862 |
+
args = parse_args()
|
| 863 |
+
prompt, prompt_task, prompt_output_type, prompt_target = build_task_prompt(args)
|
| 864 |
+
stream_decoder: StreamingGeometryDecoder | None = None
|
| 865 |
+
stream_drawer: GeometryImageDrawer | None = None
|
| 866 |
+
stream_boxes: list[StreamBox] = []
|
| 867 |
+
stream_points: list[StreamPoint] = []
|
| 868 |
+
|
| 869 |
+
def handle_stream_token(token_id: int, step: int, piece: str, elapsed_s: float) -> None:
|
| 870 |
+
assert stream_decoder is not None
|
| 871 |
+
assert stream_drawer is not None
|
| 872 |
+
print(f"[Stream Token] step={step:03d} token={token_id} text={piece!r}")
|
| 873 |
+
geometry = stream_decoder.push(token_id)
|
| 874 |
+
if geometry is None:
|
| 875 |
+
return
|
| 876 |
+
kind, value = geometry
|
| 877 |
+
if kind == "point":
|
| 878 |
+
assert isinstance(value, Point)
|
| 879 |
+
stream_point = StreamPoint(
|
| 880 |
+
index=len(stream_points) + 1,
|
| 881 |
+
token_step=step,
|
| 882 |
+
elapsed_s=elapsed_s,
|
| 883 |
+
point=value,
|
| 884 |
+
)
|
| 885 |
+
stream_points.append(stream_point)
|
| 886 |
+
stream_drawer.add_point(value, stream_point.index)
|
| 887 |
+
print(
|
| 888 |
+
f"[Stream Point] #{stream_point.index} step={step} "
|
| 889 |
+
f"elapsed={elapsed_s:.3f}s saved={args.output}"
|
| 890 |
+
)
|
| 891 |
+
return
|
| 892 |
+
|
| 893 |
+
assert isinstance(value, Box)
|
| 894 |
+
stream_box = StreamBox(
|
| 895 |
+
index=len(stream_boxes) + 1,
|
| 896 |
+
token_step=step,
|
| 897 |
+
elapsed_s=elapsed_s,
|
| 898 |
+
box=value,
|
| 899 |
+
)
|
| 900 |
+
stream_boxes.append(stream_box)
|
| 901 |
+
stream_drawer.add_box(value, stream_box.index)
|
| 902 |
+
print(
|
| 903 |
+
f"[Stream Box] #{stream_box.index} step={step} "
|
| 904 |
+
f"elapsed={elapsed_s:.3f}s saved={args.output}"
|
| 905 |
+
)
|
| 906 |
+
|
| 907 |
+
print(
|
| 908 |
+
f"[Task Prompt] task={prompt_task} output={prompt_output_type} "
|
| 909 |
+
f"target={prompt_target!r} prompt={prompt!r}"
|
| 910 |
+
)
|
| 911 |
+
runner = LocateAnythingAxEngineRunner(args.tokenizer, args.llm_dir, args.image_encoder)
|
| 912 |
+
try:
|
| 913 |
+
image_size_hint = Image.open(args.image).size
|
| 914 |
+
stream_decoder = StreamingGeometryDecoder(image_size_hint)
|
| 915 |
+
stream_drawer = GeometryImageDrawer(args.image, args.output)
|
| 916 |
+
token_ids, text, image_size, used_seed, timings = runner.generate(
|
| 917 |
+
prompt=prompt,
|
| 918 |
+
image_path=args.image,
|
| 919 |
+
max_new_tokens=args.max_new_tokens,
|
| 920 |
+
system_prompt=args.system_prompt,
|
| 921 |
+
temperature=args.temperature,
|
| 922 |
+
top_p=args.top_p,
|
| 923 |
+
repetition_penalty=args.repetition_penalty,
|
| 924 |
+
seed=args.seed,
|
| 925 |
+
on_token=handle_stream_token,
|
| 926 |
+
)
|
| 927 |
+
finally:
|
| 928 |
+
runner.close()
|
| 929 |
+
|
| 930 |
+
boxes, points, decode_s = time_geometry_decode(token_ids, image_size)
|
| 931 |
+
timings["geometry_decode_s"] = decode_s
|
| 932 |
+
stream_consistent = [x.box for x in stream_boxes] == boxes
|
| 933 |
+
stream_points_consistent = [x.point for x in stream_points] == points
|
| 934 |
+
if not stream_consistent or not stream_points_consistent:
|
| 935 |
+
print("[WARN] Stream geometries differ from final strict decode; rewriting final image.")
|
| 936 |
+
draw_geometries(args.image, boxes, points, args.output)
|
| 937 |
+
|
| 938 |
+
print("\n[LLM output]")
|
| 939 |
+
print(text)
|
| 940 |
+
print(f"\n[Seed] {used_seed}")
|
| 941 |
+
print(f"\n[Geometries] boxes={len(boxes)} points={len(points)} decode={decode_s * 1000:.3f}ms")
|
| 942 |
+
print(
|
| 943 |
+
f"[Stream] boxes={len(stream_boxes)} consistent={stream_consistent} "
|
| 944 |
+
f"points={len(stream_points)} points_consistent={stream_points_consistent}"
|
| 945 |
+
)
|
| 946 |
+
for i, box in enumerate(boxes, start=1):
|
| 947 |
+
print(f" [{i}] ({box.x1:.2f},{box.y1:.2f}) -> ({box.x2:.2f},{box.y2:.2f})")
|
| 948 |
+
for i, point in enumerate(points, start=1):
|
| 949 |
+
print(f" [P{i}] ({point.x:.2f},{point.y:.2f})")
|
| 950 |
+
|
| 951 |
+
if args.save_response:
|
| 952 |
+
with open(args.save_response, "w", encoding="utf-8") as f:
|
| 953 |
+
json.dump(
|
| 954 |
+
{
|
| 955 |
+
"task": prompt_task,
|
| 956 |
+
"task_output_type": prompt_output_type,
|
| 957 |
+
"target": prompt_target,
|
| 958 |
+
"prompt": prompt,
|
| 959 |
+
"seed": used_seed,
|
| 960 |
+
"temperature": args.temperature,
|
| 961 |
+
"top_p": args.top_p,
|
| 962 |
+
"repetition_penalty": args.repetition_penalty,
|
| 963 |
+
"token_ids": token_ids,
|
| 964 |
+
"text": text,
|
| 965 |
+
"boxes": [box.__dict__ for box in boxes],
|
| 966 |
+
"points": [point.__dict__ for point in points],
|
| 967 |
+
"stream_boxes": [
|
| 968 |
+
{
|
| 969 |
+
"index": x.index,
|
| 970 |
+
"token_step": x.token_step,
|
| 971 |
+
"elapsed_s": x.elapsed_s,
|
| 972 |
+
"box": x.box.__dict__,
|
| 973 |
+
}
|
| 974 |
+
for x in stream_boxes
|
| 975 |
+
],
|
| 976 |
+
"stream_points": [
|
| 977 |
+
{
|
| 978 |
+
"index": x.index,
|
| 979 |
+
"token_step": x.token_step,
|
| 980 |
+
"elapsed_s": x.elapsed_s,
|
| 981 |
+
"point": x.point.__dict__,
|
| 982 |
+
}
|
| 983 |
+
for x in stream_points
|
| 984 |
+
],
|
| 985 |
+
"stream_consistent": stream_consistent,
|
| 986 |
+
"stream_points_consistent": stream_points_consistent,
|
| 987 |
+
"timings": timings,
|
| 988 |
+
},
|
| 989 |
+
f,
|
| 990 |
+
ensure_ascii=False,
|
| 991 |
+
)
|
| 992 |
+
print("[Save] response:", args.save_response)
|
| 993 |
+
print("[Draw] saved:", args.output)
|
| 994 |
+
|
| 995 |
+
|
| 996 |
+
if __name__ == "__main__":
|
| 997 |
+
main()
|
model.embed_tokens.weight.bfloat16.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:7972da8526034a169b9a0f7e5478d3fe2a5ce61e9dd2a74b3a5b9ad1e4759db9
|
| 3 |
+
size 625381376
|
post_config.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"enable_temperature" : false,
|
| 3 |
+
"temperature" : 0.9,
|
| 4 |
+
|
| 5 |
+
"enable_repetition_penalty" : false,
|
| 6 |
+
"repetition_penalty" : 1.2,
|
| 7 |
+
"penalty_window" : 20,
|
| 8 |
+
|
| 9 |
+
"enable_top_p_sampling" : false,
|
| 10 |
+
"top_p" : 0.8,
|
| 11 |
+
|
| 12 |
+
"enable_top_k_sampling" : false,
|
| 13 |
+
"top_k" : 10
|
| 14 |
+
}
|
qwen2.5_tokenizer/README.md
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# LLM
|
| 2 |
+
|
| 3 |
+
Standalone Qwen2.5-3B language model split from LocateAnything. Original keys stripped the `language_model.` prefix.
|
qwen2.5_tokenizer/added_tokens.json
ADDED
|
@@ -0,0 +1,1040 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
| 5 |
+
"</interval>": 151675,
|
| 6 |
+
"</quad>": 151671,
|
| 7 |
+
"</ref>": 151673,
|
| 8 |
+
"</tool_call>": 151658,
|
| 9 |
+
"<0>": 151677,
|
| 10 |
+
"<1000>": 152677,
|
| 11 |
+
"<100>": 151777,
|
| 12 |
+
"<101>": 151778,
|
| 13 |
+
"<102>": 151779,
|
| 14 |
+
"<103>": 151780,
|
| 15 |
+
"<104>": 151781,
|
| 16 |
+
"<105>": 151782,
|
| 17 |
+
"<106>": 151783,
|
| 18 |
+
"<107>": 151784,
|
| 19 |
+
"<108>": 151785,
|
| 20 |
+
"<109>": 151786,
|
| 21 |
+
"<10>": 151687,
|
| 22 |
+
"<110>": 151787,
|
| 23 |
+
"<111>": 151788,
|
| 24 |
+
"<112>": 151789,
|
| 25 |
+
"<113>": 151790,
|
| 26 |
+
"<114>": 151791,
|
| 27 |
+
"<115>": 151792,
|
| 28 |
+
"<116>": 151793,
|
| 29 |
+
"<117>": 151794,
|
| 30 |
+
"<118>": 151795,
|
| 31 |
+
"<119>": 151796,
|
| 32 |
+
"<11>": 151688,
|
| 33 |
+
"<120>": 151797,
|
| 34 |
+
"<121>": 151798,
|
| 35 |
+
"<122>": 151799,
|
| 36 |
+
"<123>": 151800,
|
| 37 |
+
"<124>": 151801,
|
| 38 |
+
"<125>": 151802,
|
| 39 |
+
"<126>": 151803,
|
| 40 |
+
"<127>": 151804,
|
| 41 |
+
"<128>": 151805,
|
| 42 |
+
"<129>": 151806,
|
| 43 |
+
"<12>": 151689,
|
| 44 |
+
"<130>": 151807,
|
| 45 |
+
"<131>": 151808,
|
| 46 |
+
"<132>": 151809,
|
| 47 |
+
"<133>": 151810,
|
| 48 |
+
"<134>": 151811,
|
| 49 |
+
"<135>": 151812,
|
| 50 |
+
"<136>": 151813,
|
| 51 |
+
"<137>": 151814,
|
| 52 |
+
"<138>": 151815,
|
| 53 |
+
"<139>": 151816,
|
| 54 |
+
"<13>": 151690,
|
| 55 |
+
"<140>": 151817,
|
| 56 |
+
"<141>": 151818,
|
| 57 |
+
"<142>": 151819,
|
| 58 |
+
"<143>": 151820,
|
| 59 |
+
"<144>": 151821,
|
| 60 |
+
"<145>": 151822,
|
| 61 |
+
"<146>": 151823,
|
| 62 |
+
"<147>": 151824,
|
| 63 |
+
"<148>": 151825,
|
| 64 |
+
"<149>": 151826,
|
| 65 |
+
"<14>": 151691,
|
| 66 |
+
"<150>": 151827,
|
| 67 |
+
"<151>": 151828,
|
| 68 |
+
"<152>": 151829,
|
| 69 |
+
"<153>": 151830,
|
| 70 |
+
"<154>": 151831,
|
| 71 |
+
"<155>": 151832,
|
| 72 |
+
"<156>": 151833,
|
| 73 |
+
"<157>": 151834,
|
| 74 |
+
"<158>": 151835,
|
| 75 |
+
"<159>": 151836,
|
| 76 |
+
"<15>": 151692,
|
| 77 |
+
"<160>": 151837,
|
| 78 |
+
"<161>": 151838,
|
| 79 |
+
"<162>": 151839,
|
| 80 |
+
"<163>": 151840,
|
| 81 |
+
"<164>": 151841,
|
| 82 |
+
"<165>": 151842,
|
| 83 |
+
"<166>": 151843,
|
| 84 |
+
"<167>": 151844,
|
| 85 |
+
"<168>": 151845,
|
| 86 |
+
"<169>": 151846,
|
| 87 |
+
"<16>": 151693,
|
| 88 |
+
"<170>": 151847,
|
| 89 |
+
"<171>": 151848,
|
| 90 |
+
"<172>": 151849,
|
| 91 |
+
"<173>": 151850,
|
| 92 |
+
"<174>": 151851,
|
| 93 |
+
"<175>": 151852,
|
| 94 |
+
"<176>": 151853,
|
| 95 |
+
"<177>": 151854,
|
| 96 |
+
"<178>": 151855,
|
| 97 |
+
"<179>": 151856,
|
| 98 |
+
"<17>": 151694,
|
| 99 |
+
"<180>": 151857,
|
| 100 |
+
"<181>": 151858,
|
| 101 |
+
"<182>": 151859,
|
| 102 |
+
"<183>": 151860,
|
| 103 |
+
"<184>": 151861,
|
| 104 |
+
"<185>": 151862,
|
| 105 |
+
"<186>": 151863,
|
| 106 |
+
"<187>": 151864,
|
| 107 |
+
"<188>": 151865,
|
| 108 |
+
"<189>": 151866,
|
| 109 |
+
"<18>": 151695,
|
| 110 |
+
"<190>": 151867,
|
| 111 |
+
"<191>": 151868,
|
| 112 |
+
"<192>": 151869,
|
| 113 |
+
"<193>": 151870,
|
| 114 |
+
"<194>": 151871,
|
| 115 |
+
"<195>": 151872,
|
| 116 |
+
"<196>": 151873,
|
| 117 |
+
"<197>": 151874,
|
| 118 |
+
"<198>": 151875,
|
| 119 |
+
"<199>": 151876,
|
| 120 |
+
"<19>": 151696,
|
| 121 |
+
"<1>": 151678,
|
| 122 |
+
"<200>": 151877,
|
| 123 |
+
"<201>": 151878,
|
| 124 |
+
"<202>": 151879,
|
| 125 |
+
"<203>": 151880,
|
| 126 |
+
"<204>": 151881,
|
| 127 |
+
"<205>": 151882,
|
| 128 |
+
"<206>": 151883,
|
| 129 |
+
"<207>": 151884,
|
| 130 |
+
"<208>": 151885,
|
| 131 |
+
"<209>": 151886,
|
| 132 |
+
"<20>": 151697,
|
| 133 |
+
"<210>": 151887,
|
| 134 |
+
"<211>": 151888,
|
| 135 |
+
"<212>": 151889,
|
| 136 |
+
"<213>": 151890,
|
| 137 |
+
"<214>": 151891,
|
| 138 |
+
"<215>": 151892,
|
| 139 |
+
"<216>": 151893,
|
| 140 |
+
"<217>": 151894,
|
| 141 |
+
"<218>": 151895,
|
| 142 |
+
"<219>": 151896,
|
| 143 |
+
"<21>": 151698,
|
| 144 |
+
"<220>": 151897,
|
| 145 |
+
"<221>": 151898,
|
| 146 |
+
"<222>": 151899,
|
| 147 |
+
"<223>": 151900,
|
| 148 |
+
"<224>": 151901,
|
| 149 |
+
"<225>": 151902,
|
| 150 |
+
"<226>": 151903,
|
| 151 |
+
"<227>": 151904,
|
| 152 |
+
"<228>": 151905,
|
| 153 |
+
"<229>": 151906,
|
| 154 |
+
"<22>": 151699,
|
| 155 |
+
"<230>": 151907,
|
| 156 |
+
"<231>": 151908,
|
| 157 |
+
"<232>": 151909,
|
| 158 |
+
"<233>": 151910,
|
| 159 |
+
"<234>": 151911,
|
| 160 |
+
"<235>": 151912,
|
| 161 |
+
"<236>": 151913,
|
| 162 |
+
"<237>": 151914,
|
| 163 |
+
"<238>": 151915,
|
| 164 |
+
"<239>": 151916,
|
| 165 |
+
"<23>": 151700,
|
| 166 |
+
"<240>": 151917,
|
| 167 |
+
"<241>": 151918,
|
| 168 |
+
"<242>": 151919,
|
| 169 |
+
"<243>": 151920,
|
| 170 |
+
"<244>": 151921,
|
| 171 |
+
"<245>": 151922,
|
| 172 |
+
"<246>": 151923,
|
| 173 |
+
"<247>": 151924,
|
| 174 |
+
"<248>": 151925,
|
| 175 |
+
"<249>": 151926,
|
| 176 |
+
"<24>": 151701,
|
| 177 |
+
"<250>": 151927,
|
| 178 |
+
"<251>": 151928,
|
| 179 |
+
"<252>": 151929,
|
| 180 |
+
"<253>": 151930,
|
| 181 |
+
"<254>": 151931,
|
| 182 |
+
"<255>": 151932,
|
| 183 |
+
"<256>": 151933,
|
| 184 |
+
"<257>": 151934,
|
| 185 |
+
"<258>": 151935,
|
| 186 |
+
"<259>": 151936,
|
| 187 |
+
"<25>": 151702,
|
| 188 |
+
"<260>": 151937,
|
| 189 |
+
"<261>": 151938,
|
| 190 |
+
"<262>": 151939,
|
| 191 |
+
"<263>": 151940,
|
| 192 |
+
"<264>": 151941,
|
| 193 |
+
"<265>": 151942,
|
| 194 |
+
"<266>": 151943,
|
| 195 |
+
"<267>": 151944,
|
| 196 |
+
"<268>": 151945,
|
| 197 |
+
"<269>": 151946,
|
| 198 |
+
"<26>": 151703,
|
| 199 |
+
"<270>": 151947,
|
| 200 |
+
"<271>": 151948,
|
| 201 |
+
"<272>": 151949,
|
| 202 |
+
"<273>": 151950,
|
| 203 |
+
"<274>": 151951,
|
| 204 |
+
"<275>": 151952,
|
| 205 |
+
"<276>": 151953,
|
| 206 |
+
"<277>": 151954,
|
| 207 |
+
"<278>": 151955,
|
| 208 |
+
"<279>": 151956,
|
| 209 |
+
"<27>": 151704,
|
| 210 |
+
"<280>": 151957,
|
| 211 |
+
"<281>": 151958,
|
| 212 |
+
"<282>": 151959,
|
| 213 |
+
"<283>": 151960,
|
| 214 |
+
"<284>": 151961,
|
| 215 |
+
"<285>": 151962,
|
| 216 |
+
"<286>": 151963,
|
| 217 |
+
"<287>": 151964,
|
| 218 |
+
"<288>": 151965,
|
| 219 |
+
"<289>": 151966,
|
| 220 |
+
"<28>": 151705,
|
| 221 |
+
"<290>": 151967,
|
| 222 |
+
"<291>": 151968,
|
| 223 |
+
"<292>": 151969,
|
| 224 |
+
"<293>": 151970,
|
| 225 |
+
"<294>": 151971,
|
| 226 |
+
"<295>": 151972,
|
| 227 |
+
"<296>": 151973,
|
| 228 |
+
"<297>": 151974,
|
| 229 |
+
"<298>": 151975,
|
| 230 |
+
"<299>": 151976,
|
| 231 |
+
"<29>": 151706,
|
| 232 |
+
"<2>": 151679,
|
| 233 |
+
"<300>": 151977,
|
| 234 |
+
"<301>": 151978,
|
| 235 |
+
"<302>": 151979,
|
| 236 |
+
"<303>": 151980,
|
| 237 |
+
"<304>": 151981,
|
| 238 |
+
"<305>": 151982,
|
| 239 |
+
"<306>": 151983,
|
| 240 |
+
"<307>": 151984,
|
| 241 |
+
"<308>": 151985,
|
| 242 |
+
"<309>": 151986,
|
| 243 |
+
"<30>": 151707,
|
| 244 |
+
"<310>": 151987,
|
| 245 |
+
"<311>": 151988,
|
| 246 |
+
"<312>": 151989,
|
| 247 |
+
"<313>": 151990,
|
| 248 |
+
"<314>": 151991,
|
| 249 |
+
"<315>": 151992,
|
| 250 |
+
"<316>": 151993,
|
| 251 |
+
"<317>": 151994,
|
| 252 |
+
"<318>": 151995,
|
| 253 |
+
"<319>": 151996,
|
| 254 |
+
"<31>": 151708,
|
| 255 |
+
"<320>": 151997,
|
| 256 |
+
"<321>": 151998,
|
| 257 |
+
"<322>": 151999,
|
| 258 |
+
"<323>": 152000,
|
| 259 |
+
"<324>": 152001,
|
| 260 |
+
"<325>": 152002,
|
| 261 |
+
"<326>": 152003,
|
| 262 |
+
"<327>": 152004,
|
| 263 |
+
"<328>": 152005,
|
| 264 |
+
"<329>": 152006,
|
| 265 |
+
"<32>": 151709,
|
| 266 |
+
"<330>": 152007,
|
| 267 |
+
"<331>": 152008,
|
| 268 |
+
"<332>": 152009,
|
| 269 |
+
"<333>": 152010,
|
| 270 |
+
"<334>": 152011,
|
| 271 |
+
"<335>": 152012,
|
| 272 |
+
"<336>": 152013,
|
| 273 |
+
"<337>": 152014,
|
| 274 |
+
"<338>": 152015,
|
| 275 |
+
"<339>": 152016,
|
| 276 |
+
"<33>": 151710,
|
| 277 |
+
"<340>": 152017,
|
| 278 |
+
"<341>": 152018,
|
| 279 |
+
"<342>": 152019,
|
| 280 |
+
"<343>": 152020,
|
| 281 |
+
"<344>": 152021,
|
| 282 |
+
"<345>": 152022,
|
| 283 |
+
"<346>": 152023,
|
| 284 |
+
"<347>": 152024,
|
| 285 |
+
"<348>": 152025,
|
| 286 |
+
"<349>": 152026,
|
| 287 |
+
"<34>": 151711,
|
| 288 |
+
"<350>": 152027,
|
| 289 |
+
"<351>": 152028,
|
| 290 |
+
"<352>": 152029,
|
| 291 |
+
"<353>": 152030,
|
| 292 |
+
"<354>": 152031,
|
| 293 |
+
"<355>": 152032,
|
| 294 |
+
"<356>": 152033,
|
| 295 |
+
"<357>": 152034,
|
| 296 |
+
"<358>": 152035,
|
| 297 |
+
"<359>": 152036,
|
| 298 |
+
"<35>": 151712,
|
| 299 |
+
"<360>": 152037,
|
| 300 |
+
"<361>": 152038,
|
| 301 |
+
"<362>": 152039,
|
| 302 |
+
"<363>": 152040,
|
| 303 |
+
"<364>": 152041,
|
| 304 |
+
"<365>": 152042,
|
| 305 |
+
"<366>": 152043,
|
| 306 |
+
"<367>": 152044,
|
| 307 |
+
"<368>": 152045,
|
| 308 |
+
"<369>": 152046,
|
| 309 |
+
"<36>": 151713,
|
| 310 |
+
"<370>": 152047,
|
| 311 |
+
"<371>": 152048,
|
| 312 |
+
"<372>": 152049,
|
| 313 |
+
"<373>": 152050,
|
| 314 |
+
"<374>": 152051,
|
| 315 |
+
"<375>": 152052,
|
| 316 |
+
"<376>": 152053,
|
| 317 |
+
"<377>": 152054,
|
| 318 |
+
"<378>": 152055,
|
| 319 |
+
"<379>": 152056,
|
| 320 |
+
"<37>": 151714,
|
| 321 |
+
"<380>": 152057,
|
| 322 |
+
"<381>": 152058,
|
| 323 |
+
"<382>": 152059,
|
| 324 |
+
"<383>": 152060,
|
| 325 |
+
"<384>": 152061,
|
| 326 |
+
"<385>": 152062,
|
| 327 |
+
"<386>": 152063,
|
| 328 |
+
"<387>": 152064,
|
| 329 |
+
"<388>": 152065,
|
| 330 |
+
"<389>": 152066,
|
| 331 |
+
"<38>": 151715,
|
| 332 |
+
"<390>": 152067,
|
| 333 |
+
"<391>": 152068,
|
| 334 |
+
"<392>": 152069,
|
| 335 |
+
"<393>": 152070,
|
| 336 |
+
"<394>": 152071,
|
| 337 |
+
"<395>": 152072,
|
| 338 |
+
"<396>": 152073,
|
| 339 |
+
"<397>": 152074,
|
| 340 |
+
"<398>": 152075,
|
| 341 |
+
"<399>": 152076,
|
| 342 |
+
"<39>": 151716,
|
| 343 |
+
"<3>": 151680,
|
| 344 |
+
"<400>": 152077,
|
| 345 |
+
"<401>": 152078,
|
| 346 |
+
"<402>": 152079,
|
| 347 |
+
"<403>": 152080,
|
| 348 |
+
"<404>": 152081,
|
| 349 |
+
"<405>": 152082,
|
| 350 |
+
"<406>": 152083,
|
| 351 |
+
"<407>": 152084,
|
| 352 |
+
"<408>": 152085,
|
| 353 |
+
"<409>": 152086,
|
| 354 |
+
"<40>": 151717,
|
| 355 |
+
"<410>": 152087,
|
| 356 |
+
"<411>": 152088,
|
| 357 |
+
"<412>": 152089,
|
| 358 |
+
"<413>": 152090,
|
| 359 |
+
"<414>": 152091,
|
| 360 |
+
"<415>": 152092,
|
| 361 |
+
"<416>": 152093,
|
| 362 |
+
"<417>": 152094,
|
| 363 |
+
"<418>": 152095,
|
| 364 |
+
"<419>": 152096,
|
| 365 |
+
"<41>": 151718,
|
| 366 |
+
"<420>": 152097,
|
| 367 |
+
"<421>": 152098,
|
| 368 |
+
"<422>": 152099,
|
| 369 |
+
"<423>": 152100,
|
| 370 |
+
"<424>": 152101,
|
| 371 |
+
"<425>": 152102,
|
| 372 |
+
"<426>": 152103,
|
| 373 |
+
"<427>": 152104,
|
| 374 |
+
"<428>": 152105,
|
| 375 |
+
"<429>": 152106,
|
| 376 |
+
"<42>": 151719,
|
| 377 |
+
"<430>": 152107,
|
| 378 |
+
"<431>": 152108,
|
| 379 |
+
"<432>": 152109,
|
| 380 |
+
"<433>": 152110,
|
| 381 |
+
"<434>": 152111,
|
| 382 |
+
"<435>": 152112,
|
| 383 |
+
"<436>": 152113,
|
| 384 |
+
"<437>": 152114,
|
| 385 |
+
"<438>": 152115,
|
| 386 |
+
"<439>": 152116,
|
| 387 |
+
"<43>": 151720,
|
| 388 |
+
"<440>": 152117,
|
| 389 |
+
"<441>": 152118,
|
| 390 |
+
"<442>": 152119,
|
| 391 |
+
"<443>": 152120,
|
| 392 |
+
"<444>": 152121,
|
| 393 |
+
"<445>": 152122,
|
| 394 |
+
"<446>": 152123,
|
| 395 |
+
"<447>": 152124,
|
| 396 |
+
"<448>": 152125,
|
| 397 |
+
"<449>": 152126,
|
| 398 |
+
"<44>": 151721,
|
| 399 |
+
"<450>": 152127,
|
| 400 |
+
"<451>": 152128,
|
| 401 |
+
"<452>": 152129,
|
| 402 |
+
"<453>": 152130,
|
| 403 |
+
"<454>": 152131,
|
| 404 |
+
"<455>": 152132,
|
| 405 |
+
"<456>": 152133,
|
| 406 |
+
"<457>": 152134,
|
| 407 |
+
"<458>": 152135,
|
| 408 |
+
"<459>": 152136,
|
| 409 |
+
"<45>": 151722,
|
| 410 |
+
"<460>": 152137,
|
| 411 |
+
"<461>": 152138,
|
| 412 |
+
"<462>": 152139,
|
| 413 |
+
"<463>": 152140,
|
| 414 |
+
"<464>": 152141,
|
| 415 |
+
"<465>": 152142,
|
| 416 |
+
"<466>": 152143,
|
| 417 |
+
"<467>": 152144,
|
| 418 |
+
"<468>": 152145,
|
| 419 |
+
"<469>": 152146,
|
| 420 |
+
"<46>": 151723,
|
| 421 |
+
"<470>": 152147,
|
| 422 |
+
"<471>": 152148,
|
| 423 |
+
"<472>": 152149,
|
| 424 |
+
"<473>": 152150,
|
| 425 |
+
"<474>": 152151,
|
| 426 |
+
"<475>": 152152,
|
| 427 |
+
"<476>": 152153,
|
| 428 |
+
"<477>": 152154,
|
| 429 |
+
"<478>": 152155,
|
| 430 |
+
"<479>": 152156,
|
| 431 |
+
"<47>": 151724,
|
| 432 |
+
"<480>": 152157,
|
| 433 |
+
"<481>": 152158,
|
| 434 |
+
"<482>": 152159,
|
| 435 |
+
"<483>": 152160,
|
| 436 |
+
"<484>": 152161,
|
| 437 |
+
"<485>": 152162,
|
| 438 |
+
"<486>": 152163,
|
| 439 |
+
"<487>": 152164,
|
| 440 |
+
"<488>": 152165,
|
| 441 |
+
"<489>": 152166,
|
| 442 |
+
"<48>": 151725,
|
| 443 |
+
"<490>": 152167,
|
| 444 |
+
"<491>": 152168,
|
| 445 |
+
"<492>": 152169,
|
| 446 |
+
"<493>": 152170,
|
| 447 |
+
"<494>": 152171,
|
| 448 |
+
"<495>": 152172,
|
| 449 |
+
"<496>": 152173,
|
| 450 |
+
"<497>": 152174,
|
| 451 |
+
"<498>": 152175,
|
| 452 |
+
"<499>": 152176,
|
| 453 |
+
"<49>": 151726,
|
| 454 |
+
"<4>": 151681,
|
| 455 |
+
"<500>": 152177,
|
| 456 |
+
"<501>": 152178,
|
| 457 |
+
"<502>": 152179,
|
| 458 |
+
"<503>": 152180,
|
| 459 |
+
"<504>": 152181,
|
| 460 |
+
"<505>": 152182,
|
| 461 |
+
"<506>": 152183,
|
| 462 |
+
"<507>": 152184,
|
| 463 |
+
"<508>": 152185,
|
| 464 |
+
"<509>": 152186,
|
| 465 |
+
"<50>": 151727,
|
| 466 |
+
"<510>": 152187,
|
| 467 |
+
"<511>": 152188,
|
| 468 |
+
"<512>": 152189,
|
| 469 |
+
"<513>": 152190,
|
| 470 |
+
"<514>": 152191,
|
| 471 |
+
"<515>": 152192,
|
| 472 |
+
"<516>": 152193,
|
| 473 |
+
"<517>": 152194,
|
| 474 |
+
"<518>": 152195,
|
| 475 |
+
"<519>": 152196,
|
| 476 |
+
"<51>": 151728,
|
| 477 |
+
"<520>": 152197,
|
| 478 |
+
"<521>": 152198,
|
| 479 |
+
"<522>": 152199,
|
| 480 |
+
"<523>": 152200,
|
| 481 |
+
"<524>": 152201,
|
| 482 |
+
"<525>": 152202,
|
| 483 |
+
"<526>": 152203,
|
| 484 |
+
"<527>": 152204,
|
| 485 |
+
"<528>": 152205,
|
| 486 |
+
"<529>": 152206,
|
| 487 |
+
"<52>": 151729,
|
| 488 |
+
"<530>": 152207,
|
| 489 |
+
"<531>": 152208,
|
| 490 |
+
"<532>": 152209,
|
| 491 |
+
"<533>": 152210,
|
| 492 |
+
"<534>": 152211,
|
| 493 |
+
"<535>": 152212,
|
| 494 |
+
"<536>": 152213,
|
| 495 |
+
"<537>": 152214,
|
| 496 |
+
"<538>": 152215,
|
| 497 |
+
"<539>": 152216,
|
| 498 |
+
"<53>": 151730,
|
| 499 |
+
"<540>": 152217,
|
| 500 |
+
"<541>": 152218,
|
| 501 |
+
"<542>": 152219,
|
| 502 |
+
"<543>": 152220,
|
| 503 |
+
"<544>": 152221,
|
| 504 |
+
"<545>": 152222,
|
| 505 |
+
"<546>": 152223,
|
| 506 |
+
"<547>": 152224,
|
| 507 |
+
"<548>": 152225,
|
| 508 |
+
"<549>": 152226,
|
| 509 |
+
"<54>": 151731,
|
| 510 |
+
"<550>": 152227,
|
| 511 |
+
"<551>": 152228,
|
| 512 |
+
"<552>": 152229,
|
| 513 |
+
"<553>": 152230,
|
| 514 |
+
"<554>": 152231,
|
| 515 |
+
"<555>": 152232,
|
| 516 |
+
"<556>": 152233,
|
| 517 |
+
"<557>": 152234,
|
| 518 |
+
"<558>": 152235,
|
| 519 |
+
"<559>": 152236,
|
| 520 |
+
"<55>": 151732,
|
| 521 |
+
"<560>": 152237,
|
| 522 |
+
"<561>": 152238,
|
| 523 |
+
"<562>": 152239,
|
| 524 |
+
"<563>": 152240,
|
| 525 |
+
"<564>": 152241,
|
| 526 |
+
"<565>": 152242,
|
| 527 |
+
"<566>": 152243,
|
| 528 |
+
"<567>": 152244,
|
| 529 |
+
"<568>": 152245,
|
| 530 |
+
"<569>": 152246,
|
| 531 |
+
"<56>": 151733,
|
| 532 |
+
"<570>": 152247,
|
| 533 |
+
"<571>": 152248,
|
| 534 |
+
"<572>": 152249,
|
| 535 |
+
"<573>": 152250,
|
| 536 |
+
"<574>": 152251,
|
| 537 |
+
"<575>": 152252,
|
| 538 |
+
"<576>": 152253,
|
| 539 |
+
"<577>": 152254,
|
| 540 |
+
"<578>": 152255,
|
| 541 |
+
"<579>": 152256,
|
| 542 |
+
"<57>": 151734,
|
| 543 |
+
"<580>": 152257,
|
| 544 |
+
"<581>": 152258,
|
| 545 |
+
"<582>": 152259,
|
| 546 |
+
"<583>": 152260,
|
| 547 |
+
"<584>": 152261,
|
| 548 |
+
"<585>": 152262,
|
| 549 |
+
"<586>": 152263,
|
| 550 |
+
"<587>": 152264,
|
| 551 |
+
"<588>": 152265,
|
| 552 |
+
"<589>": 152266,
|
| 553 |
+
"<58>": 151735,
|
| 554 |
+
"<590>": 152267,
|
| 555 |
+
"<591>": 152268,
|
| 556 |
+
"<592>": 152269,
|
| 557 |
+
"<593>": 152270,
|
| 558 |
+
"<594>": 152271,
|
| 559 |
+
"<595>": 152272,
|
| 560 |
+
"<596>": 152273,
|
| 561 |
+
"<597>": 152274,
|
| 562 |
+
"<598>": 152275,
|
| 563 |
+
"<599>": 152276,
|
| 564 |
+
"<59>": 151736,
|
| 565 |
+
"<5>": 151682,
|
| 566 |
+
"<600>": 152277,
|
| 567 |
+
"<601>": 152278,
|
| 568 |
+
"<602>": 152279,
|
| 569 |
+
"<603>": 152280,
|
| 570 |
+
"<604>": 152281,
|
| 571 |
+
"<605>": 152282,
|
| 572 |
+
"<606>": 152283,
|
| 573 |
+
"<607>": 152284,
|
| 574 |
+
"<608>": 152285,
|
| 575 |
+
"<609>": 152286,
|
| 576 |
+
"<60>": 151737,
|
| 577 |
+
"<610>": 152287,
|
| 578 |
+
"<611>": 152288,
|
| 579 |
+
"<612>": 152289,
|
| 580 |
+
"<613>": 152290,
|
| 581 |
+
"<614>": 152291,
|
| 582 |
+
"<615>": 152292,
|
| 583 |
+
"<616>": 152293,
|
| 584 |
+
"<617>": 152294,
|
| 585 |
+
"<618>": 152295,
|
| 586 |
+
"<619>": 152296,
|
| 587 |
+
"<61>": 151738,
|
| 588 |
+
"<620>": 152297,
|
| 589 |
+
"<621>": 152298,
|
| 590 |
+
"<622>": 152299,
|
| 591 |
+
"<623>": 152300,
|
| 592 |
+
"<624>": 152301,
|
| 593 |
+
"<625>": 152302,
|
| 594 |
+
"<626>": 152303,
|
| 595 |
+
"<627>": 152304,
|
| 596 |
+
"<628>": 152305,
|
| 597 |
+
"<629>": 152306,
|
| 598 |
+
"<62>": 151739,
|
| 599 |
+
"<630>": 152307,
|
| 600 |
+
"<631>": 152308,
|
| 601 |
+
"<632>": 152309,
|
| 602 |
+
"<633>": 152310,
|
| 603 |
+
"<634>": 152311,
|
| 604 |
+
"<635>": 152312,
|
| 605 |
+
"<636>": 152313,
|
| 606 |
+
"<637>": 152314,
|
| 607 |
+
"<638>": 152315,
|
| 608 |
+
"<639>": 152316,
|
| 609 |
+
"<63>": 151740,
|
| 610 |
+
"<640>": 152317,
|
| 611 |
+
"<641>": 152318,
|
| 612 |
+
"<642>": 152319,
|
| 613 |
+
"<643>": 152320,
|
| 614 |
+
"<644>": 152321,
|
| 615 |
+
"<645>": 152322,
|
| 616 |
+
"<646>": 152323,
|
| 617 |
+
"<647>": 152324,
|
| 618 |
+
"<648>": 152325,
|
| 619 |
+
"<649>": 152326,
|
| 620 |
+
"<64>": 151741,
|
| 621 |
+
"<650>": 152327,
|
| 622 |
+
"<651>": 152328,
|
| 623 |
+
"<652>": 152329,
|
| 624 |
+
"<653>": 152330,
|
| 625 |
+
"<654>": 152331,
|
| 626 |
+
"<655>": 152332,
|
| 627 |
+
"<656>": 152333,
|
| 628 |
+
"<657>": 152334,
|
| 629 |
+
"<658>": 152335,
|
| 630 |
+
"<659>": 152336,
|
| 631 |
+
"<65>": 151742,
|
| 632 |
+
"<660>": 152337,
|
| 633 |
+
"<661>": 152338,
|
| 634 |
+
"<662>": 152339,
|
| 635 |
+
"<663>": 152340,
|
| 636 |
+
"<664>": 152341,
|
| 637 |
+
"<665>": 152342,
|
| 638 |
+
"<666>": 152343,
|
| 639 |
+
"<667>": 152344,
|
| 640 |
+
"<668>": 152345,
|
| 641 |
+
"<669>": 152346,
|
| 642 |
+
"<66>": 151743,
|
| 643 |
+
"<670>": 152347,
|
| 644 |
+
"<671>": 152348,
|
| 645 |
+
"<672>": 152349,
|
| 646 |
+
"<673>": 152350,
|
| 647 |
+
"<674>": 152351,
|
| 648 |
+
"<675>": 152352,
|
| 649 |
+
"<676>": 152353,
|
| 650 |
+
"<677>": 152354,
|
| 651 |
+
"<678>": 152355,
|
| 652 |
+
"<679>": 152356,
|
| 653 |
+
"<67>": 151744,
|
| 654 |
+
"<680>": 152357,
|
| 655 |
+
"<681>": 152358,
|
| 656 |
+
"<682>": 152359,
|
| 657 |
+
"<683>": 152360,
|
| 658 |
+
"<684>": 152361,
|
| 659 |
+
"<685>": 152362,
|
| 660 |
+
"<686>": 152363,
|
| 661 |
+
"<687>": 152364,
|
| 662 |
+
"<688>": 152365,
|
| 663 |
+
"<689>": 152366,
|
| 664 |
+
"<68>": 151745,
|
| 665 |
+
"<690>": 152367,
|
| 666 |
+
"<691>": 152368,
|
| 667 |
+
"<692>": 152369,
|
| 668 |
+
"<693>": 152370,
|
| 669 |
+
"<694>": 152371,
|
| 670 |
+
"<695>": 152372,
|
| 671 |
+
"<696>": 152373,
|
| 672 |
+
"<697>": 152374,
|
| 673 |
+
"<698>": 152375,
|
| 674 |
+
"<699>": 152376,
|
| 675 |
+
"<69>": 151746,
|
| 676 |
+
"<6>": 151683,
|
| 677 |
+
"<700>": 152377,
|
| 678 |
+
"<701>": 152378,
|
| 679 |
+
"<702>": 152379,
|
| 680 |
+
"<703>": 152380,
|
| 681 |
+
"<704>": 152381,
|
| 682 |
+
"<705>": 152382,
|
| 683 |
+
"<706>": 152383,
|
| 684 |
+
"<707>": 152384,
|
| 685 |
+
"<708>": 152385,
|
| 686 |
+
"<709>": 152386,
|
| 687 |
+
"<70>": 151747,
|
| 688 |
+
"<710>": 152387,
|
| 689 |
+
"<711>": 152388,
|
| 690 |
+
"<712>": 152389,
|
| 691 |
+
"<713>": 152390,
|
| 692 |
+
"<714>": 152391,
|
| 693 |
+
"<715>": 152392,
|
| 694 |
+
"<716>": 152393,
|
| 695 |
+
"<717>": 152394,
|
| 696 |
+
"<718>": 152395,
|
| 697 |
+
"<719>": 152396,
|
| 698 |
+
"<71>": 151748,
|
| 699 |
+
"<720>": 152397,
|
| 700 |
+
"<721>": 152398,
|
| 701 |
+
"<722>": 152399,
|
| 702 |
+
"<723>": 152400,
|
| 703 |
+
"<724>": 152401,
|
| 704 |
+
"<725>": 152402,
|
| 705 |
+
"<726>": 152403,
|
| 706 |
+
"<727>": 152404,
|
| 707 |
+
"<728>": 152405,
|
| 708 |
+
"<729>": 152406,
|
| 709 |
+
"<72>": 151749,
|
| 710 |
+
"<730>": 152407,
|
| 711 |
+
"<731>": 152408,
|
| 712 |
+
"<732>": 152409,
|
| 713 |
+
"<733>": 152410,
|
| 714 |
+
"<734>": 152411,
|
| 715 |
+
"<735>": 152412,
|
| 716 |
+
"<736>": 152413,
|
| 717 |
+
"<737>": 152414,
|
| 718 |
+
"<738>": 152415,
|
| 719 |
+
"<739>": 152416,
|
| 720 |
+
"<73>": 151750,
|
| 721 |
+
"<740>": 152417,
|
| 722 |
+
"<741>": 152418,
|
| 723 |
+
"<742>": 152419,
|
| 724 |
+
"<743>": 152420,
|
| 725 |
+
"<744>": 152421,
|
| 726 |
+
"<745>": 152422,
|
| 727 |
+
"<746>": 152423,
|
| 728 |
+
"<747>": 152424,
|
| 729 |
+
"<748>": 152425,
|
| 730 |
+
"<749>": 152426,
|
| 731 |
+
"<74>": 151751,
|
| 732 |
+
"<750>": 152427,
|
| 733 |
+
"<751>": 152428,
|
| 734 |
+
"<752>": 152429,
|
| 735 |
+
"<753>": 152430,
|
| 736 |
+
"<754>": 152431,
|
| 737 |
+
"<755>": 152432,
|
| 738 |
+
"<756>": 152433,
|
| 739 |
+
"<757>": 152434,
|
| 740 |
+
"<758>": 152435,
|
| 741 |
+
"<759>": 152436,
|
| 742 |
+
"<75>": 151752,
|
| 743 |
+
"<760>": 152437,
|
| 744 |
+
"<761>": 152438,
|
| 745 |
+
"<762>": 152439,
|
| 746 |
+
"<763>": 152440,
|
| 747 |
+
"<764>": 152441,
|
| 748 |
+
"<765>": 152442,
|
| 749 |
+
"<766>": 152443,
|
| 750 |
+
"<767>": 152444,
|
| 751 |
+
"<768>": 152445,
|
| 752 |
+
"<769>": 152446,
|
| 753 |
+
"<76>": 151753,
|
| 754 |
+
"<770>": 152447,
|
| 755 |
+
"<771>": 152448,
|
| 756 |
+
"<772>": 152449,
|
| 757 |
+
"<773>": 152450,
|
| 758 |
+
"<774>": 152451,
|
| 759 |
+
"<775>": 152452,
|
| 760 |
+
"<776>": 152453,
|
| 761 |
+
"<777>": 152454,
|
| 762 |
+
"<778>": 152455,
|
| 763 |
+
"<779>": 152456,
|
| 764 |
+
"<77>": 151754,
|
| 765 |
+
"<780>": 152457,
|
| 766 |
+
"<781>": 152458,
|
| 767 |
+
"<782>": 152459,
|
| 768 |
+
"<783>": 152460,
|
| 769 |
+
"<784>": 152461,
|
| 770 |
+
"<785>": 152462,
|
| 771 |
+
"<786>": 152463,
|
| 772 |
+
"<787>": 152464,
|
| 773 |
+
"<788>": 152465,
|
| 774 |
+
"<789>": 152466,
|
| 775 |
+
"<78>": 151755,
|
| 776 |
+
"<790>": 152467,
|
| 777 |
+
"<791>": 152468,
|
| 778 |
+
"<792>": 152469,
|
| 779 |
+
"<793>": 152470,
|
| 780 |
+
"<794>": 152471,
|
| 781 |
+
"<795>": 152472,
|
| 782 |
+
"<796>": 152473,
|
| 783 |
+
"<797>": 152474,
|
| 784 |
+
"<798>": 152475,
|
| 785 |
+
"<799>": 152476,
|
| 786 |
+
"<79>": 151756,
|
| 787 |
+
"<7>": 151684,
|
| 788 |
+
"<800>": 152477,
|
| 789 |
+
"<801>": 152478,
|
| 790 |
+
"<802>": 152479,
|
| 791 |
+
"<803>": 152480,
|
| 792 |
+
"<804>": 152481,
|
| 793 |
+
"<805>": 152482,
|
| 794 |
+
"<806>": 152483,
|
| 795 |
+
"<807>": 152484,
|
| 796 |
+
"<808>": 152485,
|
| 797 |
+
"<809>": 152486,
|
| 798 |
+
"<80>": 151757,
|
| 799 |
+
"<810>": 152487,
|
| 800 |
+
"<811>": 152488,
|
| 801 |
+
"<812>": 152489,
|
| 802 |
+
"<813>": 152490,
|
| 803 |
+
"<814>": 152491,
|
| 804 |
+
"<815>": 152492,
|
| 805 |
+
"<816>": 152493,
|
| 806 |
+
"<817>": 152494,
|
| 807 |
+
"<818>": 152495,
|
| 808 |
+
"<819>": 152496,
|
| 809 |
+
"<81>": 151758,
|
| 810 |
+
"<820>": 152497,
|
| 811 |
+
"<821>": 152498,
|
| 812 |
+
"<822>": 152499,
|
| 813 |
+
"<823>": 152500,
|
| 814 |
+
"<824>": 152501,
|
| 815 |
+
"<825>": 152502,
|
| 816 |
+
"<826>": 152503,
|
| 817 |
+
"<827>": 152504,
|
| 818 |
+
"<828>": 152505,
|
| 819 |
+
"<829>": 152506,
|
| 820 |
+
"<82>": 151759,
|
| 821 |
+
"<830>": 152507,
|
| 822 |
+
"<831>": 152508,
|
| 823 |
+
"<832>": 152509,
|
| 824 |
+
"<833>": 152510,
|
| 825 |
+
"<834>": 152511,
|
| 826 |
+
"<835>": 152512,
|
| 827 |
+
"<836>": 152513,
|
| 828 |
+
"<837>": 152514,
|
| 829 |
+
"<838>": 152515,
|
| 830 |
+
"<839>": 152516,
|
| 831 |
+
"<83>": 151760,
|
| 832 |
+
"<840>": 152517,
|
| 833 |
+
"<841>": 152518,
|
| 834 |
+
"<842>": 152519,
|
| 835 |
+
"<843>": 152520,
|
| 836 |
+
"<844>": 152521,
|
| 837 |
+
"<845>": 152522,
|
| 838 |
+
"<846>": 152523,
|
| 839 |
+
"<847>": 152524,
|
| 840 |
+
"<848>": 152525,
|
| 841 |
+
"<849>": 152526,
|
| 842 |
+
"<84>": 151761,
|
| 843 |
+
"<850>": 152527,
|
| 844 |
+
"<851>": 152528,
|
| 845 |
+
"<852>": 152529,
|
| 846 |
+
"<853>": 152530,
|
| 847 |
+
"<854>": 152531,
|
| 848 |
+
"<855>": 152532,
|
| 849 |
+
"<856>": 152533,
|
| 850 |
+
"<857>": 152534,
|
| 851 |
+
"<858>": 152535,
|
| 852 |
+
"<859>": 152536,
|
| 853 |
+
"<85>": 151762,
|
| 854 |
+
"<860>": 152537,
|
| 855 |
+
"<861>": 152538,
|
| 856 |
+
"<862>": 152539,
|
| 857 |
+
"<863>": 152540,
|
| 858 |
+
"<864>": 152541,
|
| 859 |
+
"<865>": 152542,
|
| 860 |
+
"<866>": 152543,
|
| 861 |
+
"<867>": 152544,
|
| 862 |
+
"<868>": 152545,
|
| 863 |
+
"<869>": 152546,
|
| 864 |
+
"<86>": 151763,
|
| 865 |
+
"<870>": 152547,
|
| 866 |
+
"<871>": 152548,
|
| 867 |
+
"<872>": 152549,
|
| 868 |
+
"<873>": 152550,
|
| 869 |
+
"<874>": 152551,
|
| 870 |
+
"<875>": 152552,
|
| 871 |
+
"<876>": 152553,
|
| 872 |
+
"<877>": 152554,
|
| 873 |
+
"<878>": 152555,
|
| 874 |
+
"<879>": 152556,
|
| 875 |
+
"<87>": 151764,
|
| 876 |
+
"<880>": 152557,
|
| 877 |
+
"<881>": 152558,
|
| 878 |
+
"<882>": 152559,
|
| 879 |
+
"<883>": 152560,
|
| 880 |
+
"<884>": 152561,
|
| 881 |
+
"<885>": 152562,
|
| 882 |
+
"<886>": 152563,
|
| 883 |
+
"<887>": 152564,
|
| 884 |
+
"<888>": 152565,
|
| 885 |
+
"<889>": 152566,
|
| 886 |
+
"<88>": 151765,
|
| 887 |
+
"<890>": 152567,
|
| 888 |
+
"<891>": 152568,
|
| 889 |
+
"<892>": 152569,
|
| 890 |
+
"<893>": 152570,
|
| 891 |
+
"<894>": 152571,
|
| 892 |
+
"<895>": 152572,
|
| 893 |
+
"<896>": 152573,
|
| 894 |
+
"<897>": 152574,
|
| 895 |
+
"<898>": 152575,
|
| 896 |
+
"<899>": 152576,
|
| 897 |
+
"<89>": 151766,
|
| 898 |
+
"<8>": 151685,
|
| 899 |
+
"<900>": 152577,
|
| 900 |
+
"<901>": 152578,
|
| 901 |
+
"<902>": 152579,
|
| 902 |
+
"<903>": 152580,
|
| 903 |
+
"<904>": 152581,
|
| 904 |
+
"<905>": 152582,
|
| 905 |
+
"<906>": 152583,
|
| 906 |
+
"<907>": 152584,
|
| 907 |
+
"<908>": 152585,
|
| 908 |
+
"<909>": 152586,
|
| 909 |
+
"<90>": 151767,
|
| 910 |
+
"<910>": 152587,
|
| 911 |
+
"<911>": 152588,
|
| 912 |
+
"<912>": 152589,
|
| 913 |
+
"<913>": 152590,
|
| 914 |
+
"<914>": 152591,
|
| 915 |
+
"<915>": 152592,
|
| 916 |
+
"<916>": 152593,
|
| 917 |
+
"<917>": 152594,
|
| 918 |
+
"<918>": 152595,
|
| 919 |
+
"<919>": 152596,
|
| 920 |
+
"<91>": 151768,
|
| 921 |
+
"<920>": 152597,
|
| 922 |
+
"<921>": 152598,
|
| 923 |
+
"<922>": 152599,
|
| 924 |
+
"<923>": 152600,
|
| 925 |
+
"<924>": 152601,
|
| 926 |
+
"<925>": 152602,
|
| 927 |
+
"<926>": 152603,
|
| 928 |
+
"<927>": 152604,
|
| 929 |
+
"<928>": 152605,
|
| 930 |
+
"<929>": 152606,
|
| 931 |
+
"<92>": 151769,
|
| 932 |
+
"<930>": 152607,
|
| 933 |
+
"<931>": 152608,
|
| 934 |
+
"<932>": 152609,
|
| 935 |
+
"<933>": 152610,
|
| 936 |
+
"<934>": 152611,
|
| 937 |
+
"<935>": 152612,
|
| 938 |
+
"<936>": 152613,
|
| 939 |
+
"<937>": 152614,
|
| 940 |
+
"<938>": 152615,
|
| 941 |
+
"<939>": 152616,
|
| 942 |
+
"<93>": 151770,
|
| 943 |
+
"<940>": 152617,
|
| 944 |
+
"<941>": 152618,
|
| 945 |
+
"<942>": 152619,
|
| 946 |
+
"<943>": 152620,
|
| 947 |
+
"<944>": 152621,
|
| 948 |
+
"<945>": 152622,
|
| 949 |
+
"<946>": 152623,
|
| 950 |
+
"<947>": 152624,
|
| 951 |
+
"<948>": 152625,
|
| 952 |
+
"<949>": 152626,
|
| 953 |
+
"<94>": 151771,
|
| 954 |
+
"<950>": 152627,
|
| 955 |
+
"<951>": 152628,
|
| 956 |
+
"<952>": 152629,
|
| 957 |
+
"<953>": 152630,
|
| 958 |
+
"<954>": 152631,
|
| 959 |
+
"<955>": 152632,
|
| 960 |
+
"<956>": 152633,
|
| 961 |
+
"<957>": 152634,
|
| 962 |
+
"<958>": 152635,
|
| 963 |
+
"<959>": 152636,
|
| 964 |
+
"<95>": 151772,
|
| 965 |
+
"<960>": 152637,
|
| 966 |
+
"<961>": 152638,
|
| 967 |
+
"<962>": 152639,
|
| 968 |
+
"<963>": 152640,
|
| 969 |
+
"<964>": 152641,
|
| 970 |
+
"<965>": 152642,
|
| 971 |
+
"<966>": 152643,
|
| 972 |
+
"<967>": 152644,
|
| 973 |
+
"<968>": 152645,
|
| 974 |
+
"<969>": 152646,
|
| 975 |
+
"<96>": 151773,
|
| 976 |
+
"<970>": 152647,
|
| 977 |
+
"<971>": 152648,
|
| 978 |
+
"<972>": 152649,
|
| 979 |
+
"<973>": 152650,
|
| 980 |
+
"<974>": 152651,
|
| 981 |
+
"<975>": 152652,
|
| 982 |
+
"<976>": 152653,
|
| 983 |
+
"<977>": 152654,
|
| 984 |
+
"<978>": 152655,
|
| 985 |
+
"<979>": 152656,
|
| 986 |
+
"<97>": 151774,
|
| 987 |
+
"<980>": 152657,
|
| 988 |
+
"<981>": 152658,
|
| 989 |
+
"<982>": 152659,
|
| 990 |
+
"<983>": 152660,
|
| 991 |
+
"<984>": 152661,
|
| 992 |
+
"<985>": 152662,
|
| 993 |
+
"<986>": 152663,
|
| 994 |
+
"<987>": 152664,
|
| 995 |
+
"<988>": 152665,
|
| 996 |
+
"<989>": 152666,
|
| 997 |
+
"<98>": 151775,
|
| 998 |
+
"<990>": 152667,
|
| 999 |
+
"<991>": 152668,
|
| 1000 |
+
"<992>": 152669,
|
| 1001 |
+
"<993>": 152670,
|
| 1002 |
+
"<994>": 152671,
|
| 1003 |
+
"<995>": 152672,
|
| 1004 |
+
"<996>": 152673,
|
| 1005 |
+
"<997>": 152674,
|
| 1006 |
+
"<998>": 152675,
|
| 1007 |
+
"<999>": 152676,
|
| 1008 |
+
"<99>": 151776,
|
| 1009 |
+
"<9>": 151686,
|
| 1010 |
+
"<IMG_CONTEXT>": 151665,
|
| 1011 |
+
"<box>": 151668,
|
| 1012 |
+
"<img>": 151666,
|
| 1013 |
+
"<interval>": 151674,
|
| 1014 |
+
"<null>": 152678,
|
| 1015 |
+
"<quad>": 151670,
|
| 1016 |
+
"<ref>": 151672,
|
| 1017 |
+
"<switch>": 152679,
|
| 1018 |
+
"<text_mask>": 151676,
|
| 1019 |
+
"<tool_call>": 151657,
|
| 1020 |
+
"<|box_end|>": 151649,
|
| 1021 |
+
"<|box_start|>": 151648,
|
| 1022 |
+
"<|endoftext|>": 151643,
|
| 1023 |
+
"<|file_sep|>": 151664,
|
| 1024 |
+
"<|fim_middle|>": 151660,
|
| 1025 |
+
"<|fim_pad|>": 151662,
|
| 1026 |
+
"<|fim_prefix|>": 151659,
|
| 1027 |
+
"<|fim_suffix|>": 151661,
|
| 1028 |
+
"<|im_end|>": 151645,
|
| 1029 |
+
"<|im_start|>": 151644,
|
| 1030 |
+
"<|image_pad|>": 151655,
|
| 1031 |
+
"<|object_ref_end|>": 151647,
|
| 1032 |
+
"<|object_ref_start|>": 151646,
|
| 1033 |
+
"<|quad_end|>": 151651,
|
| 1034 |
+
"<|quad_start|>": 151650,
|
| 1035 |
+
"<|repo_name|>": 151663,
|
| 1036 |
+
"<|video_pad|>": 151656,
|
| 1037 |
+
"<|vision_end|>": 151653,
|
| 1038 |
+
"<|vision_pad|>": 151654,
|
| 1039 |
+
"<|vision_start|>": 151652
|
| 1040 |
+
}
|
qwen2.5_tokenizer/chat_template.jinja
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{%- if tools %}
|
| 2 |
+
{{- '<|im_start|>system\n' }}
|
| 3 |
+
{%- if messages[0]['role'] == 'system' %}
|
| 4 |
+
{{- messages[0]['content'] }}
|
| 5 |
+
{%- else %}
|
| 6 |
+
{{- 'You are Qwen, created by Alibaba Cloud. You are a helpful assistant.' }}
|
| 7 |
+
{%- endif %}
|
| 8 |
+
{{- "\n\n# Tools\n\nYou may call one or more functions to assist with the user query.\n\nYou are provided with function signatures within <tools></tools> XML tags:\n<tools>" }}
|
| 9 |
+
{%- for tool in tools %}
|
| 10 |
+
{{- "\n" }}
|
| 11 |
+
{{- tool | tojson }}
|
| 12 |
+
{%- endfor %}
|
| 13 |
+
{{- "\n</tools>\n\nFor each function call, return a json object with function name and arguments within <tool_call></tool_call> XML tags:\n<tool_call>\n{\"name\": <function-name>, \"arguments\": <args-json-object>}\n</tool_call><|im_end|>\n" }}
|
| 14 |
+
{%- else %}
|
| 15 |
+
{%- if messages[0]['role'] == 'system' %}
|
| 16 |
+
{{- '<|im_start|>system\n' + messages[0]['content'] + '<|im_end|>\n' }}
|
| 17 |
+
{%- else %}
|
| 18 |
+
{{- '<|im_start|>system\nYou are Qwen, created by Alibaba Cloud. You are a helpful assistant.<|im_end|>\n' }}
|
| 19 |
+
{%- endif %}
|
| 20 |
+
{%- endif %}
|
| 21 |
+
{%- for message in messages %}
|
| 22 |
+
{%- if (message.role == "user") or (message.role == "system" and not loop.first) or (message.role == "assistant" and not message.tool_calls) %}
|
| 23 |
+
{{- '<|im_start|>' + message.role + '\n' + message.content + '<|im_end|>' + '\n' }}
|
| 24 |
+
{%- elif message.role == "assistant" %}
|
| 25 |
+
{{- '<|im_start|>' + message.role }}
|
| 26 |
+
{%- if message.content %}
|
| 27 |
+
{{- '\n' + message.content }}
|
| 28 |
+
{%- endif %}
|
| 29 |
+
{%- for tool_call in message.tool_calls %}
|
| 30 |
+
{%- if tool_call.function is defined %}
|
| 31 |
+
{%- set tool_call = tool_call.function %}
|
| 32 |
+
{%- endif %}
|
| 33 |
+
{{- '\n<tool_call>\n{"name": "' }}
|
| 34 |
+
{{- tool_call.name }}
|
| 35 |
+
{{- '", "arguments": ' }}
|
| 36 |
+
{{- tool_call.arguments | tojson }}
|
| 37 |
+
{{- '}\n</tool_call>' }}
|
| 38 |
+
{%- endfor %}
|
| 39 |
+
{{- '<|im_end|>\n' }}
|
| 40 |
+
{%- elif message.role == "tool" %}
|
| 41 |
+
{%- if (loop.index0 == 0) or (messages[loop.index0 - 1].role != "tool") %}
|
| 42 |
+
{{- '<|im_start|>user' }}
|
| 43 |
+
{%- endif %}
|
| 44 |
+
{{- '\n<tool_response>\n' }}
|
| 45 |
+
{{- message.content }}
|
| 46 |
+
{{- '\n</tool_response>' }}
|
| 47 |
+
{%- if loop.last or (messages[loop.index0 + 1].role != "tool") %}
|
| 48 |
+
{{- '<|im_end|>\n' }}
|
| 49 |
+
{%- endif %}
|
| 50 |
+
{%- endif %}
|
| 51 |
+
{%- endfor %}
|
| 52 |
+
{%- if add_generation_prompt %}
|
| 53 |
+
{{- '<|im_start|>assistant\n' }}
|
| 54 |
+
{%- endif %}
|
qwen2.5_tokenizer/chat_template.json
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"chat_template": "{% set image_count = namespace(value=0) %}{% set video_count = namespace(value=0) %}{% for message in messages %}{% if loop.first and message['role'] != 'system' %}<|im_start|>system\nYou are a helpful assistant.<|im_end|>\n{% endif %}<|im_start|>{{ message['role'] }}\n{% if message['content'] is string %}{{ message['content'] }}<|im_end|>\n{% else %}{% for content in message['content'] %}{% if content['type'] == 'image' or 'image' in content or 'image_url' in content %}{% set image_count.value = image_count.value + 1 %}{% if add_vision_id %}<image {{ image_count.value }}>{% endif %}<image-{{ image_count.value }}>{% elif content['type'] == 'video' or 'video' in content %}{% set video_count.value = video_count.value + 1 %}{% if add_vision_id %}<video {{ video_count.value }}>{% endif %}<video-{{ video_count.value }}>{% elif 'text' in content %}{{ content['text'] }}{% endif %}{% endfor %}<|im_end|>\n{% endif %}{% endfor %}{% if add_generation_prompt %}<|im_start|>assistant\n{% endif %}"
|
| 3 |
+
}
|
| 4 |
+
|
qwen2.5_tokenizer/config.json
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"architectures": [
|
| 3 |
+
"Qwen2ForCausalLM"
|
| 4 |
+
],
|
| 5 |
+
"attention_dropout": 0.0,
|
| 6 |
+
"auto_map": {
|
| 7 |
+
"AutoConfig": "configuration_qwen2.Qwen2Config",
|
| 8 |
+
"AutoModelForCausalLM": "modeling_qwen2.Qwen2ForCausalLM"
|
| 9 |
+
},
|
| 10 |
+
"block_size": 6,
|
| 11 |
+
"bos_token_id": 151643,
|
| 12 |
+
"causal_attn": false,
|
| 13 |
+
"dtype": "bfloat16",
|
| 14 |
+
"eos_token_id": 151645,
|
| 15 |
+
"hidden_act": "silu",
|
| 16 |
+
"hidden_size": 2048,
|
| 17 |
+
"initializer_range": 0.02,
|
| 18 |
+
"intermediate_size": 11008,
|
| 19 |
+
"layer_types": [
|
| 20 |
+
"full_attention",
|
| 21 |
+
"full_attention",
|
| 22 |
+
"full_attention",
|
| 23 |
+
"full_attention",
|
| 24 |
+
"full_attention",
|
| 25 |
+
"full_attention",
|
| 26 |
+
"full_attention",
|
| 27 |
+
"full_attention",
|
| 28 |
+
"full_attention",
|
| 29 |
+
"full_attention",
|
| 30 |
+
"full_attention",
|
| 31 |
+
"full_attention",
|
| 32 |
+
"full_attention",
|
| 33 |
+
"full_attention",
|
| 34 |
+
"full_attention",
|
| 35 |
+
"full_attention",
|
| 36 |
+
"full_attention",
|
| 37 |
+
"full_attention",
|
| 38 |
+
"full_attention",
|
| 39 |
+
"full_attention",
|
| 40 |
+
"full_attention",
|
| 41 |
+
"full_attention",
|
| 42 |
+
"full_attention",
|
| 43 |
+
"full_attention",
|
| 44 |
+
"full_attention",
|
| 45 |
+
"full_attention",
|
| 46 |
+
"full_attention",
|
| 47 |
+
"full_attention",
|
| 48 |
+
"full_attention",
|
| 49 |
+
"full_attention",
|
| 50 |
+
"full_attention",
|
| 51 |
+
"full_attention",
|
| 52 |
+
"full_attention",
|
| 53 |
+
"full_attention",
|
| 54 |
+
"full_attention",
|
| 55 |
+
"full_attention"
|
| 56 |
+
],
|
| 57 |
+
"max_position_embeddings": 32768,
|
| 58 |
+
"max_window_layers": 70,
|
| 59 |
+
"model_type": "qwen2",
|
| 60 |
+
"null_token_id": 152678,
|
| 61 |
+
"num_attention_heads": 16,
|
| 62 |
+
"num_hidden_layers": 36,
|
| 63 |
+
"num_key_value_heads": 2,
|
| 64 |
+
"pad_token_id": 151643,
|
| 65 |
+
"quantization_config": {
|
| 66 |
+
"bits": 4,
|
| 67 |
+
"checkpoint_format": "gptq",
|
| 68 |
+
"desc_act": false,
|
| 69 |
+
"format": "gptq",
|
| 70 |
+
"group_size": 128,
|
| 71 |
+
"lm_head": false,
|
| 72 |
+
"meta": {
|
| 73 |
+
"act_group_aware": true,
|
| 74 |
+
"auto_forward_data_parallel": true,
|
| 75 |
+
"damp_auto_increment": 0.01,
|
| 76 |
+
"damp_percent": 0.05,
|
| 77 |
+
"dense_vram_strategy": "exclusive",
|
| 78 |
+
"dense_vram_strategy_devices": null,
|
| 79 |
+
"fallback": {
|
| 80 |
+
"smooth": null,
|
| 81 |
+
"strategy": "rtn",
|
| 82 |
+
"threshold": "0.5%"
|
| 83 |
+
},
|
| 84 |
+
"foem": null,
|
| 85 |
+
"gc_mode": "interval",
|
| 86 |
+
"gptaq": null,
|
| 87 |
+
"hessian": {
|
| 88 |
+
"chunk_bytes": null,
|
| 89 |
+
"chunk_size": null,
|
| 90 |
+
"staging_dtype": "float32"
|
| 91 |
+
},
|
| 92 |
+
"mock_quantization": false,
|
| 93 |
+
"moe_vram_strategy": "exclusive",
|
| 94 |
+
"moe_vram_strategy_devices": null,
|
| 95 |
+
"mse": 0.0,
|
| 96 |
+
"offload_to_disk": true,
|
| 97 |
+
"offload_to_disk_path": "/tmp/gptqmodel_42jjgpwr",
|
| 98 |
+
"pack_impl": "cpu",
|
| 99 |
+
"quantizer": [
|
| 100 |
+
"gptqmodel:7.1.0"
|
| 101 |
+
],
|
| 102 |
+
"static_groups": false,
|
| 103 |
+
"true_sequential": true,
|
| 104 |
+
"uri": "https://github.com/modelcloud/gptqmodel",
|
| 105 |
+
"wait_for_submodule_finalizers": false
|
| 106 |
+
},
|
| 107 |
+
"method": "gptq",
|
| 108 |
+
"pack_dtype": "int32",
|
| 109 |
+
"quant_method": "gptq",
|
| 110 |
+
"sym": true
|
| 111 |
+
},
|
| 112 |
+
"rms_norm_eps": 1e-06,
|
| 113 |
+
"rope_parameters": {
|
| 114 |
+
"rope_theta": 10000.0,
|
| 115 |
+
"rope_type": "default"
|
| 116 |
+
},
|
| 117 |
+
"sliding_window": null,
|
| 118 |
+
"switch_token_id": 152679,
|
| 119 |
+
"text_mask_token_id": 151676,
|
| 120 |
+
"tie_word_embeddings": true,
|
| 121 |
+
"transformers_version": "5.10.2",
|
| 122 |
+
"use_cache": false,
|
| 123 |
+
"use_sliding_window": false,
|
| 124 |
+
"vocab_size": 152681
|
| 125 |
+
}
|
qwen2.5_tokenizer/configuration_qwen2.py
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# coding=utf-8
|
| 2 |
+
# Copyright 2024 The Qwen team, Alibaba Group and the HuggingFace Inc. team. All rights reserved.
|
| 3 |
+
#
|
| 4 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 |
+
# you may not use this file except in compliance with the License.
|
| 6 |
+
# You may obtain a copy of the License at
|
| 7 |
+
#
|
| 8 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 9 |
+
#
|
| 10 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 11 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 |
+
# See the License for the specific language governing permissions and
|
| 14 |
+
# limitations under the License.
|
| 15 |
+
""" Qwen2 model configuration"""
|
| 16 |
+
|
| 17 |
+
from transformers.configuration_utils import PretrainedConfig
|
| 18 |
+
from transformers.utils import logging
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
logger = logging.get_logger(__name__)
|
| 22 |
+
|
| 23 |
+
QWEN2_PRETRAINED_CONFIG_ARCHIVE_MAP = {
|
| 24 |
+
"Qwen/Qwen2-7B-beta": "https://huggingface.co/Qwen/Qwen2-7B-beta/resolve/main/config.json",
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
class Qwen2Config(PretrainedConfig):
|
| 29 |
+
r"""
|
| 30 |
+
This is the configuration class to store the configuration of a [`Qwen2Model`]. It is used to instantiate a
|
| 31 |
+
Qwen2 model according to the specified arguments, defining the model architecture. Instantiating a configuration
|
| 32 |
+
with the defaults will yield a similar configuration to that of
|
| 33 |
+
Qwen2-7B-beta [Qwen/Qwen2-7B-beta](https://huggingface.co/Qwen/Qwen2-7B-beta).
|
| 34 |
+
|
| 35 |
+
Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
|
| 36 |
+
documentation from [`PretrainedConfig`] for more information.
|
| 37 |
+
|
| 38 |
+
|
| 39 |
+
Args:
|
| 40 |
+
vocab_size (`int`, *optional*, defaults to 151936):
|
| 41 |
+
Vocabulary size of the Qwen2 model. Defines the number of different tokens that can be represented by the
|
| 42 |
+
`inputs_ids` passed when calling [`Qwen2Model`]
|
| 43 |
+
hidden_size (`int`, *optional*, defaults to 4096):
|
| 44 |
+
Dimension of the hidden representations.
|
| 45 |
+
intermediate_size (`int`, *optional*, defaults to 22016):
|
| 46 |
+
Dimension of the MLP representations.
|
| 47 |
+
num_hidden_layers (`int`, *optional*, defaults to 32):
|
| 48 |
+
Number of hidden layers in the Transformer encoder.
|
| 49 |
+
num_attention_heads (`int`, *optional*, defaults to 32):
|
| 50 |
+
Number of attention heads for each attention layer in the Transformer encoder.
|
| 51 |
+
num_key_value_heads (`int`, *optional*, defaults to 32):
|
| 52 |
+
This is the number of key_value heads that should be used to implement Grouped Query Attention. If
|
| 53 |
+
`num_key_value_heads=num_attention_heads`, the model will use Multi Head Attention (MHA), if
|
| 54 |
+
`num_key_value_heads=1 the model will use Multi Query Attention (MQA) otherwise GQA is used. When
|
| 55 |
+
converting a multi-head checkpoint to a GQA checkpoint, each group key and value head should be constructed
|
| 56 |
+
by meanpooling all the original heads within that group. For more details checkout [this
|
| 57 |
+
paper](https://arxiv.org/pdf/2305.13245.pdf). If it is not specified, will default to `32`.
|
| 58 |
+
hidden_act (`str` or `function`, *optional*, defaults to `"silu"`):
|
| 59 |
+
The non-linear activation function (function or string) in the decoder.
|
| 60 |
+
max_position_embeddings (`int`, *optional*, defaults to 32768):
|
| 61 |
+
The maximum sequence length that this model might ever be used with.
|
| 62 |
+
initializer_range (`float`, *optional*, defaults to 0.02):
|
| 63 |
+
The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
|
| 64 |
+
rms_norm_eps (`float`, *optional*, defaults to 1e-06):
|
| 65 |
+
The epsilon used by the rms normalization layers.
|
| 66 |
+
use_cache (`bool`, *optional*, defaults to `True`):
|
| 67 |
+
Whether or not the model should return the last key/values attentions (not used by all models). Only
|
| 68 |
+
relevant if `config.is_decoder=True`.
|
| 69 |
+
tie_word_embeddings (`bool`, *optional*, defaults to `False`):
|
| 70 |
+
Whether the model's input and output word embeddings should be tied.
|
| 71 |
+
rope_theta (`float`, *optional*, defaults to 10000.0):
|
| 72 |
+
The base period of the RoPE embeddings.
|
| 73 |
+
use_sliding_window (`bool`, *optional*, defaults to `False`):
|
| 74 |
+
Whether to use sliding window attention.
|
| 75 |
+
sliding_window (`int`, *optional*, defaults to 4096):
|
| 76 |
+
Sliding window attention (SWA) window size. If not specified, will default to `4096`.
|
| 77 |
+
max_window_layers (`int`, *optional*, defaults to 28):
|
| 78 |
+
The number of layers that use SWA (Sliding Window Attention). The bottom layers use SWA while the top use full attention.
|
| 79 |
+
attention_dropout (`float`, *optional*, defaults to 0.0):
|
| 80 |
+
The dropout ratio for the attention probabilities.
|
| 81 |
+
|
| 82 |
+
```python
|
| 83 |
+
>>> from transformers import Qwen2Model, Qwen2Config
|
| 84 |
+
|
| 85 |
+
>>> # Initializing a Qwen2 style configuration
|
| 86 |
+
>>> configuration = Qwen2Config()
|
| 87 |
+
|
| 88 |
+
>>> # Initializing a model from the Qwen2-7B style configuration
|
| 89 |
+
>>> model = Qwen2Model(configuration)
|
| 90 |
+
|
| 91 |
+
>>> # Accessing the model configuration
|
| 92 |
+
>>> configuration = model.config
|
| 93 |
+
```"""
|
| 94 |
+
|
| 95 |
+
model_type = "qwen2"
|
| 96 |
+
keys_to_ignore_at_inference = ["past_key_values"]
|
| 97 |
+
|
| 98 |
+
def __init__(
|
| 99 |
+
self,
|
| 100 |
+
vocab_size=151936,
|
| 101 |
+
hidden_size=4096,
|
| 102 |
+
intermediate_size=22016,
|
| 103 |
+
num_hidden_layers=32,
|
| 104 |
+
num_attention_heads=32,
|
| 105 |
+
num_key_value_heads=32,
|
| 106 |
+
hidden_act="silu",
|
| 107 |
+
max_position_embeddings=32768,
|
| 108 |
+
initializer_range=0.02,
|
| 109 |
+
rms_norm_eps=1e-6,
|
| 110 |
+
use_cache=True,
|
| 111 |
+
tie_word_embeddings=False,
|
| 112 |
+
rope_theta=10000.0,
|
| 113 |
+
use_sliding_window=False,
|
| 114 |
+
sliding_window=4096,
|
| 115 |
+
max_window_layers=28,
|
| 116 |
+
attention_dropout=0.0,
|
| 117 |
+
**kwargs,
|
| 118 |
+
):
|
| 119 |
+
self.vocab_size = vocab_size
|
| 120 |
+
self.max_position_embeddings = max_position_embeddings
|
| 121 |
+
self.hidden_size = hidden_size
|
| 122 |
+
self.intermediate_size = intermediate_size
|
| 123 |
+
self.num_hidden_layers = num_hidden_layers
|
| 124 |
+
self.num_attention_heads = num_attention_heads
|
| 125 |
+
self.use_sliding_window = use_sliding_window
|
| 126 |
+
self.sliding_window = sliding_window
|
| 127 |
+
self.max_window_layers = max_window_layers
|
| 128 |
+
|
| 129 |
+
# for backward compatibility
|
| 130 |
+
if num_key_value_heads is None:
|
| 131 |
+
num_key_value_heads = num_attention_heads
|
| 132 |
+
|
| 133 |
+
self.num_key_value_heads = num_key_value_heads
|
| 134 |
+
self.hidden_act = hidden_act
|
| 135 |
+
self.initializer_range = initializer_range
|
| 136 |
+
self.rms_norm_eps = rms_norm_eps
|
| 137 |
+
self.use_cache = use_cache
|
| 138 |
+
self.rope_theta = rope_theta
|
| 139 |
+
self.attention_dropout = attention_dropout
|
| 140 |
+
if kwargs.get('attn_implementation', None) is None:
|
| 141 |
+
self.attn_implementation = kwargs['attn_implementation'] = 'flash_attention_2'
|
| 142 |
+
else:
|
| 143 |
+
self.attn_implementation = kwargs['attn_implementation']
|
| 144 |
+
|
| 145 |
+
super().__init__(
|
| 146 |
+
tie_word_embeddings=tie_word_embeddings,
|
| 147 |
+
**kwargs,
|
| 148 |
+
)
|
qwen2.5_tokenizer/generation_config.json
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"_from_model_config": true,
|
| 3 |
+
"bos_token_id": 151643,
|
| 4 |
+
"do_sample": true,
|
| 5 |
+
"eos_token_id": 151645,
|
| 6 |
+
"transformers_version": "5.10.2"
|
| 7 |
+
}
|
qwen2.5_tokenizer/mask_magi_utils.py
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) 2026, NVIDIA CORPORATION. All rights reserved.
|
| 2 |
+
#
|
| 3 |
+
# NVIDIA CORPORATION and its licensors retain all intellectual property
|
| 4 |
+
# and proprietary rights in and to this software, related documentation
|
| 5 |
+
# and any modifications thereto. Any use, reproduction, disclosure or
|
| 6 |
+
# distribution of this software and related documentation without an express
|
| 7 |
+
# license agreement from NVIDIA CORPORATION is strictly prohibited.
|
| 8 |
+
|
| 9 |
+
import torch
|
| 10 |
+
|
| 11 |
+
# MagiAttention attn_type_map convention
|
| 12 |
+
FULL, CAUSAL = 0, 1
|
| 13 |
+
|
| 14 |
+
def build_magi_ranges(kv_len: int, q_len: int, block_size: int, ar_decode: bool=False, device: str = "cpu"):
|
| 15 |
+
"""
|
| 16 |
+
Fixed strategy:
|
| 17 |
+
- use_cache=True: Mask blocked_k = (kv_len - block_size - 1) column
|
| 18 |
+
- causal_attn=False: Window interior is FULL (bidirectional)
|
| 19 |
+
- If q_len==kv_len: Use coarse prefix version (fewer ranges)
|
| 20 |
+
- Otherwise: General decode version (recompute rows expanding visible region row by row)
|
| 21 |
+
|
| 22 |
+
Conventions:
|
| 23 |
+
- K/V global length kv_len: [0, kv_len)
|
| 24 |
+
- Current Q is "last q_len tokens"
|
| 25 |
+
- First r=q_len-block_size rows are recomputed; last block_size rows are window
|
| 26 |
+
"""
|
| 27 |
+
assert 0 < q_len <= kv_len
|
| 28 |
+
|
| 29 |
+
if ar_decode:
|
| 30 |
+
return {
|
| 31 |
+
"q_ranges": torch.tensor([[0, q_len]], dtype=torch.int32, device=device).contiguous(),
|
| 32 |
+
"k_ranges": torch.tensor([[0, kv_len]], dtype=torch.int32, device=device).contiguous(),
|
| 33 |
+
"attn_type_map": torch.tensor([CAUSAL], dtype=torch.int32, device=device).contiguous(),
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
|
| 37 |
+
assert 0 < block_size <= q_len <= kv_len
|
| 38 |
+
B = block_size
|
| 39 |
+
r = q_len - B
|
| 40 |
+
q_global_start = kv_len - q_len
|
| 41 |
+
|
| 42 |
+
window_start_k = kv_len - B
|
| 43 |
+
blocked_k = window_start_k - 1 # The column that is blocked
|
| 44 |
+
|
| 45 |
+
q_ranges, k_ranges, types = [], [], []
|
| 46 |
+
|
| 47 |
+
# -------- prefix (q_len == kv_len) coarse-grained --------
|
| 48 |
+
if q_len == kv_len:
|
| 49 |
+
prefix_len = window_start_k # kv_len - B
|
| 50 |
+
|
| 51 |
+
# prefix->prefix: causal
|
| 52 |
+
if prefix_len > 0:
|
| 53 |
+
q_ranges += [[0, prefix_len]]
|
| 54 |
+
k_ranges += [[0, prefix_len]]
|
| 55 |
+
types += [CAUSAL]
|
| 56 |
+
|
| 57 |
+
# window->prefix: full, but exclude blocked_k => keys [0, blocked_k)
|
| 58 |
+
if prefix_len > 0 and blocked_k > 0:
|
| 59 |
+
q_ranges += [[prefix_len, kv_len]]
|
| 60 |
+
k_ranges += [[0, blocked_k]]
|
| 61 |
+
types += [FULL]
|
| 62 |
+
|
| 63 |
+
# window->window: full
|
| 64 |
+
q_ranges += [[prefix_len, kv_len]]
|
| 65 |
+
k_ranges += [[prefix_len, kv_len]]
|
| 66 |
+
types += [FULL]
|
| 67 |
+
|
| 68 |
+
return {
|
| 69 |
+
"q_ranges": torch.tensor(q_ranges, dtype=torch.int32, device=device).contiguous(),
|
| 70 |
+
"k_ranges": torch.tensor(k_ranges, dtype=torch.int32, device=device).contiguous(),
|
| 71 |
+
"attn_type_map": torch.tensor(types, dtype=torch.int32, device=device).contiguous(),
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
# -------- decode / general (q_len < kv_len) --------
|
| 75 |
+
|
| 76 |
+
# A) Recomputed rows: expand visible key cutoff row by row (use FULL + single-row q_range for precise shape)
|
| 77 |
+
for i in range(r):
|
| 78 |
+
g = q_global_start + i
|
| 79 |
+
q_ranges.append([i, i + 1])
|
| 80 |
+
k_ranges.append([0, g + 1]) # Allow keys [0, g]
|
| 81 |
+
types.append(FULL)
|
| 82 |
+
|
| 83 |
+
# B) Window rows: allow prefix but block blocked_k; window interior is full
|
| 84 |
+
q_win = [r, q_len]
|
| 85 |
+
|
| 86 |
+
# prefix keys [0, blocked_k)
|
| 87 |
+
if blocked_k > 0:
|
| 88 |
+
q_ranges.append(q_win)
|
| 89 |
+
k_ranges.append([0, blocked_k])
|
| 90 |
+
types.append(FULL)
|
| 91 |
+
|
| 92 |
+
# window keys [window_start_k, kv_len)
|
| 93 |
+
q_ranges.append(q_win)
|
| 94 |
+
k_ranges.append([window_start_k, kv_len])
|
| 95 |
+
types.append(FULL)
|
| 96 |
+
|
| 97 |
+
return {
|
| 98 |
+
"q_ranges": torch.tensor(q_ranges, dtype=torch.int32, device=device).contiguous(),
|
| 99 |
+
"k_ranges": torch.tensor(k_ranges, dtype=torch.int32, device=device).contiguous(),
|
| 100 |
+
"attn_type_map": torch.tensor(types, dtype=torch.int32, device=device).contiguous(),
|
| 101 |
+
}
|
qwen2.5_tokenizer/mask_sdpa_utils.py
ADDED
|
@@ -0,0 +1,232 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright (c) 2026, NVIDIA CORPORATION. All rights reserved.
|
| 2 |
+
#
|
| 3 |
+
# NVIDIA CORPORATION and its licensors retain all intellectual property
|
| 4 |
+
# and proprietary rights in and to this software, related documentation
|
| 5 |
+
# and any modifications thereto. Any use, reproduction, disclosure or
|
| 6 |
+
# distribution of this software and related documentation without an express
|
| 7 |
+
# license agreement from NVIDIA CORPORATION is strictly prohibited.
|
| 8 |
+
|
| 9 |
+
import torch
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
def find_prefix_seq_length_by_pe(
|
| 13 |
+
pe: torch.Tensor
|
| 14 |
+
) -> torch.Tensor:
|
| 15 |
+
"""
|
| 16 |
+
Find the sequence length where position encoding drops (indicating prefix boundary).
|
| 17 |
+
Args:
|
| 18 |
+
pe: Position encoding tensor of shape [Batch size, Sequence length ]
|
| 19 |
+
Contains position indices for each token in the sequence.
|
| 20 |
+
Returns:
|
| 21 |
+
torch.Tensor: A tensor of shape [B] containing:
|
| 22 |
+
- The index where position encoding drops for each sequence
|
| 23 |
+
- -1 if no drop occurs in the sequence
|
| 24 |
+
"""
|
| 25 |
+
batch_size, seq_len = pe.shape
|
| 26 |
+
prev = pe[:, :-1]
|
| 27 |
+
curr = pe[:, 1:]
|
| 28 |
+
drop_mask = curr < prev # [batch_size, seq_len-1]
|
| 29 |
+
|
| 30 |
+
seq_len = torch.full((batch_size,), -1, dtype=torch.long)
|
| 31 |
+
|
| 32 |
+
for b in range(batch_size):
|
| 33 |
+
drop_pos = torch.nonzero(drop_mask[b], as_tuple=False)
|
| 34 |
+
if drop_pos.numel() > 0:
|
| 35 |
+
i = drop_pos[0].item() + 1 # Take first drop position (+1 because we compared shifted sequences)
|
| 36 |
+
seq_len[b] = i
|
| 37 |
+
|
| 38 |
+
return seq_len
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
def update_causal_mask_with_pad_non_visible_2d(
|
| 43 |
+
input_ids: torch.Tensor,
|
| 44 |
+
attn_mask_2d: torch.Tensor,
|
| 45 |
+
text_mask_token_id: int,
|
| 46 |
+
block_size: int = 4,
|
| 47 |
+
causal_attn: bool = False
|
| 48 |
+
) -> torch.Tensor:
|
| 49 |
+
"""
|
| 50 |
+
Updates a 2D attention mask for hole sequence through input_ids and text_mask_token_id
|
| 51 |
+
|
| 52 |
+
Args:
|
| 53 |
+
input_ids: Input token IDs (unused in current implementation)
|
| 54 |
+
attn_mask_2d: 2D attention mask matrix of shape [seq_len, seq_len] where:
|
| 55 |
+
- 0.0 indicates allowed attention
|
| 56 |
+
- -inf indicates masked attention
|
| 57 |
+
text_mask_token_id: ID representing masked tokens
|
| 58 |
+
block_size: Size of the diffusion window
|
| 59 |
+
causal_attn: If True, maintains strict causal masking throughout
|
| 60 |
+
|
| 61 |
+
Returns:
|
| 62 |
+
Modified attention mask with updated visibility patterns
|
| 63 |
+
"""
|
| 64 |
+
seq_len = input_ids.shape[0]
|
| 65 |
+
device = input_ids.device
|
| 66 |
+
|
| 67 |
+
# Identify masked tokens and their preceding positions
|
| 68 |
+
input_mask = input_ids.eq(text_mask_token_id)
|
| 69 |
+
input_before_mask = torch.zeros_like(input_mask)
|
| 70 |
+
input_before_mask[:-1] = input_mask[1:]
|
| 71 |
+
mask_cols = (input_mask | input_before_mask)
|
| 72 |
+
non_mask = ~mask_cols
|
| 73 |
+
|
| 74 |
+
rows = torch.arange(seq_len, device=device)[:, None]
|
| 75 |
+
cols = torch.arange(seq_len, device=device)
|
| 76 |
+
|
| 77 |
+
indices = torch.arange(seq_len, device=device)
|
| 78 |
+
prev_non_mask = (indices * non_mask).cummax(dim=0).values
|
| 79 |
+
|
| 80 |
+
max_value = torch.iinfo(indices.dtype).max
|
| 81 |
+
mask_indices = torch.where(non_mask, indices, torch.full_like(indices, max_value))
|
| 82 |
+
reversed_mask_indices = torch.flip(mask_indices, dims=[0])
|
| 83 |
+
reversed_cummin = reversed_mask_indices.cummin(dim=0).values
|
| 84 |
+
next_non_mask = torch.flip(reversed_cummin, dims=[0])
|
| 85 |
+
|
| 86 |
+
infra_mask = (
|
| 87 |
+
(cols > prev_non_mask) &
|
| 88 |
+
(rows >= next_non_mask[None, :]) &
|
| 89 |
+
mask_cols[None, :]
|
| 90 |
+
)
|
| 91 |
+
attn_mask_2d.masked_fill_(infra_mask, -float('inf'))
|
| 92 |
+
|
| 93 |
+
if not causal_attn:
|
| 94 |
+
visible_mask = (
|
| 95 |
+
(rows > prev_non_mask[None, :]) &
|
| 96 |
+
(rows < cols) &
|
| 97 |
+
mask_cols[None, :]
|
| 98 |
+
)
|
| 99 |
+
attn_mask_2d.masked_fill_(visible_mask, 0.0)
|
| 100 |
+
|
| 101 |
+
return attn_mask_2d
|
| 102 |
+
|
| 103 |
+
|
| 104 |
+
def update_causal_mask_for_one_gen_window_2d(
|
| 105 |
+
input_ids: torch.Tensor,
|
| 106 |
+
attn_mask_2d: torch.Tensor,
|
| 107 |
+
block_size: int = 4,
|
| 108 |
+
use_cache: bool = True,
|
| 109 |
+
causal_attn: bool = False
|
| 110 |
+
) -> torch.Tensor:
|
| 111 |
+
"""
|
| 112 |
+
Updates a 2D attention mask for a diffusion window in transformer inference.
|
| 113 |
+
|
| 114 |
+
Args:
|
| 115 |
+
input_ids: Input token IDs (unused in current implementation)
|
| 116 |
+
attn_mask_2d: 2D attention mask matrix of shape [seq_len, seq_len] where:
|
| 117 |
+
- 0.0 indicates allowed attention
|
| 118 |
+
- -inf indicates masked attention
|
| 119 |
+
block_size: Size of the diffusion window
|
| 120 |
+
use_cache: Whether key-value cache is being used
|
| 121 |
+
causal_attn: If True, maintains strict causal masking throughout
|
| 122 |
+
|
| 123 |
+
Returns:
|
| 124 |
+
Modified attention mask with updated visibility patterns
|
| 125 |
+
"""
|
| 126 |
+
|
| 127 |
+
if not causal_attn:
|
| 128 |
+
# Make the diffusion window (last block_size tokens) fully visible to itself
|
| 129 |
+
# This allows bidirectional attention within the diffusion window
|
| 130 |
+
attn_mask_2d[-block_size:, -block_size:] = 0.0
|
| 131 |
+
if use_cache:
|
| 132 |
+
# Mask the last token from previous round to prevent recomputation and maintain generation consistency.
|
| 133 |
+
attn_mask_2d[-block_size:, -block_size-1] = -float('inf')
|
| 134 |
+
|
| 135 |
+
return attn_mask_2d
|
| 136 |
+
|
| 137 |
+
|
| 138 |
+
def create_block_diff_mask_by_pe_4d(
|
| 139 |
+
block_size: int,
|
| 140 |
+
x0_len_list: torch.Tensor,
|
| 141 |
+
position_ids: torch.Tensor,
|
| 142 |
+
causal_attn: bool = False
|
| 143 |
+
) -> tuple[torch.Tensor, torch.Tensor]:
|
| 144 |
+
"""Generates a 4D attention mask for block-difference attention patterns.
|
| 145 |
+
|
| 146 |
+
The mask consists of three regions:
|
| 147 |
+
1. Causal block (top-left): Standard causal attention for `x0` tokens.
|
| 148 |
+
2. Mutual block (bottom-right): Non-causal attention within the same block for non-`x0` tokens.
|
| 149 |
+
3. Prefix block (bottom-left): Non-`x0` tokens can attend to a prefix of `x0` tokens.
|
| 150 |
+
|
| 151 |
+
Args:
|
| 152 |
+
block_size (int): Size of processing blocks for non-`x0` tokens.
|
| 153 |
+
x0_len_list (torch.Tensor): Tensor of shape [B] containing lengths of `x0` segments per batch.
|
| 154 |
+
position_ids (torch.Tensor): Tensor of shape [B, seq_len] containing position IDs.
|
| 155 |
+
causal_attn (bool, optional): If True, enforces causal masking in mutual blocks. Defaults to False.
|
| 156 |
+
|
| 157 |
+
Returns:
|
| 158 |
+
tuple[torch.Tensor, torch.Tensor]:
|
| 159 |
+
- A float mask of shape [batch_size, 1, seq_len, seq_len] with `-inf` for masked positions (non visiable).
|
| 160 |
+
- A boolean mask of shape [batch_size, 1, seq_len, seq_len] indicating allowed attention positions.
|
| 161 |
+
"""
|
| 162 |
+
batch_size, seq_len = position_ids.shape
|
| 163 |
+
device = position_ids.device
|
| 164 |
+
|
| 165 |
+
# Create position indices [batch_size, seq_len, seq_len]
|
| 166 |
+
q_idx = torch.arange(seq_len, device=device).view(1, seq_len, 1) # [1, seq_len, 1]
|
| 167 |
+
kv_idx = torch.arange(seq_len, device=device).view(1, 1, seq_len) # [1, 1, seq_len]
|
| 168 |
+
|
| 169 |
+
# Broadcast to [B, seq_len, seq_len]
|
| 170 |
+
x0_len = x0_len_list.view(batch_size, 1, 1) # [batch_size, 1, 1]
|
| 171 |
+
x0_flag_q = q_idx < x0_len # [batch_size, seq_len, seq_len]
|
| 172 |
+
x0_flag_kv = kv_idx < x0_len
|
| 173 |
+
|
| 174 |
+
# Block indices calculation [batch_size, seq_len, seq_len]
|
| 175 |
+
q_block_idx = (q_idx - x0_len) // block_size
|
| 176 |
+
kv_block_idx = (kv_idx - x0_len) // block_size
|
| 177 |
+
|
| 178 |
+
# causal block (top-left)
|
| 179 |
+
block_causal = x0_flag_q & x0_flag_kv & (q_idx >= kv_idx)
|
| 180 |
+
|
| 181 |
+
mutual_condition = (q_idx >= kv_idx) if causal_attn else torch.ones_like(q_idx, dtype=torch.bool)
|
| 182 |
+
block_mutual = (
|
| 183 |
+
~x0_flag_q & ~x0_flag_kv &
|
| 184 |
+
(q_block_idx == kv_block_idx) &
|
| 185 |
+
mutual_condition
|
| 186 |
+
)
|
| 187 |
+
|
| 188 |
+
q_blk = torch.div(q_idx - x0_len, block_size, rounding_mode='floor')
|
| 189 |
+
q_blk_start = (x0_len_list.view(batch_size, 1) + q_blk[:, :, 0] * block_size).clamp(min=0, max=seq_len - 1)
|
| 190 |
+
prefix_len = position_ids.gather(1, q_blk_start)
|
| 191 |
+
prefix_len = prefix_len.unsqueeze(2)
|
| 192 |
+
block_prefix = (~x0_flag_q & x0_flag_kv) & (kv_idx < prefix_len)
|
| 193 |
+
|
| 194 |
+
final_mask = (block_causal | block_mutual | block_prefix)
|
| 195 |
+
customized_mask = torch.full_like(final_mask, float('-inf'), dtype=torch.bfloat16)
|
| 196 |
+
customized_mask.masked_fill_(final_mask, 0.0)
|
| 197 |
+
|
| 198 |
+
return customized_mask.unsqueeze(1).to(device=device), final_mask.unsqueeze(1).to(device=device)
|
| 199 |
+
|
| 200 |
+
|
| 201 |
+
def find_pred_pos_from_input_ids(
|
| 202 |
+
input_ids: torch.LongTensor = None,
|
| 203 |
+
text_mask_token_id: int = None,
|
| 204 |
+
) -> torch.Tensor:
|
| 205 |
+
"""Compute the relative prediction positions for masked tokens in a sequence.
|
| 206 |
+
|
| 207 |
+
For non-masked positions, the output is 0. For masked positions, the value increments
|
| 208 |
+
by 1 for each consecutive mask token, indicating how many steps ahead the prediction is.
|
| 209 |
+
|
| 210 |
+
Args:
|
| 211 |
+
input_ids (torch.LongTensor): Input token IDs of shape [batch_size, seq_len].
|
| 212 |
+
text_mask_token_id (int, optional): Token ID representing masked positions. Defaults to 151666.
|
| 213 |
+
|
| 214 |
+
Returns:
|
| 215 |
+
torch.Tensor: A tensor of shape [batch_size, seq_len] where:
|
| 216 |
+
- 0 indicates a non-masked token.
|
| 217 |
+
- n > 0 indicates the nth consecutive masked token (e.g., 1 = first mask, 2 = second mask, etc.).
|
| 218 |
+
"""
|
| 219 |
+
batch_size, seq_len = input_ids.shape
|
| 220 |
+
device = input_ids.device
|
| 221 |
+
|
| 222 |
+
is_mask = (input_ids == text_mask_token_id)
|
| 223 |
+
|
| 224 |
+
base_mask = torch.zeros((batch_size, seq_len), dtype=torch.int8, device=device)
|
| 225 |
+
|
| 226 |
+
for b in range(batch_size):
|
| 227 |
+
for ix in range(1, seq_len):
|
| 228 |
+
if is_mask[b][ix] == True:
|
| 229 |
+
# Increment counter if current token is masked
|
| 230 |
+
base_mask[b][ix] = base_mask[b][ix-1] + 1
|
| 231 |
+
|
| 232 |
+
return base_mask
|
qwen2.5_tokenizer/merges.txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
qwen2.5_tokenizer/model.safetensors.index.json
ADDED
|
@@ -0,0 +1,442 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"metadata": {
|
| 3 |
+
"total_size": 6800310272
|
| 4 |
+
},
|
| 5 |
+
"weight_map": {
|
| 6 |
+
"lm_head.weight": "model-00002-of-00002.safetensors",
|
| 7 |
+
"model.embed_tokens.weight": "model-00001-of-00002.safetensors",
|
| 8 |
+
"model.layers.0.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 9 |
+
"model.layers.0.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 10 |
+
"model.layers.0.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 11 |
+
"model.layers.0.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 12 |
+
"model.layers.0.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 13 |
+
"model.layers.0.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
|
| 14 |
+
"model.layers.0.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 15 |
+
"model.layers.0.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 16 |
+
"model.layers.0.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
|
| 17 |
+
"model.layers.0.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 18 |
+
"model.layers.0.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
|
| 19 |
+
"model.layers.0.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 20 |
+
"model.layers.1.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 21 |
+
"model.layers.1.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 22 |
+
"model.layers.1.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 23 |
+
"model.layers.1.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 24 |
+
"model.layers.1.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 25 |
+
"model.layers.1.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
|
| 26 |
+
"model.layers.1.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 27 |
+
"model.layers.1.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 28 |
+
"model.layers.1.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
|
| 29 |
+
"model.layers.1.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 30 |
+
"model.layers.1.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
|
| 31 |
+
"model.layers.1.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 32 |
+
"model.layers.10.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 33 |
+
"model.layers.10.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 34 |
+
"model.layers.10.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 35 |
+
"model.layers.10.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 36 |
+
"model.layers.10.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 37 |
+
"model.layers.10.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
|
| 38 |
+
"model.layers.10.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 39 |
+
"model.layers.10.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 40 |
+
"model.layers.10.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
|
| 41 |
+
"model.layers.10.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 42 |
+
"model.layers.10.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
|
| 43 |
+
"model.layers.10.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 44 |
+
"model.layers.11.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 45 |
+
"model.layers.11.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 46 |
+
"model.layers.11.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 47 |
+
"model.layers.11.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 48 |
+
"model.layers.11.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 49 |
+
"model.layers.11.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
|
| 50 |
+
"model.layers.11.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 51 |
+
"model.layers.11.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 52 |
+
"model.layers.11.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
|
| 53 |
+
"model.layers.11.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 54 |
+
"model.layers.11.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
|
| 55 |
+
"model.layers.11.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 56 |
+
"model.layers.12.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 57 |
+
"model.layers.12.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 58 |
+
"model.layers.12.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 59 |
+
"model.layers.12.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 60 |
+
"model.layers.12.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 61 |
+
"model.layers.12.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
|
| 62 |
+
"model.layers.12.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 63 |
+
"model.layers.12.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 64 |
+
"model.layers.12.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
|
| 65 |
+
"model.layers.12.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 66 |
+
"model.layers.12.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
|
| 67 |
+
"model.layers.12.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 68 |
+
"model.layers.13.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 69 |
+
"model.layers.13.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 70 |
+
"model.layers.13.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 71 |
+
"model.layers.13.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 72 |
+
"model.layers.13.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 73 |
+
"model.layers.13.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
|
| 74 |
+
"model.layers.13.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 75 |
+
"model.layers.13.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 76 |
+
"model.layers.13.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
|
| 77 |
+
"model.layers.13.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 78 |
+
"model.layers.13.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
|
| 79 |
+
"model.layers.13.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 80 |
+
"model.layers.14.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 81 |
+
"model.layers.14.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 82 |
+
"model.layers.14.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 83 |
+
"model.layers.14.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 84 |
+
"model.layers.14.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 85 |
+
"model.layers.14.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
|
| 86 |
+
"model.layers.14.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 87 |
+
"model.layers.14.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 88 |
+
"model.layers.14.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
|
| 89 |
+
"model.layers.14.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 90 |
+
"model.layers.14.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
|
| 91 |
+
"model.layers.14.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 92 |
+
"model.layers.15.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 93 |
+
"model.layers.15.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 94 |
+
"model.layers.15.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 95 |
+
"model.layers.15.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 96 |
+
"model.layers.15.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 97 |
+
"model.layers.15.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
|
| 98 |
+
"model.layers.15.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 99 |
+
"model.layers.15.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 100 |
+
"model.layers.15.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
|
| 101 |
+
"model.layers.15.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 102 |
+
"model.layers.15.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
|
| 103 |
+
"model.layers.15.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 104 |
+
"model.layers.16.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 105 |
+
"model.layers.16.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 106 |
+
"model.layers.16.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 107 |
+
"model.layers.16.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 108 |
+
"model.layers.16.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 109 |
+
"model.layers.16.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
|
| 110 |
+
"model.layers.16.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 111 |
+
"model.layers.16.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 112 |
+
"model.layers.16.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
|
| 113 |
+
"model.layers.16.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 114 |
+
"model.layers.16.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
|
| 115 |
+
"model.layers.16.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 116 |
+
"model.layers.17.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 117 |
+
"model.layers.17.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 118 |
+
"model.layers.17.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 119 |
+
"model.layers.17.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 120 |
+
"model.layers.17.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 121 |
+
"model.layers.17.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
|
| 122 |
+
"model.layers.17.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 123 |
+
"model.layers.17.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 124 |
+
"model.layers.17.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
|
| 125 |
+
"model.layers.17.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 126 |
+
"model.layers.17.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
|
| 127 |
+
"model.layers.17.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 128 |
+
"model.layers.18.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 129 |
+
"model.layers.18.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 130 |
+
"model.layers.18.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 131 |
+
"model.layers.18.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 132 |
+
"model.layers.18.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 133 |
+
"model.layers.18.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
|
| 134 |
+
"model.layers.18.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 135 |
+
"model.layers.18.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 136 |
+
"model.layers.18.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
|
| 137 |
+
"model.layers.18.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 138 |
+
"model.layers.18.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
|
| 139 |
+
"model.layers.18.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 140 |
+
"model.layers.19.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 141 |
+
"model.layers.19.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 142 |
+
"model.layers.19.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 143 |
+
"model.layers.19.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 144 |
+
"model.layers.19.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 145 |
+
"model.layers.19.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
|
| 146 |
+
"model.layers.19.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 147 |
+
"model.layers.19.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 148 |
+
"model.layers.19.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
|
| 149 |
+
"model.layers.19.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 150 |
+
"model.layers.19.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
|
| 151 |
+
"model.layers.19.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 152 |
+
"model.layers.2.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 153 |
+
"model.layers.2.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 154 |
+
"model.layers.2.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 155 |
+
"model.layers.2.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 156 |
+
"model.layers.2.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 157 |
+
"model.layers.2.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
|
| 158 |
+
"model.layers.2.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 159 |
+
"model.layers.2.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 160 |
+
"model.layers.2.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
|
| 161 |
+
"model.layers.2.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 162 |
+
"model.layers.2.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
|
| 163 |
+
"model.layers.2.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 164 |
+
"model.layers.20.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 165 |
+
"model.layers.20.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 166 |
+
"model.layers.20.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 167 |
+
"model.layers.20.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 168 |
+
"model.layers.20.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 169 |
+
"model.layers.20.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
|
| 170 |
+
"model.layers.20.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 171 |
+
"model.layers.20.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 172 |
+
"model.layers.20.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
|
| 173 |
+
"model.layers.20.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 174 |
+
"model.layers.20.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
|
| 175 |
+
"model.layers.20.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 176 |
+
"model.layers.21.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 177 |
+
"model.layers.21.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 178 |
+
"model.layers.21.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 179 |
+
"model.layers.21.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 180 |
+
"model.layers.21.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 181 |
+
"model.layers.21.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
|
| 182 |
+
"model.layers.21.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 183 |
+
"model.layers.21.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 184 |
+
"model.layers.21.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
|
| 185 |
+
"model.layers.21.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 186 |
+
"model.layers.21.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
|
| 187 |
+
"model.layers.21.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 188 |
+
"model.layers.22.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 189 |
+
"model.layers.22.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
| 190 |
+
"model.layers.22.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 191 |
+
"model.layers.22.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 192 |
+
"model.layers.22.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 193 |
+
"model.layers.22.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
|
| 194 |
+
"model.layers.22.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 195 |
+
"model.layers.22.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 196 |
+
"model.layers.22.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
|
| 197 |
+
"model.layers.22.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 198 |
+
"model.layers.22.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
|
| 199 |
+
"model.layers.22.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 200 |
+
"model.layers.23.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 201 |
+
"model.layers.23.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
| 202 |
+
"model.layers.23.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
| 203 |
+
"model.layers.23.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
| 204 |
+
"model.layers.23.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 205 |
+
"model.layers.23.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
|
| 206 |
+
"model.layers.23.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
| 207 |
+
"model.layers.23.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
| 208 |
+
"model.layers.23.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
|
| 209 |
+
"model.layers.23.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
| 210 |
+
"model.layers.23.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
|
| 211 |
+
"model.layers.23.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
| 212 |
+
"model.layers.24.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 213 |
+
"model.layers.24.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
| 214 |
+
"model.layers.24.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
| 215 |
+
"model.layers.24.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
| 216 |
+
"model.layers.24.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 217 |
+
"model.layers.24.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
|
| 218 |
+
"model.layers.24.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
| 219 |
+
"model.layers.24.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
| 220 |
+
"model.layers.24.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
|
| 221 |
+
"model.layers.24.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
| 222 |
+
"model.layers.24.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
|
| 223 |
+
"model.layers.24.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
| 224 |
+
"model.layers.25.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 225 |
+
"model.layers.25.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
| 226 |
+
"model.layers.25.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
| 227 |
+
"model.layers.25.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
| 228 |
+
"model.layers.25.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 229 |
+
"model.layers.25.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
|
| 230 |
+
"model.layers.25.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
| 231 |
+
"model.layers.25.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
| 232 |
+
"model.layers.25.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
|
| 233 |
+
"model.layers.25.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
| 234 |
+
"model.layers.25.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
|
| 235 |
+
"model.layers.25.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
| 236 |
+
"model.layers.26.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 237 |
+
"model.layers.26.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
| 238 |
+
"model.layers.26.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
| 239 |
+
"model.layers.26.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
| 240 |
+
"model.layers.26.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 241 |
+
"model.layers.26.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
|
| 242 |
+
"model.layers.26.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
| 243 |
+
"model.layers.26.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
| 244 |
+
"model.layers.26.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
|
| 245 |
+
"model.layers.26.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
| 246 |
+
"model.layers.26.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
|
| 247 |
+
"model.layers.26.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
| 248 |
+
"model.layers.27.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 249 |
+
"model.layers.27.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
| 250 |
+
"model.layers.27.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
| 251 |
+
"model.layers.27.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
| 252 |
+
"model.layers.27.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 253 |
+
"model.layers.27.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
|
| 254 |
+
"model.layers.27.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
| 255 |
+
"model.layers.27.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
| 256 |
+
"model.layers.27.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
|
| 257 |
+
"model.layers.27.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
| 258 |
+
"model.layers.27.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
|
| 259 |
+
"model.layers.27.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
| 260 |
+
"model.layers.28.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 261 |
+
"model.layers.28.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
| 262 |
+
"model.layers.28.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
| 263 |
+
"model.layers.28.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
| 264 |
+
"model.layers.28.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 265 |
+
"model.layers.28.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
|
| 266 |
+
"model.layers.28.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
| 267 |
+
"model.layers.28.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
| 268 |
+
"model.layers.28.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
|
| 269 |
+
"model.layers.28.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
| 270 |
+
"model.layers.28.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
|
| 271 |
+
"model.layers.28.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
| 272 |
+
"model.layers.29.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 273 |
+
"model.layers.29.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
| 274 |
+
"model.layers.29.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
| 275 |
+
"model.layers.29.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
| 276 |
+
"model.layers.29.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 277 |
+
"model.layers.29.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
|
| 278 |
+
"model.layers.29.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
| 279 |
+
"model.layers.29.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
| 280 |
+
"model.layers.29.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
|
| 281 |
+
"model.layers.29.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
| 282 |
+
"model.layers.29.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
|
| 283 |
+
"model.layers.29.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
| 284 |
+
"model.layers.3.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 285 |
+
"model.layers.3.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 286 |
+
"model.layers.3.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 287 |
+
"model.layers.3.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 288 |
+
"model.layers.3.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 289 |
+
"model.layers.3.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
|
| 290 |
+
"model.layers.3.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 291 |
+
"model.layers.3.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 292 |
+
"model.layers.3.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
|
| 293 |
+
"model.layers.3.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 294 |
+
"model.layers.3.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
|
| 295 |
+
"model.layers.3.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 296 |
+
"model.layers.30.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 297 |
+
"model.layers.30.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
| 298 |
+
"model.layers.30.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
| 299 |
+
"model.layers.30.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
| 300 |
+
"model.layers.30.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 301 |
+
"model.layers.30.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
|
| 302 |
+
"model.layers.30.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
| 303 |
+
"model.layers.30.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
| 304 |
+
"model.layers.30.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
|
| 305 |
+
"model.layers.30.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
| 306 |
+
"model.layers.30.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
|
| 307 |
+
"model.layers.30.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
| 308 |
+
"model.layers.31.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 309 |
+
"model.layers.31.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
| 310 |
+
"model.layers.31.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
| 311 |
+
"model.layers.31.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
| 312 |
+
"model.layers.31.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 313 |
+
"model.layers.31.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
|
| 314 |
+
"model.layers.31.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
| 315 |
+
"model.layers.31.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
| 316 |
+
"model.layers.31.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
|
| 317 |
+
"model.layers.31.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
| 318 |
+
"model.layers.31.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
|
| 319 |
+
"model.layers.31.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
| 320 |
+
"model.layers.32.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 321 |
+
"model.layers.32.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
| 322 |
+
"model.layers.32.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
| 323 |
+
"model.layers.32.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
| 324 |
+
"model.layers.32.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 325 |
+
"model.layers.32.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
|
| 326 |
+
"model.layers.32.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
| 327 |
+
"model.layers.32.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
| 328 |
+
"model.layers.32.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
|
| 329 |
+
"model.layers.32.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
| 330 |
+
"model.layers.32.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
|
| 331 |
+
"model.layers.32.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
| 332 |
+
"model.layers.33.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 333 |
+
"model.layers.33.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
| 334 |
+
"model.layers.33.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
| 335 |
+
"model.layers.33.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
| 336 |
+
"model.layers.33.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 337 |
+
"model.layers.33.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
|
| 338 |
+
"model.layers.33.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
| 339 |
+
"model.layers.33.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
| 340 |
+
"model.layers.33.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
|
| 341 |
+
"model.layers.33.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
| 342 |
+
"model.layers.33.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
|
| 343 |
+
"model.layers.33.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
| 344 |
+
"model.layers.34.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 345 |
+
"model.layers.34.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
| 346 |
+
"model.layers.34.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
| 347 |
+
"model.layers.34.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
| 348 |
+
"model.layers.34.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 349 |
+
"model.layers.34.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
|
| 350 |
+
"model.layers.34.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
| 351 |
+
"model.layers.34.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
| 352 |
+
"model.layers.34.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
|
| 353 |
+
"model.layers.34.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
| 354 |
+
"model.layers.34.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
|
| 355 |
+
"model.layers.34.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
| 356 |
+
"model.layers.35.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 357 |
+
"model.layers.35.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
| 358 |
+
"model.layers.35.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
| 359 |
+
"model.layers.35.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
| 360 |
+
"model.layers.35.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 361 |
+
"model.layers.35.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
|
| 362 |
+
"model.layers.35.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
| 363 |
+
"model.layers.35.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
| 364 |
+
"model.layers.35.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
|
| 365 |
+
"model.layers.35.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
| 366 |
+
"model.layers.35.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
|
| 367 |
+
"model.layers.35.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
| 368 |
+
"model.layers.4.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 369 |
+
"model.layers.4.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 370 |
+
"model.layers.4.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 371 |
+
"model.layers.4.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 372 |
+
"model.layers.4.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 373 |
+
"model.layers.4.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
|
| 374 |
+
"model.layers.4.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 375 |
+
"model.layers.4.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 376 |
+
"model.layers.4.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
|
| 377 |
+
"model.layers.4.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 378 |
+
"model.layers.4.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
|
| 379 |
+
"model.layers.4.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 380 |
+
"model.layers.5.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 381 |
+
"model.layers.5.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 382 |
+
"model.layers.5.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 383 |
+
"model.layers.5.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 384 |
+
"model.layers.5.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 385 |
+
"model.layers.5.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
|
| 386 |
+
"model.layers.5.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 387 |
+
"model.layers.5.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 388 |
+
"model.layers.5.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
|
| 389 |
+
"model.layers.5.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 390 |
+
"model.layers.5.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
|
| 391 |
+
"model.layers.5.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 392 |
+
"model.layers.6.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 393 |
+
"model.layers.6.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 394 |
+
"model.layers.6.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 395 |
+
"model.layers.6.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 396 |
+
"model.layers.6.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 397 |
+
"model.layers.6.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
|
| 398 |
+
"model.layers.6.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 399 |
+
"model.layers.6.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 400 |
+
"model.layers.6.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
|
| 401 |
+
"model.layers.6.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 402 |
+
"model.layers.6.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
|
| 403 |
+
"model.layers.6.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 404 |
+
"model.layers.7.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 405 |
+
"model.layers.7.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 406 |
+
"model.layers.7.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 407 |
+
"model.layers.7.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 408 |
+
"model.layers.7.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 409 |
+
"model.layers.7.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
|
| 410 |
+
"model.layers.7.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 411 |
+
"model.layers.7.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 412 |
+
"model.layers.7.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
|
| 413 |
+
"model.layers.7.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 414 |
+
"model.layers.7.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
|
| 415 |
+
"model.layers.7.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 416 |
+
"model.layers.8.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 417 |
+
"model.layers.8.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 418 |
+
"model.layers.8.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 419 |
+
"model.layers.8.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 420 |
+
"model.layers.8.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 421 |
+
"model.layers.8.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
|
| 422 |
+
"model.layers.8.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 423 |
+
"model.layers.8.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 424 |
+
"model.layers.8.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
|
| 425 |
+
"model.layers.8.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 426 |
+
"model.layers.8.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
|
| 427 |
+
"model.layers.8.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 428 |
+
"model.layers.9.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 429 |
+
"model.layers.9.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 430 |
+
"model.layers.9.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 431 |
+
"model.layers.9.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 432 |
+
"model.layers.9.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 433 |
+
"model.layers.9.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
|
| 434 |
+
"model.layers.9.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 435 |
+
"model.layers.9.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 436 |
+
"model.layers.9.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
|
| 437 |
+
"model.layers.9.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 438 |
+
"model.layers.9.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
|
| 439 |
+
"model.layers.9.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 440 |
+
"model.norm.weight": "model-00002-of-00002.safetensors"
|
| 441 |
+
}
|
| 442 |
+
}
|
qwen2.5_tokenizer/model.safetensors.index.json.bak
ADDED
|
@@ -0,0 +1,442 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"metadata": {
|
| 3 |
+
"total_size": 6800310272
|
| 4 |
+
},
|
| 5 |
+
"weight_map": {
|
| 6 |
+
"lm_head.weight": "model-00002-of-00002.safetensors",
|
| 7 |
+
"model.embed_tokens.weight": "model-00001-of-00002.safetensors",
|
| 8 |
+
"model.layers.0.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 9 |
+
"model.layers.0.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 10 |
+
"model.layers.0.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 11 |
+
"model.layers.0.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 12 |
+
"model.layers.0.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 13 |
+
"model.layers.0.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
|
| 14 |
+
"model.layers.0.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 15 |
+
"model.layers.0.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 16 |
+
"model.layers.0.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
|
| 17 |
+
"model.layers.0.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 18 |
+
"model.layers.0.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
|
| 19 |
+
"model.layers.0.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 20 |
+
"model.layers.1.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 21 |
+
"model.layers.1.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 22 |
+
"model.layers.1.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 23 |
+
"model.layers.1.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 24 |
+
"model.layers.1.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 25 |
+
"model.layers.1.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
|
| 26 |
+
"model.layers.1.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 27 |
+
"model.layers.1.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 28 |
+
"model.layers.1.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
|
| 29 |
+
"model.layers.1.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 30 |
+
"model.layers.1.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
|
| 31 |
+
"model.layers.1.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 32 |
+
"model.layers.10.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 33 |
+
"model.layers.10.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 34 |
+
"model.layers.10.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 35 |
+
"model.layers.10.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 36 |
+
"model.layers.10.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 37 |
+
"model.layers.10.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
|
| 38 |
+
"model.layers.10.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 39 |
+
"model.layers.10.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 40 |
+
"model.layers.10.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
|
| 41 |
+
"model.layers.10.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 42 |
+
"model.layers.10.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
|
| 43 |
+
"model.layers.10.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 44 |
+
"model.layers.11.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 45 |
+
"model.layers.11.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 46 |
+
"model.layers.11.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 47 |
+
"model.layers.11.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 48 |
+
"model.layers.11.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 49 |
+
"model.layers.11.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
|
| 50 |
+
"model.layers.11.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 51 |
+
"model.layers.11.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 52 |
+
"model.layers.11.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
|
| 53 |
+
"model.layers.11.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 54 |
+
"model.layers.11.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
|
| 55 |
+
"model.layers.11.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 56 |
+
"model.layers.12.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 57 |
+
"model.layers.12.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 58 |
+
"model.layers.12.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 59 |
+
"model.layers.12.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 60 |
+
"model.layers.12.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 61 |
+
"model.layers.12.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
|
| 62 |
+
"model.layers.12.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 63 |
+
"model.layers.12.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 64 |
+
"model.layers.12.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
|
| 65 |
+
"model.layers.12.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 66 |
+
"model.layers.12.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
|
| 67 |
+
"model.layers.12.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 68 |
+
"model.layers.13.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 69 |
+
"model.layers.13.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 70 |
+
"model.layers.13.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 71 |
+
"model.layers.13.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 72 |
+
"model.layers.13.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 73 |
+
"model.layers.13.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
|
| 74 |
+
"model.layers.13.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 75 |
+
"model.layers.13.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 76 |
+
"model.layers.13.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
|
| 77 |
+
"model.layers.13.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 78 |
+
"model.layers.13.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
|
| 79 |
+
"model.layers.13.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 80 |
+
"model.layers.14.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 81 |
+
"model.layers.14.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 82 |
+
"model.layers.14.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 83 |
+
"model.layers.14.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 84 |
+
"model.layers.14.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 85 |
+
"model.layers.14.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
|
| 86 |
+
"model.layers.14.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 87 |
+
"model.layers.14.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 88 |
+
"model.layers.14.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
|
| 89 |
+
"model.layers.14.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 90 |
+
"model.layers.14.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
|
| 91 |
+
"model.layers.14.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 92 |
+
"model.layers.15.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 93 |
+
"model.layers.15.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 94 |
+
"model.layers.15.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 95 |
+
"model.layers.15.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 96 |
+
"model.layers.15.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 97 |
+
"model.layers.15.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
|
| 98 |
+
"model.layers.15.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 99 |
+
"model.layers.15.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 100 |
+
"model.layers.15.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
|
| 101 |
+
"model.layers.15.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 102 |
+
"model.layers.15.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
|
| 103 |
+
"model.layers.15.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 104 |
+
"model.layers.16.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 105 |
+
"model.layers.16.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 106 |
+
"model.layers.16.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 107 |
+
"model.layers.16.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 108 |
+
"model.layers.16.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 109 |
+
"model.layers.16.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
|
| 110 |
+
"model.layers.16.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 111 |
+
"model.layers.16.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 112 |
+
"model.layers.16.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
|
| 113 |
+
"model.layers.16.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 114 |
+
"model.layers.16.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
|
| 115 |
+
"model.layers.16.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 116 |
+
"model.layers.17.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 117 |
+
"model.layers.17.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 118 |
+
"model.layers.17.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 119 |
+
"model.layers.17.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 120 |
+
"model.layers.17.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 121 |
+
"model.layers.17.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
|
| 122 |
+
"model.layers.17.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 123 |
+
"model.layers.17.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 124 |
+
"model.layers.17.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
|
| 125 |
+
"model.layers.17.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 126 |
+
"model.layers.17.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
|
| 127 |
+
"model.layers.17.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 128 |
+
"model.layers.18.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 129 |
+
"model.layers.18.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 130 |
+
"model.layers.18.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 131 |
+
"model.layers.18.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 132 |
+
"model.layers.18.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 133 |
+
"model.layers.18.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
|
| 134 |
+
"model.layers.18.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 135 |
+
"model.layers.18.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 136 |
+
"model.layers.18.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
|
| 137 |
+
"model.layers.18.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 138 |
+
"model.layers.18.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
|
| 139 |
+
"model.layers.18.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 140 |
+
"model.layers.19.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 141 |
+
"model.layers.19.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 142 |
+
"model.layers.19.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 143 |
+
"model.layers.19.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 144 |
+
"model.layers.19.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 145 |
+
"model.layers.19.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
|
| 146 |
+
"model.layers.19.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 147 |
+
"model.layers.19.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 148 |
+
"model.layers.19.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
|
| 149 |
+
"model.layers.19.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 150 |
+
"model.layers.19.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
|
| 151 |
+
"model.layers.19.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 152 |
+
"model.layers.2.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 153 |
+
"model.layers.2.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 154 |
+
"model.layers.2.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 155 |
+
"model.layers.2.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 156 |
+
"model.layers.2.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 157 |
+
"model.layers.2.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
|
| 158 |
+
"model.layers.2.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 159 |
+
"model.layers.2.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 160 |
+
"model.layers.2.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
|
| 161 |
+
"model.layers.2.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 162 |
+
"model.layers.2.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
|
| 163 |
+
"model.layers.2.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 164 |
+
"model.layers.20.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 165 |
+
"model.layers.20.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 166 |
+
"model.layers.20.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 167 |
+
"model.layers.20.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 168 |
+
"model.layers.20.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 169 |
+
"model.layers.20.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
|
| 170 |
+
"model.layers.20.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 171 |
+
"model.layers.20.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 172 |
+
"model.layers.20.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
|
| 173 |
+
"model.layers.20.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 174 |
+
"model.layers.20.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
|
| 175 |
+
"model.layers.20.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 176 |
+
"model.layers.21.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 177 |
+
"model.layers.21.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 178 |
+
"model.layers.21.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 179 |
+
"model.layers.21.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 180 |
+
"model.layers.21.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 181 |
+
"model.layers.21.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
|
| 182 |
+
"model.layers.21.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 183 |
+
"model.layers.21.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 184 |
+
"model.layers.21.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
|
| 185 |
+
"model.layers.21.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 186 |
+
"model.layers.21.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
|
| 187 |
+
"model.layers.21.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 188 |
+
"model.layers.22.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 189 |
+
"model.layers.22.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
| 190 |
+
"model.layers.22.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 191 |
+
"model.layers.22.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 192 |
+
"model.layers.22.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 193 |
+
"model.layers.22.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
|
| 194 |
+
"model.layers.22.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 195 |
+
"model.layers.22.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 196 |
+
"model.layers.22.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
|
| 197 |
+
"model.layers.22.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 198 |
+
"model.layers.22.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
|
| 199 |
+
"model.layers.22.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 200 |
+
"model.layers.23.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 201 |
+
"model.layers.23.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
| 202 |
+
"model.layers.23.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
| 203 |
+
"model.layers.23.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
| 204 |
+
"model.layers.23.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 205 |
+
"model.layers.23.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
|
| 206 |
+
"model.layers.23.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
| 207 |
+
"model.layers.23.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
| 208 |
+
"model.layers.23.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
|
| 209 |
+
"model.layers.23.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
| 210 |
+
"model.layers.23.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
|
| 211 |
+
"model.layers.23.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
| 212 |
+
"model.layers.24.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 213 |
+
"model.layers.24.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
| 214 |
+
"model.layers.24.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
| 215 |
+
"model.layers.24.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
| 216 |
+
"model.layers.24.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 217 |
+
"model.layers.24.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
|
| 218 |
+
"model.layers.24.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
| 219 |
+
"model.layers.24.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
| 220 |
+
"model.layers.24.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
|
| 221 |
+
"model.layers.24.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
| 222 |
+
"model.layers.24.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
|
| 223 |
+
"model.layers.24.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
| 224 |
+
"model.layers.25.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 225 |
+
"model.layers.25.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
| 226 |
+
"model.layers.25.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
| 227 |
+
"model.layers.25.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
| 228 |
+
"model.layers.25.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 229 |
+
"model.layers.25.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
|
| 230 |
+
"model.layers.25.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
| 231 |
+
"model.layers.25.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
| 232 |
+
"model.layers.25.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
|
| 233 |
+
"model.layers.25.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
| 234 |
+
"model.layers.25.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
|
| 235 |
+
"model.layers.25.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
| 236 |
+
"model.layers.26.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 237 |
+
"model.layers.26.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
| 238 |
+
"model.layers.26.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
| 239 |
+
"model.layers.26.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
| 240 |
+
"model.layers.26.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 241 |
+
"model.layers.26.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
|
| 242 |
+
"model.layers.26.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
| 243 |
+
"model.layers.26.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
| 244 |
+
"model.layers.26.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
|
| 245 |
+
"model.layers.26.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
| 246 |
+
"model.layers.26.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
|
| 247 |
+
"model.layers.26.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
| 248 |
+
"model.layers.27.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 249 |
+
"model.layers.27.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
| 250 |
+
"model.layers.27.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
| 251 |
+
"model.layers.27.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
| 252 |
+
"model.layers.27.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 253 |
+
"model.layers.27.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
|
| 254 |
+
"model.layers.27.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
| 255 |
+
"model.layers.27.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
| 256 |
+
"model.layers.27.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
|
| 257 |
+
"model.layers.27.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
| 258 |
+
"model.layers.27.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
|
| 259 |
+
"model.layers.27.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
| 260 |
+
"model.layers.28.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 261 |
+
"model.layers.28.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
| 262 |
+
"model.layers.28.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
| 263 |
+
"model.layers.28.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
| 264 |
+
"model.layers.28.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 265 |
+
"model.layers.28.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
|
| 266 |
+
"model.layers.28.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
| 267 |
+
"model.layers.28.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
| 268 |
+
"model.layers.28.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
|
| 269 |
+
"model.layers.28.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
| 270 |
+
"model.layers.28.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
|
| 271 |
+
"model.layers.28.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
| 272 |
+
"model.layers.29.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 273 |
+
"model.layers.29.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
| 274 |
+
"model.layers.29.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
| 275 |
+
"model.layers.29.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
| 276 |
+
"model.layers.29.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 277 |
+
"model.layers.29.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
|
| 278 |
+
"model.layers.29.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
| 279 |
+
"model.layers.29.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
| 280 |
+
"model.layers.29.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
|
| 281 |
+
"model.layers.29.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
| 282 |
+
"model.layers.29.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
|
| 283 |
+
"model.layers.29.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
| 284 |
+
"model.layers.3.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 285 |
+
"model.layers.3.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 286 |
+
"model.layers.3.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 287 |
+
"model.layers.3.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 288 |
+
"model.layers.3.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 289 |
+
"model.layers.3.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
|
| 290 |
+
"model.layers.3.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 291 |
+
"model.layers.3.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 292 |
+
"model.layers.3.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
|
| 293 |
+
"model.layers.3.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 294 |
+
"model.layers.3.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
|
| 295 |
+
"model.layers.3.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 296 |
+
"model.layers.30.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 297 |
+
"model.layers.30.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
| 298 |
+
"model.layers.30.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
| 299 |
+
"model.layers.30.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
| 300 |
+
"model.layers.30.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 301 |
+
"model.layers.30.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
|
| 302 |
+
"model.layers.30.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
| 303 |
+
"model.layers.30.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
| 304 |
+
"model.layers.30.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
|
| 305 |
+
"model.layers.30.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
| 306 |
+
"model.layers.30.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
|
| 307 |
+
"model.layers.30.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
| 308 |
+
"model.layers.31.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 309 |
+
"model.layers.31.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
| 310 |
+
"model.layers.31.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
| 311 |
+
"model.layers.31.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
| 312 |
+
"model.layers.31.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 313 |
+
"model.layers.31.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
|
| 314 |
+
"model.layers.31.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
| 315 |
+
"model.layers.31.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
| 316 |
+
"model.layers.31.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
|
| 317 |
+
"model.layers.31.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
| 318 |
+
"model.layers.31.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
|
| 319 |
+
"model.layers.31.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
| 320 |
+
"model.layers.32.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 321 |
+
"model.layers.32.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
| 322 |
+
"model.layers.32.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
| 323 |
+
"model.layers.32.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
| 324 |
+
"model.layers.32.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 325 |
+
"model.layers.32.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
|
| 326 |
+
"model.layers.32.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
| 327 |
+
"model.layers.32.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
| 328 |
+
"model.layers.32.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
|
| 329 |
+
"model.layers.32.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
| 330 |
+
"model.layers.32.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
|
| 331 |
+
"model.layers.32.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
| 332 |
+
"model.layers.33.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 333 |
+
"model.layers.33.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
| 334 |
+
"model.layers.33.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
| 335 |
+
"model.layers.33.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
| 336 |
+
"model.layers.33.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 337 |
+
"model.layers.33.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
|
| 338 |
+
"model.layers.33.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
| 339 |
+
"model.layers.33.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
| 340 |
+
"model.layers.33.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
|
| 341 |
+
"model.layers.33.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
| 342 |
+
"model.layers.33.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
|
| 343 |
+
"model.layers.33.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
| 344 |
+
"model.layers.34.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 345 |
+
"model.layers.34.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
| 346 |
+
"model.layers.34.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
| 347 |
+
"model.layers.34.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
| 348 |
+
"model.layers.34.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 349 |
+
"model.layers.34.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
|
| 350 |
+
"model.layers.34.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
| 351 |
+
"model.layers.34.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
| 352 |
+
"model.layers.34.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
|
| 353 |
+
"model.layers.34.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
| 354 |
+
"model.layers.34.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
|
| 355 |
+
"model.layers.34.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
| 356 |
+
"model.layers.35.input_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 357 |
+
"model.layers.35.mlp.down_proj.weight": "model-00002-of-00002.safetensors",
|
| 358 |
+
"model.layers.35.mlp.gate_proj.weight": "model-00002-of-00002.safetensors",
|
| 359 |
+
"model.layers.35.mlp.up_proj.weight": "model-00002-of-00002.safetensors",
|
| 360 |
+
"model.layers.35.post_attention_layernorm.weight": "model-00002-of-00002.safetensors",
|
| 361 |
+
"model.layers.35.self_attn.k_proj.bias": "model-00002-of-00002.safetensors",
|
| 362 |
+
"model.layers.35.self_attn.k_proj.weight": "model-00002-of-00002.safetensors",
|
| 363 |
+
"model.layers.35.self_attn.o_proj.weight": "model-00002-of-00002.safetensors",
|
| 364 |
+
"model.layers.35.self_attn.q_proj.bias": "model-00002-of-00002.safetensors",
|
| 365 |
+
"model.layers.35.self_attn.q_proj.weight": "model-00002-of-00002.safetensors",
|
| 366 |
+
"model.layers.35.self_attn.v_proj.bias": "model-00002-of-00002.safetensors",
|
| 367 |
+
"model.layers.35.self_attn.v_proj.weight": "model-00002-of-00002.safetensors",
|
| 368 |
+
"model.layers.4.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 369 |
+
"model.layers.4.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 370 |
+
"model.layers.4.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 371 |
+
"model.layers.4.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 372 |
+
"model.layers.4.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 373 |
+
"model.layers.4.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
|
| 374 |
+
"model.layers.4.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 375 |
+
"model.layers.4.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 376 |
+
"model.layers.4.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
|
| 377 |
+
"model.layers.4.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 378 |
+
"model.layers.4.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
|
| 379 |
+
"model.layers.4.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 380 |
+
"model.layers.5.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 381 |
+
"model.layers.5.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 382 |
+
"model.layers.5.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 383 |
+
"model.layers.5.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 384 |
+
"model.layers.5.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 385 |
+
"model.layers.5.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
|
| 386 |
+
"model.layers.5.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 387 |
+
"model.layers.5.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 388 |
+
"model.layers.5.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
|
| 389 |
+
"model.layers.5.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 390 |
+
"model.layers.5.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
|
| 391 |
+
"model.layers.5.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 392 |
+
"model.layers.6.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 393 |
+
"model.layers.6.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 394 |
+
"model.layers.6.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 395 |
+
"model.layers.6.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 396 |
+
"model.layers.6.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 397 |
+
"model.layers.6.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
|
| 398 |
+
"model.layers.6.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 399 |
+
"model.layers.6.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 400 |
+
"model.layers.6.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
|
| 401 |
+
"model.layers.6.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 402 |
+
"model.layers.6.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
|
| 403 |
+
"model.layers.6.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 404 |
+
"model.layers.7.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 405 |
+
"model.layers.7.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 406 |
+
"model.layers.7.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 407 |
+
"model.layers.7.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 408 |
+
"model.layers.7.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 409 |
+
"model.layers.7.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
|
| 410 |
+
"model.layers.7.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 411 |
+
"model.layers.7.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 412 |
+
"model.layers.7.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
|
| 413 |
+
"model.layers.7.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 414 |
+
"model.layers.7.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
|
| 415 |
+
"model.layers.7.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 416 |
+
"model.layers.8.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 417 |
+
"model.layers.8.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 418 |
+
"model.layers.8.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 419 |
+
"model.layers.8.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 420 |
+
"model.layers.8.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 421 |
+
"model.layers.8.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
|
| 422 |
+
"model.layers.8.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 423 |
+
"model.layers.8.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 424 |
+
"model.layers.8.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
|
| 425 |
+
"model.layers.8.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 426 |
+
"model.layers.8.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
|
| 427 |
+
"model.layers.8.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 428 |
+
"model.layers.9.input_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 429 |
+
"model.layers.9.mlp.down_proj.weight": "model-00001-of-00002.safetensors",
|
| 430 |
+
"model.layers.9.mlp.gate_proj.weight": "model-00001-of-00002.safetensors",
|
| 431 |
+
"model.layers.9.mlp.up_proj.weight": "model-00001-of-00002.safetensors",
|
| 432 |
+
"model.layers.9.post_attention_layernorm.weight": "model-00001-of-00002.safetensors",
|
| 433 |
+
"model.layers.9.self_attn.k_proj.bias": "model-00001-of-00002.safetensors",
|
| 434 |
+
"model.layers.9.self_attn.k_proj.weight": "model-00001-of-00002.safetensors",
|
| 435 |
+
"model.layers.9.self_attn.o_proj.weight": "model-00001-of-00002.safetensors",
|
| 436 |
+
"model.layers.9.self_attn.q_proj.bias": "model-00001-of-00002.safetensors",
|
| 437 |
+
"model.layers.9.self_attn.q_proj.weight": "model-00001-of-00002.safetensors",
|
| 438 |
+
"model.layers.9.self_attn.v_proj.bias": "model-00001-of-00002.safetensors",
|
| 439 |
+
"model.layers.9.self_attn.v_proj.weight": "model-00001-of-00002.safetensors",
|
| 440 |
+
"model.norm.weight": "model-00002-of-00002.safetensors"
|
| 441 |
+
}
|
| 442 |
+
}
|
qwen2.5_tokenizer/modeling_qwen2.py
ADDED
|
@@ -0,0 +1,1738 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# coding=utf-8
|
| 2 |
+
# Copyright 2024 The Qwen team, Alibaba Group and the HuggingFace Inc. team. All rights reserved.
|
| 3 |
+
#
|
| 4 |
+
# This code is based on EleutherAI's GPT-NeoX library and the GPT-NeoX
|
| 5 |
+
# and OPT implementations in this library. It has been modified from its
|
| 6 |
+
# original forms to accommodate minor architectural differences compared
|
| 7 |
+
# to GPT-NeoX and OPT used by the Meta AI team that trained the model.
|
| 8 |
+
#
|
| 9 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
| 10 |
+
# you may not use this file except in compliance with the License.
|
| 11 |
+
# You may obtain a copy of the License at
|
| 12 |
+
#
|
| 13 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
| 14 |
+
#
|
| 15 |
+
# Unless required by applicable law or agreed to in writing, software
|
| 16 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
| 17 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 18 |
+
# See the License for the specific language governing permissions and
|
| 19 |
+
# limitations under the License.
|
| 20 |
+
""" PyTorch Qwen2 model."""
|
| 21 |
+
import inspect
|
| 22 |
+
import math
|
| 23 |
+
import copy
|
| 24 |
+
import warnings
|
| 25 |
+
from functools import partial
|
| 26 |
+
from typing import List, Optional, Tuple, Union
|
| 27 |
+
|
| 28 |
+
import torch
|
| 29 |
+
import torch.nn.functional as F
|
| 30 |
+
import torch.utils.checkpoint
|
| 31 |
+
from torch import nn
|
| 32 |
+
from torch.nn import BCEWithLogitsLoss, CrossEntropyLoss, MSELoss
|
| 33 |
+
|
| 34 |
+
from transformers.activations import ACT2FN
|
| 35 |
+
from transformers.cache_utils import Cache, DynamicCache
|
| 36 |
+
from transformers.modeling_attn_mask_utils import _prepare_4d_causal_attention_mask, _prepare_4d_causal_attention_mask_for_sdpa
|
| 37 |
+
from transformers.modeling_outputs import BaseModelOutputWithPast, CausalLMOutputWithPast, SequenceClassifierOutputWithPast
|
| 38 |
+
from transformers.modeling_utils import PreTrainedModel
|
| 39 |
+
from transformers.utils import (
|
| 40 |
+
add_start_docstrings,
|
| 41 |
+
add_start_docstrings_to_model_forward,
|
| 42 |
+
is_flash_attn_2_available,
|
| 43 |
+
is_flash_attn_greater_or_equal_2_10,
|
| 44 |
+
logging,
|
| 45 |
+
replace_return_docstrings,
|
| 46 |
+
)
|
| 47 |
+
from .configuration_qwen2 import Qwen2Config
|
| 48 |
+
|
| 49 |
+
if is_flash_attn_2_available():
|
| 50 |
+
from flash_attn import flash_attn_func, flash_attn_varlen_func
|
| 51 |
+
from flash_attn.bert_padding import index_first_axis, pad_input, unpad_input # noqa
|
| 52 |
+
|
| 53 |
+
_flash_supports_window_size = "window_size" in list(inspect.signature(flash_attn_func).parameters)
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
logger = logging.get_logger(__name__)
|
| 57 |
+
|
| 58 |
+
# Magi Attention Supported
|
| 59 |
+
_MAGI_AVAILABLE = False
|
| 60 |
+
try:
|
| 61 |
+
from magi_attention.functional.flex_flash_attn import flex_flash_attn_func
|
| 62 |
+
_MAGI_AVAILABLE = True
|
| 63 |
+
except ImportError:
|
| 64 |
+
flex_flash_attn_func = None
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
_CHECKPOINT_FOR_DOC = "Qwen/Qwen2-7B-beta"
|
| 68 |
+
_CONFIG_FOR_DOC = "Qwen2Config"
|
| 69 |
+
|
| 70 |
+
QWEN2_PRETRAINED_MODEL_ARCHIVE_LIST = [
|
| 71 |
+
"Qwen/Qwen2-7B-beta",
|
| 72 |
+
# See all Qwen2 models at https://huggingface.co/models?filter=qwen2
|
| 73 |
+
]
|
| 74 |
+
|
| 75 |
+
from .mask_sdpa_utils import (
|
| 76 |
+
find_prefix_seq_length_by_pe,
|
| 77 |
+
update_causal_mask_with_pad_non_visible_2d,
|
| 78 |
+
update_causal_mask_for_one_gen_window_2d,
|
| 79 |
+
create_block_diff_mask_by_pe_4d,
|
| 80 |
+
find_pred_pos_from_input_ids
|
| 81 |
+
)
|
| 82 |
+
|
| 83 |
+
from .mask_magi_utils import build_magi_ranges
|
| 84 |
+
|
| 85 |
+
# Copied from transformers.models.llama.modeling_llama._get_unpad_data
|
| 86 |
+
def _get_unpad_data(attention_mask):
|
| 87 |
+
seqlens_in_batch = attention_mask.sum(dim=-1, dtype=torch.int32)
|
| 88 |
+
indices = torch.nonzero(attention_mask.flatten(), as_tuple=False).flatten()
|
| 89 |
+
max_seqlen_in_batch = seqlens_in_batch.max().item()
|
| 90 |
+
cu_seqlens = F.pad(torch.cumsum(seqlens_in_batch, dim=0, dtype=torch.torch.int32), (1, 0))
|
| 91 |
+
return (
|
| 92 |
+
indices,
|
| 93 |
+
cu_seqlens,
|
| 94 |
+
max_seqlen_in_batch,
|
| 95 |
+
)
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
# Copied from transformers.models.llama.modeling_llama.LlamaRMSNorm with Llama->Qwen2
|
| 99 |
+
class Qwen2RMSNorm(nn.Module):
|
| 100 |
+
def __init__(self, hidden_size, eps=1e-6):
|
| 101 |
+
"""
|
| 102 |
+
Qwen2RMSNorm is equivalent to T5LayerNorm
|
| 103 |
+
"""
|
| 104 |
+
super().__init__()
|
| 105 |
+
self.weight = nn.Parameter(torch.ones(hidden_size))
|
| 106 |
+
self.variance_epsilon = eps
|
| 107 |
+
|
| 108 |
+
def forward(self, hidden_states):
|
| 109 |
+
input_dtype = hidden_states.dtype
|
| 110 |
+
hidden_states = hidden_states.to(torch.float32)
|
| 111 |
+
variance = hidden_states.pow(2).mean(-1, keepdim=True)
|
| 112 |
+
hidden_states = hidden_states * torch.rsqrt(variance + self.variance_epsilon)
|
| 113 |
+
return self.weight * hidden_states.to(input_dtype)
|
| 114 |
+
|
| 115 |
+
|
| 116 |
+
# Copied from transformers.models.llama.modeling_llama.LlamaRotaryEmbedding with Llama->Qwen2
|
| 117 |
+
class Qwen2RotaryEmbedding(nn.Module):
|
| 118 |
+
def __init__(self, dim, max_position_embeddings=2048, base=10000, device=None):
|
| 119 |
+
super().__init__()
|
| 120 |
+
|
| 121 |
+
self.dim = dim
|
| 122 |
+
self.max_position_embeddings = max_position_embeddings
|
| 123 |
+
self.base = base
|
| 124 |
+
inv_freq = 1.0 / (self.base ** (torch.arange(0, self.dim, 2).float().to(device) / self.dim))
|
| 125 |
+
self.register_buffer("inv_freq", inv_freq, persistent=False)
|
| 126 |
+
|
| 127 |
+
# Build here to make `torch.jit.trace` work.
|
| 128 |
+
self._set_cos_sin_cache(
|
| 129 |
+
seq_len=max_position_embeddings, device=self.inv_freq.device, dtype=torch.get_default_dtype()
|
| 130 |
+
)
|
| 131 |
+
|
| 132 |
+
def _set_cos_sin_cache(self, seq_len, device, dtype):
|
| 133 |
+
self.max_seq_len_cached = seq_len
|
| 134 |
+
t = torch.arange(self.max_seq_len_cached, device=device, dtype=self.inv_freq.dtype)
|
| 135 |
+
|
| 136 |
+
freqs = torch.outer(t, self.inv_freq)
|
| 137 |
+
# Different from paper, but it uses a different permutation in order to obtain the same calculation
|
| 138 |
+
emb = torch.cat((freqs, freqs), dim=-1)
|
| 139 |
+
self.register_buffer("cos_cached", emb.cos().to(dtype), persistent=False)
|
| 140 |
+
self.register_buffer("sin_cached", emb.sin().to(dtype), persistent=False)
|
| 141 |
+
|
| 142 |
+
def forward(self, x, seq_len=None):
|
| 143 |
+
# x: [bs, num_attention_heads, seq_len, head_size]
|
| 144 |
+
if seq_len > self.max_seq_len_cached:
|
| 145 |
+
self._set_cos_sin_cache(seq_len=seq_len, device=x.device, dtype=x.dtype)
|
| 146 |
+
|
| 147 |
+
return (
|
| 148 |
+
self.cos_cached[:seq_len].to(dtype=x.dtype),
|
| 149 |
+
self.sin_cached[:seq_len].to(dtype=x.dtype),
|
| 150 |
+
)
|
| 151 |
+
|
| 152 |
+
|
| 153 |
+
# Copied from transformers.models.llama.modeling_llama.rotate_half
|
| 154 |
+
def rotate_half(x):
|
| 155 |
+
"""Rotates half the hidden dims of the input."""
|
| 156 |
+
x1 = x[..., : x.shape[-1] // 2]
|
| 157 |
+
x2 = x[..., x.shape[-1] // 2 :]
|
| 158 |
+
return torch.cat((-x2, x1), dim=-1)
|
| 159 |
+
|
| 160 |
+
|
| 161 |
+
# Copied from transformers.models.llama.modeling_llama.apply_rotary_pos_emb
|
| 162 |
+
def apply_rotary_pos_emb(q, k, cos, sin, position_ids, unsqueeze_dim=1):
|
| 163 |
+
"""Applies Rotary Position Embedding to the query and key tensors.
|
| 164 |
+
|
| 165 |
+
Args:
|
| 166 |
+
q (`torch.Tensor`): The query tensor.
|
| 167 |
+
k (`torch.Tensor`): The key tensor.
|
| 168 |
+
cos (`torch.Tensor`): The cosine part of the rotary embedding.
|
| 169 |
+
sin (`torch.Tensor`): The sine part of the rotary embedding.
|
| 170 |
+
position_ids (`torch.Tensor`):
|
| 171 |
+
The position indices of the tokens corresponding to the query and key tensors. For example, this can be
|
| 172 |
+
used to pass offsetted position ids when working with a KV-cache.
|
| 173 |
+
unsqueeze_dim (`int`, *optional*, defaults to 1):
|
| 174 |
+
The 'unsqueeze_dim' argument specifies the dimension along which to unsqueeze cos[position_ids] and
|
| 175 |
+
sin[position_ids] so that they can be properly broadcasted to the dimensions of q and k. For example, note
|
| 176 |
+
that cos[position_ids] and sin[position_ids] have the shape [batch_size, seq_len, head_dim]. Then, if q and
|
| 177 |
+
k have the shape [batch_size, heads, seq_len, head_dim], then setting unsqueeze_dim=1 makes
|
| 178 |
+
cos[position_ids] and sin[position_ids] broadcastable to the shapes of q and k. Similarly, if q and k have
|
| 179 |
+
the shape [batch_size, seq_len, heads, head_dim], then set unsqueeze_dim=2.
|
| 180 |
+
Returns:
|
| 181 |
+
`tuple(torch.Tensor)` comprising of the query and key tensors rotated using the Rotary Position Embedding.
|
| 182 |
+
"""
|
| 183 |
+
cos = cos[position_ids].unsqueeze(unsqueeze_dim)
|
| 184 |
+
sin = sin[position_ids].unsqueeze(unsqueeze_dim)
|
| 185 |
+
q_embed = (q * cos) + (rotate_half(q) * sin)
|
| 186 |
+
k_embed = (k * cos) + (rotate_half(k) * sin)
|
| 187 |
+
return q_embed, k_embed
|
| 188 |
+
|
| 189 |
+
|
| 190 |
+
# Copied from transformers.models.mistral.modeling_mistral.MistralMLP with Mistral->Qwen2
|
| 191 |
+
class Qwen2MLP(nn.Module):
|
| 192 |
+
def __init__(self, config):
|
| 193 |
+
super().__init__()
|
| 194 |
+
self.config = config
|
| 195 |
+
self.hidden_size = config.hidden_size
|
| 196 |
+
self.intermediate_size = config.intermediate_size
|
| 197 |
+
self.gate_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=False)
|
| 198 |
+
self.up_proj = nn.Linear(self.hidden_size, self.intermediate_size, bias=False)
|
| 199 |
+
self.down_proj = nn.Linear(self.intermediate_size, self.hidden_size, bias=False)
|
| 200 |
+
self.act_fn = ACT2FN[config.hidden_act]
|
| 201 |
+
|
| 202 |
+
def forward(self, x):
|
| 203 |
+
return self.down_proj(self.act_fn(self.gate_proj(x)) * self.up_proj(x))
|
| 204 |
+
|
| 205 |
+
|
| 206 |
+
# Copied from transformers.models.llama.modeling_llama.repeat_kv
|
| 207 |
+
def repeat_kv(hidden_states: torch.Tensor, n_rep: int) -> torch.Tensor:
|
| 208 |
+
"""
|
| 209 |
+
This is the equivalent of torch.repeat_interleave(x, dim=1, repeats=n_rep). The hidden states go from (batch,
|
| 210 |
+
num_key_value_heads, seqlen, head_dim) to (batch, num_attention_heads, seqlen, head_dim)
|
| 211 |
+
"""
|
| 212 |
+
batch, num_key_value_heads, slen, head_dim = hidden_states.shape
|
| 213 |
+
if n_rep == 1:
|
| 214 |
+
return hidden_states
|
| 215 |
+
hidden_states = hidden_states[:, :, None, :, :].expand(batch, num_key_value_heads, n_rep, slen, head_dim)
|
| 216 |
+
return hidden_states.reshape(batch, num_key_value_heads * n_rep, slen, head_dim)
|
| 217 |
+
|
| 218 |
+
|
| 219 |
+
class Qwen2Attention(nn.Module):
|
| 220 |
+
"""
|
| 221 |
+
Multi-headed attention from 'Attention Is All You Need' paper. Modified to use sliding window attention: Longformer
|
| 222 |
+
and "Generating Long Sequences with Sparse Transformers".
|
| 223 |
+
"""
|
| 224 |
+
|
| 225 |
+
def __init__(self, config: Qwen2Config, layer_idx: Optional[int] = None):
|
| 226 |
+
super().__init__()
|
| 227 |
+
self.config = config
|
| 228 |
+
self.layer_idx = layer_idx
|
| 229 |
+
if layer_idx is None:
|
| 230 |
+
logger.warning_once(
|
| 231 |
+
f"Instantiating {self.__class__.__name__} without passing `layer_idx` is not recommended and will "
|
| 232 |
+
"to errors during the forward call, if caching is used. Please make sure to provide a `layer_idx` "
|
| 233 |
+
"when creating this class."
|
| 234 |
+
)
|
| 235 |
+
|
| 236 |
+
self.hidden_size = config.hidden_size
|
| 237 |
+
self.num_heads = config.num_attention_heads
|
| 238 |
+
self.head_dim = self.hidden_size // self.num_heads
|
| 239 |
+
self.num_key_value_heads = config.num_key_value_heads
|
| 240 |
+
self.num_key_value_groups = self.num_heads // self.num_key_value_heads
|
| 241 |
+
self.max_position_embeddings = config.max_position_embeddings
|
| 242 |
+
self.rope_theta = config.rope_theta
|
| 243 |
+
self.is_causal = True
|
| 244 |
+
self.attention_dropout = config.attention_dropout
|
| 245 |
+
|
| 246 |
+
if (self.head_dim * self.num_heads) != self.hidden_size:
|
| 247 |
+
raise ValueError(
|
| 248 |
+
f"hidden_size must be divisible by num_heads (got `hidden_size`: {self.hidden_size}"
|
| 249 |
+
f" and `num_heads`: {self.num_heads})."
|
| 250 |
+
)
|
| 251 |
+
self.q_proj = nn.Linear(self.hidden_size, self.num_heads * self.head_dim, bias=True)
|
| 252 |
+
self.k_proj = nn.Linear(self.hidden_size, self.num_key_value_heads * self.head_dim, bias=True)
|
| 253 |
+
self.v_proj = nn.Linear(self.hidden_size, self.num_key_value_heads * self.head_dim, bias=True)
|
| 254 |
+
self.o_proj = nn.Linear(self.num_heads * self.head_dim, self.hidden_size, bias=False)
|
| 255 |
+
|
| 256 |
+
self.rotary_emb = Qwen2RotaryEmbedding(
|
| 257 |
+
self.head_dim,
|
| 258 |
+
max_position_embeddings=self.max_position_embeddings,
|
| 259 |
+
base=self.rope_theta,
|
| 260 |
+
)
|
| 261 |
+
|
| 262 |
+
def forward(
|
| 263 |
+
self,
|
| 264 |
+
hidden_states: torch.Tensor,
|
| 265 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 266 |
+
position_ids: Optional[torch.LongTensor] = None,
|
| 267 |
+
past_key_value: Optional[Cache] = None,
|
| 268 |
+
output_attentions: bool = False,
|
| 269 |
+
use_cache: bool = False,
|
| 270 |
+
**kwargs,
|
| 271 |
+
) -> Tuple[torch.Tensor, Optional[torch.Tensor], Optional[Tuple[torch.Tensor]]]:
|
| 272 |
+
if "padding_mask" in kwargs:
|
| 273 |
+
warnings.warn(
|
| 274 |
+
"Passing `padding_mask` is deprecated and will be removed in v4.37. Please make sure use `attention_mask` instead.`"
|
| 275 |
+
)
|
| 276 |
+
bsz, q_len, _ = hidden_states.size()
|
| 277 |
+
|
| 278 |
+
query_states = self.q_proj(hidden_states)
|
| 279 |
+
key_states = self.k_proj(hidden_states)
|
| 280 |
+
value_states = self.v_proj(hidden_states)
|
| 281 |
+
|
| 282 |
+
query_states = query_states.view(bsz, q_len, self.num_heads, self.head_dim).transpose(1, 2)
|
| 283 |
+
key_states = key_states.view(bsz, q_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
|
| 284 |
+
value_states = value_states.view(bsz, q_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
|
| 285 |
+
|
| 286 |
+
kv_seq_len = key_states.shape[-2]
|
| 287 |
+
if past_key_value is not None:
|
| 288 |
+
if self.layer_idx is None:
|
| 289 |
+
raise ValueError(
|
| 290 |
+
f"The cache structure has changed since version v4.36. If you are using {self.__class__.__name__} "
|
| 291 |
+
"for auto-regressive decoding with k/v caching, please make sure to initialize the attention class "
|
| 292 |
+
"with a layer index."
|
| 293 |
+
)
|
| 294 |
+
kv_seq_len += past_key_value.get_seq_length(self.layer_idx)
|
| 295 |
+
cos, sin = self.rotary_emb(value_states, seq_len=kv_seq_len)
|
| 296 |
+
query_states, key_states = apply_rotary_pos_emb(query_states, key_states, cos, sin, position_ids)
|
| 297 |
+
|
| 298 |
+
if past_key_value is not None:
|
| 299 |
+
cache_kwargs = {"sin": sin, "cos": cos} # Specific to RoPE models
|
| 300 |
+
key_states, value_states = past_key_value.update(key_states, value_states, self.layer_idx, cache_kwargs)
|
| 301 |
+
|
| 302 |
+
# repeat k/v heads if n_kv_heads < n_heads
|
| 303 |
+
key_states = repeat_kv(key_states, self.num_key_value_groups)
|
| 304 |
+
value_states = repeat_kv(value_states, self.num_key_value_groups)
|
| 305 |
+
|
| 306 |
+
attn_weights = torch.matmul(query_states, key_states.transpose(2, 3)) / math.sqrt(self.head_dim)
|
| 307 |
+
|
| 308 |
+
if attn_weights.size() != (bsz, self.num_heads, q_len, kv_seq_len):
|
| 309 |
+
raise ValueError(
|
| 310 |
+
f"Attention weights should be of size {(bsz, self.num_heads, q_len, kv_seq_len)}, but is"
|
| 311 |
+
f" {attn_weights.size()}"
|
| 312 |
+
)
|
| 313 |
+
|
| 314 |
+
if attention_mask is not None:
|
| 315 |
+
if attention_mask.size() != (bsz, 1, q_len, kv_seq_len):
|
| 316 |
+
raise ValueError(
|
| 317 |
+
f"Attention mask should be of size {(bsz, 1, q_len, kv_seq_len)}, but is {attention_mask.size()}"
|
| 318 |
+
)
|
| 319 |
+
|
| 320 |
+
attn_weights = attn_weights + attention_mask
|
| 321 |
+
|
| 322 |
+
# upcast attention to fp32
|
| 323 |
+
attn_weights = nn.functional.softmax(attn_weights, dim=-1, dtype=torch.float32).to(query_states.dtype)
|
| 324 |
+
attn_weights = nn.functional.dropout(attn_weights, p=self.attention_dropout, training=self.training)
|
| 325 |
+
attn_output = torch.matmul(attn_weights, value_states)
|
| 326 |
+
|
| 327 |
+
if attn_output.size() != (bsz, self.num_heads, q_len, self.head_dim):
|
| 328 |
+
raise ValueError(
|
| 329 |
+
f"`attn_output` should be of size {(bsz, self.num_heads, q_len, self.head_dim)}, but is"
|
| 330 |
+
f" {attn_output.size()}"
|
| 331 |
+
)
|
| 332 |
+
|
| 333 |
+
attn_output = attn_output.transpose(1, 2).contiguous()
|
| 334 |
+
attn_output = attn_output.reshape(bsz, q_len, self.hidden_size)
|
| 335 |
+
|
| 336 |
+
attn_output = self.o_proj(attn_output)
|
| 337 |
+
|
| 338 |
+
if not output_attentions:
|
| 339 |
+
attn_weights = None
|
| 340 |
+
|
| 341 |
+
return attn_output, attn_weights, past_key_value
|
| 342 |
+
|
| 343 |
+
|
| 344 |
+
class Qwen2FlashAttention2(Qwen2Attention):
|
| 345 |
+
"""
|
| 346 |
+
Qwen2 flash attention module, following Qwen2 attention module. This module inherits from `Qwen2Attention`
|
| 347 |
+
as the weights of the module stays untouched. The only required change would be on the forward pass
|
| 348 |
+
where it needs to correctly call the public API of flash attention and deal with padding tokens
|
| 349 |
+
in case the input contains any of them. Additionally, for sliding window attention, we apply SWA only to the bottom
|
| 350 |
+
config.max_window_layers layers.
|
| 351 |
+
"""
|
| 352 |
+
|
| 353 |
+
# Copied from transformers.models.llama.modeling_llama.LlamaFlashAttention2.__init__
|
| 354 |
+
def __init__(self, *args, **kwargs):
|
| 355 |
+
super().__init__(*args, **kwargs)
|
| 356 |
+
|
| 357 |
+
# TODO: Should be removed once Flash Attention for RoCm is bumped to 2.1.
|
| 358 |
+
# flash_attn<2.1 generates top-left aligned causal mask, while what is needed here is bottom-right alignement, that was made default for flash_attn>=2.1. This attribute is used to handle this difference. Reference: https://github.com/Dao-AILab/flash-attention/releases/tag/v2.1.0.
|
| 359 |
+
# Beware that with flash_attn<2.1, using q_seqlen != k_seqlen (except for the case q_seqlen == 1) produces a wrong mask (top-left).
|
| 360 |
+
self._flash_attn_uses_top_left_mask = not is_flash_attn_greater_or_equal_2_10()
|
| 361 |
+
|
| 362 |
+
def forward(
|
| 363 |
+
self,
|
| 364 |
+
hidden_states: torch.Tensor,
|
| 365 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 366 |
+
position_ids: Optional[torch.LongTensor] = None,
|
| 367 |
+
past_key_value: Optional[Cache] = None,
|
| 368 |
+
output_attentions: bool = False,
|
| 369 |
+
use_cache: bool = False,
|
| 370 |
+
**kwargs,
|
| 371 |
+
):
|
| 372 |
+
if "padding_mask" in kwargs:
|
| 373 |
+
warnings.warn(
|
| 374 |
+
"Passing `padding_mask` is deprecated and will be removed in v4.37. Please make sure use `attention_mask` instead.`"
|
| 375 |
+
)
|
| 376 |
+
|
| 377 |
+
# overwrite attention_mask with padding_mask
|
| 378 |
+
attention_mask = kwargs.pop("padding_mask")
|
| 379 |
+
bsz, q_len, _ = hidden_states.size()
|
| 380 |
+
|
| 381 |
+
query_states = self.q_proj(hidden_states)
|
| 382 |
+
key_states = self.k_proj(hidden_states)
|
| 383 |
+
value_states = self.v_proj(hidden_states)
|
| 384 |
+
|
| 385 |
+
query_states = query_states.view(bsz, q_len, self.num_heads, self.head_dim).transpose(1, 2)
|
| 386 |
+
key_states = key_states.view(bsz, q_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
|
| 387 |
+
value_states = value_states.view(bsz, q_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
|
| 388 |
+
|
| 389 |
+
kv_seq_len = key_states.shape[-2]
|
| 390 |
+
if past_key_value is not None:
|
| 391 |
+
if self.layer_idx is None:
|
| 392 |
+
raise ValueError(
|
| 393 |
+
f"The cache structure has changed since version v4.36. If you are using {self.__class__.__name__} "
|
| 394 |
+
"for auto-regressive decoding with k/v caching, please make sure to initialize the attention class "
|
| 395 |
+
"with a layer index."
|
| 396 |
+
)
|
| 397 |
+
kv_seq_len += past_key_value.get_seq_length(self.layer_idx)
|
| 398 |
+
|
| 399 |
+
# Because the input can be padded, the absolute sequence length depends on the max position id.
|
| 400 |
+
rotary_seq_len = max(kv_seq_len, position_ids[:, -1].max().item()) + 1
|
| 401 |
+
cos, sin = self.rotary_emb(value_states, seq_len=rotary_seq_len)
|
| 402 |
+
|
| 403 |
+
query_states, key_states = apply_rotary_pos_emb(query_states, key_states, cos, sin, position_ids)
|
| 404 |
+
|
| 405 |
+
use_sliding_windows = (
|
| 406 |
+
_flash_supports_window_size
|
| 407 |
+
and getattr(self.config, "sliding_window", None) is not None
|
| 408 |
+
and kv_seq_len > self.config.sliding_window
|
| 409 |
+
and self.config.use_sliding_window
|
| 410 |
+
)
|
| 411 |
+
|
| 412 |
+
if not _flash_supports_window_size:
|
| 413 |
+
logger.warning_once(
|
| 414 |
+
"The current flash attention version does not support sliding window attention, for a more memory efficient implementation"
|
| 415 |
+
" make sure to upgrade flash-attn library."
|
| 416 |
+
)
|
| 417 |
+
|
| 418 |
+
if past_key_value is not None:
|
| 419 |
+
# Activate slicing cache only if the config has a value `sliding_windows` attribute
|
| 420 |
+
cache_has_contents = past_key_value.get_seq_length(self.layer_idx) > 0
|
| 421 |
+
if (
|
| 422 |
+
getattr(self.config, "sliding_window", None) is not None
|
| 423 |
+
and kv_seq_len > self.config.sliding_window
|
| 424 |
+
and cache_has_contents
|
| 425 |
+
):
|
| 426 |
+
slicing_tokens = 1 - self.config.sliding_window
|
| 427 |
+
|
| 428 |
+
past_key = past_key_value[self.layer_idx][0]
|
| 429 |
+
past_value = past_key_value[self.layer_idx][1]
|
| 430 |
+
|
| 431 |
+
past_key = past_key[:, :, slicing_tokens:, :].contiguous()
|
| 432 |
+
past_value = past_value[:, :, slicing_tokens:, :].contiguous()
|
| 433 |
+
|
| 434 |
+
if past_key.shape[-2] != self.config.sliding_window - 1:
|
| 435 |
+
raise ValueError(
|
| 436 |
+
f"past key must have a shape of (`batch_size, num_heads, self.config.sliding_window-1, head_dim`), got"
|
| 437 |
+
f" {past_key.shape}"
|
| 438 |
+
)
|
| 439 |
+
|
| 440 |
+
if attention_mask is not None:
|
| 441 |
+
attention_mask = attention_mask[:, slicing_tokens:]
|
| 442 |
+
attention_mask = torch.cat([attention_mask, torch.ones_like(attention_mask[:, -1:])], dim=-1)
|
| 443 |
+
|
| 444 |
+
cache_kwargs = {"sin": sin, "cos": cos} # Specific to RoPE models
|
| 445 |
+
key_states, value_states = past_key_value.update(key_states, value_states, self.layer_idx, cache_kwargs)
|
| 446 |
+
|
| 447 |
+
# repeat k/v heads if n_kv_heads < n_heads
|
| 448 |
+
key_states = repeat_kv(key_states, self.num_key_value_groups)
|
| 449 |
+
value_states = repeat_kv(value_states, self.num_key_value_groups)
|
| 450 |
+
dropout_rate = 0.0 if not self.training else self.attention_dropout
|
| 451 |
+
|
| 452 |
+
# In PEFT, usually we cast the layer norms in float32 for training stability reasons
|
| 453 |
+
# therefore the input hidden states gets silently casted in float32. Hence, we need
|
| 454 |
+
# cast them back in float16 just to be sure everything works as expected.
|
| 455 |
+
input_dtype = query_states.dtype
|
| 456 |
+
if input_dtype == torch.float32:
|
| 457 |
+
if torch.is_autocast_enabled():
|
| 458 |
+
target_dtype = torch.get_autocast_gpu_dtype()
|
| 459 |
+
# Handle the case where the model is quantized
|
| 460 |
+
elif hasattr(self.config, "_pre_quantization_dtype"):
|
| 461 |
+
target_dtype = self.config._pre_quantization_dtype
|
| 462 |
+
else:
|
| 463 |
+
target_dtype = self.q_proj.weight.dtype
|
| 464 |
+
|
| 465 |
+
logger.warning_once(
|
| 466 |
+
f"The input hidden states seems to be silently casted in float32, this might be related to"
|
| 467 |
+
f" the fact you have upcasted embedding or layer norm layers in float32. We will cast back the input in"
|
| 468 |
+
f" {target_dtype}."
|
| 469 |
+
)
|
| 470 |
+
|
| 471 |
+
query_states = query_states.to(target_dtype)
|
| 472 |
+
key_states = key_states.to(target_dtype)
|
| 473 |
+
value_states = value_states.to(target_dtype)
|
| 474 |
+
|
| 475 |
+
# Reashape to the expected shape for Flash Attention
|
| 476 |
+
query_states = query_states.transpose(1, 2)
|
| 477 |
+
key_states = key_states.transpose(1, 2)
|
| 478 |
+
value_states = value_states.transpose(1, 2)
|
| 479 |
+
|
| 480 |
+
attn_output = self._flash_attention_forward(
|
| 481 |
+
query_states,
|
| 482 |
+
key_states,
|
| 483 |
+
value_states,
|
| 484 |
+
attention_mask,
|
| 485 |
+
q_len,
|
| 486 |
+
dropout=dropout_rate,
|
| 487 |
+
use_sliding_windows=use_sliding_windows,
|
| 488 |
+
)
|
| 489 |
+
|
| 490 |
+
attn_output = attn_output.reshape(bsz, q_len, self.hidden_size).contiguous()
|
| 491 |
+
attn_output = self.o_proj(attn_output)
|
| 492 |
+
|
| 493 |
+
if not output_attentions:
|
| 494 |
+
attn_weights = None
|
| 495 |
+
|
| 496 |
+
return attn_output, attn_weights, past_key_value
|
| 497 |
+
|
| 498 |
+
def _flash_attention_forward(
|
| 499 |
+
self,
|
| 500 |
+
query_states,
|
| 501 |
+
key_states,
|
| 502 |
+
value_states,
|
| 503 |
+
attention_mask,
|
| 504 |
+
query_length,
|
| 505 |
+
dropout=0.0,
|
| 506 |
+
softmax_scale=None,
|
| 507 |
+
use_sliding_windows=False,
|
| 508 |
+
):
|
| 509 |
+
"""
|
| 510 |
+
Calls the forward method of Flash Attention - if the input hidden states contain at least one padding token
|
| 511 |
+
first unpad the input, then computes the attention scores and pad the final attention scores.
|
| 512 |
+
|
| 513 |
+
Args:
|
| 514 |
+
query_states (`torch.Tensor`):
|
| 515 |
+
Input query states to be passed to Flash Attention API
|
| 516 |
+
key_states (`torch.Tensor`):
|
| 517 |
+
Input key states to be passed to Flash Attention API
|
| 518 |
+
value_states (`torch.Tensor`):
|
| 519 |
+
Input value states to be passed to Flash Attention API
|
| 520 |
+
attention_mask (`torch.Tensor`):
|
| 521 |
+
The padding mask - corresponds to a tensor of size `(batch_size, seq_len)` where 0 stands for the
|
| 522 |
+
position of padding tokens and 1 for the position of non-padding tokens.
|
| 523 |
+
dropout (`int`, *optional*):
|
| 524 |
+
Attention dropout
|
| 525 |
+
softmax_scale (`float`, *optional*):
|
| 526 |
+
The scaling of QK^T before applying softmax. Default to 1 / sqrt(head_dim)
|
| 527 |
+
use_sliding_windows (`bool`, *optional*):
|
| 528 |
+
Whether to activate sliding window attention.
|
| 529 |
+
"""
|
| 530 |
+
if not self._flash_attn_uses_top_left_mask:
|
| 531 |
+
causal = self.is_causal
|
| 532 |
+
else:
|
| 533 |
+
# TODO: Remove the `query_length != 1` check once Flash Attention for RoCm is bumped to 2.1. For details, please see the comment in LlamaFlashAttention2 __init__.
|
| 534 |
+
causal = self.is_causal and query_length != 1
|
| 535 |
+
|
| 536 |
+
# Decide whether to use SWA or not by layer index.
|
| 537 |
+
if use_sliding_windows and self.layer_idx >= self.config.max_window_layers:
|
| 538 |
+
use_sliding_windows = False
|
| 539 |
+
|
| 540 |
+
# Contains at least one padding token in the sequence
|
| 541 |
+
if attention_mask is not None:
|
| 542 |
+
batch_size = query_states.shape[0]
|
| 543 |
+
query_states, key_states, value_states, indices_q, cu_seq_lens, max_seq_lens = self._upad_input(
|
| 544 |
+
query_states, key_states, value_states, attention_mask, query_length
|
| 545 |
+
)
|
| 546 |
+
|
| 547 |
+
cu_seqlens_q, cu_seqlens_k = cu_seq_lens
|
| 548 |
+
max_seqlen_in_batch_q, max_seqlen_in_batch_k = max_seq_lens
|
| 549 |
+
|
| 550 |
+
if not use_sliding_windows:
|
| 551 |
+
attn_output_unpad = flash_attn_varlen_func(
|
| 552 |
+
query_states,
|
| 553 |
+
key_states,
|
| 554 |
+
value_states,
|
| 555 |
+
cu_seqlens_q=cu_seqlens_q,
|
| 556 |
+
cu_seqlens_k=cu_seqlens_k,
|
| 557 |
+
max_seqlen_q=max_seqlen_in_batch_q,
|
| 558 |
+
max_seqlen_k=max_seqlen_in_batch_k,
|
| 559 |
+
dropout_p=dropout,
|
| 560 |
+
softmax_scale=softmax_scale,
|
| 561 |
+
causal=causal,
|
| 562 |
+
)
|
| 563 |
+
else:
|
| 564 |
+
attn_output_unpad = flash_attn_varlen_func(
|
| 565 |
+
query_states,
|
| 566 |
+
key_states,
|
| 567 |
+
value_states,
|
| 568 |
+
cu_seqlens_q=cu_seqlens_q,
|
| 569 |
+
cu_seqlens_k=cu_seqlens_k,
|
| 570 |
+
max_seqlen_q=max_seqlen_in_batch_q,
|
| 571 |
+
max_seqlen_k=max_seqlen_in_batch_k,
|
| 572 |
+
dropout_p=dropout,
|
| 573 |
+
softmax_scale=softmax_scale,
|
| 574 |
+
causal=causal,
|
| 575 |
+
window_size=(self.config.sliding_window, self.config.sliding_window),
|
| 576 |
+
)
|
| 577 |
+
|
| 578 |
+
attn_output = pad_input(attn_output_unpad, indices_q, batch_size, query_length)
|
| 579 |
+
else:
|
| 580 |
+
if not use_sliding_windows:
|
| 581 |
+
attn_output = flash_attn_func(
|
| 582 |
+
query_states,
|
| 583 |
+
key_states,
|
| 584 |
+
value_states,
|
| 585 |
+
dropout,
|
| 586 |
+
softmax_scale=softmax_scale,
|
| 587 |
+
causal=causal,
|
| 588 |
+
)
|
| 589 |
+
else:
|
| 590 |
+
attn_output = flash_attn_func(
|
| 591 |
+
query_states,
|
| 592 |
+
key_states,
|
| 593 |
+
value_states,
|
| 594 |
+
dropout,
|
| 595 |
+
softmax_scale=softmax_scale,
|
| 596 |
+
causal=causal,
|
| 597 |
+
window_size=(self.config.sliding_window, self.config.sliding_window),
|
| 598 |
+
)
|
| 599 |
+
|
| 600 |
+
return attn_output
|
| 601 |
+
|
| 602 |
+
# Copied from transformers.models.mistral.modeling_mistral.MistralFlashAttention2._upad_input
|
| 603 |
+
def _upad_input(self, query_layer, key_layer, value_layer, attention_mask, query_length):
|
| 604 |
+
batch_size, kv_seq_len, num_heads, head_dim = key_layer.shape
|
| 605 |
+
|
| 606 |
+
# On the first iteration we need to properly re-create the padding mask
|
| 607 |
+
# by slicing it on the proper place
|
| 608 |
+
if kv_seq_len != attention_mask.shape[-1]:
|
| 609 |
+
attention_mask_num_tokens = attention_mask.shape[-1]
|
| 610 |
+
attention_mask = attention_mask[:, attention_mask_num_tokens - kv_seq_len :]
|
| 611 |
+
|
| 612 |
+
indices_k, cu_seqlens_k, max_seqlen_in_batch_k = _get_unpad_data(attention_mask)
|
| 613 |
+
|
| 614 |
+
key_layer = index_first_axis(key_layer.reshape(batch_size * kv_seq_len, num_heads, head_dim), indices_k)
|
| 615 |
+
value_layer = index_first_axis(value_layer.reshape(batch_size * kv_seq_len, num_heads, head_dim), indices_k)
|
| 616 |
+
|
| 617 |
+
if query_length == kv_seq_len:
|
| 618 |
+
query_layer = index_first_axis(
|
| 619 |
+
query_layer.reshape(batch_size * kv_seq_len, num_heads, head_dim), indices_k
|
| 620 |
+
)
|
| 621 |
+
cu_seqlens_q = cu_seqlens_k
|
| 622 |
+
max_seqlen_in_batch_q = max_seqlen_in_batch_k
|
| 623 |
+
indices_q = indices_k
|
| 624 |
+
elif query_length == 1:
|
| 625 |
+
max_seqlen_in_batch_q = 1
|
| 626 |
+
cu_seqlens_q = torch.arange(
|
| 627 |
+
batch_size + 1, dtype=torch.int32, device=query_layer.device
|
| 628 |
+
) # There is a memcpy here, that is very bad.
|
| 629 |
+
indices_q = cu_seqlens_q[:-1]
|
| 630 |
+
query_layer = query_layer.squeeze(1)
|
| 631 |
+
else:
|
| 632 |
+
# The -q_len: slice assumes left padding.
|
| 633 |
+
attention_mask = attention_mask[:, -query_length:]
|
| 634 |
+
query_layer, indices_q, cu_seqlens_q, max_seqlen_in_batch_q = unpad_input(query_layer, attention_mask)
|
| 635 |
+
|
| 636 |
+
return (
|
| 637 |
+
query_layer,
|
| 638 |
+
key_layer,
|
| 639 |
+
value_layer,
|
| 640 |
+
indices_q,
|
| 641 |
+
(cu_seqlens_q, cu_seqlens_k),
|
| 642 |
+
(max_seqlen_in_batch_q, max_seqlen_in_batch_k),
|
| 643 |
+
)
|
| 644 |
+
|
| 645 |
+
|
| 646 |
+
# Copied from transformers.models.llama.modeling_llama.LlamaSdpaAttention with Llama->Qwen2
|
| 647 |
+
class Qwen2SdpaAttention(Qwen2Attention):
|
| 648 |
+
"""
|
| 649 |
+
Qwen2 attention module using torch.nn.functional.scaled_dot_product_attention. This module inherits from
|
| 650 |
+
`Qwen2Attention` as the weights of the module stays untouched. The only changes are on the forward pass to adapt to
|
| 651 |
+
SDPA API.
|
| 652 |
+
"""
|
| 653 |
+
|
| 654 |
+
# Adapted from Qwen2Attention.forward
|
| 655 |
+
def forward(
|
| 656 |
+
self,
|
| 657 |
+
hidden_states: torch.Tensor,
|
| 658 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 659 |
+
position_ids: Optional[torch.LongTensor] = None,
|
| 660 |
+
past_key_value: Optional[Cache] = None,
|
| 661 |
+
output_attentions: bool = False,
|
| 662 |
+
use_cache: bool = False,
|
| 663 |
+
) -> Tuple[torch.Tensor, Optional[torch.Tensor], Optional[Tuple[torch.Tensor]]]:
|
| 664 |
+
if output_attentions:
|
| 665 |
+
# TODO: Improve this warning with e.g. `model.config.attn_implementation = "manual"` once this is implemented.
|
| 666 |
+
logger.warning_once(
|
| 667 |
+
"Qwen2Model is using Qwen2SdpaAttention, but `torch.nn.functional.scaled_dot_product_attention` does not support `output_attentions=True`. Falling back to the manual attention implementation, "
|
| 668 |
+
'but specifying the manual implementation will be required from Transformers version v5.0.0 onwards. This warning can be removed using the argument `attn_implementation="eager"` when loading the model.'
|
| 669 |
+
)
|
| 670 |
+
return super().forward(
|
| 671 |
+
hidden_states=hidden_states,
|
| 672 |
+
attention_mask=attention_mask,
|
| 673 |
+
position_ids=position_ids,
|
| 674 |
+
past_key_value=past_key_value,
|
| 675 |
+
output_attentions=output_attentions,
|
| 676 |
+
use_cache=use_cache,
|
| 677 |
+
)
|
| 678 |
+
|
| 679 |
+
bsz, q_len, _ = hidden_states.size()
|
| 680 |
+
|
| 681 |
+
query_states = self.q_proj(hidden_states)
|
| 682 |
+
key_states = self.k_proj(hidden_states)
|
| 683 |
+
value_states = self.v_proj(hidden_states)
|
| 684 |
+
|
| 685 |
+
query_states = query_states.view(bsz, q_len, self.num_heads, self.head_dim).transpose(1, 2)
|
| 686 |
+
key_states = key_states.view(bsz, q_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
|
| 687 |
+
value_states = value_states.view(bsz, q_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
|
| 688 |
+
|
| 689 |
+
kv_seq_len = key_states.shape[-2]
|
| 690 |
+
if past_key_value is not None:
|
| 691 |
+
kv_seq_len += past_key_value.get_seq_length(self.layer_idx)
|
| 692 |
+
cos, sin = self.rotary_emb(value_states, seq_len=kv_seq_len)
|
| 693 |
+
|
| 694 |
+
query_states, key_states = apply_rotary_pos_emb(query_states, key_states, cos, sin, position_ids)
|
| 695 |
+
|
| 696 |
+
if past_key_value is not None:
|
| 697 |
+
cache_kwargs = {"sin": sin, "cos": cos} # Specific to RoPE models
|
| 698 |
+
key_states, value_states = past_key_value.update(key_states, value_states, self.layer_idx, cache_kwargs)
|
| 699 |
+
|
| 700 |
+
key_states = repeat_kv(key_states, self.num_key_value_groups)
|
| 701 |
+
value_states = repeat_kv(value_states, self.num_key_value_groups)
|
| 702 |
+
|
| 703 |
+
if attention_mask is not None:
|
| 704 |
+
if attention_mask.size() != (bsz, 1, q_len, kv_seq_len):
|
| 705 |
+
raise ValueError(
|
| 706 |
+
f"Attention mask should be of size {(bsz, 1, q_len, kv_seq_len)}, but is {attention_mask.size()}"
|
| 707 |
+
)
|
| 708 |
+
|
| 709 |
+
# SDPA with memory-efficient backend is currently (torch==2.1.2) bugged with non-contiguous inputs with custom attn_mask,
|
| 710 |
+
# Reference: https://github.com/pytorch/pytorch/issues/112577.
|
| 711 |
+
if query_states.device.type == "cuda" and attention_mask is not None:
|
| 712 |
+
query_states = query_states.contiguous()
|
| 713 |
+
key_states = key_states.contiguous()
|
| 714 |
+
value_states = value_states.contiguous()
|
| 715 |
+
|
| 716 |
+
attn_output = torch.nn.functional.scaled_dot_product_attention(
|
| 717 |
+
query_states,
|
| 718 |
+
key_states,
|
| 719 |
+
value_states,
|
| 720 |
+
attn_mask=attention_mask,
|
| 721 |
+
dropout_p=self.attention_dropout if self.training else 0.0,
|
| 722 |
+
is_causal=False,
|
| 723 |
+
)
|
| 724 |
+
|
| 725 |
+
attn_output = attn_output.transpose(1, 2).contiguous()
|
| 726 |
+
attn_output = attn_output.reshape(bsz, q_len, self.hidden_size)
|
| 727 |
+
|
| 728 |
+
attn_output = self.o_proj(attn_output)
|
| 729 |
+
|
| 730 |
+
return attn_output, None, past_key_value
|
| 731 |
+
|
| 732 |
+
|
| 733 |
+
class Qwen2SdpaAttentionGqa(Qwen2Attention):
|
| 734 |
+
"""
|
| 735 |
+
Qwen2 attention module using torch.nn.functional.scaled_dot_product_attention. This module inherits from
|
| 736 |
+
`Qwen2Attention` as the weights of the module stays untouched. The only changes are on the forward pass to adapt to
|
| 737 |
+
SDPA API.
|
| 738 |
+
"""
|
| 739 |
+
|
| 740 |
+
# Adapted from Qwen2Attention.forward
|
| 741 |
+
def forward(
|
| 742 |
+
self,
|
| 743 |
+
hidden_states: torch.Tensor,
|
| 744 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 745 |
+
position_ids: Optional[torch.LongTensor] = None,
|
| 746 |
+
past_key_value: Optional[Cache] = None,
|
| 747 |
+
output_attentions: bool = False,
|
| 748 |
+
use_cache: bool = False,
|
| 749 |
+
) -> Tuple[torch.Tensor, Optional[torch.Tensor], Optional[Tuple[torch.Tensor]]]:
|
| 750 |
+
if output_attentions:
|
| 751 |
+
# TODO: Improve this warning with e.g. `model.config.attn_implementation = "manual"` once this is implemented.
|
| 752 |
+
logger.warning_once(
|
| 753 |
+
"Qwen2Model is using Qwen2SdpaAttention, but `torch.nn.functional.scaled_dot_product_attention` does not support `output_attentions=True`. Falling back to the manual attention implementation, "
|
| 754 |
+
'but specifying the manual implementation will be required from Transformers version v5.0.0 onwards. This warning can be removed using the argument `attn_implementation="eager"` when loading the model.'
|
| 755 |
+
)
|
| 756 |
+
return super().forward(
|
| 757 |
+
hidden_states=hidden_states,
|
| 758 |
+
attention_mask=attention_mask,
|
| 759 |
+
position_ids=position_ids,
|
| 760 |
+
past_key_value=past_key_value,
|
| 761 |
+
output_attentions=output_attentions,
|
| 762 |
+
use_cache=use_cache,
|
| 763 |
+
)
|
| 764 |
+
|
| 765 |
+
bsz, q_len, _ = hidden_states.size()
|
| 766 |
+
|
| 767 |
+
query_states = self.q_proj(hidden_states)
|
| 768 |
+
key_states = self.k_proj(hidden_states)
|
| 769 |
+
value_states = self.v_proj(hidden_states)
|
| 770 |
+
|
| 771 |
+
query_states = query_states.view(bsz, q_len, self.num_heads, self.head_dim).transpose(1, 2)
|
| 772 |
+
key_states = key_states.view(bsz, q_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
|
| 773 |
+
value_states = value_states.view(bsz, q_len, self.num_key_value_heads, self.head_dim).transpose(1, 2)
|
| 774 |
+
|
| 775 |
+
kv_seq_len = key_states.shape[-2]
|
| 776 |
+
if past_key_value is not None:
|
| 777 |
+
kv_seq_len += past_key_value.get_seq_length(self.layer_idx)
|
| 778 |
+
cos, sin = self.rotary_emb(value_states, seq_len=kv_seq_len)
|
| 779 |
+
|
| 780 |
+
query_states, key_states = apply_rotary_pos_emb(query_states, key_states, cos, sin, position_ids)
|
| 781 |
+
|
| 782 |
+
if past_key_value is not None:
|
| 783 |
+
cache_kwargs = {"sin": sin, "cos": cos} # Specific to RoPE models
|
| 784 |
+
key_states, value_states = past_key_value.update(key_states, value_states, self.layer_idx, cache_kwargs)
|
| 785 |
+
|
| 786 |
+
# key_states = repeat_kv(key_states, self.num_key_value_groups)
|
| 787 |
+
# value_states = repeat_kv(value_states, self.num_key_value_groups)
|
| 788 |
+
|
| 789 |
+
if attention_mask is not None:
|
| 790 |
+
if attention_mask.size() != (bsz, 1, q_len, kv_seq_len):
|
| 791 |
+
raise ValueError(
|
| 792 |
+
f"Attention mask should be of size {(bsz, 1, q_len, kv_seq_len)}, but is {attention_mask.size()}"
|
| 793 |
+
)
|
| 794 |
+
|
| 795 |
+
# SDPA with memory-efficient backend is currently (torch==2.1.2) bugged with non-contiguous inputs with custom attn_mask,
|
| 796 |
+
# Reference: https://github.com/pytorch/pytorch/issues/112577.
|
| 797 |
+
if query_states.device.type == "cuda" and attention_mask is not None:
|
| 798 |
+
query_states = query_states.contiguous()
|
| 799 |
+
key_states = key_states.contiguous()
|
| 800 |
+
value_states = value_states.contiguous()
|
| 801 |
+
|
| 802 |
+
with torch.backends.cuda.sdp_kernel(enable_flash=True,
|
| 803 |
+
enable_math=True,
|
| 804 |
+
enable_mem_efficient=False):
|
| 805 |
+
|
| 806 |
+
attn_output = torch.nn.functional.scaled_dot_product_attention(
|
| 807 |
+
query_states,
|
| 808 |
+
key_states,
|
| 809 |
+
value_states,
|
| 810 |
+
attn_mask=attention_mask,
|
| 811 |
+
enable_gqa=True,
|
| 812 |
+
dropout_p=self.attention_dropout if self.training else 0.0,
|
| 813 |
+
is_causal=False,
|
| 814 |
+
)
|
| 815 |
+
|
| 816 |
+
attn_output = attn_output.transpose(1, 2).contiguous()
|
| 817 |
+
attn_output = attn_output.reshape(bsz, q_len, self.hidden_size)
|
| 818 |
+
|
| 819 |
+
attn_output = self.o_proj(attn_output)
|
| 820 |
+
|
| 821 |
+
return attn_output, None, past_key_value
|
| 822 |
+
|
| 823 |
+
|
| 824 |
+
class Qwen2MagiAttention(Qwen2Attention):
|
| 825 |
+
"""
|
| 826 |
+
Qwen2 attention using MagiAttention for efficient training with MTP packing support.
|
| 827 |
+
|
| 828 |
+
MagiAttention uses range-based sparse attention patterns:
|
| 829 |
+
- q_ranges/k_ranges define which query/key ranges attend to each other
|
| 830 |
+
- attn_type_map specifies causal(1) or full(0) attention for each range pair
|
| 831 |
+
"""
|
| 832 |
+
|
| 833 |
+
def __init__(self, *args, **kwargs):
|
| 834 |
+
super().__init__(*args, **kwargs)
|
| 835 |
+
if not _MAGI_AVAILABLE:
|
| 836 |
+
raise ImportError(
|
| 837 |
+
"magi_attention is not installed. Install with: pip install magi-attention"
|
| 838 |
+
)
|
| 839 |
+
self.softmax_scale = self.head_dim ** -0.5
|
| 840 |
+
|
| 841 |
+
def forward(
|
| 842 |
+
self,
|
| 843 |
+
hidden_states: torch.Tensor,
|
| 844 |
+
attention_mask: Optional[dict] = None, # magi_plan dict
|
| 845 |
+
position_ids: Optional[torch.LongTensor] = None,
|
| 846 |
+
past_key_value: Optional[Cache] = None,
|
| 847 |
+
output_attentions: bool = False,
|
| 848 |
+
use_cache: bool = False,
|
| 849 |
+
) -> Tuple[torch.Tensor, Optional[torch.Tensor], Optional[Tuple[torch.Tensor]]]:
|
| 850 |
+
if output_attentions:
|
| 851 |
+
raise NotImplementedError('MagiAttention does not support output_attentions=True')
|
| 852 |
+
|
| 853 |
+
bsz, q_len, _ = hidden_states.size()
|
| 854 |
+
assert bsz == 1, "MagiAttention only supports batch_size=1 (use packing instead)"
|
| 855 |
+
|
| 856 |
+
query_states = self.q_proj(hidden_states)
|
| 857 |
+
key_states = self.k_proj(hidden_states)
|
| 858 |
+
value_states = self.v_proj(hidden_states)
|
| 859 |
+
|
| 860 |
+
# Magi expects [T, H, D] format (no batch dimension)
|
| 861 |
+
query_states = query_states.view(q_len, self.num_heads, self.head_dim)
|
| 862 |
+
key_states = key_states.view(q_len, self.num_key_value_heads, self.head_dim)
|
| 863 |
+
value_states = value_states.view(q_len, self.num_key_value_heads, self.head_dim)
|
| 864 |
+
|
| 865 |
+
kv_seq_len = q_len
|
| 866 |
+
if past_key_value is not None:
|
| 867 |
+
if self.layer_idx is None:
|
| 868 |
+
raise ValueError(
|
| 869 |
+
f"The cache structure has changed since version v4.36. If you are using {self.__class__.__name__} "
|
| 870 |
+
"for auto-regressive decoding with k/v caching, please make sure to initialize the attention class "
|
| 871 |
+
"with a layer index."
|
| 872 |
+
)
|
| 873 |
+
kv_seq_len += past_key_value.get_seq_length(self.layer_idx)
|
| 874 |
+
|
| 875 |
+
cos, sin = self.rotary_emb(value_states.unsqueeze(0).transpose(1, 2), seq_len=kv_seq_len)
|
| 876 |
+
|
| 877 |
+
# Apply RoPE: need [B, H, L, D] format for apply_rotary_pos_emb
|
| 878 |
+
q_for_rope = query_states.unsqueeze(0).transpose(1, 2) # [1, H, L, D]
|
| 879 |
+
k_for_rope = key_states.unsqueeze(0).transpose(1, 2) # [1, Hkv, L, D]
|
| 880 |
+
q_for_rope, k_for_rope = apply_rotary_pos_emb(q_for_rope, k_for_rope, cos, sin, position_ids)
|
| 881 |
+
|
| 882 |
+
# Back to [T, H, D]
|
| 883 |
+
query_states = q_for_rope.squeeze(0).transpose(0, 1).contiguous() # [L, H, D]
|
| 884 |
+
key_states = k_for_rope.squeeze(0).transpose(0, 1).contiguous() # [L, Hkv, D]
|
| 885 |
+
|
| 886 |
+
if past_key_value is not None:
|
| 887 |
+
cache_kwargs = {"sin": sin, "cos": cos}
|
| 888 |
+
# Note: Magi doesn't support KV cache in training, this is for potential future use
|
| 889 |
+
key_states_4d = key_states.unsqueeze(0).transpose(1, 2)
|
| 890 |
+
value_states_4d = value_states.unsqueeze(0).transpose(1, 2)
|
| 891 |
+
key_states_4d, value_states_4d = past_key_value.update(
|
| 892 |
+
key_states_4d, value_states_4d, self.layer_idx, cache_kwargs
|
| 893 |
+
)
|
| 894 |
+
key_states = key_states_4d.squeeze(0).transpose(0, 1).contiguous()
|
| 895 |
+
value_states = value_states_4d.squeeze(0).transpose(0, 1).contiguous()
|
| 896 |
+
|
| 897 |
+
# Run Magi Attention
|
| 898 |
+
# attention_mask is a magi_plan dict with q_ranges, k_ranges, attn_type_map, etc.
|
| 899 |
+
|
| 900 |
+
attn_output, _ = flex_flash_attn_func(
|
| 901 |
+
query_states.contiguous(),
|
| 902 |
+
key_states.contiguous(),
|
| 903 |
+
value_states.contiguous(),
|
| 904 |
+
q_ranges=attention_mask["q_ranges"],
|
| 905 |
+
k_ranges=attention_mask["k_ranges"],
|
| 906 |
+
attn_type_map=attention_mask["attn_type_map"],
|
| 907 |
+
softmax_scale=self.softmax_scale,
|
| 908 |
+
softcap=0.0,
|
| 909 |
+
deterministic=False,
|
| 910 |
+
) # [T, H, D]
|
| 911 |
+
|
| 912 |
+
# Reshape to [B, L, H*D]
|
| 913 |
+
attn_output = attn_output.view(1, q_len, self.hidden_size)
|
| 914 |
+
attn_output = self.o_proj(attn_output)
|
| 915 |
+
|
| 916 |
+
return attn_output, None, past_key_value
|
| 917 |
+
|
| 918 |
+
|
| 919 |
+
QWEN2_ATTENTION_CLASSES = {
|
| 920 |
+
"eager": Qwen2Attention,
|
| 921 |
+
"flash_attention_2": Qwen2FlashAttention2,
|
| 922 |
+
"sdpa": Qwen2SdpaAttention,
|
| 923 |
+
"magi": Qwen2MagiAttention,
|
| 924 |
+
}
|
| 925 |
+
|
| 926 |
+
|
| 927 |
+
class Qwen2DecoderLayer(nn.Module):
|
| 928 |
+
def __init__(self, config: Qwen2Config, layer_idx: int):
|
| 929 |
+
super().__init__()
|
| 930 |
+
self.hidden_size = config.hidden_size
|
| 931 |
+
|
| 932 |
+
if config._attn_implementation == 'magi' and not _MAGI_AVAILABLE:
|
| 933 |
+
if is_flash_attn_2_available():
|
| 934 |
+
logger.warning_once(
|
| 935 |
+
'magi_attention not available, falling back to flash_attention_2'
|
| 936 |
+
)
|
| 937 |
+
config._attn_implementation = 'flash_attention_2'
|
| 938 |
+
else:
|
| 939 |
+
logger.warning_once(
|
| 940 |
+
'magi_attention not available, falling back to sdpa'
|
| 941 |
+
)
|
| 942 |
+
config._attn_implementation = 'sdpa'
|
| 943 |
+
if config._attn_implementation == 'flash_attention_2' and not is_flash_attn_2_available():
|
| 944 |
+
logger.warning_once(
|
| 945 |
+
'flash_attn is not available, falling back to sdpa'
|
| 946 |
+
)
|
| 947 |
+
config._attn_implementation = 'sdpa'
|
| 948 |
+
|
| 949 |
+
self.self_attn = QWEN2_ATTENTION_CLASSES[config._attn_implementation](config, layer_idx)
|
| 950 |
+
|
| 951 |
+
self.mlp = Qwen2MLP(config)
|
| 952 |
+
self.input_layernorm = Qwen2RMSNorm(config.hidden_size, eps=config.rms_norm_eps)
|
| 953 |
+
self.post_attention_layernorm = Qwen2RMSNorm(config.hidden_size, eps=config.rms_norm_eps)
|
| 954 |
+
|
| 955 |
+
def forward(
|
| 956 |
+
self,
|
| 957 |
+
hidden_states: torch.Tensor,
|
| 958 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 959 |
+
position_ids: Optional[torch.LongTensor] = None,
|
| 960 |
+
past_key_value: Optional[Tuple[torch.Tensor]] = None,
|
| 961 |
+
output_attentions: Optional[bool] = False,
|
| 962 |
+
use_cache: Optional[bool] = False,
|
| 963 |
+
**kwargs,
|
| 964 |
+
) -> Tuple[torch.FloatTensor, Optional[Tuple[torch.FloatTensor, torch.FloatTensor]]]:
|
| 965 |
+
if "padding_mask" in kwargs:
|
| 966 |
+
warnings.warn(
|
| 967 |
+
"Passing `padding_mask` is deprecated and will be removed in v4.37. "
|
| 968 |
+
"Please make sure use `attention_mask` instead.`"
|
| 969 |
+
)
|
| 970 |
+
"""
|
| 971 |
+
Args:
|
| 972 |
+
hidden_states (`torch.FloatTensor`): input to the layer of shape `(batch, seq_len, embed_dim)`
|
| 973 |
+
attention_mask (`torch.FloatTensor`, *optional*): attention mask of size
|
| 974 |
+
`(batch, sequence_length)` where padding elements are indicated by 0.
|
| 975 |
+
output_attentions (`bool`, *optional*):
|
| 976 |
+
Whether or not to return the attentions tensors of all attention layers. See `attentions` under
|
| 977 |
+
returned tensors for more detail.
|
| 978 |
+
use_cache (`bool`, *optional*):
|
| 979 |
+
If set to `True`, `past_key_values` key value states are returned and can be used to speed up decoding
|
| 980 |
+
(see `past_key_values`).
|
| 981 |
+
past_key_value (`Tuple(torch.FloatTensor)`, *optional*): cached past key and value projection states
|
| 982 |
+
"""
|
| 983 |
+
|
| 984 |
+
residual = hidden_states
|
| 985 |
+
|
| 986 |
+
hidden_states = self.input_layernorm(hidden_states)
|
| 987 |
+
|
| 988 |
+
# Self Attention
|
| 989 |
+
hidden_states, self_attn_weights, present_key_value = self.self_attn(
|
| 990 |
+
hidden_states=hidden_states,
|
| 991 |
+
attention_mask=attention_mask,
|
| 992 |
+
position_ids=position_ids,
|
| 993 |
+
past_key_value=past_key_value,
|
| 994 |
+
output_attentions=output_attentions,
|
| 995 |
+
use_cache=use_cache,
|
| 996 |
+
)
|
| 997 |
+
hidden_states = residual + hidden_states
|
| 998 |
+
|
| 999 |
+
# Fully Connected
|
| 1000 |
+
residual = hidden_states
|
| 1001 |
+
hidden_states = self.post_attention_layernorm(hidden_states)
|
| 1002 |
+
hidden_states = self.mlp(hidden_states)
|
| 1003 |
+
hidden_states = residual + hidden_states
|
| 1004 |
+
|
| 1005 |
+
outputs = (hidden_states,)
|
| 1006 |
+
|
| 1007 |
+
if output_attentions:
|
| 1008 |
+
outputs += (self_attn_weights,)
|
| 1009 |
+
|
| 1010 |
+
if use_cache:
|
| 1011 |
+
outputs += (present_key_value,)
|
| 1012 |
+
|
| 1013 |
+
return outputs
|
| 1014 |
+
|
| 1015 |
+
|
| 1016 |
+
QWEN2_START_DOCSTRING = r"""
|
| 1017 |
+
This model inherits from [`PreTrainedModel`]. Check the superclass documentation for the generic methods the
|
| 1018 |
+
library implements for all its model (such as downloading or saving, resizing the input embeddings, pruning heads
|
| 1019 |
+
etc.)
|
| 1020 |
+
|
| 1021 |
+
This model is also a PyTorch [torch.nn.Module](https://pytorch.org/docs/stable/nn.html#torch.nn.Module) subclass.
|
| 1022 |
+
Use it as a regular PyTorch Module and refer to the PyTorch documentation for all matter related to general usage
|
| 1023 |
+
and behavior.
|
| 1024 |
+
|
| 1025 |
+
Parameters:
|
| 1026 |
+
config ([`Qwen2Config`]):
|
| 1027 |
+
Model configuration class with all the parameters of the model. Initializing with a config file does not
|
| 1028 |
+
load the weights associated with the model, only the configuration. Check out the
|
| 1029 |
+
[`~PreTrainedModel.from_pretrained`] method to load the model weights.
|
| 1030 |
+
"""
|
| 1031 |
+
|
| 1032 |
+
|
| 1033 |
+
@add_start_docstrings(
|
| 1034 |
+
"The bare Qwen2 Model outputting raw hidden-states without any specific head on top.",
|
| 1035 |
+
QWEN2_START_DOCSTRING,
|
| 1036 |
+
)
|
| 1037 |
+
class Qwen2PreTrainedModel(PreTrainedModel):
|
| 1038 |
+
config_class = Qwen2Config
|
| 1039 |
+
base_model_prefix = "model"
|
| 1040 |
+
supports_gradient_checkpointing = True
|
| 1041 |
+
_no_split_modules = ["Qwen2DecoderLayer"]
|
| 1042 |
+
_skip_keys_device_placement = "past_key_values"
|
| 1043 |
+
_supports_flash_attn_2 = True
|
| 1044 |
+
_supports_sdpa = True
|
| 1045 |
+
_supports_cache_class = True
|
| 1046 |
+
|
| 1047 |
+
@classmethod
|
| 1048 |
+
def _autoset_attn_implementation(cls, config, *args, **kwargs):
|
| 1049 |
+
if getattr(config, '_attn_implementation', None) == 'magi':
|
| 1050 |
+
return config
|
| 1051 |
+
return super()._autoset_attn_implementation(config, *args, **kwargs)
|
| 1052 |
+
|
| 1053 |
+
def _check_and_adjust_attn_implementation(self, attn_implementation, is_init_check=False):
|
| 1054 |
+
if attn_implementation == "magi":
|
| 1055 |
+
return "magi"
|
| 1056 |
+
return super()._check_and_adjust_attn_implementation(attn_implementation, is_init_check)
|
| 1057 |
+
|
| 1058 |
+
def _init_weights(self, module):
|
| 1059 |
+
std = self.config.initializer_range
|
| 1060 |
+
if isinstance(module, nn.Linear):
|
| 1061 |
+
module.weight.data.normal_(mean=0.0, std=std)
|
| 1062 |
+
if module.bias is not None:
|
| 1063 |
+
module.bias.data.zero_()
|
| 1064 |
+
elif isinstance(module, nn.Embedding):
|
| 1065 |
+
module.weight.data.normal_(mean=0.0, std=std)
|
| 1066 |
+
if module.padding_idx is not None:
|
| 1067 |
+
module.weight.data[module.padding_idx].zero_()
|
| 1068 |
+
|
| 1069 |
+
|
| 1070 |
+
QWEN2_INPUTS_DOCSTRING = r"""
|
| 1071 |
+
Args:
|
| 1072 |
+
input_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`):
|
| 1073 |
+
Indices of input sequence tokens in the vocabulary. Padding will be ignored by default should you provide
|
| 1074 |
+
it.
|
| 1075 |
+
|
| 1076 |
+
Indices can be obtained using [`AutoTokenizer`]. See [`PreTrainedTokenizer.encode`] and
|
| 1077 |
+
[`PreTrainedTokenizer.__call__`] for details.
|
| 1078 |
+
|
| 1079 |
+
[What are input IDs?](../glossary#input-ids)
|
| 1080 |
+
attention_mask (`torch.Tensor` of shape `(batch_size, sequence_length)`, *optional*):
|
| 1081 |
+
Mask to avoid performing attention on padding token indices. Mask values selected in `[0, 1]`:
|
| 1082 |
+
|
| 1083 |
+
- 1 for tokens that are **not masked**,
|
| 1084 |
+
- 0 for tokens that are **masked**.
|
| 1085 |
+
|
| 1086 |
+
[What are attention masks?](../glossary#attention-mask)
|
| 1087 |
+
|
| 1088 |
+
Indices can be obtained using [`AutoTokenizer`]. See [`PreTrainedTokenizer.encode`] and
|
| 1089 |
+
[`PreTrainedTokenizer.__call__`] for details.
|
| 1090 |
+
|
| 1091 |
+
If `past_key_values` is used, optionally only the last `decoder_input_ids` have to be input (see
|
| 1092 |
+
`past_key_values`).
|
| 1093 |
+
|
| 1094 |
+
If you want to change padding behavior, you should read [`modeling_opt._prepare_decoder_attention_mask`]
|
| 1095 |
+
and modify to your needs. See diagram 1 in [the paper](https://arxiv.org/abs/1910.13461) for more
|
| 1096 |
+
information on the default strategy.
|
| 1097 |
+
|
| 1098 |
+
- 1 indicates the head is **not masked**,
|
| 1099 |
+
- 0 indicates the head is **masked**.
|
| 1100 |
+
position_ids (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
|
| 1101 |
+
Indices of positions of each input sequence tokens in the position embeddings. Selected in the range `[0,
|
| 1102 |
+
config.n_positions - 1]`.
|
| 1103 |
+
|
| 1104 |
+
[What are position IDs?](../glossary#position-ids)
|
| 1105 |
+
past_key_values (`Cache` or `tuple(tuple(torch.FloatTensor))`, *optional*):
|
| 1106 |
+
Pre-computed hidden-states (key and values in the self-attention blocks and in the cross-attention
|
| 1107 |
+
blocks) that can be used to speed up sequential decoding. This typically consists in the `past_key_values`
|
| 1108 |
+
returned by the model at a previous stage of decoding, when `use_cache=True` or `config.use_cache=True`.
|
| 1109 |
+
|
| 1110 |
+
Two formats are allowed:
|
| 1111 |
+
- a [`~cache_utils.Cache`] instance;
|
| 1112 |
+
- Tuple of `tuple(torch.FloatTensor)` of length `config.n_layers`, with each tuple having 2 tensors of
|
| 1113 |
+
shape `(batch_size, num_heads, sequence_length, embed_size_per_head)`). This is also known as the legacy
|
| 1114 |
+
cache format.
|
| 1115 |
+
|
| 1116 |
+
The model will output the same cache format that is fed as input. If no `past_key_values` are passed, the
|
| 1117 |
+
legacy cache format will be returned.
|
| 1118 |
+
|
| 1119 |
+
If `past_key_values` are used, the user can optionally input only the last `input_ids` (those that don't
|
| 1120 |
+
have their past key value states given to this model) of shape `(batch_size, 1)` instead of all `input_ids`
|
| 1121 |
+
of shape `(batch_size, sequence_length)`.
|
| 1122 |
+
inputs_embeds (`torch.FloatTensor` of shape `(batch_size, sequence_length, hidden_size)`, *optional*):
|
| 1123 |
+
Optionally, instead of passing `input_ids` you can choose to directly pass an embedded representation. This
|
| 1124 |
+
is useful if you want more control over how to convert `input_ids` indices into associated vectors than the
|
| 1125 |
+
model's internal embedding lookup matrix.
|
| 1126 |
+
use_cache (`bool`, *optional*):
|
| 1127 |
+
If set to `True`, `past_key_values` key value states are returned and can be used to speed up decoding (see
|
| 1128 |
+
`past_key_values`).
|
| 1129 |
+
output_attentions (`bool`, *optional*):
|
| 1130 |
+
Whether or not to return the attentions tensors of all attention layers. See `attentions` under returned
|
| 1131 |
+
tensors for more detail.
|
| 1132 |
+
output_hidden_states (`bool`, *optional*):
|
| 1133 |
+
Whether or not to return the hidden states of all layers. See `hidden_states` under returned tensors for
|
| 1134 |
+
more detail.
|
| 1135 |
+
return_dict (`bool`, *optional*):
|
| 1136 |
+
Whether or not to return a [`~utils.ModelOutput`] instead of a plain tuple.
|
| 1137 |
+
"""
|
| 1138 |
+
|
| 1139 |
+
|
| 1140 |
+
@add_start_docstrings(
|
| 1141 |
+
"The bare Qwen2 Model outputting raw hidden-states without any specific head on top.",
|
| 1142 |
+
QWEN2_START_DOCSTRING,
|
| 1143 |
+
)
|
| 1144 |
+
class Qwen2Model(Qwen2PreTrainedModel):
|
| 1145 |
+
"""
|
| 1146 |
+
Transformer decoder consisting of *config.num_hidden_layers* layers. Each layer is a [`Qwen2DecoderLayer`]
|
| 1147 |
+
|
| 1148 |
+
Args:
|
| 1149 |
+
config: Qwen2Config
|
| 1150 |
+
"""
|
| 1151 |
+
|
| 1152 |
+
def __init__(self, config: Qwen2Config):
|
| 1153 |
+
super().__init__(config)
|
| 1154 |
+
self.padding_idx = config.pad_token_id
|
| 1155 |
+
self.vocab_size = config.vocab_size
|
| 1156 |
+
|
| 1157 |
+
self.embed_tokens = nn.Embedding(config.vocab_size, config.hidden_size, self.padding_idx)
|
| 1158 |
+
self.layers = nn.ModuleList(
|
| 1159 |
+
[Qwen2DecoderLayer(config, layer_idx) for layer_idx in range(config.num_hidden_layers)]
|
| 1160 |
+
)
|
| 1161 |
+
self._attn_implementation = config._attn_implementation
|
| 1162 |
+
self.norm = Qwen2RMSNorm(config.hidden_size, eps=config.rms_norm_eps)
|
| 1163 |
+
|
| 1164 |
+
self.gradient_checkpointing = False
|
| 1165 |
+
# Initialize weights and apply final processing
|
| 1166 |
+
self.post_init()
|
| 1167 |
+
|
| 1168 |
+
self.block_size = getattr(config, 'block_size', 6)
|
| 1169 |
+
self.causal_attn = getattr(config, 'causal_attn', False)
|
| 1170 |
+
self.text_mask_token_id = getattr(config, 'text_mask_token_id', 151676)
|
| 1171 |
+
|
| 1172 |
+
|
| 1173 |
+
def get_input_embeddings(self):
|
| 1174 |
+
return self.embed_tokens
|
| 1175 |
+
|
| 1176 |
+
def set_input_embeddings(self, value):
|
| 1177 |
+
self.embed_tokens = value
|
| 1178 |
+
|
| 1179 |
+
def image_processing(self, input_ids, visual_features, image_token_index):
|
| 1180 |
+
if visual_features is not None:
|
| 1181 |
+
input_embeds = self.get_input_embeddings()(input_ids)
|
| 1182 |
+
B, N, C = input_embeds.shape
|
| 1183 |
+
input_embeds = input_embeds.reshape(B * N, C)
|
| 1184 |
+
|
| 1185 |
+
input_ids = input_ids.reshape(B * N)
|
| 1186 |
+
selected = (input_ids == image_token_index)
|
| 1187 |
+
assert selected.sum() != 0
|
| 1188 |
+
input_embeds[selected] = visual_features.reshape(-1, C).to(input_embeds.device)
|
| 1189 |
+
input_embeds = input_embeds.reshape(B, N, C)
|
| 1190 |
+
else:
|
| 1191 |
+
input_embeds = self.get_input_embeddings()(input_ids)
|
| 1192 |
+
return input_embeds
|
| 1193 |
+
|
| 1194 |
+
@add_start_docstrings_to_model_forward(QWEN2_INPUTS_DOCSTRING)
|
| 1195 |
+
def forward(
|
| 1196 |
+
self,
|
| 1197 |
+
input_ids: torch.LongTensor = None,
|
| 1198 |
+
visual_features: Optional[torch.FloatTensor] = None,
|
| 1199 |
+
image_token_index: int = None,
|
| 1200 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 1201 |
+
position_ids: Optional[torch.LongTensor] = None,
|
| 1202 |
+
past_key_values: Optional[List[torch.FloatTensor]] = None,
|
| 1203 |
+
inputs_embeds: Optional[torch.FloatTensor] = None,
|
| 1204 |
+
use_cache: Optional[bool] = None,
|
| 1205 |
+
output_attentions: Optional[bool] = None,
|
| 1206 |
+
output_hidden_states: Optional[bool] = None,
|
| 1207 |
+
return_dict: Optional[bool] = None,
|
| 1208 |
+
) -> Union[Tuple, BaseModelOutputWithPast]:
|
| 1209 |
+
output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
|
| 1210 |
+
output_hidden_states = (
|
| 1211 |
+
output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
|
| 1212 |
+
)
|
| 1213 |
+
use_cache = use_cache if use_cache is not None else self.config.use_cache
|
| 1214 |
+
|
| 1215 |
+
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
| 1216 |
+
|
| 1217 |
+
# retrieve input_ids and inputs_embeds
|
| 1218 |
+
if input_ids is not None and inputs_embeds is not None:
|
| 1219 |
+
raise ValueError("You cannot specify both decoder_input_ids and decoder_inputs_embeds at the same time")
|
| 1220 |
+
elif input_ids is not None:
|
| 1221 |
+
batch_size, seq_length = input_ids.shape
|
| 1222 |
+
elif inputs_embeds is not None:
|
| 1223 |
+
batch_size, seq_length, _ = inputs_embeds.shape
|
| 1224 |
+
else:
|
| 1225 |
+
raise ValueError("You have to specify either decoder_input_ids or decoder_inputs_embeds")
|
| 1226 |
+
|
| 1227 |
+
if self.gradient_checkpointing and self.training:
|
| 1228 |
+
if use_cache:
|
| 1229 |
+
logger.warning_once(
|
| 1230 |
+
"`use_cache=True` is incompatible with gradient checkpointing. Setting `use_cache=False`..."
|
| 1231 |
+
)
|
| 1232 |
+
use_cache = False
|
| 1233 |
+
|
| 1234 |
+
past_key_values_length = 0
|
| 1235 |
+
|
| 1236 |
+
if use_cache:
|
| 1237 |
+
use_legacy_cache = not isinstance(past_key_values, Cache)
|
| 1238 |
+
if use_legacy_cache:
|
| 1239 |
+
if past_key_values is None:
|
| 1240 |
+
past_key_values = DynamicCache()
|
| 1241 |
+
else:
|
| 1242 |
+
past_key_values = DynamicCache.from_legacy_cache(past_key_values)
|
| 1243 |
+
past_key_values_length = past_key_values.get_seq_length()
|
| 1244 |
+
|
| 1245 |
+
if position_ids is None:
|
| 1246 |
+
device = input_ids.device if input_ids is not None else inputs_embeds.device
|
| 1247 |
+
position_ids = torch.arange(
|
| 1248 |
+
past_key_values_length, seq_length + past_key_values_length, dtype=torch.long, device=device
|
| 1249 |
+
)
|
| 1250 |
+
position_ids = position_ids.unsqueeze(0).view(-1, seq_length)
|
| 1251 |
+
else:
|
| 1252 |
+
position_ids = position_ids.view(-1, seq_length).long()
|
| 1253 |
+
|
| 1254 |
+
if inputs_embeds is None:
|
| 1255 |
+
inputs_embeds = self.image_processing(input_ids, visual_features, image_token_index)
|
| 1256 |
+
|
| 1257 |
+
if attention_mask is not None and self._attn_implementation == "magi" and use_cache:
|
| 1258 |
+
is_padding_right = attention_mask[:, -1].sum().item() != batch_size
|
| 1259 |
+
if is_padding_right:
|
| 1260 |
+
raise ValueError(
|
| 1261 |
+
"You are attempting to perform batched generation with padding_side='right'"
|
| 1262 |
+
" this may lead to unexpected behaviour for Flash Attention version of Qwen2. Make sure to "
|
| 1263 |
+
" call `tokenizer.padding_side = 'left'` before tokenizing the input. "
|
| 1264 |
+
)
|
| 1265 |
+
|
| 1266 |
+
device = input_ids.device if input_ids is not None else inputs_embeds.device
|
| 1267 |
+
|
| 1268 |
+
x0_len = find_prefix_seq_length_by_pe(position_ids).to(device=device)
|
| 1269 |
+
|
| 1270 |
+
def _prepare_block_mask_for_inference(attention_mask):
|
| 1271 |
+
attention_mask = _prepare_4d_causal_attention_mask(
|
| 1272 |
+
attention_mask,
|
| 1273 |
+
(batch_size, seq_length),
|
| 1274 |
+
inputs_embeds,
|
| 1275 |
+
past_key_values_length,
|
| 1276 |
+
sliding_window=self.config.sliding_window,
|
| 1277 |
+
)
|
| 1278 |
+
# switch to ar mode
|
| 1279 |
+
if seq_length == 1 or (input_ids is not None and input_ids[0][-1].item() != self.text_mask_token_id):
|
| 1280 |
+
return attention_mask
|
| 1281 |
+
|
| 1282 |
+
|
| 1283 |
+
if attention_mask is None or len(attention_mask.shape) != 4:
|
| 1284 |
+
return attention_mask
|
| 1285 |
+
|
| 1286 |
+
# For SDLM, the generation window should set to bidirectional attention
|
| 1287 |
+
if use_cache:
|
| 1288 |
+
update_mask_func = partial(
|
| 1289 |
+
update_causal_mask_for_one_gen_window_2d,
|
| 1290 |
+
block_size=self.block_size,
|
| 1291 |
+
use_cache=use_cache,
|
| 1292 |
+
causal_attn=self.causal_attn,
|
| 1293 |
+
)
|
| 1294 |
+
else:
|
| 1295 |
+
update_mask_func = partial(
|
| 1296 |
+
update_causal_mask_with_pad_non_visible_2d,
|
| 1297 |
+
block_size=self.block_size,
|
| 1298 |
+
text_mask_token_id=self.text_mask_token_id,
|
| 1299 |
+
causal_attn=self.causal_attn,
|
| 1300 |
+
)
|
| 1301 |
+
|
| 1302 |
+
new_attention_mask = []
|
| 1303 |
+
for b in range(attention_mask.shape[0]):
|
| 1304 |
+
new_attention_mask.append(
|
| 1305 |
+
update_mask_func(
|
| 1306 |
+
input_ids[b],
|
| 1307 |
+
attention_mask[b][0],
|
| 1308 |
+
).unsqueeze(0)
|
| 1309 |
+
)
|
| 1310 |
+
return torch.stack(new_attention_mask, dim=0)
|
| 1311 |
+
|
| 1312 |
+
def _prepare_block_mask_for_training():
|
| 1313 |
+
block_mask, _ = create_block_diff_mask_by_pe_4d(
|
| 1314 |
+
block_size=self.block_size,
|
| 1315 |
+
x0_len_list=x0_len,
|
| 1316 |
+
position_ids=position_ids,
|
| 1317 |
+
causal_attn=self.causal_attn,
|
| 1318 |
+
)
|
| 1319 |
+
return block_mask
|
| 1320 |
+
|
| 1321 |
+
if self._attn_implementation == "magi":
|
| 1322 |
+
ar_decode = seq_length == 1 or (input_ids is not None and input_ids[0][-1].item() != self.text_mask_token_id)
|
| 1323 |
+
attention_mask = build_magi_ranges(
|
| 1324 |
+
kv_len=seq_length + past_key_values_length,
|
| 1325 |
+
q_len=seq_length,
|
| 1326 |
+
block_size=self.block_size,
|
| 1327 |
+
ar_decode=ar_decode,
|
| 1328 |
+
device=device
|
| 1329 |
+
)
|
| 1330 |
+
|
| 1331 |
+
elif self._attn_implementation == "sdpa":
|
| 1332 |
+
attention_mask = _prepare_block_mask_for_training() if self.training else _prepare_block_mask_for_inference(attention_mask)
|
| 1333 |
+
|
| 1334 |
+
else:
|
| 1335 |
+
raise NotImplementedError(f'{self._attn_implementation=}')
|
| 1336 |
+
|
| 1337 |
+
|
| 1338 |
+
hidden_states = inputs_embeds
|
| 1339 |
+
|
| 1340 |
+
# decoder layers
|
| 1341 |
+
all_hidden_states = () if output_hidden_states else None
|
| 1342 |
+
all_self_attns = () if output_attentions else None
|
| 1343 |
+
next_decoder_cache = None
|
| 1344 |
+
|
| 1345 |
+
for decoder_layer in self.layers:
|
| 1346 |
+
if output_hidden_states:
|
| 1347 |
+
all_hidden_states += (hidden_states,)
|
| 1348 |
+
|
| 1349 |
+
if self.gradient_checkpointing and self.training:
|
| 1350 |
+
layer_outputs = self._gradient_checkpointing_func(
|
| 1351 |
+
decoder_layer.__call__,
|
| 1352 |
+
hidden_states,
|
| 1353 |
+
attention_mask,
|
| 1354 |
+
position_ids,
|
| 1355 |
+
past_key_values,
|
| 1356 |
+
output_attentions,
|
| 1357 |
+
use_cache,
|
| 1358 |
+
)
|
| 1359 |
+
else:
|
| 1360 |
+
layer_outputs = decoder_layer(
|
| 1361 |
+
hidden_states,
|
| 1362 |
+
attention_mask=attention_mask,
|
| 1363 |
+
position_ids=position_ids,
|
| 1364 |
+
past_key_value=past_key_values,
|
| 1365 |
+
output_attentions=output_attentions,
|
| 1366 |
+
use_cache=use_cache,
|
| 1367 |
+
)
|
| 1368 |
+
|
| 1369 |
+
hidden_states = layer_outputs[0]
|
| 1370 |
+
|
| 1371 |
+
if use_cache:
|
| 1372 |
+
next_decoder_cache = layer_outputs[2 if output_attentions else 1]
|
| 1373 |
+
|
| 1374 |
+
if output_attentions:
|
| 1375 |
+
all_self_attns += (layer_outputs[1],)
|
| 1376 |
+
|
| 1377 |
+
hidden_states = self.norm(hidden_states)
|
| 1378 |
+
|
| 1379 |
+
# add hidden states from the last decoder layer
|
| 1380 |
+
if output_hidden_states:
|
| 1381 |
+
all_hidden_states += (hidden_states,)
|
| 1382 |
+
|
| 1383 |
+
next_cache = None
|
| 1384 |
+
if use_cache:
|
| 1385 |
+
next_cache = next_decoder_cache.to_legacy_cache() if use_legacy_cache else next_decoder_cache
|
| 1386 |
+
|
| 1387 |
+
if not return_dict:
|
| 1388 |
+
return tuple(v for v in [hidden_states, next_cache, all_hidden_states, all_self_attns] if v is not None)
|
| 1389 |
+
return BaseModelOutputWithPast(
|
| 1390 |
+
last_hidden_state=hidden_states,
|
| 1391 |
+
past_key_values=next_cache,
|
| 1392 |
+
hidden_states=all_hidden_states,
|
| 1393 |
+
attentions=all_self_attns,
|
| 1394 |
+
)
|
| 1395 |
+
|
| 1396 |
+
|
| 1397 |
+
class Qwen2ForCausalLM(Qwen2PreTrainedModel):
|
| 1398 |
+
_tied_weights_keys = ["lm_head.weight"]
|
| 1399 |
+
|
| 1400 |
+
def __init__(self, config):
|
| 1401 |
+
super().__init__(config)
|
| 1402 |
+
self.model = Qwen2Model(config)
|
| 1403 |
+
self.vocab_size = config.vocab_size
|
| 1404 |
+
self.lm_head = nn.Linear(config.hidden_size, config.vocab_size, bias=False)
|
| 1405 |
+
|
| 1406 |
+
self.text_mask_token_id = getattr(config, 'text_mask_token_id', 151676)
|
| 1407 |
+
|
| 1408 |
+
# Initialize weights and apply final processing
|
| 1409 |
+
self.post_init()
|
| 1410 |
+
|
| 1411 |
+
|
| 1412 |
+
def get_input_embeddings(self):
|
| 1413 |
+
return self.model.embed_tokens
|
| 1414 |
+
|
| 1415 |
+
def set_input_embeddings(self, value):
|
| 1416 |
+
self.model.embed_tokens = value
|
| 1417 |
+
|
| 1418 |
+
def get_output_embeddings(self):
|
| 1419 |
+
return self.lm_head
|
| 1420 |
+
|
| 1421 |
+
def set_output_embeddings(self, new_embeddings):
|
| 1422 |
+
self.lm_head = new_embeddings
|
| 1423 |
+
|
| 1424 |
+
def set_decoder(self, decoder):
|
| 1425 |
+
self.model = decoder
|
| 1426 |
+
|
| 1427 |
+
def get_decoder(self):
|
| 1428 |
+
return self.model
|
| 1429 |
+
|
| 1430 |
+
@add_start_docstrings_to_model_forward(QWEN2_INPUTS_DOCSTRING)
|
| 1431 |
+
@replace_return_docstrings(output_type=CausalLMOutputWithPast, config_class=_CONFIG_FOR_DOC)
|
| 1432 |
+
def forward(
|
| 1433 |
+
self,
|
| 1434 |
+
input_ids: torch.LongTensor = None,
|
| 1435 |
+
visual_features: Optional[torch.FloatTensor] = None,
|
| 1436 |
+
image_token_index: int = None,
|
| 1437 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 1438 |
+
position_ids: Optional[torch.LongTensor] = None,
|
| 1439 |
+
past_key_values: Optional[List[torch.FloatTensor]] = None,
|
| 1440 |
+
inputs_embeds: Optional[torch.FloatTensor] = None,
|
| 1441 |
+
labels: Optional[torch.LongTensor] = None,
|
| 1442 |
+
use_cache: Optional[bool] = None,
|
| 1443 |
+
output_attentions: Optional[bool] = None,
|
| 1444 |
+
output_hidden_states: Optional[bool] = None,
|
| 1445 |
+
return_dict: Optional[bool] = None,
|
| 1446 |
+
) -> Union[Tuple, CausalLMOutputWithPast]:
|
| 1447 |
+
r"""
|
| 1448 |
+
Args:
|
| 1449 |
+
labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
|
| 1450 |
+
Labels for computing the masked language modeling loss. Indices should either be in `[0, ...,
|
| 1451 |
+
config.vocab_size]` or -100 (see `input_ids` docstring). Tokens with indices set to `-100` are ignored
|
| 1452 |
+
(masked), the loss is only computed for the tokens with labels in `[0, ..., config.vocab_size]`.
|
| 1453 |
+
|
| 1454 |
+
Returns:
|
| 1455 |
+
|
| 1456 |
+
Example:
|
| 1457 |
+
|
| 1458 |
+
```python
|
| 1459 |
+
>>> from transformers import AutoTokenizer, Qwen2ForCausalLM
|
| 1460 |
+
|
| 1461 |
+
>>> model = Qwen2ForCausalLM.from_pretrained(PATH_TO_CONVERTED_WEIGHTS)
|
| 1462 |
+
>>> tokenizer = AutoTokenizer.from_pretrained(PATH_TO_CONVERTED_TOKENIZER)
|
| 1463 |
+
|
| 1464 |
+
>>> prompt = "Hey, are you conscious? Can you talk to me?"
|
| 1465 |
+
>>> inputs = tokenizer(prompt, return_tensors="pt")
|
| 1466 |
+
|
| 1467 |
+
>>> # Generate
|
| 1468 |
+
>>> generate_ids = model.generate(inputs.input_ids, max_length=30)
|
| 1469 |
+
>>> tokenizer.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]
|
| 1470 |
+
"Hey, are you conscious? Can you talk to me?\nI'm not conscious, but I can talk to you."
|
| 1471 |
+
```"""
|
| 1472 |
+
|
| 1473 |
+
output_attentions = output_attentions if output_attentions is not None else self.config.output_attentions
|
| 1474 |
+
output_hidden_states = (
|
| 1475 |
+
output_hidden_states if output_hidden_states is not None else self.config.output_hidden_states
|
| 1476 |
+
)
|
| 1477 |
+
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
| 1478 |
+
|
| 1479 |
+
# decoder outputs consists of (dec_features, layer_state, dec_hidden, dec_attn)
|
| 1480 |
+
outputs = self.model(
|
| 1481 |
+
input_ids=input_ids,
|
| 1482 |
+
visual_features=visual_features,
|
| 1483 |
+
image_token_index=image_token_index,
|
| 1484 |
+
attention_mask=attention_mask,
|
| 1485 |
+
position_ids=position_ids,
|
| 1486 |
+
past_key_values=past_key_values,
|
| 1487 |
+
inputs_embeds=inputs_embeds,
|
| 1488 |
+
use_cache=use_cache,
|
| 1489 |
+
output_attentions=output_attentions,
|
| 1490 |
+
output_hidden_states=output_hidden_states,
|
| 1491 |
+
return_dict=return_dict,
|
| 1492 |
+
)
|
| 1493 |
+
|
| 1494 |
+
hidden_states = outputs[0]
|
| 1495 |
+
logits = self.lm_head(hidden_states)
|
| 1496 |
+
logits = logits.float()
|
| 1497 |
+
|
| 1498 |
+
loss = None
|
| 1499 |
+
if labels is not None:
|
| 1500 |
+
|
| 1501 |
+
# Shift so that tokens < n predict n
|
| 1502 |
+
shift_logits = logits[..., :-1, :].contiguous()
|
| 1503 |
+
shift_labels = labels[..., 1:].contiguous()
|
| 1504 |
+
|
| 1505 |
+
# Flatten the tokens
|
| 1506 |
+
loss_fct = CrossEntropyLoss()
|
| 1507 |
+
shift_logits = shift_logits.view(-1, self.config.vocab_size)
|
| 1508 |
+
|
| 1509 |
+
shift_labels = shift_labels.view(-1)
|
| 1510 |
+
shift_labels = shift_labels.to(shift_logits.device)
|
| 1511 |
+
loss = loss_fct(shift_logits, shift_labels)
|
| 1512 |
+
|
| 1513 |
+
pos_masks = find_pred_pos_from_input_ids(input_ids, text_mask_token_id=self.text_mask_token_id)
|
| 1514 |
+
shift_input_ids = input_ids[..., :-1].contiguous()
|
| 1515 |
+
shift_pos_masks = pos_masks[:, :-1]
|
| 1516 |
+
shift_input_ids = shift_input_ids.view(-1)
|
| 1517 |
+
max_n_future_tokens = min(4, self.model.block_size)
|
| 1518 |
+
pos_loss_list = torch.zeros(max_n_future_tokens, device=shift_logits.device)
|
| 1519 |
+
shift_pos_masks = shift_pos_masks.reshape(-1)
|
| 1520 |
+
|
| 1521 |
+
for ix in range(max_n_future_tokens):
|
| 1522 |
+
seg_loss = F.cross_entropy(
|
| 1523 |
+
shift_logits[shift_pos_masks == ix],
|
| 1524 |
+
shift_labels[shift_pos_masks == ix],
|
| 1525 |
+
reduction='mean'
|
| 1526 |
+
)
|
| 1527 |
+
pos_loss_list[ix] = seg_loss
|
| 1528 |
+
|
| 1529 |
+
|
| 1530 |
+
if not return_dict:
|
| 1531 |
+
output = (logits,) + outputs[1:]
|
| 1532 |
+
return (loss,) + output if loss is not None else output
|
| 1533 |
+
|
| 1534 |
+
if self.training:
|
| 1535 |
+
return CausalLMOutputWithPast(
|
| 1536 |
+
loss=loss,
|
| 1537 |
+
logits=logits,
|
| 1538 |
+
past_key_values=outputs.past_key_values,
|
| 1539 |
+
hidden_states=outputs.hidden_states,
|
| 1540 |
+
attentions=outputs.attentions,
|
| 1541 |
+
), pos_loss_list
|
| 1542 |
+
|
| 1543 |
+
return CausalLMOutputWithPast(
|
| 1544 |
+
loss=loss,
|
| 1545 |
+
logits=logits,
|
| 1546 |
+
past_key_values=outputs.past_key_values,
|
| 1547 |
+
hidden_states=outputs.hidden_states,
|
| 1548 |
+
attentions=outputs.attentions,
|
| 1549 |
+
)
|
| 1550 |
+
|
| 1551 |
+
def prepare_inputs_for_generation(
|
| 1552 |
+
self, input_ids, past_key_values=None, attention_mask=None, inputs_embeds=None, **kwargs
|
| 1553 |
+
):
|
| 1554 |
+
# Omit tokens covered by past_key_values
|
| 1555 |
+
if past_key_values is not None:
|
| 1556 |
+
if isinstance(past_key_values, Cache):
|
| 1557 |
+
cache_length = past_key_values.get_seq_length()
|
| 1558 |
+
past_length = past_key_values.seen_tokens
|
| 1559 |
+
max_cache_length = past_key_values.get_max_length()
|
| 1560 |
+
else:
|
| 1561 |
+
cache_length = past_length = past_key_values[0][0].shape[2]
|
| 1562 |
+
max_cache_length = None
|
| 1563 |
+
|
| 1564 |
+
# Keep only the unprocessed tokens:
|
| 1565 |
+
# 1 - If the length of the attention_mask exceeds the length of input_ids, then we are in a setting where
|
| 1566 |
+
# some of the inputs are exclusively passed as part of the cache (e.g. when passing input_embeds as
|
| 1567 |
+
# input)
|
| 1568 |
+
if attention_mask is not None and attention_mask.shape[1] > input_ids.shape[1]:
|
| 1569 |
+
input_ids = input_ids[:, -(attention_mask.shape[1] - past_length) :]
|
| 1570 |
+
# 2 - If the past_length is smaller than input_ids', then input_ids holds all input tokens. We can discard
|
| 1571 |
+
# input_ids based on the past_length.
|
| 1572 |
+
elif past_length < input_ids.shape[1]:
|
| 1573 |
+
input_ids = input_ids[:, past_length:]
|
| 1574 |
+
# 3 - Otherwise (past_length >= input_ids.shape[1]), let's assume input_ids only has unprocessed tokens.
|
| 1575 |
+
|
| 1576 |
+
# If we are about to go beyond the maximum cache length, we need to crop the input attention mask.
|
| 1577 |
+
if (
|
| 1578 |
+
max_cache_length is not None
|
| 1579 |
+
and attention_mask is not None
|
| 1580 |
+
and cache_length + input_ids.shape[1] > max_cache_length
|
| 1581 |
+
):
|
| 1582 |
+
attention_mask = attention_mask[:, -max_cache_length:]
|
| 1583 |
+
|
| 1584 |
+
position_ids = kwargs.get("position_ids", None)
|
| 1585 |
+
if attention_mask is not None and position_ids is None:
|
| 1586 |
+
# create position_ids on the fly for batch generation
|
| 1587 |
+
position_ids = attention_mask.long().cumsum(-1) - 1
|
| 1588 |
+
position_ids.masked_fill_(attention_mask == 0, 1)
|
| 1589 |
+
if past_key_values:
|
| 1590 |
+
position_ids = position_ids[:, -input_ids.shape[1] :]
|
| 1591 |
+
|
| 1592 |
+
# if `inputs_embeds` are passed, we only want to use them in the 1st generation step
|
| 1593 |
+
if inputs_embeds is not None and past_key_values is None:
|
| 1594 |
+
model_inputs = {"inputs_embeds": inputs_embeds}
|
| 1595 |
+
else:
|
| 1596 |
+
model_inputs = {"input_ids": input_ids}
|
| 1597 |
+
|
| 1598 |
+
model_inputs.update(
|
| 1599 |
+
{
|
| 1600 |
+
"position_ids": position_ids,
|
| 1601 |
+
"past_key_values": past_key_values,
|
| 1602 |
+
"use_cache": kwargs.get("use_cache"),
|
| 1603 |
+
"attention_mask": attention_mask,
|
| 1604 |
+
}
|
| 1605 |
+
)
|
| 1606 |
+
return model_inputs
|
| 1607 |
+
|
| 1608 |
+
@staticmethod
|
| 1609 |
+
def _reorder_cache(past_key_values, beam_idx):
|
| 1610 |
+
reordered_past = ()
|
| 1611 |
+
for layer_past in past_key_values:
|
| 1612 |
+
reordered_past += (
|
| 1613 |
+
tuple(past_state.index_select(0, beam_idx.to(past_state.device)) for past_state in layer_past),
|
| 1614 |
+
)
|
| 1615 |
+
return reordered_past
|
| 1616 |
+
|
| 1617 |
+
|
| 1618 |
+
@add_start_docstrings(
|
| 1619 |
+
"""
|
| 1620 |
+
The Qwen2 Model transformer with a sequence classification head on top (linear layer).
|
| 1621 |
+
|
| 1622 |
+
[`Qwen2ForSequenceClassification`] uses the last token in order to do the classification, as other causal models
|
| 1623 |
+
(e.g. GPT-2) do.
|
| 1624 |
+
|
| 1625 |
+
Since it does classification on the last token, it requires to know the position of the last token. If a
|
| 1626 |
+
`pad_token_id` is defined in the configuration, it finds the last token that is not a padding token in each row. If
|
| 1627 |
+
no `pad_token_id` is defined, it simply takes the last value in each row of the batch. Since it cannot guess the
|
| 1628 |
+
padding tokens when `inputs_embeds` are passed instead of `input_ids`, it does the same (take the last value in
|
| 1629 |
+
each row of the batch).
|
| 1630 |
+
""",
|
| 1631 |
+
QWEN2_START_DOCSTRING,
|
| 1632 |
+
)
|
| 1633 |
+
class Qwen2ForSequenceClassification(Qwen2PreTrainedModel):
|
| 1634 |
+
def __init__(self, config):
|
| 1635 |
+
super().__init__(config)
|
| 1636 |
+
self.num_labels = config.num_labels
|
| 1637 |
+
self.model = Qwen2Model(config)
|
| 1638 |
+
self.score = nn.Linear(config.hidden_size, self.num_labels, bias=False)
|
| 1639 |
+
|
| 1640 |
+
# Initialize weights and apply final processing
|
| 1641 |
+
self.post_init()
|
| 1642 |
+
|
| 1643 |
+
def get_input_embeddings(self):
|
| 1644 |
+
return self.model.embed_tokens
|
| 1645 |
+
|
| 1646 |
+
def set_input_embeddings(self, value):
|
| 1647 |
+
self.model.embed_tokens = value
|
| 1648 |
+
|
| 1649 |
+
@add_start_docstrings_to_model_forward(QWEN2_INPUTS_DOCSTRING)
|
| 1650 |
+
def forward(
|
| 1651 |
+
self,
|
| 1652 |
+
input_ids: torch.LongTensor = None,
|
| 1653 |
+
attention_mask: Optional[torch.Tensor] = None,
|
| 1654 |
+
position_ids: Optional[torch.LongTensor] = None,
|
| 1655 |
+
past_key_values: Optional[List[torch.FloatTensor]] = None,
|
| 1656 |
+
inputs_embeds: Optional[torch.FloatTensor] = None,
|
| 1657 |
+
labels: Optional[torch.LongTensor] = None,
|
| 1658 |
+
use_cache: Optional[bool] = None,
|
| 1659 |
+
output_attentions: Optional[bool] = None,
|
| 1660 |
+
output_hidden_states: Optional[bool] = None,
|
| 1661 |
+
return_dict: Optional[bool] = None,
|
| 1662 |
+
) -> Union[Tuple, SequenceClassifierOutputWithPast]:
|
| 1663 |
+
r"""
|
| 1664 |
+
labels (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
|
| 1665 |
+
Labels for computing the sequence classification/regression loss. Indices should be in `[0, ...,
|
| 1666 |
+
config.num_labels - 1]`. If `config.num_labels == 1` a regression loss is computed (Mean-Square loss), If
|
| 1667 |
+
`config.num_labels > 1` a classification loss is computed (Cross-Entropy).
|
| 1668 |
+
"""
|
| 1669 |
+
return_dict = return_dict if return_dict is not None else self.config.use_return_dict
|
| 1670 |
+
|
| 1671 |
+
transformer_outputs = self.model(
|
| 1672 |
+
input_ids,
|
| 1673 |
+
attention_mask=attention_mask,
|
| 1674 |
+
position_ids=position_ids,
|
| 1675 |
+
past_key_values=past_key_values,
|
| 1676 |
+
inputs_embeds=inputs_embeds,
|
| 1677 |
+
use_cache=use_cache,
|
| 1678 |
+
output_attentions=output_attentions,
|
| 1679 |
+
output_hidden_states=output_hidden_states,
|
| 1680 |
+
return_dict=return_dict,
|
| 1681 |
+
)
|
| 1682 |
+
hidden_states = transformer_outputs[0]
|
| 1683 |
+
logits = self.score(hidden_states)
|
| 1684 |
+
|
| 1685 |
+
if input_ids is not None:
|
| 1686 |
+
batch_size = input_ids.shape[0]
|
| 1687 |
+
else:
|
| 1688 |
+
batch_size = inputs_embeds.shape[0]
|
| 1689 |
+
|
| 1690 |
+
if self.config.pad_token_id is None and batch_size != 1:
|
| 1691 |
+
raise ValueError("Cannot handle batch sizes > 1 if no padding token is defined.")
|
| 1692 |
+
if self.config.pad_token_id is None:
|
| 1693 |
+
sequence_lengths = -1
|
| 1694 |
+
else:
|
| 1695 |
+
if input_ids is not None:
|
| 1696 |
+
# if no pad token found, use modulo instead of reverse indexing for ONNX compatibility
|
| 1697 |
+
sequence_lengths = torch.eq(input_ids, self.config.pad_token_id).int().argmax(-1) - 1
|
| 1698 |
+
sequence_lengths = sequence_lengths % input_ids.shape[-1]
|
| 1699 |
+
sequence_lengths = sequence_lengths.to(logits.device)
|
| 1700 |
+
else:
|
| 1701 |
+
sequence_lengths = -1
|
| 1702 |
+
|
| 1703 |
+
pooled_logits = logits[torch.arange(batch_size, device=logits.device), sequence_lengths]
|
| 1704 |
+
|
| 1705 |
+
loss = None
|
| 1706 |
+
if labels is not None:
|
| 1707 |
+
labels = labels.to(logits.device)
|
| 1708 |
+
if self.config.problem_type is None:
|
| 1709 |
+
if self.num_labels == 1:
|
| 1710 |
+
self.config.problem_type = "regression"
|
| 1711 |
+
elif self.num_labels > 1 and (labels.dtype == torch.long or labels.dtype == torch.int):
|
| 1712 |
+
self.config.problem_type = "single_label_classification"
|
| 1713 |
+
else:
|
| 1714 |
+
self.config.problem_type = "multi_label_classification"
|
| 1715 |
+
|
| 1716 |
+
if self.config.problem_type == "regression":
|
| 1717 |
+
loss_fct = MSELoss()
|
| 1718 |
+
if self.num_labels == 1:
|
| 1719 |
+
loss = loss_fct(pooled_logits.squeeze(), labels.squeeze())
|
| 1720 |
+
else:
|
| 1721 |
+
loss = loss_fct(pooled_logits, labels)
|
| 1722 |
+
elif self.config.problem_type == "single_label_classification":
|
| 1723 |
+
loss_fct = CrossEntropyLoss()
|
| 1724 |
+
loss = loss_fct(pooled_logits.view(-1, self.num_labels), labels.view(-1))
|
| 1725 |
+
elif self.config.problem_type == "multi_label_classification":
|
| 1726 |
+
loss_fct = BCEWithLogitsLoss()
|
| 1727 |
+
loss = loss_fct(pooled_logits, labels)
|
| 1728 |
+
if not return_dict:
|
| 1729 |
+
output = (pooled_logits,) + transformer_outputs[1:]
|
| 1730 |
+
return ((loss,) + output) if loss is not None else output
|
| 1731 |
+
|
| 1732 |
+
return SequenceClassifierOutputWithPast(
|
| 1733 |
+
loss=loss,
|
| 1734 |
+
logits=pooled_logits,
|
| 1735 |
+
past_key_values=transformer_outputs.past_key_values,
|
| 1736 |
+
hidden_states=transformer_outputs.hidden_states,
|
| 1737 |
+
attentions=transformer_outputs.attentions,
|
| 1738 |
+
)
|
qwen2.5_tokenizer/quant_log.csv
ADDED
|
@@ -0,0 +1,253 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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n.o_proj,0.0000002079,0.05000,0.973
|
| 6 |
+
0,mlp.gate_proj,0.0000028578,0.05000,1.696
|
| 7 |
+
0,mlp.up_proj,0.0000022065,0.05000,1.714
|
| 8 |
+
0,mlp.down_proj,0.0000005557,0.05000,4.253
|
| 9 |
+
1,self_attn.v_proj,0.0000000238,0.05000,3.020
|
| 10 |
+
1,self_attn.k_proj,0.0000001244,0.05000,3.038
|
| 11 |
+
1,self_attn.q_proj,0.0000004455,0.05000,3.103
|
| 12 |
+
1,self_attn.o_proj,0.0000000834,0.05000,0.920
|
| 13 |
+
1,mlp.up_proj,0.0000957824,0.05000,1.378
|
| 14 |
+
1,mlp.gate_proj,0.0001252921,0.05000,1.436
|
| 15 |
+
1,mlp.down_proj,0.0000000248,0.05000,4.110
|
| 16 |
+
2,self_attn.v_proj,0.0000000376,0.05000,3.022
|
| 17 |
+
2,self_attn.q_proj,0.0000006681,0.05000,3.177
|
| 18 |
+
2,self_attn.k_proj,0.0000001465,0.05000,3.203
|
| 19 |
+
2,self_attn.o_proj,0.0000000641,0.05000,1.082
|
| 20 |
+
2,mlp.gate_proj,0.0000304530,0.05000,1.268
|
| 21 |
+
2,mlp.up_proj,0.0000303662,0.05000,1.334
|
| 22 |
+
2,mlp.down_proj,0.0000120081,0.05000,4.371
|
| 23 |
+
3,self_attn.k_proj,0.0000006040,0.05000,3.001
|
| 24 |
+
3,self_attn.q_proj,0.0000028064,0.05000,3.063
|
| 25 |
+
3,self_attn.v_proj,0.0000001111,0.05000,3.032
|
| 26 |
+
3,self_attn.o_proj,0.0000000855,0.05000,0.928
|
| 27 |
+
3,mlp.up_proj,0.0000360368,0.05000,1.576
|
| 28 |
+
3,mlp.gate_proj,0.0000382443,0.05000,1.606
|
| 29 |
+
3,mlp.down_proj,0.0000003860,0.05000,4.249
|
| 30 |
+
4,self_attn.q_proj,0.0000022345,0.05000,3.843
|
| 31 |
+
4,self_attn.k_proj,0.0000004367,0.05000,3.907
|
| 32 |
+
4,self_attn.v_proj,0.0000001491,0.05000,3.939
|
| 33 |
+
4,self_attn.o_proj,0.0000001581,0.05000,0.863
|
| 34 |
+
4,mlp.up_proj,0.0000284978,0.05000,1.413
|
| 35 |
+
4,mlp.gate_proj,0.0000365522,0.05000,1.449
|
| 36 |
+
4,mlp.down_proj,0.0000003562,0.05000,4.254
|
| 37 |
+
5,self_attn.v_proj,0.0000004122,0.05000,2.760
|
| 38 |
+
5,self_attn.k_proj,0.0000008967,0.05000,2.809
|
| 39 |
+
5,self_attn.q_proj,0.0000050007,0.05000,2.831
|
| 40 |
+
5,self_attn.o_proj,0.0000001279,0.05000,0.942
|
| 41 |
+
5,mlp.gate_proj,0.0000520914,0.05000,1.275
|
| 42 |
+
5,mlp.up_proj,0.0000442293,0.05000,1.282
|
| 43 |
+
5,mlp.down_proj,0.0000007485,0.05000,5.679
|
| 44 |
+
6,self_attn.k_proj,0.0000004771,0.05000,3.021
|
| 45 |
+
6,self_attn.v_proj,0.0000003296,0.05000,3.142
|
| 46 |
+
6,self_attn.q_proj,0.0000030048,0.05000,3.150
|
| 47 |
+
6,self_attn.o_proj,0.0000002717,0.05000,0.938
|
| 48 |
+
6,mlp.up_proj,0.0000590103,0.05000,1.374
|
| 49 |
+
6,mlp.gate_proj,0.0000687621,0.05000,1.421
|
| 50 |
+
6,mlp.down_proj,0.0000011120,0.05000,4.512
|
| 51 |
+
7,self_attn.q_proj,0.0000041045,0.05000,2.921
|
| 52 |
+
7,self_attn.k_proj,0.0000006536,0.05000,2.968
|
| 53 |
+
7,self_attn.v_proj,0.0000004090,0.05000,2.974
|
| 54 |
+
7,self_attn.o_proj,0.0000002103,0.05000,0.866
|
| 55 |
+
7,mlp.gate_proj,0.0000712782,0.05000,1.340
|
| 56 |
+
7,mlp.up_proj,0.0000586724,0.05000,1.357
|
| 57 |
+
7,mlp.down_proj,0.0000014121,0.05000,4.585
|
| 58 |
+
8,self_attn.k_proj,0.0000006371,0.05000,3.163
|
| 59 |
+
8,self_attn.v_proj,0.0000004388,0.05000,3.356
|
| 60 |
+
8,self_attn.q_proj,0.0000041995,0.05000,3.369
|
| 61 |
+
8,self_attn.o_proj,0.0000002558,0.05000,0.978
|
| 62 |
+
8,mlp.up_proj,0.0000598540,0.05000,1.155
|
| 63 |
+
8,mlp.gate_proj,0.0000840462,0.05000,1.206
|
| 64 |
+
8,mlp.down_proj,0.0000018146,0.05000,4.143
|
| 65 |
+
9,self_attn.v_proj,0.0000003784,0.05000,2.766
|
| 66 |
+
9,self_attn.q_proj,0.0000037226,0.05000,2.783
|
| 67 |
+
9,self_attn.k_proj,0.0000006510,0.05000,2.768
|
| 68 |
+
9,self_attn.o_proj,0.0000004260,0.05000,0.930
|
| 69 |
+
9,mlp.up_proj,0.0000524589,0.05000,1.571
|
| 70 |
+
9,mlp.gate_proj,0.0000783262,0.05000,1.598
|
| 71 |
+
9,mlp.down_proj,0.0000024518,0.05000,5.082
|
| 72 |
+
10,self_attn.q_proj,0.0000052897,0.05000,2.622
|
| 73 |
+
10,self_attn.k_proj,0.0000007815,0.05000,2.717
|
| 74 |
+
10,self_attn.v_proj,0.0000006292,0.05000,2.743
|
| 75 |
+
10,self_attn.o_proj,0.0000003979,0.05000,1.276
|
| 76 |
+
10,mlp.gate_proj,0.0000586628,0.05000,1.290
|
| 77 |
+
10,mlp.up_proj,0.0000382535,0.05000,1.371
|
| 78 |
+
10,mlp.down_proj,0.0000026338,0.05000,4.219
|
| 79 |
+
11,self_attn.k_proj,0.0000005685,0.05000,2.966
|
| 80 |
+
11,self_attn.v_proj,0.0000005079,0.05000,2.980
|
| 81 |
+
11,self_attn.q_proj,0.0000038576,0.05000,2.991
|
| 82 |
+
11,self_attn.o_proj,0.0000005243,0.05000,1.047
|
| 83 |
+
11,mlp.up_proj,0.0000218057,0.05000,1.301
|
| 84 |
+
11,mlp.gate_proj,0.0000305343,0.05000,1.333
|
| 85 |
+
11,mlp.down_proj,0.0000027184,0.05000,4.218
|
| 86 |
+
12,self_attn.q_proj,0.0000040775,0.05000,2.488
|
| 87 |
+
12,self_attn.k_proj,0.0000006225,0.05000,2.505
|
| 88 |
+
12,self_attn.v_proj,0.0000004578,0.05000,2.521
|
| 89 |
+
12,self_attn.o_proj,0.0000004894,0.05000,0.662
|
| 90 |
+
12,mlp.gate_proj,0.0000336821,0.05000,1.277
|
| 91 |
+
12,mlp.up_proj,0.0000236778,0.05000,1.291
|
| 92 |
+
12,mlp.down_proj,0.0000022740,0.05000,4.415
|
| 93 |
+
13,self_attn.q_proj,0.0000048006,0.05000,3.943
|
| 94 |
+
13,self_attn.v_proj,0.0000003174,0.05000,3.952
|
| 95 |
+
13,self_attn.k_proj,0.0000008770,0.05000,3.995
|
| 96 |
+
13,self_attn.o_proj,0.0000003654,0.05000,0.734
|
| 97 |
+
13,mlp.gate_proj,0.0000177235,0.05000,1.341
|
| 98 |
+
13,mlp.up_proj,0.0000169780,0.05000,1.368
|
| 99 |
+
13,mlp.down_proj,0.0000021166,0.05000,4.304
|
| 100 |
+
14,self_attn.q_proj,0.0000036348,0.05000,2.822
|
| 101 |
+
14,self_attn.k_proj,0.0000005575,0.05000,2.855
|
| 102 |
+
14,self_attn.v_proj,0.0000003621,0.05000,2.864
|
| 103 |
+
14,self_attn.o_proj,0.0000007141,0.05000,1.039
|
| 104 |
+
14,mlp.up_proj,0.0000165291,0.05000,1.228
|
| 105 |
+
14,mlp.gate_proj,0.0000172143,0.05000,1.244
|
| 106 |
+
14,mlp.down_proj,0.0000020680,0.05000,4.865
|
| 107 |
+
15,self_attn.q_proj,0.0000037588,0.05000,2.502
|
| 108 |
+
15,self_attn.k_proj,0.0000005889,0.05000,2.505
|
| 109 |
+
15,self_attn.v_proj,0.0000003618,0.05000,2.549
|
| 110 |
+
15,self_attn.o_proj,0.0000008058,0.05000,0.835
|
| 111 |
+
15,mlp.up_proj,0.0000149748,0.05000,1.265
|
| 112 |
+
15,mlp.gate_proj,0.0000143409,0.05000,1.283
|
| 113 |
+
15,mlp.down_proj,0.0000018108,0.05000,4.185
|
| 114 |
+
16,self_attn.k_proj,0.0000006456,0.05000,2.311
|
| 115 |
+
16,self_attn.q_proj,0.0000038739,0.05000,2.370
|
| 116 |
+
16,self_attn.v_proj,0.0000003734,0.05000,2.386
|
| 117 |
+
16,self_attn.o_proj,0.0000005621,0.05000,0.878
|
| 118 |
+
16,mlp.gate_proj,0.0000152835,0.05000,1.159
|
| 119 |
+
16,mlp.up_proj,0.0000149767,0.05000,1.230
|
| 120 |
+
16,mlp.down_proj,0.0000016259,0.05000,5.022
|
| 121 |
+
17,self_attn.v_proj,0.0000005680,0.05000,2.477
|
| 122 |
+
17,self_attn.k_proj,0.0000010732,0.05000,2.463
|
| 123 |
+
17,self_attn.q_proj,0.0000062434,0.05000,2.502
|
| 124 |
+
17,self_attn.o_proj,0.0000006299,0.05000,0.774
|
| 125 |
+
17,mlp.up_proj,0.0000129082,0.05000,1.237
|
| 126 |
+
17,mlp.gate_proj,0.0000127357,0.05000,1.305
|
| 127 |
+
17,mlp.down_proj,0.0000018334,0.05000,4.142
|
| 128 |
+
18,self_attn.q_proj,0.0000035806,0.05000,2.411
|
| 129 |
+
18,self_attn.k_proj,0.0000005222,0.05000,2.460
|
| 130 |
+
18,self_attn.v_proj,0.0000003745,0.05000,2.489
|
| 131 |
+
18,self_attn.o_proj,0.0000006935,0.05000,1.018
|
| 132 |
+
18,mlp.up_proj,0.0000123926,0.05000,1.250
|
| 133 |
+
18,mlp.gate_proj,0.0000127913,0.05000,1.322
|
| 134 |
+
18,mlp.down_proj,0.0000014052,0.05000,4.173
|
| 135 |
+
19,self_attn.v_proj,0.0000003944,0.05000,3.463
|
| 136 |
+
19,self_attn.k_proj,0.0000006968,0.05000,3.586
|
| 137 |
+
19,self_attn.q_proj,0.0000039632,0.05000,3.608
|
| 138 |
+
19,self_attn.o_proj,0.0000009026,0.05000,0.818
|
| 139 |
+
19,mlp.gate_proj,0.0000114576,0.05000,1.112
|
| 140 |
+
19,mlp.up_proj,0.0000119524,0.05000,1.161
|
| 141 |
+
19,mlp.down_proj,0.0000014570,0.05000,4.321
|
| 142 |
+
20,self_attn.k_proj,0.0000007010,0.05000,2.711
|
| 143 |
+
20,self_attn.v_proj,0.0000007374,0.05000,2.718
|
| 144 |
+
20,self_attn.q_proj,0.0000060873,0.05000,2.745
|
| 145 |
+
20,self_attn.o_proj,0.0000007991,0.05000,0.912
|
| 146 |
+
20,mlp.gate_proj,0.0000118486,0.05000,1.426
|
| 147 |
+
20,mlp.up_proj,0.0000121822,0.05000,1.442
|
| 148 |
+
20,mlp.down_proj,0.0000014912,0.05000,4.249
|
| 149 |
+
21,self_attn.k_proj,0.0000007058,0.05000,2.460
|
| 150 |
+
21,self_attn.q_proj,0.0000043860,0.05000,2.542
|
| 151 |
+
21,self_attn.v_proj,0.0000004948,0.05000,2.576
|
| 152 |
+
21,self_attn.o_proj,0.0000006633,0.05000,0.855
|
| 153 |
+
21,mlp.up_proj,0.0000111701,0.05000,1.315
|
| 154 |
+
21,mlp.gate_proj,0.0000118580,0.05000,1.357
|
| 155 |
+
21,mlp.down_proj,0.0000010636,0.05000,4.237
|
| 156 |
+
22,self_attn.q_proj,0.0000050432,0.05000,2.470
|
| 157 |
+
22,self_attn.k_proj,0.0000007732,0.05000,2.483
|
| 158 |
+
22,self_attn.v_proj,0.0000006412,0.05000,2.494
|
| 159 |
+
22,self_attn.o_proj,0.0000006260,0.05000,0.899
|
| 160 |
+
22,mlp.gate_proj,0.0000112563,0.05000,1.363
|
| 161 |
+
22,mlp.up_proj,0.0000109995,0.05000,1.422
|
| 162 |
+
22,mlp.down_proj,0.0000010489,0.05000,4.304
|
| 163 |
+
23,self_attn.k_proj,0.0000007014,0.05000,3.266
|
| 164 |
+
23,self_attn.q_proj,0.0000048249,0.05000,3.317
|
| 165 |
+
23,self_attn.v_proj,0.0000003740,0.05000,3.373
|
| 166 |
+
23,self_attn.o_proj,0.0000007296,0.05000,0.939
|
| 167 |
+
23,mlp.gate_proj,0.0000105611,0.05000,1.372
|
| 168 |
+
23,mlp.up_proj,0.0000110128,0.05000,1.381
|
| 169 |
+
23,mlp.down_proj,0.0000012117,0.05000,4.254
|
| 170 |
+
24,self_attn.v_proj,0.0000004095,0.05000,2.385
|
| 171 |
+
24,self_attn.k_proj,0.0000004718,0.05000,2.412
|
| 172 |
+
24,self_attn.q_proj,0.0000034988,0.05000,2.413
|
| 173 |
+
24,self_attn.o_proj,0.0000007943,0.05000,0.955
|
| 174 |
+
24,mlp.up_proj,0.0000105276,0.05000,1.198
|
| 175 |
+
24,mlp.gate_proj,0.0000102487,0.05000,1.258
|
| 176 |
+
24,mlp.down_proj,0.0000014155,0.05000,4.128
|
| 177 |
+
25,self_attn.k_proj,0.0000004508,0.05000,2.690
|
| 178 |
+
25,self_attn.v_proj,0.0000006476,0.05000,2.825
|
| 179 |
+
25,self_attn.q_proj,0.0000047023,0.05000,2.832
|
| 180 |
+
25,self_attn.o_proj,0.0000006867,0.05000,0.852
|
| 181 |
+
25,mlp.up_proj,0.0000116300,0.05000,1.634
|
| 182 |
+
25,mlp.gate_proj,0.0000114514,0.05000,1.708
|
| 183 |
+
25,mlp.down_proj,0.0000016359,0.05000,4.386
|
| 184 |
+
26,self_attn.k_proj,0.0000004960,0.05000,3.098
|
| 185 |
+
26,self_attn.q_proj,0.0000038692,0.05000,3.103
|
| 186 |
+
26,self_attn.v_proj,0.0000006341,0.05000,3.127
|
| 187 |
+
26,self_attn.o_proj,0.0000009083,0.05000,0.835
|
| 188 |
+
26,mlp.up_proj,0.0000133298,0.05000,1.431
|
| 189 |
+
26,mlp.gate_proj,0.0000125842,0.05000,1.454
|
| 190 |
+
26,mlp.down_proj,0.0000022201,0.05000,4.144
|
| 191 |
+
27,self_attn.q_proj,0.0000063679,0.05000,3.371
|
| 192 |
+
27,self_attn.k_proj,0.0000005433,0.05000,3.429
|
| 193 |
+
27,self_attn.v_proj,0.0000008838,0.05000,3.431
|
| 194 |
+
27,self_attn.o_proj,0.0000011006,0.05000,1.076
|
| 195 |
+
27,mlp.gate_proj,0.0000139996,0.05000,1.350
|
| 196 |
+
27,mlp.up_proj,0.0000141233,0.05000,1.353
|
| 197 |
+
27,mlp.down_proj,0.0000025846,0.05000,4.317
|
| 198 |
+
28,self_attn.v_proj,0.0000008987,0.05000,4.054
|
| 199 |
+
28,self_attn.k_proj,0.0000005489,0.05000,4.102
|
| 200 |
+
28,self_attn.q_proj,0.0000051061,0.05000,4.118
|
| 201 |
+
28,self_attn.o_proj,0.0000011722,0.05000,1.007
|
| 202 |
+
28,mlp.up_proj,0.0000153893,0.05000,1.213
|
| 203 |
+
28,mlp.gate_proj,0.0000153670,0.05000,1.274
|
| 204 |
+
28,mlp.down_proj,0.0000028280,0.05000,4.456
|
| 205 |
+
29,self_attn.v_proj,0.0000007629,0.05000,3.439
|
| 206 |
+
29,self_attn.k_proj,0.0000005342,0.05000,3.521
|
| 207 |
+
29,self_attn.q_proj,0.0000046298,0.05000,3.534
|
| 208 |
+
29,self_attn.o_proj,0.0000009201,0.05000,0.812
|
| 209 |
+
29,mlp.gate_proj,0.0000180554,0.05000,1.402
|
| 210 |
+
29,mlp.up_proj,0.0000184227,0.05000,1.406
|
| 211 |
+
29,mlp.down_proj,0.0000038424,0.05000,4.300
|
| 212 |
+
30,self_attn.v_proj,0.0000020394,0.05000,3.110
|
| 213 |
+
30,self_attn.k_proj,0.0000006122,0.05000,3.143
|
| 214 |
+
30,self_attn.q_proj,0.0000070738,0.05000,3.167
|
| 215 |
+
30,self_attn.o_proj,0.0000011594,0.05000,1.005
|
| 216 |
+
30,mlp.gate_proj,0.0000228827,0.05000,1.470
|
| 217 |
+
30,mlp.up_proj,0.0000249021,0.05000,1.495
|
| 218 |
+
30,mlp.down_proj,0.0000158357,0.05000,4.416
|
| 219 |
+
31,self_attn.q_proj,0.0000093229,0.05000,2.831
|
| 220 |
+
31,self_attn.k_proj,0.0000009378,0.05000,2.882
|
| 221 |
+
31,self_attn.v_proj,0.0000024443,0.05000,2.891
|
| 222 |
+
31,self_attn.o_proj,0.0000030832,0.05000,0.684
|
| 223 |
+
31,mlp.gate_proj,0.0000264529,0.05000,1.345
|
| 224 |
+
31,mlp.up_proj,0.0000300895,0.05000,1.400
|
| 225 |
+
31,mlp.down_proj,0.0000134932,0.05000,4.460
|
| 226 |
+
32,self_attn.q_proj,0.0000164472,0.05000,3.071
|
| 227 |
+
32,self_attn.k_proj,0.0000014786,0.05000,3.103
|
| 228 |
+
32,self_attn.v_proj,0.0000073760,0.05000,3.108
|
| 229 |
+
32,self_attn.o_proj,0.0000065663,0.05000,0.774
|
| 230 |
+
32,mlp.up_proj,0.0000336128,0.05000,1.444
|
| 231 |
+
32,mlp.gate_proj,0.0000295613,0.05000,1.467
|
| 232 |
+
32,mlp.down_proj,0.0000133721,0.05000,4.501
|
| 233 |
+
33,self_attn.v_proj,0.0000151532,0.05000,2.874
|
| 234 |
+
33,self_attn.q_proj,0.0000151740,0.05000,2.961
|
| 235 |
+
33,self_attn.k_proj,0.0000012399,0.05000,2.964
|
| 236 |
+
33,self_attn.o_proj,0.0000136846,0.05000,0.722
|
| 237 |
+
33,mlp.gate_proj,0.0000268336,0.05000,1.449
|
| 238 |
+
33,mlp.up_proj,0.0000334955,0.05000,1.466
|
| 239 |
+
33,mlp.down_proj,0.0000303056,0.05000,4.839
|
| 240 |
+
34,self_attn.q_proj,0.0000051019,0.05000,3.116
|
| 241 |
+
34,self_attn.k_proj,0.0000005239,0.05000,3.161
|
| 242 |
+
34,self_attn.v_proj,0.0000017698,0.05000,3.193
|
| 243 |
+
34,self_attn.o_proj,0.0000030042,0.05000,0.749
|
| 244 |
+
34,mlp.up_proj,0.0000342593,0.05000,1.270
|
| 245 |
+
34,mlp.gate_proj,0.0000294181,0.05000,1.299
|
| 246 |
+
34,mlp.down_proj,0.0000177885,0.05000,4.654
|
| 247 |
+
35,self_attn.v_proj,0.0000014588,0.05000,3.398
|
| 248 |
+
35,self_attn.q_proj,0.0000045896,0.05000,3.432
|
| 249 |
+
35,self_attn.k_proj,0.0000004904,0.05000,3.471
|
| 250 |
+
35,self_attn.o_proj,0.0000032275,0.05000,0.855
|
| 251 |
+
35,mlp.gate_proj,0.0000420900,0.05000,1.395
|
| 252 |
+
35,mlp.up_proj,0.0000445427,0.05000,1.458
|
| 253 |
+
35,mlp.down_proj,0.0000312161,0.05000,4.283
|
qwen2.5_tokenizer/quantize_config.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"bits": 4,
|
| 3 |
+
"group_size": 128,
|
| 4 |
+
"desc_act": false,
|
| 5 |
+
"lm_head": false,
|
| 6 |
+
"method": "gptq",
|
| 7 |
+
"quant_method": "gptq",
|
| 8 |
+
"format": "gptq",
|
| 9 |
+
"checkpoint_format": "gptq",
|
| 10 |
+
"pack_dtype": "int32",
|
| 11 |
+
"meta": {
|
| 12 |
+
"quantizer": [
|
| 13 |
+
"gptqmodel:7.1.0"
|
| 14 |
+
],
|
| 15 |
+
"uri": "https://github.com/modelcloud/gptqmodel",
|
| 16 |
+
"damp_percent": 0.05,
|
| 17 |
+
"damp_auto_increment": 0.01,
|
| 18 |
+
"static_groups": false,
|
| 19 |
+
"true_sequential": true,
|
| 20 |
+
"mse": 0.0,
|
| 21 |
+
"gptaq": null,
|
| 22 |
+
"foem": null,
|
| 23 |
+
"act_group_aware": true,
|
| 24 |
+
"fallback": {
|
| 25 |
+
"strategy": "rtn",
|
| 26 |
+
"threshold": "0.5%",
|
| 27 |
+
"smooth": null
|
| 28 |
+
},
|
| 29 |
+
"offload_to_disk": true,
|
| 30 |
+
"offload_to_disk_path": "/tmp/gptqmodel_42jjgpwr",
|
| 31 |
+
"pack_impl": "cpu",
|
| 32 |
+
"gc_mode": "interval",
|
| 33 |
+
"wait_for_submodule_finalizers": false,
|
| 34 |
+
"auto_forward_data_parallel": true,
|
| 35 |
+
"dense_vram_strategy": "exclusive",
|
| 36 |
+
"dense_vram_strategy_devices": null,
|
| 37 |
+
"moe_vram_strategy": "exclusive",
|
| 38 |
+
"moe_vram_strategy_devices": null,
|
| 39 |
+
"mock_quantization": false,
|
| 40 |
+
"hessian": {
|
| 41 |
+
"chunk_size": null,
|
| 42 |
+
"chunk_bytes": null,
|
| 43 |
+
"staging_dtype": "float32"
|
| 44 |
+
}
|
| 45 |
+
},
|
| 46 |
+
"sym": true
|
| 47 |
+
}
|
qwen2.5_tokenizer/qwen2_5_tokenizer.txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
qwen2.5_tokenizer/special_tokens_map.json
ADDED
|
@@ -0,0 +1,1053 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"additional_special_tokens": [
|
| 3 |
+
"<|im_start|>",
|
| 4 |
+
"<|im_end|>",
|
| 5 |
+
"<|object_ref_start|>",
|
| 6 |
+
"<|object_ref_end|>",
|
| 7 |
+
"<|box_start|>",
|
| 8 |
+
"<|box_end|>",
|
| 9 |
+
"<|quad_start|>",
|
| 10 |
+
"<|quad_end|>",
|
| 11 |
+
"<|vision_start|>",
|
| 12 |
+
"<|vision_end|>",
|
| 13 |
+
"<|vision_pad|>",
|
| 14 |
+
"<|image_pad|>",
|
| 15 |
+
"<|video_pad|>",
|
| 16 |
+
"<IMG_CONTEXT>",
|
| 17 |
+
"<img>",
|
| 18 |
+
"</img>",
|
| 19 |
+
"<box>",
|
| 20 |
+
"</box>",
|
| 21 |
+
"<quad>",
|
| 22 |
+
"</quad>",
|
| 23 |
+
"<ref>",
|
| 24 |
+
"</ref>",
|
| 25 |
+
"<interval>",
|
| 26 |
+
"</interval>",
|
| 27 |
+
"<text_mask>",
|
| 28 |
+
"<0>",
|
| 29 |
+
"<1>",
|
| 30 |
+
"<2>",
|
| 31 |
+
"<3>",
|
| 32 |
+
"<4>",
|
| 33 |
+
"<5>",
|
| 34 |
+
"<6>",
|
| 35 |
+
"<7>",
|
| 36 |
+
"<8>",
|
| 37 |
+
"<9>",
|
| 38 |
+
"<10>",
|
| 39 |
+
"<11>",
|
| 40 |
+
"<12>",
|
| 41 |
+
"<13>",
|
| 42 |
+
"<14>",
|
| 43 |
+
"<15>",
|
| 44 |
+
"<16>",
|
| 45 |
+
"<17>",
|
| 46 |
+
"<18>",
|
| 47 |
+
"<19>",
|
| 48 |
+
"<20>",
|
| 49 |
+
"<21>",
|
| 50 |
+
"<22>",
|
| 51 |
+
"<23>",
|
| 52 |
+
"<24>",
|
| 53 |
+
"<25>",
|
| 54 |
+
"<26>",
|
| 55 |
+
"<27>",
|
| 56 |
+
"<28>",
|
| 57 |
+
"<29>",
|
| 58 |
+
"<30>",
|
| 59 |
+
"<31>",
|
| 60 |
+
"<32>",
|
| 61 |
+
"<33>",
|
| 62 |
+
"<34>",
|
| 63 |
+
"<35>",
|
| 64 |
+
"<36>",
|
| 65 |
+
"<37>",
|
| 66 |
+
"<38>",
|
| 67 |
+
"<39>",
|
| 68 |
+
"<40>",
|
| 69 |
+
"<41>",
|
| 70 |
+
"<42>",
|
| 71 |
+
"<43>",
|
| 72 |
+
"<44>",
|
| 73 |
+
"<45>",
|
| 74 |
+
"<46>",
|
| 75 |
+
"<47>",
|
| 76 |
+
"<48>",
|
| 77 |
+
"<49>",
|
| 78 |
+
"<50>",
|
| 79 |
+
"<51>",
|
| 80 |
+
"<52>",
|
| 81 |
+
"<53>",
|
| 82 |
+
"<54>",
|
| 83 |
+
"<55>",
|
| 84 |
+
"<56>",
|
| 85 |
+
"<57>",
|
| 86 |
+
"<58>",
|
| 87 |
+
"<59>",
|
| 88 |
+
"<60>",
|
| 89 |
+
"<61>",
|
| 90 |
+
"<62>",
|
| 91 |
+
"<63>",
|
| 92 |
+
"<64>",
|
| 93 |
+
"<65>",
|
| 94 |
+
"<66>",
|
| 95 |
+
"<67>",
|
| 96 |
+
"<68>",
|
| 97 |
+
"<69>",
|
| 98 |
+
"<70>",
|
| 99 |
+
"<71>",
|
| 100 |
+
"<72>",
|
| 101 |
+
"<73>",
|
| 102 |
+
"<74>",
|
| 103 |
+
"<75>",
|
| 104 |
+
"<76>",
|
| 105 |
+
"<77>",
|
| 106 |
+
"<78>",
|
| 107 |
+
"<79>",
|
| 108 |
+
"<80>",
|
| 109 |
+
"<81>",
|
| 110 |
+
"<82>",
|
| 111 |
+
"<83>",
|
| 112 |
+
"<84>",
|
| 113 |
+
"<85>",
|
| 114 |
+
"<86>",
|
| 115 |
+
"<87>",
|
| 116 |
+
"<88>",
|
| 117 |
+
"<89>",
|
| 118 |
+
"<90>",
|
| 119 |
+
"<91>",
|
| 120 |
+
"<92>",
|
| 121 |
+
"<93>",
|
| 122 |
+
"<94>",
|
| 123 |
+
"<95>",
|
| 124 |
+
"<96>",
|
| 125 |
+
"<97>",
|
| 126 |
+
"<98>",
|
| 127 |
+
"<99>",
|
| 128 |
+
"<100>",
|
| 129 |
+
"<101>",
|
| 130 |
+
"<102>",
|
| 131 |
+
"<103>",
|
| 132 |
+
"<104>",
|
| 133 |
+
"<105>",
|
| 134 |
+
"<106>",
|
| 135 |
+
"<107>",
|
| 136 |
+
"<108>",
|
| 137 |
+
"<109>",
|
| 138 |
+
"<110>",
|
| 139 |
+
"<111>",
|
| 140 |
+
"<112>",
|
| 141 |
+
"<113>",
|
| 142 |
+
"<114>",
|
| 143 |
+
"<115>",
|
| 144 |
+
"<116>",
|
| 145 |
+
"<117>",
|
| 146 |
+
"<118>",
|
| 147 |
+
"<119>",
|
| 148 |
+
"<120>",
|
| 149 |
+
"<121>",
|
| 150 |
+
"<122>",
|
| 151 |
+
"<123>",
|
| 152 |
+
"<124>",
|
| 153 |
+
"<125>",
|
| 154 |
+
"<126>",
|
| 155 |
+
"<127>",
|
| 156 |
+
"<128>",
|
| 157 |
+
"<129>",
|
| 158 |
+
"<130>",
|
| 159 |
+
"<131>",
|
| 160 |
+
"<132>",
|
| 161 |
+
"<133>",
|
| 162 |
+
"<134>",
|
| 163 |
+
"<135>",
|
| 164 |
+
"<136>",
|
| 165 |
+
"<137>",
|
| 166 |
+
"<138>",
|
| 167 |
+
"<139>",
|
| 168 |
+
"<140>",
|
| 169 |
+
"<141>",
|
| 170 |
+
"<142>",
|
| 171 |
+
"<143>",
|
| 172 |
+
"<144>",
|
| 173 |
+
"<145>",
|
| 174 |
+
"<146>",
|
| 175 |
+
"<147>",
|
| 176 |
+
"<148>",
|
| 177 |
+
"<149>",
|
| 178 |
+
"<150>",
|
| 179 |
+
"<151>",
|
| 180 |
+
"<152>",
|
| 181 |
+
"<153>",
|
| 182 |
+
"<154>",
|
| 183 |
+
"<155>",
|
| 184 |
+
"<156>",
|
| 185 |
+
"<157>",
|
| 186 |
+
"<158>",
|
| 187 |
+
"<159>",
|
| 188 |
+
"<160>",
|
| 189 |
+
"<161>",
|
| 190 |
+
"<162>",
|
| 191 |
+
"<163>",
|
| 192 |
+
"<164>",
|
| 193 |
+
"<165>",
|
| 194 |
+
"<166>",
|
| 195 |
+
"<167>",
|
| 196 |
+
"<168>",
|
| 197 |
+
"<169>",
|
| 198 |
+
"<170>",
|
| 199 |
+
"<171>",
|
| 200 |
+
"<172>",
|
| 201 |
+
"<173>",
|
| 202 |
+
"<174>",
|
| 203 |
+
"<175>",
|
| 204 |
+
"<176>",
|
| 205 |
+
"<177>",
|
| 206 |
+
"<178>",
|
| 207 |
+
"<179>",
|
| 208 |
+
"<180>",
|
| 209 |
+
"<181>",
|
| 210 |
+
"<182>",
|
| 211 |
+
"<183>",
|
| 212 |
+
"<184>",
|
| 213 |
+
"<185>",
|
| 214 |
+
"<186>",
|
| 215 |
+
"<187>",
|
| 216 |
+
"<188>",
|
| 217 |
+
"<189>",
|
| 218 |
+
"<190>",
|
| 219 |
+
"<191>",
|
| 220 |
+
"<192>",
|
| 221 |
+
"<193>",
|
| 222 |
+
"<194>",
|
| 223 |
+
"<195>",
|
| 224 |
+
"<196>",
|
| 225 |
+
"<197>",
|
| 226 |
+
"<198>",
|
| 227 |
+
"<199>",
|
| 228 |
+
"<200>",
|
| 229 |
+
"<201>",
|
| 230 |
+
"<202>",
|
| 231 |
+
"<203>",
|
| 232 |
+
"<204>",
|
| 233 |
+
"<205>",
|
| 234 |
+
"<206>",
|
| 235 |
+
"<207>",
|
| 236 |
+
"<208>",
|
| 237 |
+
"<209>",
|
| 238 |
+
"<210>",
|
| 239 |
+
"<211>",
|
| 240 |
+
"<212>",
|
| 241 |
+
"<213>",
|
| 242 |
+
"<214>",
|
| 243 |
+
"<215>",
|
| 244 |
+
"<216>",
|
| 245 |
+
"<217>",
|
| 246 |
+
"<218>",
|
| 247 |
+
"<219>",
|
| 248 |
+
"<220>",
|
| 249 |
+
"<221>",
|
| 250 |
+
"<222>",
|
| 251 |
+
"<223>",
|
| 252 |
+
"<224>",
|
| 253 |
+
"<225>",
|
| 254 |
+
"<226>",
|
| 255 |
+
"<227>",
|
| 256 |
+
"<228>",
|
| 257 |
+
"<229>",
|
| 258 |
+
"<230>",
|
| 259 |
+
"<231>",
|
| 260 |
+
"<232>",
|
| 261 |
+
"<233>",
|
| 262 |
+
"<234>",
|
| 263 |
+
"<235>",
|
| 264 |
+
"<236>",
|
| 265 |
+
"<237>",
|
| 266 |
+
"<238>",
|
| 267 |
+
"<239>",
|
| 268 |
+
"<240>",
|
| 269 |
+
"<241>",
|
| 270 |
+
"<242>",
|
| 271 |
+
"<243>",
|
| 272 |
+
"<244>",
|
| 273 |
+
"<245>",
|
| 274 |
+
"<246>",
|
| 275 |
+
"<247>",
|
| 276 |
+
"<248>",
|
| 277 |
+
"<249>",
|
| 278 |
+
"<250>",
|
| 279 |
+
"<251>",
|
| 280 |
+
"<252>",
|
| 281 |
+
"<253>",
|
| 282 |
+
"<254>",
|
| 283 |
+
"<255>",
|
| 284 |
+
"<256>",
|
| 285 |
+
"<257>",
|
| 286 |
+
"<258>",
|
| 287 |
+
"<259>",
|
| 288 |
+
"<260>",
|
| 289 |
+
"<261>",
|
| 290 |
+
"<262>",
|
| 291 |
+
"<263>",
|
| 292 |
+
"<264>",
|
| 293 |
+
"<265>",
|
| 294 |
+
"<266>",
|
| 295 |
+
"<267>",
|
| 296 |
+
"<268>",
|
| 297 |
+
"<269>",
|
| 298 |
+
"<270>",
|
| 299 |
+
"<271>",
|
| 300 |
+
"<272>",
|
| 301 |
+
"<273>",
|
| 302 |
+
"<274>",
|
| 303 |
+
"<275>",
|
| 304 |
+
"<276>",
|
| 305 |
+
"<277>",
|
| 306 |
+
"<278>",
|
| 307 |
+
"<279>",
|
| 308 |
+
"<280>",
|
| 309 |
+
"<281>",
|
| 310 |
+
"<282>",
|
| 311 |
+
"<283>",
|
| 312 |
+
"<284>",
|
| 313 |
+
"<285>",
|
| 314 |
+
"<286>",
|
| 315 |
+
"<287>",
|
| 316 |
+
"<288>",
|
| 317 |
+
"<289>",
|
| 318 |
+
"<290>",
|
| 319 |
+
"<291>",
|
| 320 |
+
"<292>",
|
| 321 |
+
"<293>",
|
| 322 |
+
"<294>",
|
| 323 |
+
"<295>",
|
| 324 |
+
"<296>",
|
| 325 |
+
"<297>",
|
| 326 |
+
"<298>",
|
| 327 |
+
"<299>",
|
| 328 |
+
"<300>",
|
| 329 |
+
"<301>",
|
| 330 |
+
"<302>",
|
| 331 |
+
"<303>",
|
| 332 |
+
"<304>",
|
| 333 |
+
"<305>",
|
| 334 |
+
"<306>",
|
| 335 |
+
"<307>",
|
| 336 |
+
"<308>",
|
| 337 |
+
"<309>",
|
| 338 |
+
"<310>",
|
| 339 |
+
"<311>",
|
| 340 |
+
"<312>",
|
| 341 |
+
"<313>",
|
| 342 |
+
"<314>",
|
| 343 |
+
"<315>",
|
| 344 |
+
"<316>",
|
| 345 |
+
"<317>",
|
| 346 |
+
"<318>",
|
| 347 |
+
"<319>",
|
| 348 |
+
"<320>",
|
| 349 |
+
"<321>",
|
| 350 |
+
"<322>",
|
| 351 |
+
"<323>",
|
| 352 |
+
"<324>",
|
| 353 |
+
"<325>",
|
| 354 |
+
"<326>",
|
| 355 |
+
"<327>",
|
| 356 |
+
"<328>",
|
| 357 |
+
"<329>",
|
| 358 |
+
"<330>",
|
| 359 |
+
"<331>",
|
| 360 |
+
"<332>",
|
| 361 |
+
"<333>",
|
| 362 |
+
"<334>",
|
| 363 |
+
"<335>",
|
| 364 |
+
"<336>",
|
| 365 |
+
"<337>",
|
| 366 |
+
"<338>",
|
| 367 |
+
"<339>",
|
| 368 |
+
"<340>",
|
| 369 |
+
"<341>",
|
| 370 |
+
"<342>",
|
| 371 |
+
"<343>",
|
| 372 |
+
"<344>",
|
| 373 |
+
"<345>",
|
| 374 |
+
"<346>",
|
| 375 |
+
"<347>",
|
| 376 |
+
"<348>",
|
| 377 |
+
"<349>",
|
| 378 |
+
"<350>",
|
| 379 |
+
"<351>",
|
| 380 |
+
"<352>",
|
| 381 |
+
"<353>",
|
| 382 |
+
"<354>",
|
| 383 |
+
"<355>",
|
| 384 |
+
"<356>",
|
| 385 |
+
"<357>",
|
| 386 |
+
"<358>",
|
| 387 |
+
"<359>",
|
| 388 |
+
"<360>",
|
| 389 |
+
"<361>",
|
| 390 |
+
"<362>",
|
| 391 |
+
"<363>",
|
| 392 |
+
"<364>",
|
| 393 |
+
"<365>",
|
| 394 |
+
"<366>",
|
| 395 |
+
"<367>",
|
| 396 |
+
"<368>",
|
| 397 |
+
"<369>",
|
| 398 |
+
"<370>",
|
| 399 |
+
"<371>",
|
| 400 |
+
"<372>",
|
| 401 |
+
"<373>",
|
| 402 |
+
"<374>",
|
| 403 |
+
"<375>",
|
| 404 |
+
"<376>",
|
| 405 |
+
"<377>",
|
| 406 |
+
"<378>",
|
| 407 |
+
"<379>",
|
| 408 |
+
"<380>",
|
| 409 |
+
"<381>",
|
| 410 |
+
"<382>",
|
| 411 |
+
"<383>",
|
| 412 |
+
"<384>",
|
| 413 |
+
"<385>",
|
| 414 |
+
"<386>",
|
| 415 |
+
"<387>",
|
| 416 |
+
"<388>",
|
| 417 |
+
"<389>",
|
| 418 |
+
"<390>",
|
| 419 |
+
"<391>",
|
| 420 |
+
"<392>",
|
| 421 |
+
"<393>",
|
| 422 |
+
"<394>",
|
| 423 |
+
"<395>",
|
| 424 |
+
"<396>",
|
| 425 |
+
"<397>",
|
| 426 |
+
"<398>",
|
| 427 |
+
"<399>",
|
| 428 |
+
"<400>",
|
| 429 |
+
"<401>",
|
| 430 |
+
"<402>",
|
| 431 |
+
"<403>",
|
| 432 |
+
"<404>",
|
| 433 |
+
"<405>",
|
| 434 |
+
"<406>",
|
| 435 |
+
"<407>",
|
| 436 |
+
"<408>",
|
| 437 |
+
"<409>",
|
| 438 |
+
"<410>",
|
| 439 |
+
"<411>",
|
| 440 |
+
"<412>",
|
| 441 |
+
"<413>",
|
| 442 |
+
"<414>",
|
| 443 |
+
"<415>",
|
| 444 |
+
"<416>",
|
| 445 |
+
"<417>",
|
| 446 |
+
"<418>",
|
| 447 |
+
"<419>",
|
| 448 |
+
"<420>",
|
| 449 |
+
"<421>",
|
| 450 |
+
"<422>",
|
| 451 |
+
"<423>",
|
| 452 |
+
"<424>",
|
| 453 |
+
"<425>",
|
| 454 |
+
"<426>",
|
| 455 |
+
"<427>",
|
| 456 |
+
"<428>",
|
| 457 |
+
"<429>",
|
| 458 |
+
"<430>",
|
| 459 |
+
"<431>",
|
| 460 |
+
"<432>",
|
| 461 |
+
"<433>",
|
| 462 |
+
"<434>",
|
| 463 |
+
"<435>",
|
| 464 |
+
"<436>",
|
| 465 |
+
"<437>",
|
| 466 |
+
"<438>",
|
| 467 |
+
"<439>",
|
| 468 |
+
"<440>",
|
| 469 |
+
"<441>",
|
| 470 |
+
"<442>",
|
| 471 |
+
"<443>",
|
| 472 |
+
"<444>",
|
| 473 |
+
"<445>",
|
| 474 |
+
"<446>",
|
| 475 |
+
"<447>",
|
| 476 |
+
"<448>",
|
| 477 |
+
"<449>",
|
| 478 |
+
"<450>",
|
| 479 |
+
"<451>",
|
| 480 |
+
"<452>",
|
| 481 |
+
"<453>",
|
| 482 |
+
"<454>",
|
| 483 |
+
"<455>",
|
| 484 |
+
"<456>",
|
| 485 |
+
"<457>",
|
| 486 |
+
"<458>",
|
| 487 |
+
"<459>",
|
| 488 |
+
"<460>",
|
| 489 |
+
"<461>",
|
| 490 |
+
"<462>",
|
| 491 |
+
"<463>",
|
| 492 |
+
"<464>",
|
| 493 |
+
"<465>",
|
| 494 |
+
"<466>",
|
| 495 |
+
"<467>",
|
| 496 |
+
"<468>",
|
| 497 |
+
"<469>",
|
| 498 |
+
"<470>",
|
| 499 |
+
"<471>",
|
| 500 |
+
"<472>",
|
| 501 |
+
"<473>",
|
| 502 |
+
"<474>",
|
| 503 |
+
"<475>",
|
| 504 |
+
"<476>",
|
| 505 |
+
"<477>",
|
| 506 |
+
"<478>",
|
| 507 |
+
"<479>",
|
| 508 |
+
"<480>",
|
| 509 |
+
"<481>",
|
| 510 |
+
"<482>",
|
| 511 |
+
"<483>",
|
| 512 |
+
"<484>",
|
| 513 |
+
"<485>",
|
| 514 |
+
"<486>",
|
| 515 |
+
"<487>",
|
| 516 |
+
"<488>",
|
| 517 |
+
"<489>",
|
| 518 |
+
"<490>",
|
| 519 |
+
"<491>",
|
| 520 |
+
"<492>",
|
| 521 |
+
"<493>",
|
| 522 |
+
"<494>",
|
| 523 |
+
"<495>",
|
| 524 |
+
"<496>",
|
| 525 |
+
"<497>",
|
| 526 |
+
"<498>",
|
| 527 |
+
"<499>",
|
| 528 |
+
"<500>",
|
| 529 |
+
"<501>",
|
| 530 |
+
"<502>",
|
| 531 |
+
"<503>",
|
| 532 |
+
"<504>",
|
| 533 |
+
"<505>",
|
| 534 |
+
"<506>",
|
| 535 |
+
"<507>",
|
| 536 |
+
"<508>",
|
| 537 |
+
"<509>",
|
| 538 |
+
"<510>",
|
| 539 |
+
"<511>",
|
| 540 |
+
"<512>",
|
| 541 |
+
"<513>",
|
| 542 |
+
"<514>",
|
| 543 |
+
"<515>",
|
| 544 |
+
"<516>",
|
| 545 |
+
"<517>",
|
| 546 |
+
"<518>",
|
| 547 |
+
"<519>",
|
| 548 |
+
"<520>",
|
| 549 |
+
"<521>",
|
| 550 |
+
"<522>",
|
| 551 |
+
"<523>",
|
| 552 |
+
"<524>",
|
| 553 |
+
"<525>",
|
| 554 |
+
"<526>",
|
| 555 |
+
"<527>",
|
| 556 |
+
"<528>",
|
| 557 |
+
"<529>",
|
| 558 |
+
"<530>",
|
| 559 |
+
"<531>",
|
| 560 |
+
"<532>",
|
| 561 |
+
"<533>",
|
| 562 |
+
"<534>",
|
| 563 |
+
"<535>",
|
| 564 |
+
"<536>",
|
| 565 |
+
"<537>",
|
| 566 |
+
"<538>",
|
| 567 |
+
"<539>",
|
| 568 |
+
"<540>",
|
| 569 |
+
"<541>",
|
| 570 |
+
"<542>",
|
| 571 |
+
"<543>",
|
| 572 |
+
"<544>",
|
| 573 |
+
"<545>",
|
| 574 |
+
"<546>",
|
| 575 |
+
"<547>",
|
| 576 |
+
"<548>",
|
| 577 |
+
"<549>",
|
| 578 |
+
"<550>",
|
| 579 |
+
"<551>",
|
| 580 |
+
"<552>",
|
| 581 |
+
"<553>",
|
| 582 |
+
"<554>",
|
| 583 |
+
"<555>",
|
| 584 |
+
"<556>",
|
| 585 |
+
"<557>",
|
| 586 |
+
"<558>",
|
| 587 |
+
"<559>",
|
| 588 |
+
"<560>",
|
| 589 |
+
"<561>",
|
| 590 |
+
"<562>",
|
| 591 |
+
"<563>",
|
| 592 |
+
"<564>",
|
| 593 |
+
"<565>",
|
| 594 |
+
"<566>",
|
| 595 |
+
"<567>",
|
| 596 |
+
"<568>",
|
| 597 |
+
"<569>",
|
| 598 |
+
"<570>",
|
| 599 |
+
"<571>",
|
| 600 |
+
"<572>",
|
| 601 |
+
"<573>",
|
| 602 |
+
"<574>",
|
| 603 |
+
"<575>",
|
| 604 |
+
"<576>",
|
| 605 |
+
"<577>",
|
| 606 |
+
"<578>",
|
| 607 |
+
"<579>",
|
| 608 |
+
"<580>",
|
| 609 |
+
"<581>",
|
| 610 |
+
"<582>",
|
| 611 |
+
"<583>",
|
| 612 |
+
"<584>",
|
| 613 |
+
"<585>",
|
| 614 |
+
"<586>",
|
| 615 |
+
"<587>",
|
| 616 |
+
"<588>",
|
| 617 |
+
"<589>",
|
| 618 |
+
"<590>",
|
| 619 |
+
"<591>",
|
| 620 |
+
"<592>",
|
| 621 |
+
"<593>",
|
| 622 |
+
"<594>",
|
| 623 |
+
"<595>",
|
| 624 |
+
"<596>",
|
| 625 |
+
"<597>",
|
| 626 |
+
"<598>",
|
| 627 |
+
"<599>",
|
| 628 |
+
"<600>",
|
| 629 |
+
"<601>",
|
| 630 |
+
"<602>",
|
| 631 |
+
"<603>",
|
| 632 |
+
"<604>",
|
| 633 |
+
"<605>",
|
| 634 |
+
"<606>",
|
| 635 |
+
"<607>",
|
| 636 |
+
"<608>",
|
| 637 |
+
"<609>",
|
| 638 |
+
"<610>",
|
| 639 |
+
"<611>",
|
| 640 |
+
"<612>",
|
| 641 |
+
"<613>",
|
| 642 |
+
"<614>",
|
| 643 |
+
"<615>",
|
| 644 |
+
"<616>",
|
| 645 |
+
"<617>",
|
| 646 |
+
"<618>",
|
| 647 |
+
"<619>",
|
| 648 |
+
"<620>",
|
| 649 |
+
"<621>",
|
| 650 |
+
"<622>",
|
| 651 |
+
"<623>",
|
| 652 |
+
"<624>",
|
| 653 |
+
"<625>",
|
| 654 |
+
"<626>",
|
| 655 |
+
"<627>",
|
| 656 |
+
"<628>",
|
| 657 |
+
"<629>",
|
| 658 |
+
"<630>",
|
| 659 |
+
"<631>",
|
| 660 |
+
"<632>",
|
| 661 |
+
"<633>",
|
| 662 |
+
"<634>",
|
| 663 |
+
"<635>",
|
| 664 |
+
"<636>",
|
| 665 |
+
"<637>",
|
| 666 |
+
"<638>",
|
| 667 |
+
"<639>",
|
| 668 |
+
"<640>",
|
| 669 |
+
"<641>",
|
| 670 |
+
"<642>",
|
| 671 |
+
"<643>",
|
| 672 |
+
"<644>",
|
| 673 |
+
"<645>",
|
| 674 |
+
"<646>",
|
| 675 |
+
"<647>",
|
| 676 |
+
"<648>",
|
| 677 |
+
"<649>",
|
| 678 |
+
"<650>",
|
| 679 |
+
"<651>",
|
| 680 |
+
"<652>",
|
| 681 |
+
"<653>",
|
| 682 |
+
"<654>",
|
| 683 |
+
"<655>",
|
| 684 |
+
"<656>",
|
| 685 |
+
"<657>",
|
| 686 |
+
"<658>",
|
| 687 |
+
"<659>",
|
| 688 |
+
"<660>",
|
| 689 |
+
"<661>",
|
| 690 |
+
"<662>",
|
| 691 |
+
"<663>",
|
| 692 |
+
"<664>",
|
| 693 |
+
"<665>",
|
| 694 |
+
"<666>",
|
| 695 |
+
"<667>",
|
| 696 |
+
"<668>",
|
| 697 |
+
"<669>",
|
| 698 |
+
"<670>",
|
| 699 |
+
"<671>",
|
| 700 |
+
"<672>",
|
| 701 |
+
"<673>",
|
| 702 |
+
"<674>",
|
| 703 |
+
"<675>",
|
| 704 |
+
"<676>",
|
| 705 |
+
"<677>",
|
| 706 |
+
"<678>",
|
| 707 |
+
"<679>",
|
| 708 |
+
"<680>",
|
| 709 |
+
"<681>",
|
| 710 |
+
"<682>",
|
| 711 |
+
"<683>",
|
| 712 |
+
"<684>",
|
| 713 |
+
"<685>",
|
| 714 |
+
"<686>",
|
| 715 |
+
"<687>",
|
| 716 |
+
"<688>",
|
| 717 |
+
"<689>",
|
| 718 |
+
"<690>",
|
| 719 |
+
"<691>",
|
| 720 |
+
"<692>",
|
| 721 |
+
"<693>",
|
| 722 |
+
"<694>",
|
| 723 |
+
"<695>",
|
| 724 |
+
"<696>",
|
| 725 |
+
"<697>",
|
| 726 |
+
"<698>",
|
| 727 |
+
"<699>",
|
| 728 |
+
"<700>",
|
| 729 |
+
"<701>",
|
| 730 |
+
"<702>",
|
| 731 |
+
"<703>",
|
| 732 |
+
"<704>",
|
| 733 |
+
"<705>",
|
| 734 |
+
"<706>",
|
| 735 |
+
"<707>",
|
| 736 |
+
"<708>",
|
| 737 |
+
"<709>",
|
| 738 |
+
"<710>",
|
| 739 |
+
"<711>",
|
| 740 |
+
"<712>",
|
| 741 |
+
"<713>",
|
| 742 |
+
"<714>",
|
| 743 |
+
"<715>",
|
| 744 |
+
"<716>",
|
| 745 |
+
"<717>",
|
| 746 |
+
"<718>",
|
| 747 |
+
"<719>",
|
| 748 |
+
"<720>",
|
| 749 |
+
"<721>",
|
| 750 |
+
"<722>",
|
| 751 |
+
"<723>",
|
| 752 |
+
"<724>",
|
| 753 |
+
"<725>",
|
| 754 |
+
"<726>",
|
| 755 |
+
"<727>",
|
| 756 |
+
"<728>",
|
| 757 |
+
"<729>",
|
| 758 |
+
"<730>",
|
| 759 |
+
"<731>",
|
| 760 |
+
"<732>",
|
| 761 |
+
"<733>",
|
| 762 |
+
"<734>",
|
| 763 |
+
"<735>",
|
| 764 |
+
"<736>",
|
| 765 |
+
"<737>",
|
| 766 |
+
"<738>",
|
| 767 |
+
"<739>",
|
| 768 |
+
"<740>",
|
| 769 |
+
"<741>",
|
| 770 |
+
"<742>",
|
| 771 |
+
"<743>",
|
| 772 |
+
"<744>",
|
| 773 |
+
"<745>",
|
| 774 |
+
"<746>",
|
| 775 |
+
"<747>",
|
| 776 |
+
"<748>",
|
| 777 |
+
"<749>",
|
| 778 |
+
"<750>",
|
| 779 |
+
"<751>",
|
| 780 |
+
"<752>",
|
| 781 |
+
"<753>",
|
| 782 |
+
"<754>",
|
| 783 |
+
"<755>",
|
| 784 |
+
"<756>",
|
| 785 |
+
"<757>",
|
| 786 |
+
"<758>",
|
| 787 |
+
"<759>",
|
| 788 |
+
"<760>",
|
| 789 |
+
"<761>",
|
| 790 |
+
"<762>",
|
| 791 |
+
"<763>",
|
| 792 |
+
"<764>",
|
| 793 |
+
"<765>",
|
| 794 |
+
"<766>",
|
| 795 |
+
"<767>",
|
| 796 |
+
"<768>",
|
| 797 |
+
"<769>",
|
| 798 |
+
"<770>",
|
| 799 |
+
"<771>",
|
| 800 |
+
"<772>",
|
| 801 |
+
"<773>",
|
| 802 |
+
"<774>",
|
| 803 |
+
"<775>",
|
| 804 |
+
"<776>",
|
| 805 |
+
"<777>",
|
| 806 |
+
"<778>",
|
| 807 |
+
"<779>",
|
| 808 |
+
"<780>",
|
| 809 |
+
"<781>",
|
| 810 |
+
"<782>",
|
| 811 |
+
"<783>",
|
| 812 |
+
"<784>",
|
| 813 |
+
"<785>",
|
| 814 |
+
"<786>",
|
| 815 |
+
"<787>",
|
| 816 |
+
"<788>",
|
| 817 |
+
"<789>",
|
| 818 |
+
"<790>",
|
| 819 |
+
"<791>",
|
| 820 |
+
"<792>",
|
| 821 |
+
"<793>",
|
| 822 |
+
"<794>",
|
| 823 |
+
"<795>",
|
| 824 |
+
"<796>",
|
| 825 |
+
"<797>",
|
| 826 |
+
"<798>",
|
| 827 |
+
"<799>",
|
| 828 |
+
"<800>",
|
| 829 |
+
"<801>",
|
| 830 |
+
"<802>",
|
| 831 |
+
"<803>",
|
| 832 |
+
"<804>",
|
| 833 |
+
"<805>",
|
| 834 |
+
"<806>",
|
| 835 |
+
"<807>",
|
| 836 |
+
"<808>",
|
| 837 |
+
"<809>",
|
| 838 |
+
"<810>",
|
| 839 |
+
"<811>",
|
| 840 |
+
"<812>",
|
| 841 |
+
"<813>",
|
| 842 |
+
"<814>",
|
| 843 |
+
"<815>",
|
| 844 |
+
"<816>",
|
| 845 |
+
"<817>",
|
| 846 |
+
"<818>",
|
| 847 |
+
"<819>",
|
| 848 |
+
"<820>",
|
| 849 |
+
"<821>",
|
| 850 |
+
"<822>",
|
| 851 |
+
"<823>",
|
| 852 |
+
"<824>",
|
| 853 |
+
"<825>",
|
| 854 |
+
"<826>",
|
| 855 |
+
"<827>",
|
| 856 |
+
"<828>",
|
| 857 |
+
"<829>",
|
| 858 |
+
"<830>",
|
| 859 |
+
"<831>",
|
| 860 |
+
"<832>",
|
| 861 |
+
"<833>",
|
| 862 |
+
"<834>",
|
| 863 |
+
"<835>",
|
| 864 |
+
"<836>",
|
| 865 |
+
"<837>",
|
| 866 |
+
"<838>",
|
| 867 |
+
"<839>",
|
| 868 |
+
"<840>",
|
| 869 |
+
"<841>",
|
| 870 |
+
"<842>",
|
| 871 |
+
"<843>",
|
| 872 |
+
"<844>",
|
| 873 |
+
"<845>",
|
| 874 |
+
"<846>",
|
| 875 |
+
"<847>",
|
| 876 |
+
"<848>",
|
| 877 |
+
"<849>",
|
| 878 |
+
"<850>",
|
| 879 |
+
"<851>",
|
| 880 |
+
"<852>",
|
| 881 |
+
"<853>",
|
| 882 |
+
"<854>",
|
| 883 |
+
"<855>",
|
| 884 |
+
"<856>",
|
| 885 |
+
"<857>",
|
| 886 |
+
"<858>",
|
| 887 |
+
"<859>",
|
| 888 |
+
"<860>",
|
| 889 |
+
"<861>",
|
| 890 |
+
"<862>",
|
| 891 |
+
"<863>",
|
| 892 |
+
"<864>",
|
| 893 |
+
"<865>",
|
| 894 |
+
"<866>",
|
| 895 |
+
"<867>",
|
| 896 |
+
"<868>",
|
| 897 |
+
"<869>",
|
| 898 |
+
"<870>",
|
| 899 |
+
"<871>",
|
| 900 |
+
"<872>",
|
| 901 |
+
"<873>",
|
| 902 |
+
"<874>",
|
| 903 |
+
"<875>",
|
| 904 |
+
"<876>",
|
| 905 |
+
"<877>",
|
| 906 |
+
"<878>",
|
| 907 |
+
"<879>",
|
| 908 |
+
"<880>",
|
| 909 |
+
"<881>",
|
| 910 |
+
"<882>",
|
| 911 |
+
"<883>",
|
| 912 |
+
"<884>",
|
| 913 |
+
"<885>",
|
| 914 |
+
"<886>",
|
| 915 |
+
"<887>",
|
| 916 |
+
"<888>",
|
| 917 |
+
"<889>",
|
| 918 |
+
"<890>",
|
| 919 |
+
"<891>",
|
| 920 |
+
"<892>",
|
| 921 |
+
"<893>",
|
| 922 |
+
"<894>",
|
| 923 |
+
"<895>",
|
| 924 |
+
"<896>",
|
| 925 |
+
"<897>",
|
| 926 |
+
"<898>",
|
| 927 |
+
"<899>",
|
| 928 |
+
"<900>",
|
| 929 |
+
"<901>",
|
| 930 |
+
"<902>",
|
| 931 |
+
"<903>",
|
| 932 |
+
"<904>",
|
| 933 |
+
"<905>",
|
| 934 |
+
"<906>",
|
| 935 |
+
"<907>",
|
| 936 |
+
"<908>",
|
| 937 |
+
"<909>",
|
| 938 |
+
"<910>",
|
| 939 |
+
"<911>",
|
| 940 |
+
"<912>",
|
| 941 |
+
"<913>",
|
| 942 |
+
"<914>",
|
| 943 |
+
"<915>",
|
| 944 |
+
"<916>",
|
| 945 |
+
"<917>",
|
| 946 |
+
"<918>",
|
| 947 |
+
"<919>",
|
| 948 |
+
"<920>",
|
| 949 |
+
"<921>",
|
| 950 |
+
"<922>",
|
| 951 |
+
"<923>",
|
| 952 |
+
"<924>",
|
| 953 |
+
"<925>",
|
| 954 |
+
"<926>",
|
| 955 |
+
"<927>",
|
| 956 |
+
"<928>",
|
| 957 |
+
"<929>",
|
| 958 |
+
"<930>",
|
| 959 |
+
"<931>",
|
| 960 |
+
"<932>",
|
| 961 |
+
"<933>",
|
| 962 |
+
"<934>",
|
| 963 |
+
"<935>",
|
| 964 |
+
"<936>",
|
| 965 |
+
"<937>",
|
| 966 |
+
"<938>",
|
| 967 |
+
"<939>",
|
| 968 |
+
"<940>",
|
| 969 |
+
"<941>",
|
| 970 |
+
"<942>",
|
| 971 |
+
"<943>",
|
| 972 |
+
"<944>",
|
| 973 |
+
"<945>",
|
| 974 |
+
"<946>",
|
| 975 |
+
"<947>",
|
| 976 |
+
"<948>",
|
| 977 |
+
"<949>",
|
| 978 |
+
"<950>",
|
| 979 |
+
"<951>",
|
| 980 |
+
"<952>",
|
| 981 |
+
"<953>",
|
| 982 |
+
"<954>",
|
| 983 |
+
"<955>",
|
| 984 |
+
"<956>",
|
| 985 |
+
"<957>",
|
| 986 |
+
"<958>",
|
| 987 |
+
"<959>",
|
| 988 |
+
"<960>",
|
| 989 |
+
"<961>",
|
| 990 |
+
"<962>",
|
| 991 |
+
"<963>",
|
| 992 |
+
"<964>",
|
| 993 |
+
"<965>",
|
| 994 |
+
"<966>",
|
| 995 |
+
"<967>",
|
| 996 |
+
"<968>",
|
| 997 |
+
"<969>",
|
| 998 |
+
"<970>",
|
| 999 |
+
"<971>",
|
| 1000 |
+
"<972>",
|
| 1001 |
+
"<973>",
|
| 1002 |
+
"<974>",
|
| 1003 |
+
"<975>",
|
| 1004 |
+
"<976>",
|
| 1005 |
+
"<977>",
|
| 1006 |
+
"<978>",
|
| 1007 |
+
"<979>",
|
| 1008 |
+
"<980>",
|
| 1009 |
+
"<981>",
|
| 1010 |
+
"<982>",
|
| 1011 |
+
"<983>",
|
| 1012 |
+
"<984>",
|
| 1013 |
+
"<985>",
|
| 1014 |
+
"<986>",
|
| 1015 |
+
"<987>",
|
| 1016 |
+
"<988>",
|
| 1017 |
+
"<989>",
|
| 1018 |
+
"<990>",
|
| 1019 |
+
"<991>",
|
| 1020 |
+
"<992>",
|
| 1021 |
+
"<993>",
|
| 1022 |
+
"<994>",
|
| 1023 |
+
"<995>",
|
| 1024 |
+
"<996>",
|
| 1025 |
+
"<997>",
|
| 1026 |
+
"<998>",
|
| 1027 |
+
"<999>",
|
| 1028 |
+
"<1000>",
|
| 1029 |
+
"<null>",
|
| 1030 |
+
"<switch>",
|
| 1031 |
+
{
|
| 1032 |
+
"content": "</c>",
|
| 1033 |
+
"lstrip": false,
|
| 1034 |
+
"normalized": false,
|
| 1035 |
+
"rstrip": false,
|
| 1036 |
+
"single_word": false
|
| 1037 |
+
}
|
| 1038 |
+
],
|
| 1039 |
+
"eos_token": {
|
| 1040 |
+
"content": "<|im_end|>",
|
| 1041 |
+
"lstrip": false,
|
| 1042 |
+
"normalized": false,
|
| 1043 |
+
"rstrip": false,
|
| 1044 |
+
"single_word": false
|
| 1045 |
+
},
|
| 1046 |
+
"pad_token": {
|
| 1047 |
+
"content": "<|endoftext|>",
|
| 1048 |
+
"lstrip": false,
|
| 1049 |
+
"normalized": false,
|
| 1050 |
+
"rstrip": false,
|
| 1051 |
+
"single_word": false
|
| 1052 |
+
}
|
| 1053 |
+
}
|
qwen2.5_tokenizer/tokenizer.json
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:76fbf312c2a3772b8cbde8b6a6c45607962278c72a2f152a41740e96c906fa52
|
| 3 |
+
size 11607003
|
qwen2.5_tokenizer/tokenizer_config.json
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"add_prefix_space": false,
|
| 3 |
+
"auto_map": {
|
| 4 |
+
"AutoProcessor": "processing_locateanything.LocateAnythingProcessor"
|
| 5 |
+
},
|
| 6 |
+
"backend": "tokenizers",
|
| 7 |
+
"bos_token": null,
|
| 8 |
+
"clean_up_tokenization_spaces": false,
|
| 9 |
+
"eos_token": "<|im_end|>",
|
| 10 |
+
"errors": "replace",
|
| 11 |
+
"is_local": true,
|
| 12 |
+
"local_files_only": false,
|
| 13 |
+
"model_max_length": 16384,
|
| 14 |
+
"pad_token": "<|endoftext|>",
|
| 15 |
+
"processor_class": "LocateAnythingProcessor",
|
| 16 |
+
"split_special_tokens": false,
|
| 17 |
+
"tokenizer_class": "Qwen2TokenizerFast",
|
| 18 |
+
"unk_token": null,
|
| 19 |
+
"_commit_hash": null
|
| 20 |
+
}
|
qwen2.5_tokenizer/vocab.json
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
qwen2_5_tokenizer.txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
qwen2_p128_l0_together.axmodel
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:14daea99276e604c1b13acf8e83b3aa115ac5b5b187b5a52576f5086a8d4bd41
|
| 3 |
+
size 49490620
|
qwen2_p128_l10_together.axmodel
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a0892b977ace619fbcad0475e0457334e80949f41ea1eddbf51ebf10cbacd56c
|
| 3 |
+
size 49490620
|
qwen2_p128_l11_together.axmodel
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e9d0707267e03c8712445b4a1a477054d78d98f9e73559a1ea7b3b20ae23f3c9
|
| 3 |
+
size 49490620
|
qwen2_p128_l12_together.axmodel
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1ffeb9ccd98be5c9bdd0e86db98a5595652b64784f968e4c2b416b4cebb81711
|
| 3 |
+
size 49490620
|
qwen2_p128_l13_together.axmodel
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d6ae5219c342bfdbd410e41d5d9d00b64487844bcc56fdd48dd4d65a107161f4
|
| 3 |
+
size 49490620
|
qwen2_p128_l14_together.axmodel
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:335274effb74fc6f4811316123943c78816fa77a12bbd66654cbdec1c62c2cf2
|
| 3 |
+
size 49490620
|
qwen2_p128_l15_together.axmodel
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9c983bd2cf5fd63289de8286a46dbc48be0ab11067f86a3b77acb865f50b67de
|
| 3 |
+
size 49490620
|
qwen2_p128_l16_together.axmodel
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f9624bbccc69b5b232e0bd077eca1f3b0c47f908deb5ff73dd6720a90b5ec60d
|
| 3 |
+
size 49490620
|
qwen2_p128_l17_together.axmodel
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a20ea0552e1ec36b6c1229498285e74348b07e1b88dd45424cd70d89bdcf7a02
|
| 3 |
+
size 49490620
|
qwen2_p128_l18_together.axmodel
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0899b44d67f5aabb53682df738595eb41a8d3ecc094a32d3a80703460267acc8
|
| 3 |
+
size 49490620
|
qwen2_p128_l19_together.axmodel
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:5aec5840d9a8b2737ed66da11cc05b2c5696132793269bcfa8487345d03ee1e4
|
| 3 |
+
size 49490620
|
qwen2_p128_l1_together.axmodel
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0828672f1c3eec700db19c4a8a6c0ec26d0d6b5989eeaab4f4a52958d7904234
|
| 3 |
+
size 49490620
|
qwen2_p128_l20_together.axmodel
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0c1be677880d9689e3c989fb53feeb193590baee23698b613105132e762178a8
|
| 3 |
+
size 49490620
|
qwen2_p128_l21_together.axmodel
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4cf863c2968d082c3e2a2625a3a3a00b36d296e1cead6cfdb5026e4bfdaa5979
|
| 3 |
+
size 49490620
|
qwen2_p128_l22_together.axmodel
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8650aee44861e7f118fb0710e0603ed2b921fb7fa737cd200cb19bbe9a828fad
|
| 3 |
+
size 49490620
|
qwen2_p128_l23_together.axmodel
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9ed3c4440fb8368d7fb8e849986b82f18a80e1e2cbce4bdacbe4dd8c50c149d8
|
| 3 |
+
size 49490620
|
qwen2_p128_l24_together.axmodel
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c3e09f54ac6e779e0f547d9e4d3481bd6a60c9798b167c4aff2dbbf0f78d16df
|
| 3 |
+
size 49490620
|
qwen2_p128_l25_together.axmodel
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:364ae783456850df31cfc4a4501808fe8616457992cba900454df6ad9b99e2c0
|
| 3 |
+
size 49490620
|