PR-1
#1
by Xiao-AMD - opened
This view is limited to 50 files because it contains too many changes. See the raw diff here.
- .gitattributes +0 -2
- LICENSE +0 -27
- README.md +1 -134
- THIRD_PARTY_NOTICES.md +0 -43
- chat_template.jinja +0 -61
- config.json +0 -433
- configuration_deepseek.py +0 -214
- configuration_kimi_k25.py +0 -123
- generation_config.json +0 -6
- kimi_k25_processor.py +0 -165
- kimi_k25_vision_processing.py +0 -251
- media_utils.py +0 -368
- model-00001-of-000064.safetensors +0 -3
- model-00002-of-000064.safetensors +0 -3
- model-00003-of-000064.safetensors +0 -3
- model-00004-of-000064.safetensors +0 -3
- model-00005-of-000064.safetensors +0 -3
- model-00006-of-000064.safetensors +0 -3
- model-00007-of-000064.safetensors +0 -3
- model-00008-of-000064.safetensors +0 -3
- model-00009-of-000064.safetensors +0 -3
- model-00010-of-000064.safetensors +0 -3
- model-00011-of-000064.safetensors +0 -3
- model-00012-of-000064.safetensors +0 -3
- model-00013-of-000064.safetensors +0 -3
- model-00014-of-000064.safetensors +0 -3
- model-00015-of-000064.safetensors +0 -3
- model-00016-of-000064.safetensors +0 -3
- model-00017-of-000064.safetensors +0 -3
- model-00018-of-000064.safetensors +0 -3
- model-00019-of-000064.safetensors +0 -3
- model-00020-of-000064.safetensors +0 -3
- model-00021-of-000064.safetensors +0 -3
- model-00022-of-000064.safetensors +0 -3
- model-00023-of-000064.safetensors +0 -3
- model-00024-of-000064.safetensors +0 -3
- model-00025-of-000064.safetensors +0 -3
- model-00026-of-000064.safetensors +0 -3
- model-00027-of-000064.safetensors +0 -3
- model-00028-of-000064.safetensors +0 -3
- model-00029-of-000064.safetensors +0 -3
- model-00030-of-000064.safetensors +0 -3
- model-00031-of-000064.safetensors +0 -3
- model-00032-of-000064.safetensors +0 -3
- model-00033-of-000064.safetensors +0 -3
- model-00034-of-000064.safetensors +0 -3
- model-00035-of-000064.safetensors +0 -3
- model-00036-of-000064.safetensors +0 -3
- model-00037-of-000064.safetensors +0 -3
- model-00038-of-000064.safetensors +0 -3
.gitattributes
CHANGED
|
@@ -33,5 +33,3 @@ 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
|
| 36 |
-
model.safetensors.index.json filter=lfs diff=lfs merge=lfs -text
|
| 37 |
-
figures/demo_video.mp4 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
|
|
|
|
|
|
LICENSE
DELETED
|
@@ -1,27 +0,0 @@
|
|
| 1 |
-
Modified MIT License
|
| 2 |
-
|
| 3 |
-
Copyright (c) 2026 Moonshot AI
|
| 4 |
-
|
| 5 |
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 6 |
-
of this software and associated documentation files (the “Software”), to deal
|
| 7 |
-
in the Software without restriction, including without limitation the rights
|
| 8 |
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 9 |
-
copies of the Software, and to permit persons to whom the Software is
|
| 10 |
-
furnished to do so, subject to the following conditions:
|
| 11 |
-
|
| 12 |
-
The above copyright notice and this permission notice shall be included in all
|
| 13 |
-
copies or substantial portions of the Software.
|
| 14 |
-
|
| 15 |
-
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 16 |
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 17 |
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 18 |
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 19 |
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 20 |
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 21 |
-
SOFTWARE.
|
| 22 |
-
|
| 23 |
-
Our only modification part is that, if the Software (or any derivative works
|
| 24 |
-
thereof) is used for any of your commercial products or services that have
|
| 25 |
-
more than 100 million monthly active users, or more than 20 million US dollars
|
| 26 |
-
(or equivalent in other currencies) in monthly revenue, you shall prominently
|
| 27 |
-
display "Kimi K2.7 Code" on the user interface of such product or service.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
README.md
CHANGED
|
@@ -1,136 +1,3 @@
|
|
| 1 |
---
|
| 2 |
-
license:
|
| 3 |
-
license_name: modified-mit
|
| 4 |
-
license_link: LICENSE
|
| 5 |
-
base_model:
|
| 6 |
-
- moonshotai/Kimi-K2.7-Code
|
| 7 |
---
|
| 8 |
-
# Model Overview
|
| 9 |
-
|
| 10 |
-
- **Model Architecture:** Kimi-K2.7-Code
|
| 11 |
-
- **Input:** Text, Image, Video
|
| 12 |
-
- **Output:** Text
|
| 13 |
-
- **Supported Hardware Microarchitecture:** AMD MI350/MI355
|
| 14 |
-
- **ROCm:** 7.2.3
|
| 15 |
-
- **PyTorch:** 2.10.0
|
| 16 |
-
- **Transformers:** 5.12.1
|
| 17 |
-
- **Operating System(s):** Linux
|
| 18 |
-
- **Inference Engine:** [vLLM](https://docs.vllm.ai/en/latest/)
|
| 19 |
-
- **Model Optimizer:** [AMD-Quark](https://quark.docs.amd.com/latest/index.html) (V0.12)
|
| 20 |
-
- **Weight quantization:** OCP MXFP4, Static; self_attn Perchannel, FP8E4M3, Static
|
| 21 |
-
- **Activation quantization:** OCP MXFP4, Dynamic; self_attn Pertoken, FP8E4M3, Dynamic
|
| 22 |
-
- **Excluded from quantization:** MoE gates, `lm_head`, vision tower and multimodal projector
|
| 23 |
-
|
| 24 |
-
This model was built with the Kimi-K2.7-Code model by applying [AMD-Quark](https://quark.docs.amd.com/latest/index.html) for MXFP4 quantization.
|
| 25 |
-
|
| 26 |
-
# Model Quantization
|
| 27 |
-
|
| 28 |
-
The model was quantized from [moonshotai/Kimi-K2.7-Code](https://huggingface.co/moonshotai/Kimi-K2.7-Code) using [AMD-Quark](https://quark.docs.amd.com/latest/index.html). The MoE/Linear weights and activations are quantized to OCP MXFP4, while the attention projections use FP8 (E4M3). The vision tower and multimodal projector are kept at BF16.
|
| 29 |
-
|
| 30 |
-
**Quantization script:**
|
| 31 |
-
|
| 32 |
-
```bash
|
| 33 |
-
cd Quark/examples/torch/language_modeling/llm_ptq/
|
| 34 |
-
|
| 35 |
-
python3 quantize_quark.py \
|
| 36 |
-
--model_dir moonshotai/Kimi-K2.7-Code \
|
| 37 |
-
--output_dir Kimi-K2.7-Code-MXFP4 \
|
| 38 |
-
--file2file_quantization \
|
| 39 |
-
--trust_remote_code \
|
| 40 |
-
--quant_scheme mxfp4 \
|
| 41 |
-
--layer_quant_scheme '*self_attn*' ptpc_fp8 \
|
| 42 |
-
--exclude_layers "*lm_head*" "*mlp.gate" "*mm_projector*" \
|
| 43 |
-
"*vision_tower*" "mtp.*" "*shared_expert_gate*" "*router*" \
|
| 44 |
-
--model_export hf_format
|
| 45 |
-
```
|
| 46 |
-
|
| 47 |
-
# Deployment
|
| 48 |
-
### Use with vLLM
|
| 49 |
-
|
| 50 |
-
This model can be deployed efficiently using the [vLLM](https://docs.vllm.ai/en/latest/) backend.
|
| 51 |
-
|
| 52 |
-
Note: this model has 64 KV heads, which is incompatible with the AITER MLA
|
| 53 |
-
kernel (supports 16 or 128 only). Disable AITER MLA when serving on ROCm:
|
| 54 |
-
|
| 55 |
-
```bash
|
| 56 |
-
export VLLM_ROCM_USE_AITER=1
|
| 57 |
-
export VLLM_ROCM_USE_AITER_MLA=0
|
| 58 |
-
export VLLM_ROCM_USE_AITER_FUSION_SHARED_EXPERTS=0
|
| 59 |
-
export VLLM_ROCM_USE_AITER_FP4BMM=0
|
| 60 |
-
|
| 61 |
-
python3 -m vllm.entrypoints.openai.api_server \
|
| 62 |
-
--model amd/Kimi-K2.7-Code-MXFP4 \
|
| 63 |
-
--trust-remote-code \
|
| 64 |
-
--tensor-parallel-size 4 \
|
| 65 |
-
--gpu-memory-utilization 0.9 \
|
| 66 |
-
--max-model-len 8192
|
| 67 |
-
```
|
| 68 |
-
|
| 69 |
-
## Evaluation
|
| 70 |
-
The model was evaluated on the GSM8K benchmark.
|
| 71 |
-
|
| 72 |
-
### Accuracy
|
| 73 |
-
|
| 74 |
-
<table>
|
| 75 |
-
<tr>
|
| 76 |
-
<td><strong>Benchmark</strong>
|
| 77 |
-
</td>
|
| 78 |
-
<td><strong>Kimi-K2.7-Code</strong>
|
| 79 |
-
</td>
|
| 80 |
-
<td><strong>Kimi-K2.7-Code-MXFP4 (this model)</strong>
|
| 81 |
-
</td>
|
| 82 |
-
<td><strong>Recovery</strong>
|
| 83 |
-
</td>
|
| 84 |
-
</tr>
|
| 85 |
-
<tr>
|
| 86 |
-
<td>GSM8K (strict-match)
|
| 87 |
-
</td>
|
| 88 |
-
<td>95.07
|
| 89 |
-
</td>
|
| 90 |
-
<td>94.80
|
| 91 |
-
</td>
|
| 92 |
-
<td>99.7%
|
| 93 |
-
</td>
|
| 94 |
-
</tr>
|
| 95 |
-
<tr>
|
| 96 |
-
<td>GSM8K (flexible-extract)
|
| 97 |
-
</td>
|
| 98 |
-
<td>95.15
|
| 99 |
-
</td>
|
| 100 |
-
<td>94.77
|
| 101 |
-
</td>
|
| 102 |
-
<td>99.6%
|
| 103 |
-
</td>
|
| 104 |
-
</tr>
|
| 105 |
-
</table>
|
| 106 |
-
|
| 107 |
-
GSM8K is 5-shot, greedy decoding. The MXFP4 numbers are the mean of repeated
|
| 108 |
-
stable runs (range: strict 94.39–95.60, flexible 94.39–95.53).
|
| 109 |
-
|
| 110 |
-
### Reproduction
|
| 111 |
-
|
| 112 |
-
The GSM8K results were obtained using the `lm-evaluation-harness` framework
|
| 113 |
-
with the vLLM backend (`rocm/vllm-dev` nightly, vLLM `0.23.1rc1`). The model
|
| 114 |
-
is served first, then evaluated via the OpenAI-compatible completions API.
|
| 115 |
-
|
| 116 |
-
Important: serve with automatic prefix caching disabled
|
| 117 |
-
(`--no-enable-prefix-caching`) for deterministic evaluation results.
|
| 118 |
-
|
| 119 |
-
```bash
|
| 120 |
-
# 1) Serve
|
| 121 |
-
export VLLM_ROCM_USE_AITER=1 VLLM_ROCM_USE_AITER_MLA=0 \
|
| 122 |
-
VLLM_ROCM_USE_AITER_FUSION_SHARED_EXPERTS=0 VLLM_ROCM_USE_AITER_FP4BMM=0
|
| 123 |
-
python3 -m vllm.entrypoints.openai.api_server \
|
| 124 |
-
--model amd/Kimi-K2.7-Code-MXFP4 \
|
| 125 |
-
--trust-remote-code --tensor-parallel-size 4 \
|
| 126 |
-
--gpu-memory-utilization 0.9 --max-model-len 8192 \
|
| 127 |
-
--seed 42 --no-enable-prefix-caching
|
| 128 |
-
|
| 129 |
-
# 2) Evaluate
|
| 130 |
-
lm_eval --model local-completions \
|
| 131 |
-
--model_args "model=amd/Kimi-K2.7-Code-MXFP4,base_url=http://0.0.0.0:8000/v1/completions,num_concurrent=128,tokenized_requests=False,max_length=8192,add_bos_token=True,seed=42,trust_remote_code=True" \
|
| 132 |
-
--tasks gsm8k --num_fewshot 5 --batch_size 1 --seed 42
|
| 133 |
-
```
|
| 134 |
-
|
| 135 |
-
# License
|
| 136 |
-
Modifications Copyright(c) 2026 Advanced Micro Devices, Inc. All rights reserved.
|
|
|
|
| 1 |
---
|
| 2 |
+
license: mit
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
THIRD_PARTY_NOTICES.md
DELETED
|
@@ -1,43 +0,0 @@
|
|
| 1 |
-
# THIRD_PARTY_NOTICES
|
| 2 |
-
|
| 3 |
-
This file lists third-party software contained in Kimi-K2.7-Code along with their licenses, in compliance with the redistribution clauses of those licenses.
|
| 4 |
-
|
| 5 |
-
---
|
| 6 |
-
|
| 7 |
-
## 1. DeepSeek-V3
|
| 8 |
-
|
| 9 |
-
Our model architecture is DeepSeek-V3-like. Some of modeling codes are copied from the source repository.
|
| 10 |
-
|
| 11 |
-
- **Source Repository**
|
| 12 |
-
https://huggingface.co/deepseek-ai/DeepSeek-V3
|
| 13 |
-
|
| 14 |
-
- **Files / Directories Used**
|
| 15 |
-
- configuration_deepseek.py
|
| 16 |
-
- modeling_deepseek.py
|
| 17 |
-
|
| 18 |
-
- **License Type**
|
| 19 |
-
MIT License
|
| 20 |
-
|
| 21 |
-
- **Copyright Notice**
|
| 22 |
-
Copyright (c) 2023 DeepSeek
|
| 23 |
-
|
| 24 |
-
- **Full License Text**
|
| 25 |
-
```
|
| 26 |
-
MIT License
|
| 27 |
-
Copyright (c) 2023 DeepSeek
|
| 28 |
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 29 |
-
of this software and associated documentation files (the "Software"), to deal
|
| 30 |
-
in the Software without restriction, including without limitation the rights
|
| 31 |
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 32 |
-
copies of the Software, and to permit persons to whom the Software is
|
| 33 |
-
furnished to do so, subject to the following conditions:
|
| 34 |
-
The above copyright notice and this permission notice shall be included in all
|
| 35 |
-
copies or substantial portions of the Software.
|
| 36 |
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 37 |
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 38 |
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 39 |
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 40 |
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 41 |
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 42 |
-
SOFTWARE.
|
| 43 |
-
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
chat_template.jinja
DELETED
|
@@ -1,61 +0,0 @@
|
|
| 1 |
-
{%- macro render_content(msg) -%}
|
| 2 |
-
{%- set c = msg.get('content') -%}
|
| 3 |
-
{%- if c is string -%}
|
| 4 |
-
{{ c }}
|
| 5 |
-
{%- elif c is not none -%}
|
| 6 |
-
{% for content in c -%}
|
| 7 |
-
{% if content['type'] == 'image' or content['type'] == 'image_url' -%}
|
| 8 |
-
<|media_begin|>image<|media_content|><|media_pad|><|media_end|>
|
| 9 |
-
{% elif content['type'] == 'video' or content['type']== 'video_url'-%}
|
| 10 |
-
<|kimi_k25_video_placeholder|>
|
| 11 |
-
{% else -%}
|
| 12 |
-
{{ content['text'] }}
|
| 13 |
-
{%- endif -%}
|
| 14 |
-
{%- endfor -%}
|
| 15 |
-
{%- endif -%}
|
| 16 |
-
{%- endmacro -%}
|
| 17 |
-
{% macro set_roles(message) -%}
|
| 18 |
-
{%- set role_name = message.get('name') or message['role'] -%}
|
| 19 |
-
{%- if message['role'] == 'user' -%}
|
| 20 |
-
<|im_user|>{{role_name}}<|im_middle|>
|
| 21 |
-
{%- elif message['role'] == 'assistant' -%}
|
| 22 |
-
<|im_assistant|>{{role_name}}<|im_middle|>
|
| 23 |
-
{%- else -%}
|
| 24 |
-
<|im_system|>{{role_name}}<|im_middle|>
|
| 25 |
-
{%- endif -%}
|
| 26 |
-
{%- endmacro -%}
|
| 27 |
-
{%- macro render_toolcalls(message) -%}
|
| 28 |
-
<|tool_calls_section_begin|>
|
| 29 |
-
{%- for tool_call in message['tool_calls'] -%}
|
| 30 |
-
{%- set formatted_id = tool_call['id'] -%}
|
| 31 |
-
<|tool_call_begin|>{{ formatted_id }}<|tool_call_argument_begin|>{% if tool_call['function']['arguments'] is string %}{{ tool_call['function']['arguments'] }}{% else %}{{ tool_call['function']['arguments'] | tojson }}{% endif %}<|tool_call_end|>
|
| 32 |
-
{%- endfor -%}
|
| 33 |
-
<|tool_calls_section_end|>
|
| 34 |
-
{%- endmacro -%}
|
| 35 |
-
{%- if tools -%}
|
| 36 |
-
{%- if tools_ts_str -%}
|
| 37 |
-
<|im_system|>tool_declare<|im_middle|>{{ tools_ts_str }}<|im_end|>
|
| 38 |
-
{%- else -%}
|
| 39 |
-
<|im_system|>tool_declare<|im_middle|>{{ tools | tojson(separators=(',', ':')) }}<|im_end|>
|
| 40 |
-
{%- endif -%}
|
| 41 |
-
{%- endif -%}
|
| 42 |
-
{%- for message in messages -%}
|
| 43 |
-
{{set_roles(message)}}
|
| 44 |
-
{%- if message['role'] == 'assistant' -%}
|
| 45 |
-
{%- set rc = message.get('reasoning', message.get('reasoning_content', '')) -%}
|
| 46 |
-
<think>{{rc}}</think>{{render_content(message)}}
|
| 47 |
-
{%- if message.get('tool_calls') -%}
|
| 48 |
-
{{render_toolcalls(message)}}
|
| 49 |
-
{%- endif -%}
|
| 50 |
-
{%- elif message['role'] == 'tool' -%}
|
| 51 |
-
{%- set tool_call_id = message.tool_call_id -%}
|
| 52 |
-
## Return of {{ tool_call_id }}
|
| 53 |
-
{{render_content(message)}}
|
| 54 |
-
{%- elif message['content'] is not none -%}
|
| 55 |
-
{{render_content(message)}}
|
| 56 |
-
{%- endif -%}
|
| 57 |
-
<|im_end|>
|
| 58 |
-
{%- endfor -%}
|
| 59 |
-
{%- if add_generation_prompt -%}
|
| 60 |
-
<|im_assistant|>assistant<|im_middle|><think>
|
| 61 |
-
{%- endif -%}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
config.json
DELETED
|
@@ -1,433 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"architectures": [
|
| 3 |
-
"KimiK25ForConditionalGeneration"
|
| 4 |
-
],
|
| 5 |
-
"auto_map": {
|
| 6 |
-
"AutoConfig": "configuration_kimi_k25.KimiK25Config",
|
| 7 |
-
"AutoModel": "modeling_kimi_k25.KimiK25ForConditionalGeneration",
|
| 8 |
-
"AutoModelForCausalLM": "modeling_kimi_k25.KimiK25ForConditionalGeneration"
|
| 9 |
-
},
|
| 10 |
-
"bos_token_id": 163584,
|
| 11 |
-
"dtype": "bfloat16",
|
| 12 |
-
"eos_token_id": 163586,
|
| 13 |
-
"ignore_index": -100,
|
| 14 |
-
"media_placeholder_token_id": 163605,
|
| 15 |
-
"model_type": "kimi_k25",
|
| 16 |
-
"pad_token_id": 163839,
|
| 17 |
-
"text_config": {
|
| 18 |
-
"_name_or_path": "",
|
| 19 |
-
"add_cross_attention": false,
|
| 20 |
-
"architectures": [
|
| 21 |
-
"DeepseekV3ForCausalLM"
|
| 22 |
-
],
|
| 23 |
-
"attention_bias": false,
|
| 24 |
-
"attention_dropout": 0.0,
|
| 25 |
-
"auto_map": {
|
| 26 |
-
"AutoConfig": "configuration_deepseek.DeepseekV3Config",
|
| 27 |
-
"AutoModel": "modeling_deepseek.DeepseekV3Model",
|
| 28 |
-
"AutoModelForCausalLM": "modeling_deepseek.DeepseekV3ForCausalLM"
|
| 29 |
-
},
|
| 30 |
-
"aux_loss_alpha": 0.001,
|
| 31 |
-
"bad_words_ids": null,
|
| 32 |
-
"begin_suppress_tokens": null,
|
| 33 |
-
"bos_token_id": 163584,
|
| 34 |
-
"chunk_size_feed_forward": 0,
|
| 35 |
-
"cross_attention_hidden_size": null,
|
| 36 |
-
"decoder_start_token_id": null,
|
| 37 |
-
"diversity_penalty": 0.0,
|
| 38 |
-
"do_sample": false,
|
| 39 |
-
"dtype": "bfloat16",
|
| 40 |
-
"early_stopping": false,
|
| 41 |
-
"encoder_no_repeat_ngram_size": 0,
|
| 42 |
-
"eos_token_id": 163586,
|
| 43 |
-
"ep_size": 1,
|
| 44 |
-
"exponential_decay_length_penalty": null,
|
| 45 |
-
"finetuning_task": null,
|
| 46 |
-
"first_k_dense_replace": 1,
|
| 47 |
-
"forced_bos_token_id": null,
|
| 48 |
-
"forced_eos_token_id": null,
|
| 49 |
-
"hidden_act": "silu",
|
| 50 |
-
"hidden_size": 7168,
|
| 51 |
-
"id2label": {
|
| 52 |
-
"0": "LABEL_0",
|
| 53 |
-
"1": "LABEL_1"
|
| 54 |
-
},
|
| 55 |
-
"initializer_range": 0.02,
|
| 56 |
-
"intermediate_size": 18432,
|
| 57 |
-
"is_decoder": false,
|
| 58 |
-
"is_encoder_decoder": false,
|
| 59 |
-
"kv_lora_rank": 512,
|
| 60 |
-
"label2id": {
|
| 61 |
-
"LABEL_0": 0,
|
| 62 |
-
"LABEL_1": 1
|
| 63 |
-
},
|
| 64 |
-
"length_penalty": 1.0,
|
| 65 |
-
"max_length": 20,
|
| 66 |
-
"max_position_embeddings": 262144,
|
| 67 |
-
"min_length": 0,
|
| 68 |
-
"model_type": "kimi_k2",
|
| 69 |
-
"moe_intermediate_size": 2048,
|
| 70 |
-
"moe_layer_freq": 1,
|
| 71 |
-
"n_group": 1,
|
| 72 |
-
"n_routed_experts": 384,
|
| 73 |
-
"n_shared_experts": 1,
|
| 74 |
-
"no_repeat_ngram_size": 0,
|
| 75 |
-
"norm_topk_prob": true,
|
| 76 |
-
"num_attention_heads": 64,
|
| 77 |
-
"num_beam_groups": 1,
|
| 78 |
-
"num_beams": 1,
|
| 79 |
-
"num_experts_per_tok": 8,
|
| 80 |
-
"num_hidden_layers": 61,
|
| 81 |
-
"num_key_value_heads": 64,
|
| 82 |
-
"num_nextn_predict_layers": 0,
|
| 83 |
-
"num_return_sequences": 1,
|
| 84 |
-
"output_attentions": false,
|
| 85 |
-
"output_hidden_states": false,
|
| 86 |
-
"output_scores": false,
|
| 87 |
-
"pad_token_id": 163839,
|
| 88 |
-
"prefix": null,
|
| 89 |
-
"pretraining_tp": 1,
|
| 90 |
-
"problem_type": null,
|
| 91 |
-
"pruned_heads": {},
|
| 92 |
-
"q_lora_rank": 1536,
|
| 93 |
-
"qk_nope_head_dim": 128,
|
| 94 |
-
"qk_rope_head_dim": 64,
|
| 95 |
-
"remove_invalid_values": false,
|
| 96 |
-
"repetition_penalty": 1.0,
|
| 97 |
-
"return_dict": true,
|
| 98 |
-
"return_dict_in_generate": false,
|
| 99 |
-
"rms_norm_eps": 1e-05,
|
| 100 |
-
"rope_scaling": {
|
| 101 |
-
"beta_fast": 32.0,
|
| 102 |
-
"beta_slow": 1.0,
|
| 103 |
-
"factor": 64.0,
|
| 104 |
-
"mscale": 1.0,
|
| 105 |
-
"mscale_all_dim": 1.0,
|
| 106 |
-
"original_max_position_embeddings": 4096,
|
| 107 |
-
"type": "yarn"
|
| 108 |
-
},
|
| 109 |
-
"rope_theta": 50000.0,
|
| 110 |
-
"routed_scaling_factor": 2.827,
|
| 111 |
-
"scoring_func": "sigmoid",
|
| 112 |
-
"sep_token_id": null,
|
| 113 |
-
"seq_aux": true,
|
| 114 |
-
"suppress_tokens": null,
|
| 115 |
-
"task_specific_params": null,
|
| 116 |
-
"temperature": 1.0,
|
| 117 |
-
"tf_legacy_loss": false,
|
| 118 |
-
"tie_encoder_decoder": false,
|
| 119 |
-
"tie_word_embeddings": false,
|
| 120 |
-
"tokenizer_class": null,
|
| 121 |
-
"top_k": 50,
|
| 122 |
-
"top_p": 1.0,
|
| 123 |
-
"topk_group": 1,
|
| 124 |
-
"topk_method": "noaux_tc",
|
| 125 |
-
"torchscript": false,
|
| 126 |
-
"transformers_version": "4.56.2",
|
| 127 |
-
"typical_p": 1.0,
|
| 128 |
-
"use_bfloat16": false,
|
| 129 |
-
"use_cache": true,
|
| 130 |
-
"v_head_dim": 128,
|
| 131 |
-
"vocab_size": 163840
|
| 132 |
-
},
|
| 133 |
-
"tie_word_embeddings": false,
|
| 134 |
-
"use_unified_vision_chunk": true,
|
| 135 |
-
"video_placeholder": "<|kimi_k25_video_placeholder|>",
|
| 136 |
-
"vision_config": {
|
| 137 |
-
"_attn_implementation": "flash_attention_2",
|
| 138 |
-
"init_pos_emb_height": 64,
|
| 139 |
-
"init_pos_emb_time": 4,
|
| 140 |
-
"init_pos_emb_width": 64,
|
| 141 |
-
"merge_kernel_size": [
|
| 142 |
-
2,
|
| 143 |
-
2
|
| 144 |
-
],
|
| 145 |
-
"merge_type": "sd2_tpool",
|
| 146 |
-
"mm_hidden_size": 1152,
|
| 147 |
-
"mm_projector_type": "patchmerger",
|
| 148 |
-
"patch_size": 14,
|
| 149 |
-
"pos_emb_type": "divided_fixed",
|
| 150 |
-
"projector_hidden_act": "gelu",
|
| 151 |
-
"projector_ln_eps": 1e-05,
|
| 152 |
-
"text_hidden_size": 7168,
|
| 153 |
-
"video_attn_type": "spatial_temporal",
|
| 154 |
-
"vt_hidden_size": 1152,
|
| 155 |
-
"vt_intermediate_size": 4304,
|
| 156 |
-
"vt_num_attention_heads": 16,
|
| 157 |
-
"vt_num_hidden_layers": 27
|
| 158 |
-
},
|
| 159 |
-
"quantization_config": {
|
| 160 |
-
"global_quant_config": {
|
| 161 |
-
"input_tensors": {
|
| 162 |
-
"dtype": "fp4",
|
| 163 |
-
"is_dynamic": true,
|
| 164 |
-
"qscheme": "per_group",
|
| 165 |
-
"ch_axis": -1,
|
| 166 |
-
"group_size": 32,
|
| 167 |
-
"block_size": null,
|
| 168 |
-
"symmetric": null,
|
| 169 |
-
"round_method": "half_even",
|
| 170 |
-
"scale_type": "float",
|
| 171 |
-
"scale_format": "e8m0",
|
| 172 |
-
"scale_calculation_mode": "even",
|
| 173 |
-
"mx_element_dtype": null,
|
| 174 |
-
"observer_cls": "PerBlockMXObserver",
|
| 175 |
-
"is_scale_quant": false,
|
| 176 |
-
"enable_buffer_reuse": false,
|
| 177 |
-
"max_input_numel": 4194304
|
| 178 |
-
},
|
| 179 |
-
"output_tensors": null,
|
| 180 |
-
"weight": {
|
| 181 |
-
"dtype": "fp4",
|
| 182 |
-
"is_dynamic": false,
|
| 183 |
-
"qscheme": "per_group",
|
| 184 |
-
"ch_axis": -1,
|
| 185 |
-
"group_size": 32,
|
| 186 |
-
"block_size": null,
|
| 187 |
-
"symmetric": null,
|
| 188 |
-
"round_method": "half_even",
|
| 189 |
-
"scale_type": "float",
|
| 190 |
-
"scale_format": "e8m0",
|
| 191 |
-
"scale_calculation_mode": "even",
|
| 192 |
-
"mx_element_dtype": null,
|
| 193 |
-
"observer_cls": "PerBlockMXObserver",
|
| 194 |
-
"is_scale_quant": false,
|
| 195 |
-
"enable_buffer_reuse": false,
|
| 196 |
-
"max_input_numel": 4194304
|
| 197 |
-
},
|
| 198 |
-
"bias": null,
|
| 199 |
-
"target_device": null
|
| 200 |
-
},
|
| 201 |
-
"exclude": [
|
| 202 |
-
"language_model.lm_head",
|
| 203 |
-
"language_model.model.layers.1.mlp.gate",
|
| 204 |
-
"language_model.model.layers.10.mlp.gate",
|
| 205 |
-
"language_model.model.layers.11.mlp.gate",
|
| 206 |
-
"language_model.model.layers.12.mlp.gate",
|
| 207 |
-
"language_model.model.layers.13.mlp.gate",
|
| 208 |
-
"language_model.model.layers.14.mlp.gate",
|
| 209 |
-
"language_model.model.layers.15.mlp.gate",
|
| 210 |
-
"language_model.model.layers.16.mlp.gate",
|
| 211 |
-
"language_model.model.layers.17.mlp.gate",
|
| 212 |
-
"language_model.model.layers.18.mlp.gate",
|
| 213 |
-
"language_model.model.layers.19.mlp.gate",
|
| 214 |
-
"language_model.model.layers.2.mlp.gate",
|
| 215 |
-
"language_model.model.layers.20.mlp.gate",
|
| 216 |
-
"language_model.model.layers.21.mlp.gate",
|
| 217 |
-
"language_model.model.layers.22.mlp.gate",
|
| 218 |
-
"language_model.model.layers.23.mlp.gate",
|
| 219 |
-
"language_model.model.layers.24.mlp.gate",
|
| 220 |
-
"language_model.model.layers.25.mlp.gate",
|
| 221 |
-
"language_model.model.layers.26.mlp.gate",
|
| 222 |
-
"language_model.model.layers.27.mlp.gate",
|
| 223 |
-
"language_model.model.layers.28.mlp.gate",
|
| 224 |
-
"language_model.model.layers.29.mlp.gate",
|
| 225 |
-
"language_model.model.layers.3.mlp.gate",
|
| 226 |
-
"language_model.model.layers.30.mlp.gate",
|
| 227 |
-
"language_model.model.layers.31.mlp.gate",
|
| 228 |
-
"language_model.model.layers.32.mlp.gate",
|
| 229 |
-
"language_model.model.layers.33.mlp.gate",
|
| 230 |
-
"language_model.model.layers.34.mlp.gate",
|
| 231 |
-
"language_model.model.layers.35.mlp.gate",
|
| 232 |
-
"language_model.model.layers.36.mlp.gate",
|
| 233 |
-
"language_model.model.layers.37.mlp.gate",
|
| 234 |
-
"language_model.model.layers.38.mlp.gate",
|
| 235 |
-
"language_model.model.layers.39.mlp.gate",
|
| 236 |
-
"language_model.model.layers.4.mlp.gate",
|
| 237 |
-
"language_model.model.layers.40.mlp.gate",
|
| 238 |
-
"language_model.model.layers.41.mlp.gate",
|
| 239 |
-
"language_model.model.layers.42.mlp.gate",
|
| 240 |
-
"language_model.model.layers.43.mlp.gate",
|
| 241 |
-
"language_model.model.layers.44.mlp.gate",
|
| 242 |
-
"language_model.model.layers.45.mlp.gate",
|
| 243 |
-
"language_model.model.layers.46.mlp.gate",
|
| 244 |
-
"language_model.model.layers.47.mlp.gate",
|
| 245 |
-
"language_model.model.layers.48.mlp.gate",
|
| 246 |
-
"language_model.model.layers.49.mlp.gate",
|
| 247 |
-
"language_model.model.layers.5.mlp.gate",
|
| 248 |
-
"language_model.model.layers.50.mlp.gate",
|
| 249 |
-
"language_model.model.layers.51.mlp.gate",
|
| 250 |
-
"language_model.model.layers.52.mlp.gate",
|
| 251 |
-
"language_model.model.layers.53.mlp.gate",
|
| 252 |
-
"language_model.model.layers.54.mlp.gate",
|
| 253 |
-
"language_model.model.layers.55.mlp.gate",
|
| 254 |
-
"language_model.model.layers.56.mlp.gate",
|
| 255 |
-
"language_model.model.layers.57.mlp.gate",
|
| 256 |
-
"language_model.model.layers.58.mlp.gate",
|
| 257 |
-
"language_model.model.layers.59.mlp.gate",
|
| 258 |
-
"language_model.model.layers.6.mlp.gate",
|
| 259 |
-
"language_model.model.layers.60.mlp.gate",
|
| 260 |
-
"language_model.model.layers.7.mlp.gate",
|
| 261 |
-
"language_model.model.layers.8.mlp.gate",
|
| 262 |
-
"language_model.model.layers.9.mlp.gate",
|
| 263 |
-
"mm_projector.proj.0",
|
| 264 |
-
"mm_projector.proj.2",
|
| 265 |
-
"vision_tower.encoder.blocks.0.mlp.fc0",
|
| 266 |
-
"vision_tower.encoder.blocks.0.mlp.fc1",
|
| 267 |
-
"vision_tower.encoder.blocks.0.wo",
|
| 268 |
-
"vision_tower.encoder.blocks.0.wqkv",
|
| 269 |
-
"vision_tower.encoder.blocks.1.mlp.fc0",
|
| 270 |
-
"vision_tower.encoder.blocks.1.mlp.fc1",
|
| 271 |
-
"vision_tower.encoder.blocks.1.wo",
|
| 272 |
-
"vision_tower.encoder.blocks.1.wqkv",
|
| 273 |
-
"vision_tower.encoder.blocks.10.mlp.fc0",
|
| 274 |
-
"vision_tower.encoder.blocks.10.mlp.fc1",
|
| 275 |
-
"vision_tower.encoder.blocks.10.wo",
|
| 276 |
-
"vision_tower.encoder.blocks.10.wqkv",
|
| 277 |
-
"vision_tower.encoder.blocks.11.mlp.fc0",
|
| 278 |
-
"vision_tower.encoder.blocks.11.mlp.fc1",
|
| 279 |
-
"vision_tower.encoder.blocks.11.wo",
|
| 280 |
-
"vision_tower.encoder.blocks.11.wqkv",
|
| 281 |
-
"vision_tower.encoder.blocks.12.mlp.fc0",
|
| 282 |
-
"vision_tower.encoder.blocks.12.mlp.fc1",
|
| 283 |
-
"vision_tower.encoder.blocks.12.wo",
|
| 284 |
-
"vision_tower.encoder.blocks.12.wqkv",
|
| 285 |
-
"vision_tower.encoder.blocks.13.mlp.fc0",
|
| 286 |
-
"vision_tower.encoder.blocks.13.mlp.fc1",
|
| 287 |
-
"vision_tower.encoder.blocks.13.wo",
|
| 288 |
-
"vision_tower.encoder.blocks.13.wqkv",
|
| 289 |
-
"vision_tower.encoder.blocks.14.mlp.fc0",
|
| 290 |
-
"vision_tower.encoder.blocks.14.mlp.fc1",
|
| 291 |
-
"vision_tower.encoder.blocks.14.wo",
|
| 292 |
-
"vision_tower.encoder.blocks.14.wqkv",
|
| 293 |
-
"vision_tower.encoder.blocks.15.mlp.fc0",
|
| 294 |
-
"vision_tower.encoder.blocks.15.mlp.fc1",
|
| 295 |
-
"vision_tower.encoder.blocks.15.wo",
|
| 296 |
-
"vision_tower.encoder.blocks.15.wqkv",
|
| 297 |
-
"vision_tower.encoder.blocks.16.mlp.fc0",
|
| 298 |
-
"vision_tower.encoder.blocks.16.mlp.fc1",
|
| 299 |
-
"vision_tower.encoder.blocks.16.wo",
|
| 300 |
-
"vision_tower.encoder.blocks.16.wqkv",
|
| 301 |
-
"vision_tower.encoder.blocks.17.mlp.fc0",
|
| 302 |
-
"vision_tower.encoder.blocks.17.mlp.fc1",
|
| 303 |
-
"vision_tower.encoder.blocks.17.wo",
|
| 304 |
-
"vision_tower.encoder.blocks.17.wqkv",
|
| 305 |
-
"vision_tower.encoder.blocks.18.mlp.fc0",
|
| 306 |
-
"vision_tower.encoder.blocks.18.mlp.fc1",
|
| 307 |
-
"vision_tower.encoder.blocks.18.wo",
|
| 308 |
-
"vision_tower.encoder.blocks.18.wqkv",
|
| 309 |
-
"vision_tower.encoder.blocks.19.mlp.fc0",
|
| 310 |
-
"vision_tower.encoder.blocks.19.mlp.fc1",
|
| 311 |
-
"vision_tower.encoder.blocks.19.wo",
|
| 312 |
-
"vision_tower.encoder.blocks.19.wqkv",
|
| 313 |
-
"vision_tower.encoder.blocks.2.mlp.fc0",
|
| 314 |
-
"vision_tower.encoder.blocks.2.mlp.fc1",
|
| 315 |
-
"vision_tower.encoder.blocks.2.wo",
|
| 316 |
-
"vision_tower.encoder.blocks.2.wqkv",
|
| 317 |
-
"vision_tower.encoder.blocks.20.mlp.fc0",
|
| 318 |
-
"vision_tower.encoder.blocks.20.mlp.fc1",
|
| 319 |
-
"vision_tower.encoder.blocks.20.wo",
|
| 320 |
-
"vision_tower.encoder.blocks.20.wqkv",
|
| 321 |
-
"vision_tower.encoder.blocks.21.mlp.fc0",
|
| 322 |
-
"vision_tower.encoder.blocks.21.mlp.fc1",
|
| 323 |
-
"vision_tower.encoder.blocks.21.wo",
|
| 324 |
-
"vision_tower.encoder.blocks.21.wqkv",
|
| 325 |
-
"vision_tower.encoder.blocks.22.mlp.fc0",
|
| 326 |
-
"vision_tower.encoder.blocks.22.mlp.fc1",
|
| 327 |
-
"vision_tower.encoder.blocks.22.wo",
|
| 328 |
-
"vision_tower.encoder.blocks.22.wqkv",
|
| 329 |
-
"vision_tower.encoder.blocks.23.mlp.fc0",
|
| 330 |
-
"vision_tower.encoder.blocks.23.mlp.fc1",
|
| 331 |
-
"vision_tower.encoder.blocks.23.wo",
|
| 332 |
-
"vision_tower.encoder.blocks.23.wqkv",
|
| 333 |
-
"vision_tower.encoder.blocks.24.mlp.fc0",
|
| 334 |
-
"vision_tower.encoder.blocks.24.mlp.fc1",
|
| 335 |
-
"vision_tower.encoder.blocks.24.wo",
|
| 336 |
-
"vision_tower.encoder.blocks.24.wqkv",
|
| 337 |
-
"vision_tower.encoder.blocks.25.mlp.fc0",
|
| 338 |
-
"vision_tower.encoder.blocks.25.mlp.fc1",
|
| 339 |
-
"vision_tower.encoder.blocks.25.wo",
|
| 340 |
-
"vision_tower.encoder.blocks.25.wqkv",
|
| 341 |
-
"vision_tower.encoder.blocks.26.mlp.fc0",
|
| 342 |
-
"vision_tower.encoder.blocks.26.mlp.fc1",
|
| 343 |
-
"vision_tower.encoder.blocks.26.wo",
|
| 344 |
-
"vision_tower.encoder.blocks.26.wqkv",
|
| 345 |
-
"vision_tower.encoder.blocks.3.mlp.fc0",
|
| 346 |
-
"vision_tower.encoder.blocks.3.mlp.fc1",
|
| 347 |
-
"vision_tower.encoder.blocks.3.wo",
|
| 348 |
-
"vision_tower.encoder.blocks.3.wqkv",
|
| 349 |
-
"vision_tower.encoder.blocks.4.mlp.fc0",
|
| 350 |
-
"vision_tower.encoder.blocks.4.mlp.fc1",
|
| 351 |
-
"vision_tower.encoder.blocks.4.wo",
|
| 352 |
-
"vision_tower.encoder.blocks.4.wqkv",
|
| 353 |
-
"vision_tower.encoder.blocks.5.mlp.fc0",
|
| 354 |
-
"vision_tower.encoder.blocks.5.mlp.fc1",
|
| 355 |
-
"vision_tower.encoder.blocks.5.wo",
|
| 356 |
-
"vision_tower.encoder.blocks.5.wqkv",
|
| 357 |
-
"vision_tower.encoder.blocks.6.mlp.fc0",
|
| 358 |
-
"vision_tower.encoder.blocks.6.mlp.fc1",
|
| 359 |
-
"vision_tower.encoder.blocks.6.wo",
|
| 360 |
-
"vision_tower.encoder.blocks.6.wqkv",
|
| 361 |
-
"vision_tower.encoder.blocks.7.mlp.fc0",
|
| 362 |
-
"vision_tower.encoder.blocks.7.mlp.fc1",
|
| 363 |
-
"vision_tower.encoder.blocks.7.wo",
|
| 364 |
-
"vision_tower.encoder.blocks.7.wqkv",
|
| 365 |
-
"vision_tower.encoder.blocks.8.mlp.fc0",
|
| 366 |
-
"vision_tower.encoder.blocks.8.mlp.fc1",
|
| 367 |
-
"vision_tower.encoder.blocks.8.wo",
|
| 368 |
-
"vision_tower.encoder.blocks.8.wqkv",
|
| 369 |
-
"vision_tower.encoder.blocks.9.mlp.fc0",
|
| 370 |
-
"vision_tower.encoder.blocks.9.mlp.fc1",
|
| 371 |
-
"vision_tower.encoder.blocks.9.wo",
|
| 372 |
-
"vision_tower.encoder.blocks.9.wqkv"
|
| 373 |
-
],
|
| 374 |
-
"algo_config": null,
|
| 375 |
-
"softmax_quant_spec": null,
|
| 376 |
-
"quant_method": "quark",
|
| 377 |
-
"layer_type_quant_config": {},
|
| 378 |
-
"layer_quant_config": {
|
| 379 |
-
"*self_attn*": {
|
| 380 |
-
"input_tensors": {
|
| 381 |
-
"dtype": "fp8_e4m3",
|
| 382 |
-
"is_dynamic": true,
|
| 383 |
-
"qscheme": "per_channel",
|
| 384 |
-
"ch_axis": 1,
|
| 385 |
-
"group_size": null,
|
| 386 |
-
"block_size": null,
|
| 387 |
-
"symmetric": true,
|
| 388 |
-
"round_method": "half_even",
|
| 389 |
-
"scale_type": "float",
|
| 390 |
-
"scale_format": null,
|
| 391 |
-
"scale_calculation_mode": null,
|
| 392 |
-
"mx_element_dtype": null,
|
| 393 |
-
"observer_cls": "PerChannelMinMaxObserver",
|
| 394 |
-
"is_scale_quant": false,
|
| 395 |
-
"enable_buffer_reuse": false,
|
| 396 |
-
"max_input_numel": 4194304
|
| 397 |
-
},
|
| 398 |
-
"output_tensors": null,
|
| 399 |
-
"weight": {
|
| 400 |
-
"dtype": "fp8_e4m3",
|
| 401 |
-
"is_dynamic": false,
|
| 402 |
-
"qscheme": "per_channel",
|
| 403 |
-
"ch_axis": 0,
|
| 404 |
-
"group_size": null,
|
| 405 |
-
"block_size": null,
|
| 406 |
-
"symmetric": true,
|
| 407 |
-
"round_method": "half_even",
|
| 408 |
-
"scale_type": "float",
|
| 409 |
-
"scale_format": null,
|
| 410 |
-
"scale_calculation_mode": null,
|
| 411 |
-
"mx_element_dtype": null,
|
| 412 |
-
"observer_cls": "PerChannelMinMaxObserver",
|
| 413 |
-
"is_scale_quant": false,
|
| 414 |
-
"enable_buffer_reuse": false,
|
| 415 |
-
"max_input_numel": 4194304
|
| 416 |
-
},
|
| 417 |
-
"bias": null,
|
| 418 |
-
"target_device": null
|
| 419 |
-
}
|
| 420 |
-
},
|
| 421 |
-
"kv_cache_quant_config": {},
|
| 422 |
-
"kv_cache_post_rope": false,
|
| 423 |
-
"quant_mode": "eager_mode",
|
| 424 |
-
"version": "0.12+f7bd7b7b998",
|
| 425 |
-
"export": {
|
| 426 |
-
"kv_cache_group": [],
|
| 427 |
-
"min_kv_scale": 0.0,
|
| 428 |
-
"pack_method": "reorder",
|
| 429 |
-
"weight_format": "real_quantized",
|
| 430 |
-
"weight_merge_groups": null
|
| 431 |
-
}
|
| 432 |
-
}
|
| 433 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
configuration_deepseek.py
DELETED
|
@@ -1,214 +0,0 @@
|
|
| 1 |
-
# Copy from https://huggingface.co/deepseek-ai/DeepSeek-V3/blob/main/configuration_deepseek.py
|
| 2 |
-
|
| 3 |
-
from transformers.configuration_utils import PretrainedConfig
|
| 4 |
-
from transformers.utils import logging
|
| 5 |
-
|
| 6 |
-
logger = logging.get_logger(__name__)
|
| 7 |
-
|
| 8 |
-
DEEPSEEK_PRETRAINED_CONFIG_ARCHIVE_MAP = {}
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
class DeepseekV3Config(PretrainedConfig):
|
| 12 |
-
r"""
|
| 13 |
-
This is the configuration class to store the configuration of a [`DeepseekV3Model`]. It is used to instantiate an DeepSeek
|
| 14 |
-
model according to the specified arguments, defining the model architecture. Instantiating a configuration with the
|
| 15 |
-
defaults will yield a similar configuration to that of the DeepSeek-V3.
|
| 16 |
-
|
| 17 |
-
Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
|
| 18 |
-
documentation from [`PretrainedConfig`] for more information.
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
Args:
|
| 22 |
-
vocab_size (`int`, *optional*, defaults to 129280):
|
| 23 |
-
Vocabulary size of the Deep model. Defines the number of different tokens that can be represented by the
|
| 24 |
-
`inputs_ids` passed when calling [`DeepseekV3Model`]
|
| 25 |
-
hidden_size (`int`, *optional*, defaults to 4096):
|
| 26 |
-
Dimension of the hidden representations.
|
| 27 |
-
intermediate_size (`int`, *optional*, defaults to 11008):
|
| 28 |
-
Dimension of the MLP representations.
|
| 29 |
-
moe_intermediate_size (`int`, *optional*, defaults to 1407):
|
| 30 |
-
Dimension of the MoE representations.
|
| 31 |
-
num_hidden_layers (`int`, *optional*, defaults to 32):
|
| 32 |
-
Number of hidden layers in the Transformer decoder.
|
| 33 |
-
num_nextn_predict_layers (`int`, *optional*, defaults to 1):
|
| 34 |
-
Number of nextn predict layers in the DeepSeekV3 Model.
|
| 35 |
-
num_attention_heads (`int`, *optional*, defaults to 32):
|
| 36 |
-
Number of attention heads for each attention layer in the Transformer decoder.
|
| 37 |
-
n_shared_experts (`int`, *optional*, defaults to None):
|
| 38 |
-
Number of shared experts, None means dense model.
|
| 39 |
-
n_routed_experts (`int`, *optional*, defaults to None):
|
| 40 |
-
Number of routed experts, None means dense model.
|
| 41 |
-
routed_scaling_factor (`float`, *optional*, defaults to 1.0):
|
| 42 |
-
Scaling factor or routed experts.
|
| 43 |
-
topk_method (`str`, *optional*, defaults to `gready`):
|
| 44 |
-
Topk method used in routed gate.
|
| 45 |
-
n_group (`int`, *optional*, defaults to None):
|
| 46 |
-
Number of groups for routed experts.
|
| 47 |
-
topk_group (`int`, *optional*, defaults to None):
|
| 48 |
-
Number of selected groups for each token(for each token, ensuring the selected experts is only within `topk_group` groups).
|
| 49 |
-
num_experts_per_tok (`int`, *optional*, defaults to None):
|
| 50 |
-
Number of selected experts, None means dense model.
|
| 51 |
-
moe_layer_freq (`int`, *optional*, defaults to 1):
|
| 52 |
-
The frequency of the MoE layer: one expert layer for every `moe_layer_freq - 1` dense layers.
|
| 53 |
-
first_k_dense_replace (`int`, *optional*, defaults to 0):
|
| 54 |
-
Number of dense layers in shallow layers(embed->dense->dense->...->dense->moe->moe...->lm_head).
|
| 55 |
-
\--k dense layers--/
|
| 56 |
-
norm_topk_prob (`bool`, *optional*, defaults to False):
|
| 57 |
-
Whether to normalize the weights of the routed experts.
|
| 58 |
-
scoring_func (`str`, *optional*, defaults to 'softmax'):
|
| 59 |
-
Method of computing expert weights.
|
| 60 |
-
aux_loss_alpha (`float`, *optional*, defaults to 0.001):
|
| 61 |
-
Auxiliary loss weight coefficient.
|
| 62 |
-
seq_aux = (`bool`, *optional*, defaults to True):
|
| 63 |
-
Whether to compute the auxiliary loss for each individual sample.
|
| 64 |
-
num_key_value_heads (`int`, *optional*):
|
| 65 |
-
This is the number of key_value heads that should be used to implement Grouped Query Attention. If
|
| 66 |
-
`num_key_value_heads=num_attention_heads`, the model will use Multi Head Attention (MHA), if
|
| 67 |
-
`num_key_value_heads=1 the model will use Multi Query Attention (MQA) otherwise GQA is used. When
|
| 68 |
-
converting a multi-head checkpoint to a GQA checkpoint, each group key and value head should be constructed
|
| 69 |
-
by meanpooling all the original heads within that group. For more details checkout [this
|
| 70 |
-
paper](https://arxiv.org/pdf/2305.13245.pdf). If it is not specified, will default to
|
| 71 |
-
`num_attention_heads`.
|
| 72 |
-
hidden_act (`str` or `function`, *optional*, defaults to `"silu"`):
|
| 73 |
-
The non-linear activation function (function or string) in the decoder.
|
| 74 |
-
max_position_embeddings (`int`, *optional*, defaults to 2048):
|
| 75 |
-
The maximum sequence length that this model might ever be used with.
|
| 76 |
-
initializer_range (`float`, *optional*, defaults to 0.02):
|
| 77 |
-
The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
|
| 78 |
-
rms_norm_eps (`float`, *optional*, defaults to 1e-06):
|
| 79 |
-
The epsilon used by the rms normalization layers.
|
| 80 |
-
use_cache (`bool`, *optional*, defaults to `True`):
|
| 81 |
-
Whether or not the model should return the last key/values attentions (not used by all models). Only
|
| 82 |
-
relevant if `config.is_decoder=True`.
|
| 83 |
-
pad_token_id (`int`, *optional*):
|
| 84 |
-
Padding token id.
|
| 85 |
-
bos_token_id (`int`, *optional*, defaults to 1):
|
| 86 |
-
Beginning of stream token id.
|
| 87 |
-
eos_token_id (`int`, *optional*, defaults to 2):
|
| 88 |
-
End of stream token id.
|
| 89 |
-
pretraining_tp (`int`, *optional*, defaults to 1):
|
| 90 |
-
Experimental feature. Tensor parallelism rank used during pretraining. Please refer to [this
|
| 91 |
-
document](https://huggingface.co/docs/transformers/parallelism) to understand more about it. This value is
|
| 92 |
-
necessary to ensure exact reproducibility of the pretraining results. Please refer to [this
|
| 93 |
-
issue](https://github.com/pytorch/pytorch/issues/76232).
|
| 94 |
-
tie_word_embeddings (`bool`, *optional*, defaults to `False`):
|
| 95 |
-
Whether to tie weight embeddings
|
| 96 |
-
rope_theta (`float`, *optional*, defaults to 10000.0):
|
| 97 |
-
The base period of the RoPE embeddings.
|
| 98 |
-
rope_scaling (`Dict`, *optional*):
|
| 99 |
-
Dictionary containing the scaling configuration for the RoPE embeddings. Currently supports two scaling
|
| 100 |
-
strategies: linear and dynamic. Their scaling factor must be a float greater than 1. The expected format is
|
| 101 |
-
`{"type": strategy name, "factor": scaling factor}`. When using this flag, don't update
|
| 102 |
-
`max_position_embeddings` to the expected new maximum.
|
| 103 |
-
attention_bias (`bool`, defaults to `False`, *optional*, defaults to `False`):
|
| 104 |
-
Whether to use a bias in the query, key, value and output projection layers during self-attention.
|
| 105 |
-
attention_dropout (`float`, *optional*, defaults to 0.0):
|
| 106 |
-
The dropout ratio for the attention probabilities.
|
| 107 |
-
|
| 108 |
-
```python
|
| 109 |
-
>>> from transformers import DeepseekV3Model, DeepseekV3Config
|
| 110 |
-
|
| 111 |
-
>>> # Initializing a Deepseek-V3 style configuration
|
| 112 |
-
>>> configuration = DeepseekV3Config()
|
| 113 |
-
|
| 114 |
-
>>> # Accessing the model configuration
|
| 115 |
-
>>> configuration = model.config
|
| 116 |
-
```"""
|
| 117 |
-
|
| 118 |
-
model_type = "deepseek_v3"
|
| 119 |
-
keys_to_ignore_at_inference = ["past_key_values"]
|
| 120 |
-
|
| 121 |
-
def __init__(
|
| 122 |
-
self,
|
| 123 |
-
vocab_size=129280,
|
| 124 |
-
hidden_size=7168,
|
| 125 |
-
intermediate_size=18432,
|
| 126 |
-
moe_intermediate_size=2048,
|
| 127 |
-
num_hidden_layers=61,
|
| 128 |
-
num_nextn_predict_layers=1,
|
| 129 |
-
num_attention_heads=128,
|
| 130 |
-
num_key_value_heads=128,
|
| 131 |
-
n_shared_experts=1,
|
| 132 |
-
n_routed_experts=256,
|
| 133 |
-
ep_size=1,
|
| 134 |
-
routed_scaling_factor=2.5,
|
| 135 |
-
kv_lora_rank=512,
|
| 136 |
-
q_lora_rank=1536,
|
| 137 |
-
qk_rope_head_dim=64,
|
| 138 |
-
v_head_dim=128,
|
| 139 |
-
qk_nope_head_dim=128,
|
| 140 |
-
topk_method='noaux_tc',
|
| 141 |
-
n_group=8,
|
| 142 |
-
topk_group=4,
|
| 143 |
-
num_experts_per_tok=8,
|
| 144 |
-
moe_layer_freq=1,
|
| 145 |
-
first_k_dense_replace=3,
|
| 146 |
-
norm_topk_prob=True,
|
| 147 |
-
scoring_func='sigmoid',
|
| 148 |
-
aux_loss_alpha=0.001,
|
| 149 |
-
seq_aux=True,
|
| 150 |
-
hidden_act="silu",
|
| 151 |
-
max_position_embeddings=4096,
|
| 152 |
-
initializer_range=0.02,
|
| 153 |
-
rms_norm_eps=1e-6,
|
| 154 |
-
use_cache=True,
|
| 155 |
-
pad_token_id=None,
|
| 156 |
-
bos_token_id=0,
|
| 157 |
-
eos_token_id=1,
|
| 158 |
-
pretraining_tp=1,
|
| 159 |
-
tie_word_embeddings=False,
|
| 160 |
-
rope_theta=10000.0,
|
| 161 |
-
rope_scaling=None,
|
| 162 |
-
attention_bias=False,
|
| 163 |
-
attention_dropout=0.0,
|
| 164 |
-
**kwargs,
|
| 165 |
-
):
|
| 166 |
-
self.vocab_size = vocab_size
|
| 167 |
-
self.max_position_embeddings = max_position_embeddings
|
| 168 |
-
self.hidden_size = hidden_size
|
| 169 |
-
self.intermediate_size = intermediate_size
|
| 170 |
-
self.moe_intermediate_size = moe_intermediate_size
|
| 171 |
-
self.num_hidden_layers = num_hidden_layers
|
| 172 |
-
self.num_nextn_predict_layers = num_nextn_predict_layers
|
| 173 |
-
self.num_attention_heads = num_attention_heads
|
| 174 |
-
self.n_shared_experts = n_shared_experts
|
| 175 |
-
self.n_routed_experts = n_routed_experts
|
| 176 |
-
self.ep_size = ep_size
|
| 177 |
-
self.routed_scaling_factor = routed_scaling_factor
|
| 178 |
-
self.kv_lora_rank = kv_lora_rank
|
| 179 |
-
self.q_lora_rank = q_lora_rank
|
| 180 |
-
self.qk_rope_head_dim = qk_rope_head_dim
|
| 181 |
-
self.v_head_dim = v_head_dim
|
| 182 |
-
self.qk_nope_head_dim = qk_nope_head_dim
|
| 183 |
-
self.topk_method = topk_method
|
| 184 |
-
self.n_group = n_group
|
| 185 |
-
self.topk_group = topk_group
|
| 186 |
-
self.num_experts_per_tok = num_experts_per_tok
|
| 187 |
-
self.moe_layer_freq = moe_layer_freq
|
| 188 |
-
self.first_k_dense_replace = first_k_dense_replace
|
| 189 |
-
self.norm_topk_prob = norm_topk_prob
|
| 190 |
-
self.scoring_func = scoring_func
|
| 191 |
-
self.aux_loss_alpha = aux_loss_alpha
|
| 192 |
-
self.seq_aux = seq_aux
|
| 193 |
-
# for backward compatibility
|
| 194 |
-
if num_key_value_heads is None:
|
| 195 |
-
num_key_value_heads = num_attention_heads
|
| 196 |
-
|
| 197 |
-
self.num_key_value_heads = num_key_value_heads
|
| 198 |
-
self.hidden_act = hidden_act
|
| 199 |
-
self.initializer_range = initializer_range
|
| 200 |
-
self.rms_norm_eps = rms_norm_eps
|
| 201 |
-
self.pretraining_tp = pretraining_tp
|
| 202 |
-
self.use_cache = use_cache
|
| 203 |
-
self.rope_theta = rope_theta
|
| 204 |
-
self.rope_scaling = rope_scaling
|
| 205 |
-
self.attention_bias = attention_bias
|
| 206 |
-
self.attention_dropout = attention_dropout
|
| 207 |
-
|
| 208 |
-
super().__init__(
|
| 209 |
-
pad_token_id=pad_token_id,
|
| 210 |
-
bos_token_id=bos_token_id,
|
| 211 |
-
eos_token_id=eos_token_id,
|
| 212 |
-
tie_word_embeddings=tie_word_embeddings,
|
| 213 |
-
**kwargs,
|
| 214 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
configuration_kimi_k25.py
DELETED
|
@@ -1,123 +0,0 @@
|
|
| 1 |
-
from transformers.configuration_utils import PretrainedConfig
|
| 2 |
-
|
| 3 |
-
try:
|
| 4 |
-
from configuration_deepseek import DeepseekV3Config
|
| 5 |
-
except ImportError:
|
| 6 |
-
from .configuration_deepseek import DeepseekV3Config
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
class KimiK25VisionConfig(PretrainedConfig):
|
| 10 |
-
|
| 11 |
-
def __init__(
|
| 12 |
-
self,
|
| 13 |
-
patch_size: int = 14,
|
| 14 |
-
init_pos_emb_height: int = 64,
|
| 15 |
-
init_pos_emb_width: int = 64,
|
| 16 |
-
init_pos_emb_time: int = 4,
|
| 17 |
-
pos_emb_type: str = 'divided_fixed',
|
| 18 |
-
vt_num_attention_heads: int = 16,
|
| 19 |
-
vt_num_hidden_layers: int = 27,
|
| 20 |
-
vt_hidden_size: int = 1152,
|
| 21 |
-
vt_intermediate_size: int = 4304,
|
| 22 |
-
merge_kernel_size: tuple = (2, 2),
|
| 23 |
-
video_attn_type: str = 'spatial_temporal',
|
| 24 |
-
merge_type: str = 'sd2_tpool',
|
| 25 |
-
_attn_implementation: str = 'flash_attention_2',
|
| 26 |
-
# MM Projector parameters
|
| 27 |
-
mm_projector_type: str = 'patchmerger',
|
| 28 |
-
mm_hidden_size: int | None = None,
|
| 29 |
-
projector_hidden_act: str = "gelu",
|
| 30 |
-
projector_ln_eps: float = 1e-5,
|
| 31 |
-
# Other parameters
|
| 32 |
-
ignore_index: int = -100,
|
| 33 |
-
media_placeholder_token_id: int = 163605,
|
| 34 |
-
pad_token_id: int = 0,
|
| 35 |
-
use_unified_vision_chunk: bool = True,
|
| 36 |
-
video_placeholder="<|kimi_k25_video_placeholder|>",
|
| 37 |
-
text_hidden_size=7168,
|
| 38 |
-
**vision_config_kwargs):
|
| 39 |
-
|
| 40 |
-
self.patch_size = patch_size
|
| 41 |
-
self.init_pos_emb_height = init_pos_emb_height
|
| 42 |
-
self.init_pos_emb_width = init_pos_emb_width
|
| 43 |
-
self.init_pos_emb_time = init_pos_emb_time
|
| 44 |
-
self.pos_emb_type = pos_emb_type
|
| 45 |
-
self.vt_num_attention_heads = vt_num_attention_heads
|
| 46 |
-
self.vt_num_hidden_layers = vt_num_hidden_layers
|
| 47 |
-
self.vt_hidden_size = vt_hidden_size
|
| 48 |
-
self.vt_intermediate_size = vt_intermediate_size
|
| 49 |
-
self.merge_kernel_size = merge_kernel_size
|
| 50 |
-
self.video_attn_type = video_attn_type
|
| 51 |
-
self.merge_type = merge_type
|
| 52 |
-
self._attn_implementation = _attn_implementation
|
| 53 |
-
|
| 54 |
-
# MM Projector config
|
| 55 |
-
self.mm_projector_type = mm_projector_type
|
| 56 |
-
self.mm_hidden_size = mm_hidden_size if mm_hidden_size is not None else vt_hidden_size
|
| 57 |
-
self.projector_hidden_act = projector_hidden_act
|
| 58 |
-
self.projector_ln_eps = projector_ln_eps
|
| 59 |
-
self.text_hidden_size = text_hidden_size
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
class KimiK25Config(PretrainedConfig):
|
| 63 |
-
"""Kimi-K2.5 model configuration.
|
| 64 |
-
|
| 65 |
-
Args:
|
| 66 |
-
text_config (dict | DeepseekV3Config): Configuration for the text model.
|
| 67 |
-
|
| 68 |
-
Vision Tower Parameters (from MoonViT3dConfig):
|
| 69 |
-
patch_size (int): Patch size for vision tower.
|
| 70 |
-
init_pos_emb_height (int): Initial position embedding height.
|
| 71 |
-
init_pos_emb_width (int): Initial position embedding width.
|
| 72 |
-
init_pos_emb_time (int): Initial position embedding time dimension.
|
| 73 |
-
pos_emb_type (str): Type of position embedding.
|
| 74 |
-
vt_num_attention_heads (int): Number of attention heads in vision tower.
|
| 75 |
-
vt_num_hidden_layers (int): Number of hidden layers in vision tower.
|
| 76 |
-
vt_hidden_size (int): Hidden size of vision tower.
|
| 77 |
-
vt_intermediate_size (int): Intermediate size in vision tower FFN.
|
| 78 |
-
merge_kernel_size (tuple): Kernel size for patch merging.
|
| 79 |
-
video_attn_type (str): Type of video attention.
|
| 80 |
-
merge_type (str): Type of merge operation.
|
| 81 |
-
_attn_implementation (str): Attention implementation type.
|
| 82 |
-
|
| 83 |
-
MM Projector Parameters (from MultiModalProjectorConfig):
|
| 84 |
-
mm_projector_type (str): Type of multimodal projector.
|
| 85 |
-
mm_hidden_size (int): Hidden size from vision tower (should match vt_hidden_size).
|
| 86 |
-
projector_hidden_act (str): Activation function for projector.
|
| 87 |
-
projector_ln_eps (float): Layer norm epsilon for projector.
|
| 88 |
-
|
| 89 |
-
Other Parameters:
|
| 90 |
-
ignore_index (int): The ignore index for the loss function.
|
| 91 |
-
media_placeholder_token_id (int): The token ID to use for media placeholders.
|
| 92 |
-
pad_token_id (int): The token ID to use for padding.
|
| 93 |
-
"""
|
| 94 |
-
|
| 95 |
-
model_type = "kimi_k25"
|
| 96 |
-
|
| 97 |
-
def __init__(
|
| 98 |
-
self,
|
| 99 |
-
text_config: dict | DeepseekV3Config = None,
|
| 100 |
-
vision_config: dict | KimiK25VisionConfig = None,
|
| 101 |
-
# Other parameters
|
| 102 |
-
ignore_index: int = -100,
|
| 103 |
-
media_placeholder_token_id: int = 163605,
|
| 104 |
-
pad_token_id: int = 0,
|
| 105 |
-
use_unified_vision_chunk: bool = True,
|
| 106 |
-
video_placeholder="<|kimi_k25_video_placeholder|>",
|
| 107 |
-
**kwargs,
|
| 108 |
-
):
|
| 109 |
-
if isinstance(text_config, dict):
|
| 110 |
-
text_config = DeepseekV3Config(**text_config)
|
| 111 |
-
if isinstance(vision_config, dict):
|
| 112 |
-
vision_config = KimiK25VisionConfig(**vision_config)
|
| 113 |
-
self.text_config = text_config
|
| 114 |
-
self.vision_config = vision_config
|
| 115 |
-
# Other config
|
| 116 |
-
self.ignore_index = ignore_index
|
| 117 |
-
self.media_placeholder_token_id = media_placeholder_token_id
|
| 118 |
-
self.use_unified_vision_chunk = use_unified_vision_chunk
|
| 119 |
-
self.video_placeholder = video_placeholder
|
| 120 |
-
if getattr(self.text_config, "quantization_config", None) is not None:
|
| 121 |
-
self.quantization_config = self.text_config.quantization_config
|
| 122 |
-
|
| 123 |
-
super().__init__(pad_token_id=pad_token_id, **kwargs)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
generation_config.json
DELETED
|
@@ -1,6 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"max_length": 262144,
|
| 3 |
-
"eos_token_id": 163586,
|
| 4 |
-
"temperature": 1.0,
|
| 5 |
-
"top_p": 0.95
|
| 6 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
kimi_k25_processor.py
DELETED
|
@@ -1,165 +0,0 @@
|
|
| 1 |
-
from transformers.feature_extraction_utils import BatchFeature
|
| 2 |
-
from transformers.processing_utils import ProcessorMixin
|
| 3 |
-
from transformers.utils import logging
|
| 4 |
-
|
| 5 |
-
logger = logging.get_logger(__name__)
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
class KimiK25Processor(ProcessorMixin):
|
| 9 |
-
r"""
|
| 10 |
-
Constructs a KimiK25 processor which wraps a KimiK25 image processor and a tokenizer into a single processor.
|
| 11 |
-
|
| 12 |
-
[`KimiK25Processor`] offers all the functionalities of [`KimiK25ImageProcessor`] and [`TikTokenTokenizer`]. See the
|
| 13 |
-
[`~KimiK25Processor.__call__`] and [`~KimiK25Processor.decode`] for more information.
|
| 14 |
-
|
| 15 |
-
Args:
|
| 16 |
-
image_processor ([`KimiK25ImageProcessor`], *optional*):
|
| 17 |
-
The image processor is a required input.
|
| 18 |
-
tokenizer ([`TikTokenTokenizer`], *optional*):
|
| 19 |
-
The tokenizer is a required input.
|
| 20 |
-
chat_template (`str`, *optional*): A Jinja template which will be used to convert lists of messages
|
| 21 |
-
in a chat into a tokenizable string.
|
| 22 |
-
"""
|
| 23 |
-
|
| 24 |
-
attributes = ["image_processor", "tokenizer"]
|
| 25 |
-
valid_kwargs = ["chat_template"]
|
| 26 |
-
image_processor_class = "AutoImageProcessor"
|
| 27 |
-
tokenizer_class = "AutoTokenizer"
|
| 28 |
-
|
| 29 |
-
def __init__(
|
| 30 |
-
self,
|
| 31 |
-
image_processor=None,
|
| 32 |
-
tokenizer=None,
|
| 33 |
-
chat_template=None,
|
| 34 |
-
**kwargs,
|
| 35 |
-
):
|
| 36 |
-
super().__init__(image_processor,
|
| 37 |
-
tokenizer,
|
| 38 |
-
chat_template=chat_template)
|
| 39 |
-
self.media_processor = image_processor
|
| 40 |
-
# A special temporal placeholder to be replaced by actual video placeholders
|
| 41 |
-
self.video_placeholder = "<|kimi_k25_video_placeholder|>"
|
| 42 |
-
|
| 43 |
-
def update_raw_text(self, text: str, video_prompts: list[str]) -> str:
|
| 44 |
-
# replace video prompt in text with video chunk prompts
|
| 45 |
-
video_count = text.count(self.video_placeholder)
|
| 46 |
-
if video_count == 0:
|
| 47 |
-
return text
|
| 48 |
-
assert video_count == len(video_prompts)
|
| 49 |
-
text_parts = text.split(self.video_placeholder)
|
| 50 |
-
assert len(text_parts) == len(video_prompts) + 1
|
| 51 |
-
text = "".join([
|
| 52 |
-
text_parts[i] + video_prompts[i] for i in range(len(video_prompts))
|
| 53 |
-
])
|
| 54 |
-
text += text_parts[-1]
|
| 55 |
-
return text
|
| 56 |
-
|
| 57 |
-
def preprocess_medias(self, medias: list[dict]) -> list[dict]:
|
| 58 |
-
updated_medias = []
|
| 59 |
-
video_prompts = []
|
| 60 |
-
for media in medias:
|
| 61 |
-
if media['type'] == 'image':
|
| 62 |
-
updated_medias.append(media)
|
| 63 |
-
elif media['type'] == 'video':
|
| 64 |
-
video_chunks = self.media_processor.split_video_chunks(
|
| 65 |
-
media['video'])
|
| 66 |
-
updated_medias.extend(video_chunks)
|
| 67 |
-
video_prompts.append("".join(
|
| 68 |
-
[vc['prompt'] for vc in video_chunks]))
|
| 69 |
-
else:
|
| 70 |
-
raise ValueError(f"unsupported media type: {media['type']}")
|
| 71 |
-
return updated_medias, video_prompts
|
| 72 |
-
|
| 73 |
-
def __call__(self,
|
| 74 |
-
messages: list[dict] = None,
|
| 75 |
-
medias: list[dict] = None,
|
| 76 |
-
text: str = None,
|
| 77 |
-
return_tensors: str = "pt",
|
| 78 |
-
**kwargs) -> BatchFeature:
|
| 79 |
-
"""
|
| 80 |
-
Process multimodal inputs for Kimi-K2.5 model.
|
| 81 |
-
|
| 82 |
-
This processor accepts ordered messages and extracts both media and text in a single pass.
|
| 83 |
-
text will be automatically updated if video input detected in messages
|
| 84 |
-
|
| 85 |
-
Args:
|
| 86 |
-
messages: List of message dicts with 'role' and 'content' fields.
|
| 87 |
-
If provided, medias and text will be extracted automatically.
|
| 88 |
-
medias: Pre-extracted list of media dicts. If None, extracted from messages.
|
| 89 |
-
text: Pre-formatted text string. If None, generated via apply_chat_template.
|
| 90 |
-
return_tensors: Format of returned tensors ('pt', 'np', 'tf'). Default: 'pt'.
|
| 91 |
-
**kwargs: Additional arguments passed to tokenizer.apply_chat_template.
|
| 92 |
-
|
| 93 |
-
Returns:
|
| 94 |
-
BatchFeature with fields: input_ids, attention_mask, pixel_values, grid_thws.
|
| 95 |
-
"""
|
| 96 |
-
if messages is None and (medias is None or text is None):
|
| 97 |
-
raise ValueError(
|
| 98 |
-
"Provide either 'messages' or both 'medias' and 'text'")
|
| 99 |
-
|
| 100 |
-
if medias is not None and text is not None:
|
| 101 |
-
updated_medias, video_prompts = self.preprocess_medias(medias)
|
| 102 |
-
preprocessed = self.media_processor.preprocess(
|
| 103 |
-
updated_medias, return_tensors=return_tensors)
|
| 104 |
-
text = self.update_raw_text(text, video_prompts)
|
| 105 |
-
text_inputs = self.tokenizer(text, return_tensors=return_tensors)
|
| 106 |
-
return BatchFeature(data={**text_inputs, **preprocessed.data})
|
| 107 |
-
|
| 108 |
-
if medias is None:
|
| 109 |
-
medias = self._extract_medias_from_messages(messages)
|
| 110 |
-
updated_medias, video_prompts = self.preprocess_medias(medias)
|
| 111 |
-
preprocessed = self.media_processor.preprocess(
|
| 112 |
-
updated_medias, return_tensors=return_tensors)
|
| 113 |
-
|
| 114 |
-
# Generate text if not provided
|
| 115 |
-
if text is None:
|
| 116 |
-
text = self.tokenizer.apply_chat_template(messages, **kwargs)
|
| 117 |
-
|
| 118 |
-
text = self.update_raw_text(text, video_prompts)
|
| 119 |
-
|
| 120 |
-
text_inputs = self.tokenizer(text, return_tensors=return_tensors)
|
| 121 |
-
return BatchFeature(data={**text_inputs, **preprocessed.data})
|
| 122 |
-
|
| 123 |
-
@staticmethod
|
| 124 |
-
def _extract_medias_from_messages(messages: list[dict]) -> list[dict]:
|
| 125 |
-
"""
|
| 126 |
-
Extract media items from messages in a single pass.
|
| 127 |
-
|
| 128 |
-
This is an optimized version that processes messages only once.
|
| 129 |
-
Kept as internal method since external callers should use __call__.
|
| 130 |
-
"""
|
| 131 |
-
medias = []
|
| 132 |
-
for msg in messages:
|
| 133 |
-
if msg['role'] != 'user' or not msg.get('content'):
|
| 134 |
-
continue
|
| 135 |
-
|
| 136 |
-
for content_part in msg['content']:
|
| 137 |
-
if not isinstance(content_part, dict):
|
| 138 |
-
continue
|
| 139 |
-
|
| 140 |
-
content_type = content_part.get('type')
|
| 141 |
-
if content_type in ['video_url', 'video']:
|
| 142 |
-
medias.append({
|
| 143 |
-
'type': 'video',
|
| 144 |
-
'video': content_part['video_url']['url'],
|
| 145 |
-
'first_frame_timestamp': 0.0
|
| 146 |
-
})
|
| 147 |
-
elif content_type in ['image_url', 'image']:
|
| 148 |
-
medias.append({
|
| 149 |
-
'type': 'image',
|
| 150 |
-
'image': content_part['image_url'],
|
| 151 |
-
})
|
| 152 |
-
return medias
|
| 153 |
-
|
| 154 |
-
def apply_chat_template(self, messages, **kwargs):
|
| 155 |
-
return self.tokenizer.apply_chat_template(messages, **kwargs)
|
| 156 |
-
|
| 157 |
-
def batch_decode(self, *args, **kwargs):
|
| 158 |
-
return self.tokenizer.batch_decode(*args, **kwargs)
|
| 159 |
-
|
| 160 |
-
def decode(self, *args, **kwargs):
|
| 161 |
-
return self.tokenizer.decode(*args, **kwargs)
|
| 162 |
-
|
| 163 |
-
@property
|
| 164 |
-
def model_input_names(self):
|
| 165 |
-
return ['input_ids', 'attention_mask', 'pixel_values', 'grid_thws']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
kimi_k25_vision_processing.py
DELETED
|
@@ -1,251 +0,0 @@
|
|
| 1 |
-
"""Image processor class for Kimi-K2.5.
|
| 2 |
-
"""
|
| 3 |
-
|
| 4 |
-
import json
|
| 5 |
-
from typing import Any, Dict, Optional, Union
|
| 6 |
-
|
| 7 |
-
import numpy as np
|
| 8 |
-
import torch
|
| 9 |
-
from PIL import Image
|
| 10 |
-
from transformers.image_processing_utils import (BaseImageProcessor,
|
| 11 |
-
BatchFeature)
|
| 12 |
-
from transformers.utils import TensorType
|
| 13 |
-
|
| 14 |
-
from .media_utils import (MediaInput, VideoChunkInput, _to_tensor,
|
| 15 |
-
ensure_media_type, get_video_meta, image_to_np,
|
| 16 |
-
navit_patchify, navit_resize_image,
|
| 17 |
-
navit_resize_video, normalize,
|
| 18 |
-
real_sample_fps_and_max_num_frames, timestamp_as_str)
|
| 19 |
-
|
| 20 |
-
try:
|
| 21 |
-
from mecord import VideoReader
|
| 22 |
-
except ImportError:
|
| 23 |
-
VideoReader = None
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
def resampling(video_bytes: bytes,
|
| 27 |
-
sample_indices: list[int],
|
| 28 |
-
key_indices=None,
|
| 29 |
-
frame_time_info=None,
|
| 30 |
-
num_threads=4) -> str:
|
| 31 |
-
video = VideoReader(video_bytes,
|
| 32 |
-
num_threads=num_threads,
|
| 33 |
-
frame_time_info=frame_time_info,
|
| 34 |
-
key_indices=key_indices)
|
| 35 |
-
# extract target frames
|
| 36 |
-
frames = video[sample_indices]
|
| 37 |
-
frames = [Image.fromarray(frame) for frame in frames]
|
| 38 |
-
return frames
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
class KimiK25VisionProcessor(BaseImageProcessor):
|
| 42 |
-
model_type = "kimi_k25"
|
| 43 |
-
|
| 44 |
-
def __init__(
|
| 45 |
-
self,
|
| 46 |
-
media_proc_cfg: dict,
|
| 47 |
-
**kwargs,
|
| 48 |
-
):
|
| 49 |
-
super().__init__(**kwargs)
|
| 50 |
-
self.media_proc_cfg = media_proc_cfg
|
| 51 |
-
self.num_frames_per_chunk = media_proc_cfg[
|
| 52 |
-
'temporal_merge_kernel_size']
|
| 53 |
-
|
| 54 |
-
def media_tokens_calculator(self, media: MediaInput):
|
| 55 |
-
media = ensure_media_type(media)
|
| 56 |
-
ret = self.get_resize_config(media)
|
| 57 |
-
return ret['num_tokens']
|
| 58 |
-
|
| 59 |
-
@classmethod
|
| 60 |
-
def make_chunk_prompt(cls, timestamp_text: str) -> str:
|
| 61 |
-
return f"{timestamp_text}<|media_begin|>video<|media_content|><|media_pad|><|media_end|>"
|
| 62 |
-
|
| 63 |
-
def split_video_chunks(self,
|
| 64 |
-
video_url: str | bytes) -> list[list[Image.Image]]:
|
| 65 |
-
# video_url should be base64 str or bytes
|
| 66 |
-
video_spec = get_video_meta(video_url)
|
| 67 |
-
sample_fps = min(self.media_proc_cfg['sample_fps'], video_spec.fps)
|
| 68 |
-
sampled_nframes = max(
|
| 69 |
-
round(video_spec.num_frames * sample_fps / video_spec.fps), 1)
|
| 70 |
-
frame_inds = np.linspace(0, video_spec.num_frames - 1,
|
| 71 |
-
sampled_nframes).round().astype(int)
|
| 72 |
-
frame_inds = frame_inds.tolist()
|
| 73 |
-
sampled_frame_ids = []
|
| 74 |
-
temporal_merge_kernel_size = self.media_proc_cfg[
|
| 75 |
-
"temporal_merge_kernel_size"]
|
| 76 |
-
num_chunks = 0
|
| 77 |
-
chunk_timestamp = []
|
| 78 |
-
for i in range(0, len(frame_inds), temporal_merge_kernel_size):
|
| 79 |
-
sampled_frame_ids.extend(frame_inds[i:i +
|
| 80 |
-
temporal_merge_kernel_size])
|
| 81 |
-
start_time = frame_inds[i] / float(video_spec.fps)
|
| 82 |
-
timestamp_text = timestamp_as_str(
|
| 83 |
-
start_time, self.media_proc_cfg["timestamp_mode"])
|
| 84 |
-
chunk_timestamp.append(timestamp_text)
|
| 85 |
-
num_chunks += 1
|
| 86 |
-
|
| 87 |
-
sampled_frames = resampling(video_url, sampled_frame_ids)
|
| 88 |
-
chunks = []
|
| 89 |
-
for chunk_id in range(num_chunks):
|
| 90 |
-
chunk = sampled_frames[chunk_id *
|
| 91 |
-
temporal_merge_kernel_size:(chunk_id + 1) *
|
| 92 |
-
temporal_merge_kernel_size]
|
| 93 |
-
chunks.append(
|
| 94 |
-
VideoChunkInput(type="video_chunk",
|
| 95 |
-
video_chunk=chunk,
|
| 96 |
-
prompt=self.make_chunk_prompt(
|
| 97 |
-
chunk_timestamp[chunk_id])))
|
| 98 |
-
return chunks
|
| 99 |
-
|
| 100 |
-
def get_resize_config(self, media_input: MediaInput) -> dict:
|
| 101 |
-
if media_input['type'] == 'image':
|
| 102 |
-
w, h = media_input['image'].size
|
| 103 |
-
ret = navit_resize_image(
|
| 104 |
-
w, h, self.media_proc_cfg['patch_size'],
|
| 105 |
-
self.media_proc_cfg['merge_kernel_size'],
|
| 106 |
-
self.media_proc_cfg['in_patch_limit'],
|
| 107 |
-
self.media_proc_cfg['patch_limit_on_one_side'],
|
| 108 |
-
self.media_proc_cfg['fixed_output_tokens'])
|
| 109 |
-
return ret
|
| 110 |
-
elif media_input['type'] == 'video_chunk':
|
| 111 |
-
frame = media_input['video_chunk'][0]
|
| 112 |
-
width, height = frame.size
|
| 113 |
-
num_frames = len(media_input["video_chunk"])
|
| 114 |
-
fps = 1.0
|
| 115 |
-
|
| 116 |
-
sample_fps, max_num_frames_each_video = real_sample_fps_and_max_num_frames(
|
| 117 |
-
media_input["type"],
|
| 118 |
-
self.media_proc_cfg['sample_fps'],
|
| 119 |
-
self.media_proc_cfg['max_num_frames_each_video'],
|
| 120 |
-
)
|
| 121 |
-
|
| 122 |
-
in_patch_limit_each_frame = self.media_proc_cfg[
|
| 123 |
-
'in_patch_limit_each_frame']
|
| 124 |
-
if in_patch_limit_each_frame is None:
|
| 125 |
-
in_patch_limit_each_frame = self.media_proc_cfg[
|
| 126 |
-
'in_patch_limit']
|
| 127 |
-
|
| 128 |
-
ret = navit_resize_video(
|
| 129 |
-
width,
|
| 130 |
-
height,
|
| 131 |
-
num_frames,
|
| 132 |
-
fps,
|
| 133 |
-
sample_fps,
|
| 134 |
-
self.media_proc_cfg['patch_size'],
|
| 135 |
-
self.media_proc_cfg['merge_kernel_size'],
|
| 136 |
-
in_patch_limit_each_frame,
|
| 137 |
-
self.media_proc_cfg['patch_limit_on_one_side'],
|
| 138 |
-
self.media_proc_cfg['in_patch_limit_video'],
|
| 139 |
-
max_num_frames_each_video,
|
| 140 |
-
self.media_proc_cfg['fixed_output_tokens'],
|
| 141 |
-
)
|
| 142 |
-
return ret
|
| 143 |
-
else:
|
| 144 |
-
raise ValueError("Unsupported type: {}".format(
|
| 145 |
-
media_input['type']))
|
| 146 |
-
|
| 147 |
-
def resize_image(self, image: Image.Image, new_width: int, new_height: int,
|
| 148 |
-
pad_width: int, pad_height: int) -> np.ndarray:
|
| 149 |
-
image_np = image_to_np(image, (new_width, new_height), "resize")
|
| 150 |
-
image_np = np.pad(
|
| 151 |
-
image_np,
|
| 152 |
-
((0, pad_height), (0, pad_width), (0, 0)),
|
| 153 |
-
mode="constant",
|
| 154 |
-
constant_values=0,
|
| 155 |
-
)
|
| 156 |
-
return image_np
|
| 157 |
-
|
| 158 |
-
def preprocess(
|
| 159 |
-
self,
|
| 160 |
-
medias: list[MediaInput],
|
| 161 |
-
return_tensors: Optional[Union[str, TensorType]] = None,
|
| 162 |
-
) -> BatchFeature:
|
| 163 |
-
"""
|
| 164 |
-
Preprocess a atom vision input (images/video_chunk) into model-ready tensors.
|
| 165 |
-
|
| 166 |
-
Args:
|
| 167 |
-
medias: List of MediaInput.
|
| 168 |
-
return_tensors: Desired output format ('pt', 'np', 'tf', or None).
|
| 169 |
-
|
| 170 |
-
Returns:
|
| 171 |
-
BatchFeature containing 'pixel_values' and 'grid_thws' tensors.
|
| 172 |
-
"""
|
| 173 |
-
if not isinstance(medias, list):
|
| 174 |
-
medias = [medias]
|
| 175 |
-
if medias:
|
| 176 |
-
pixel_values = []
|
| 177 |
-
for item in medias:
|
| 178 |
-
item = ensure_media_type(item)
|
| 179 |
-
resize_config = self.get_resize_config(item)
|
| 180 |
-
new_width, new_height, pad_width, pad_height = resize_config[
|
| 181 |
-
'new_width'], resize_config['new_height'], resize_config[
|
| 182 |
-
'pad_width'], resize_config['pad_height']
|
| 183 |
-
if item['type'] == 'image':
|
| 184 |
-
image = item['image']
|
| 185 |
-
image_np = self.resize_image(image, new_width, new_height,
|
| 186 |
-
pad_width, pad_height)
|
| 187 |
-
pixel_values.append(np.expand_dims(image_np, axis=0))
|
| 188 |
-
elif item['type'] == 'video_chunk':
|
| 189 |
-
pixels = []
|
| 190 |
-
for frame in item['video_chunk']:
|
| 191 |
-
frame_np = self.resize_image(frame, new_width,
|
| 192 |
-
new_height, pad_width,
|
| 193 |
-
pad_height)
|
| 194 |
-
pixels.append(frame_np)
|
| 195 |
-
pixel_values.append(np.stack(pixels, axis=0))
|
| 196 |
-
else:
|
| 197 |
-
raise ValueError("Unsupported type: {}".format(
|
| 198 |
-
item['type']))
|
| 199 |
-
normalized_pixel_values = []
|
| 200 |
-
image_std_inv = 1.0 / np.array(self.media_proc_cfg['image_std'])
|
| 201 |
-
image_mean = np.array(self.media_proc_cfg['image_mean'])
|
| 202 |
-
for pixels in pixel_values:
|
| 203 |
-
pixels = normalize(pixels, image_mean, image_std_inv)
|
| 204 |
-
pixels_and_thw = navit_patchify(
|
| 205 |
-
pixels,
|
| 206 |
-
self.media_proc_cfg['patch_size'],
|
| 207 |
-
)
|
| 208 |
-
normalized_pixel_values.append(pixels_and_thw)
|
| 209 |
-
|
| 210 |
-
pixel_values = torch.cat([
|
| 211 |
-
_to_tensor(pixel_value['pixel_values'])
|
| 212 |
-
for pixel_value in normalized_pixel_values
|
| 213 |
-
])
|
| 214 |
-
grid_thws = torch.cat([
|
| 215 |
-
_to_tensor(pixel_value['grid_thw'],
|
| 216 |
-
dtype=torch.int64).unsqueeze(0)
|
| 217 |
-
for pixel_value in normalized_pixel_values
|
| 218 |
-
])
|
| 219 |
-
|
| 220 |
-
data = {
|
| 221 |
-
'pixel_values': pixel_values,
|
| 222 |
-
'grid_thws': grid_thws,
|
| 223 |
-
}
|
| 224 |
-
|
| 225 |
-
else:
|
| 226 |
-
data = {}
|
| 227 |
-
|
| 228 |
-
return BatchFeature(data=data, tensor_type=return_tensors)
|
| 229 |
-
|
| 230 |
-
def __repr__(self):
|
| 231 |
-
return f"KimiK25VisionProcessor(media_proc_cfg={self.media_proc_cfg})"
|
| 232 |
-
|
| 233 |
-
def to_dict(self) -> Dict[str, Any]:
|
| 234 |
-
output = super().to_dict()
|
| 235 |
-
output["media_proc_cfg"] = self.media_proc_cfg
|
| 236 |
-
if "media_processor" in output:
|
| 237 |
-
del output["media_processor"]
|
| 238 |
-
return output
|
| 239 |
-
|
| 240 |
-
@classmethod
|
| 241 |
-
def from_dict(cls, config_dict: Dict[str, Any], **kwargs):
|
| 242 |
-
config = config_dict.copy()
|
| 243 |
-
media_proc_cfg = config.pop("media_proc_cfg", {})
|
| 244 |
-
return cls(media_proc_cfg=media_proc_cfg, **config, **kwargs)
|
| 245 |
-
|
| 246 |
-
def to_json_string(self):
|
| 247 |
-
dictionary = self.to_dict()
|
| 248 |
-
for key, value in dictionary.items():
|
| 249 |
-
if hasattr(value, 'tolist'):
|
| 250 |
-
dictionary[key] = value.tolist()
|
| 251 |
-
return json.dumps(dictionary, indent=2, sort_keys=True) + "\n"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
media_utils.py
DELETED
|
@@ -1,368 +0,0 @@
|
|
| 1 |
-
import base64
|
| 2 |
-
import io
|
| 3 |
-
import math
|
| 4 |
-
import os
|
| 5 |
-
from datetime import datetime, timezone
|
| 6 |
-
from typing import List, Literal, Optional, TypedDict
|
| 7 |
-
|
| 8 |
-
import numpy as np
|
| 9 |
-
from PIL import Image
|
| 10 |
-
from pydantic import BaseModel, Field
|
| 11 |
-
|
| 12 |
-
try:
|
| 13 |
-
from mecord import VideoReader
|
| 14 |
-
except ImportError:
|
| 15 |
-
VideoReader = None
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
class VideoSpec(BaseModel):
|
| 19 |
-
media_type: str = Literal['video']
|
| 20 |
-
height: int = Field(..., gt=0, description="video frame height")
|
| 21 |
-
width: int = Field(..., gt=0, description="video frame width")
|
| 22 |
-
num_frames: int = Field(..., gt=0, description="num frames")
|
| 23 |
-
fps: float = Field(..., gt=0, description="average fps")
|
| 24 |
-
|
| 25 |
-
# optional, help to accelerate video reading
|
| 26 |
-
key_indices: list[int] = Field(None, description="key indices")
|
| 27 |
-
frame_time_info: dict = Field(None, description="frame time info")
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
class ImageInput(TypedDict):
|
| 31 |
-
type: Literal['image']
|
| 32 |
-
image: Image.Image
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
class VideoChunkInput(TypedDict):
|
| 36 |
-
type: Literal['video_chunk']
|
| 37 |
-
video_chunk: List[Image.Image]
|
| 38 |
-
prompt: Optional[str] = None
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
MediaInput = ImageInput | VideoChunkInput
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
def get_video_meta(video_src: bytes | str | os.PathLike,
|
| 45 |
-
accurate: bool = True) -> dict:
|
| 46 |
-
"""Get the dimensions of a video."""
|
| 47 |
-
if isinstance(video_src, os.PathLike):
|
| 48 |
-
video_src = str(video_src)
|
| 49 |
-
# if b64 string, decode to bytes
|
| 50 |
-
if isinstance(video_src,
|
| 51 |
-
str) and video_src.startswith('data:video/mp4;base64,'):
|
| 52 |
-
video_src = base64.b64decode(video_src.split(',')[1])
|
| 53 |
-
video = VideoReader(video_src, auto_init=accurate, num_threads=1)
|
| 54 |
-
assert video.num_frames > 0, "Invalid video format."
|
| 55 |
-
assert video.original_width > 0 and video.original_height > 0, (
|
| 56 |
-
"Invalid video format.")
|
| 57 |
-
assert video.avg_fps > 0, "Invalid video format."
|
| 58 |
-
return VideoSpec(media_type='video',
|
| 59 |
-
height=video.original_height,
|
| 60 |
-
width=video.original_width,
|
| 61 |
-
num_frames=video.num_frames,
|
| 62 |
-
fps=video.avg_fps,
|
| 63 |
-
key_indices=video.key_indices,
|
| 64 |
-
frame_time_info=video.frame_time_info)
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
def timestamp_as_str(timestamp: float,
|
| 68 |
-
timestamp_mode: str = "hh:mm:ss.fff") -> str:
|
| 69 |
-
"""Convert a timestamp to a string in the format of HH:MM:SS.mmm."""
|
| 70 |
-
if timestamp_mode == "hh:mm:ss.fff":
|
| 71 |
-
return (datetime.fromtimestamp(timestamp,
|
| 72 |
-
tz=timezone.utc).strftime("%H:%M:%S") +
|
| 73 |
-
f".{int((timestamp % 1) * 1000):03d}")
|
| 74 |
-
elif timestamp_mode == "mm:ss.fff":
|
| 75 |
-
return (datetime.fromtimestamp(timestamp,
|
| 76 |
-
tz=timezone.utc).strftime("%M:%S") +
|
| 77 |
-
f".{int((timestamp % 1) * 1000):03d}")
|
| 78 |
-
elif timestamp_mode == "mm:ss":
|
| 79 |
-
return datetime.fromtimestamp(timestamp,
|
| 80 |
-
tz=timezone.utc).strftime("%M:%S")
|
| 81 |
-
else:
|
| 82 |
-
raise ValueError(f"Invalid timestamp mode: {timestamp_mode}")
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
def navit_resize_image(
|
| 86 |
-
width: int,
|
| 87 |
-
height: int,
|
| 88 |
-
patch_size: int,
|
| 89 |
-
merge_kernel_size: int,
|
| 90 |
-
in_patch_limit: int,
|
| 91 |
-
patch_limit_on_one_side: int,
|
| 92 |
-
fixed_output_tokens: int | None,
|
| 93 |
-
):
|
| 94 |
-
# Apply the patch limits.
|
| 95 |
-
s1 = math.sqrt(
|
| 96 |
-
in_patch_limit /
|
| 97 |
-
(max(1.0, width // patch_size) * max(1.0, height // patch_size)))
|
| 98 |
-
s2 = patch_limit_on_one_side * patch_size / width
|
| 99 |
-
s3 = patch_limit_on_one_side * patch_size / height
|
| 100 |
-
scale = min(1.0, s1, s2, s3)
|
| 101 |
-
new_w, new_h = max(1, int(width * scale)), max(1, int(height * scale))
|
| 102 |
-
new_w = min(new_w, patch_limit_on_one_side * patch_size)
|
| 103 |
-
new_h = min(new_h, patch_limit_on_one_side * patch_size)
|
| 104 |
-
|
| 105 |
-
# Calculate the padding to make the height and width divisible by the merge kernel size and patch size.
|
| 106 |
-
factor = merge_kernel_size * patch_size
|
| 107 |
-
|
| 108 |
-
pad_height = (factor - new_h % factor) % factor
|
| 109 |
-
pad_width = (factor - new_w % factor) % factor
|
| 110 |
-
|
| 111 |
-
if fixed_output_tokens is not None:
|
| 112 |
-
num_tokens = fixed_output_tokens
|
| 113 |
-
else:
|
| 114 |
-
# Calculate new dimensions after padding and patching
|
| 115 |
-
token_height = (new_h + pad_height) // factor
|
| 116 |
-
token_width = (new_w + pad_width) // factor
|
| 117 |
-
|
| 118 |
-
assert token_height * merge_kernel_size <= patch_limit_on_one_side, (
|
| 119 |
-
f"token_height {token_height} * merge_kernel_size {merge_kernel_size} > patch_limit_on_one_side {patch_limit_on_one_side}"
|
| 120 |
-
)
|
| 121 |
-
assert token_width * merge_kernel_size <= patch_limit_on_one_side, (
|
| 122 |
-
f"token_width {token_width} * merge_kernel_size {merge_kernel_size} > patch_limit_on_one_side {patch_limit_on_one_side}"
|
| 123 |
-
)
|
| 124 |
-
|
| 125 |
-
num_tokens = token_height * token_width
|
| 126 |
-
return {
|
| 127 |
-
"num_tokens": num_tokens,
|
| 128 |
-
"new_width": new_w,
|
| 129 |
-
"new_height": new_h,
|
| 130 |
-
"pad_width": pad_width,
|
| 131 |
-
"pad_height": pad_height,
|
| 132 |
-
"sampled_nframes": 1,
|
| 133 |
-
}
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
def navit_resize_video(
|
| 137 |
-
width: int,
|
| 138 |
-
height: int,
|
| 139 |
-
nframes: int,
|
| 140 |
-
avg_fps: float,
|
| 141 |
-
sample_fps: float,
|
| 142 |
-
patch_size: int,
|
| 143 |
-
merge_kernel_size: int,
|
| 144 |
-
in_patch_limit_each_frame: int,
|
| 145 |
-
patch_limit_on_one_side: int,
|
| 146 |
-
in_patch_limit_total: int | None,
|
| 147 |
-
max_num_frames_each_video: int | None,
|
| 148 |
-
fixed_output_tokens_each_frame: int | None,
|
| 149 |
-
):
|
| 150 |
-
sample_fps = min(sample_fps, avg_fps)
|
| 151 |
-
# Calculate the number of frames to sample based on target FPS
|
| 152 |
-
sampled_nframes = max(round(nframes * sample_fps / avg_fps), 1)
|
| 153 |
-
if max_num_frames_each_video is not None:
|
| 154 |
-
sampled_nframes = min(sampled_nframes, max_num_frames_each_video)
|
| 155 |
-
|
| 156 |
-
if in_patch_limit_total is not None:
|
| 157 |
-
in_patch_limit_each_frame = min(
|
| 158 |
-
round(in_patch_limit_total / sampled_nframes),
|
| 159 |
-
in_patch_limit_each_frame)
|
| 160 |
-
|
| 161 |
-
ret = navit_resize_image(
|
| 162 |
-
width,
|
| 163 |
-
height,
|
| 164 |
-
patch_size,
|
| 165 |
-
merge_kernel_size,
|
| 166 |
-
in_patch_limit_each_frame,
|
| 167 |
-
patch_limit_on_one_side,
|
| 168 |
-
fixed_output_tokens_each_frame,
|
| 169 |
-
)
|
| 170 |
-
ret["sampled_nframes"] = sampled_nframes
|
| 171 |
-
return ret
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
def real_sample_fps_and_max_num_frames(
|
| 175 |
-
type_name: Literal["video", "video_chunk"],
|
| 176 |
-
sample_fps: float,
|
| 177 |
-
max_num_frames_each_video: int | None,
|
| 178 |
-
) -> tuple[int, int | None]:
|
| 179 |
-
if type_name == "video":
|
| 180 |
-
return sample_fps, max_num_frames_each_video
|
| 181 |
-
elif type_name == "video_chunk":
|
| 182 |
-
max_num_frames_each_video = None
|
| 183 |
-
sample_fps = math.inf
|
| 184 |
-
return sample_fps, max_num_frames_each_video
|
| 185 |
-
else:
|
| 186 |
-
return math.inf, None
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
def _to_pil(data: str | bytes):
|
| 190 |
-
if isinstance(data, Image.Image):
|
| 191 |
-
|
| 192 |
-
return data.convert("RGB")
|
| 193 |
-
elif isinstance(data, str):
|
| 194 |
-
if data.startswith("data:"):
|
| 195 |
-
raw_base64 = data.split(",")[1]
|
| 196 |
-
return Image.open(io.BytesIO(
|
| 197 |
-
base64.b64decode(raw_base64))).convert("RGB")
|
| 198 |
-
else:
|
| 199 |
-
return Image.open(data).convert("RGB")
|
| 200 |
-
elif isinstance(data, bytes):
|
| 201 |
-
return Image.open(io.BytesIO(data)).convert("RGB")
|
| 202 |
-
else:
|
| 203 |
-
raise ValueError(f"Unsupported data type: {type(data)}")
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
def ensure_media_type(media: MediaInput) -> MediaInput:
|
| 207 |
-
if media['type'] == 'image':
|
| 208 |
-
media['image'] = _to_pil(media['image'])
|
| 209 |
-
return media
|
| 210 |
-
elif media['type'] == 'video_chunk':
|
| 211 |
-
media['video_chunk'] = [
|
| 212 |
-
_to_pil(frame) for frame in media['video_chunk']
|
| 213 |
-
]
|
| 214 |
-
return media
|
| 215 |
-
else:
|
| 216 |
-
raise ValueError(f"Unsupported media type: {media['type']}")
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
def image_to_np(
|
| 220 |
-
image: Image.Image,
|
| 221 |
-
resize_to: tuple[int, int] | None = None,
|
| 222 |
-
mode: str = "resize",
|
| 223 |
-
raise_error_for_ill_resize: bool = True,
|
| 224 |
-
) -> np.ndarray:
|
| 225 |
-
"""Convert an image to a numpy array.
|
| 226 |
-
|
| 227 |
-
Args:
|
| 228 |
-
content: The image to convert.
|
| 229 |
-
resize_to: The size to resize the image to.
|
| 230 |
-
mode: The mode to resize the image to.
|
| 231 |
-
raise_error_for_ill_resize: Whether to raise an error for ill-sized resize.
|
| 232 |
-
|
| 233 |
-
Returns:
|
| 234 |
-
A numpy array.
|
| 235 |
-
"""
|
| 236 |
-
assert isinstance(image, Image.Image), "image must be a PIL Image"
|
| 237 |
-
if resize_to is not None:
|
| 238 |
-
if mode == "resize":
|
| 239 |
-
image = image.resize(resize_to, resample=Image.Resampling.BICUBIC)
|
| 240 |
-
|
| 241 |
-
elif mode == "rescale_and_pad_to_center":
|
| 242 |
-
scale = min(resize_to[0] / image.width,
|
| 243 |
-
resize_to[1] / image.height, 1.0)
|
| 244 |
-
new_width = round(image.width * scale)
|
| 245 |
-
new_height = round(image.height * scale)
|
| 246 |
-
if new_width == 0 or new_height == 0:
|
| 247 |
-
if raise_error_for_ill_resize:
|
| 248 |
-
raise ValueError(
|
| 249 |
-
f"Invalid resize to: {resize_to}, from image size: {image.size}"
|
| 250 |
-
)
|
| 251 |
-
else:
|
| 252 |
-
return np.zeros((resize_to[1], resize_to[0], 3),
|
| 253 |
-
dtype=np.uint8)
|
| 254 |
-
|
| 255 |
-
image = image.resize((new_width, new_height),
|
| 256 |
-
resample=Image.Resampling.BICUBIC)
|
| 257 |
-
padding_left = (resize_to[0] - new_width) // 2
|
| 258 |
-
padding_right = resize_to[0] - new_width - padding_left
|
| 259 |
-
padding_top = (resize_to[1] - new_height) // 2
|
| 260 |
-
padding_bottom = resize_to[1] - new_height - padding_top
|
| 261 |
-
image = np.asarray(image)
|
| 262 |
-
image = np.pad(
|
| 263 |
-
image,
|
| 264 |
-
((padding_top, padding_bottom), (padding_left, padding_right),
|
| 265 |
-
(0, 0)),
|
| 266 |
-
mode="constant",
|
| 267 |
-
constant_values=0,
|
| 268 |
-
)
|
| 269 |
-
assert image.shape == (resize_to[1], resize_to[0], 3)
|
| 270 |
-
|
| 271 |
-
elif mode == "rescale_and_pad_to_rightbottom":
|
| 272 |
-
scale = min(resize_to[0] / image.width,
|
| 273 |
-
resize_to[1] / image.height, 1.0)
|
| 274 |
-
new_width = round(image.width * scale)
|
| 275 |
-
new_height = round(image.height * scale)
|
| 276 |
-
if new_width == 0 or new_height == 0:
|
| 277 |
-
if raise_error_for_ill_resize:
|
| 278 |
-
raise ValueError(
|
| 279 |
-
f"Invalid resize to: {resize_to}, from image size: {image.size}"
|
| 280 |
-
)
|
| 281 |
-
else:
|
| 282 |
-
return np.zeros((resize_to[1], resize_to[0], 3),
|
| 283 |
-
dtype=np.uint8)
|
| 284 |
-
|
| 285 |
-
image = image.resize((new_width, new_height),
|
| 286 |
-
resample=Image.Resampling.BICUBIC)
|
| 287 |
-
padding_right = resize_to[0] - new_width
|
| 288 |
-
padding_bottom = resize_to[1] - new_height
|
| 289 |
-
image = np.asarray(image)
|
| 290 |
-
image = np.pad(
|
| 291 |
-
image,
|
| 292 |
-
((0, padding_bottom), (0, padding_right), (0, 0)),
|
| 293 |
-
mode="constant",
|
| 294 |
-
constant_values=0,
|
| 295 |
-
)
|
| 296 |
-
assert image.shape == (resize_to[1], resize_to[0], 3)
|
| 297 |
-
|
| 298 |
-
else:
|
| 299 |
-
raise ValueError(f"Invalid mode: {mode}")
|
| 300 |
-
|
| 301 |
-
if isinstance(image, Image.Image):
|
| 302 |
-
return np.asarray(image)
|
| 303 |
-
else:
|
| 304 |
-
return image
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
def navit_patchify(pixel_values: np.ndarray,
|
| 308 |
-
patch_size: int) -> dict[str, np.ndarray]:
|
| 309 |
-
"""Reshape the pixel values to a navit shape.
|
| 310 |
-
|
| 311 |
-
Args:
|
| 312 |
-
pixel_values: np.ndarray, shape (t, h, w, c)
|
| 313 |
-
patch_size: int
|
| 314 |
-
|
| 315 |
-
Returns:
|
| 316 |
-
dict[str, np.ndarray]
|
| 317 |
-
- patches: np.ndarray, shape (t * h//patch_size * w//patch_size, c, patch_size, patch_size)
|
| 318 |
-
- grid_thw: np.ndarray, (t, h//patch_size, w//patch_size)
|
| 319 |
-
"""
|
| 320 |
-
T, H, W, C = pixel_values.shape
|
| 321 |
-
assert C == 3, "pixel_values must have 3 channels"
|
| 322 |
-
|
| 323 |
-
patches = pixel_values.reshape(T, H // patch_size, patch_size,
|
| 324 |
-
W // patch_size, patch_size, C)
|
| 325 |
-
# (T, H//patch_size, W//patch_size, C, patch_size, patch_size)
|
| 326 |
-
patches = patches.transpose(0, 1, 3, 5, 2, 4)
|
| 327 |
-
patches = patches.reshape(-1, C, patch_size, patch_size)
|
| 328 |
-
grid_thw = np.array([T, H // patch_size, W // patch_size])
|
| 329 |
-
return {"pixel_values": patches, "grid_thw": grid_thw}
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
def normalize(x: np.ndarray,
|
| 333 |
-
mean,
|
| 334 |
-
std_inv,
|
| 335 |
-
pixels_dtype: np.dtype = np.float32) -> np.ndarray:
|
| 336 |
-
"""Normalize the image.
|
| 337 |
-
|
| 338 |
-
Args:
|
| 339 |
-
x: The image to normalize. The shape is (..., 3). The dtype is uint8. The range is [0, 255].
|
| 340 |
-
mean: The mean of the image.
|
| 341 |
-
std_inv: The inverse of the std of the image.
|
| 342 |
-
pixels_dtype: The dtype of the image.
|
| 343 |
-
Returns:
|
| 344 |
-
The normalized image. The shape is (..., 3). The dtype is determined by the pixels_dtype.
|
| 345 |
-
"""
|
| 346 |
-
x = (x / 255.0).astype(pixels_dtype)
|
| 347 |
-
x -= mean
|
| 348 |
-
x *= std_inv
|
| 349 |
-
return x
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
def _to_tensor(data, **kwargs):
|
| 353 |
-
import torch
|
| 354 |
-
|
| 355 |
-
if isinstance(data, np.ndarray):
|
| 356 |
-
return torch.from_numpy(data).to(**kwargs)
|
| 357 |
-
elif isinstance(data, torch.Tensor):
|
| 358 |
-
return data.to(**kwargs)
|
| 359 |
-
elif isinstance(data, list):
|
| 360 |
-
return [_to_tensor(item, **kwargs) for item in data]
|
| 361 |
-
elif isinstance(data, tuple):
|
| 362 |
-
return tuple(_to_tensor(item, **kwargs) for item in data)
|
| 363 |
-
elif isinstance(data, dict):
|
| 364 |
-
return {k: _to_tensor(v, **kwargs) for k, v in data.items()}
|
| 365 |
-
elif data is None:
|
| 366 |
-
return None
|
| 367 |
-
else:
|
| 368 |
-
raise ValueError(f"Unsupported data type: {type(data)}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
model-00001-of-000064.safetensors
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:a5534929491e07bcc47f8988cc1bcaab8f75ac642cdab6d303154b599e9c7d00
|
| 3 |
-
size 311876368
|
|
|
|
|
|
|
|
|
|
|
|
model-00002-of-000064.safetensors
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:a7e65f5fb3501bb344187ddb9a9f7396ed3dccc2b419c34beabbc6aad3074cff
|
| 3 |
-
size 9114734600
|
|
|
|
|
|
|
|
|
|
|
|
model-00003-of-000064.safetensors
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:1218146bf79dec04f78c860663b8bf2559207f366c3b896a681a181984e94c59
|
| 3 |
-
size 9114734600
|
|
|
|
|
|
|
|
|
|
|
|
model-00004-of-000064.safetensors
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:d634d73aa58771d79907fe8bb1eb182680476aae4c6cee895ee19a0b08b27c61
|
| 3 |
-
size 9114734600
|
|
|
|
|
|
|
|
|
|
|
|
model-00005-of-000064.safetensors
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:27999c82227bf0abac7b84ae2a39ef6b7390ceff89a44215ea918774b7f723fb
|
| 3 |
-
size 9114734600
|
|
|
|
|
|
|
|
|
|
|
|
model-00006-of-000064.safetensors
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:08d2bb54186cde897a13ee8c6fd3f95e034e6845cb19045271d0492634218601
|
| 3 |
-
size 9114734600
|
|
|
|
|
|
|
|
|
|
|
|
model-00007-of-000064.safetensors
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:6013ce1d89c6d4249ddfd18ae9ad8c999f95d1565cdd2a301cf6395eacb57255
|
| 3 |
-
size 9114734600
|
|
|
|
|
|
|
|
|
|
|
|
model-00008-of-000064.safetensors
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:f13ddf63e3f94820623e708e4410bc581ebf69cab4d6a6cf14936355459558dd
|
| 3 |
-
size 9114734600
|
|
|
|
|
|
|
|
|
|
|
|
model-00009-of-000064.safetensors
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:32d7db55afc6d8b95dd699e239b08ab4a37c012c65ee457d28d7fd2a23c4f02f
|
| 3 |
-
size 9114734600
|
|
|
|
|
|
|
|
|
|
|
|
model-00010-of-000064.safetensors
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:0f5909e62ec37d8273313adeb7b3526a31ddf42062c00a939a28a3fad8dbfb7e
|
| 3 |
-
size 9114734600
|
|
|
|
|
|
|
|
|
|
|
|
model-00011-of-000064.safetensors
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:e478571a1a8f0d7e7869e9c3a81810b06dd2f16079477f7e492c4659f94f6545
|
| 3 |
-
size 9114736920
|
|
|
|
|
|
|
|
|
|
|
|
model-00012-of-000064.safetensors
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:3f2ad758afc3ec09f1bd7c6dab3a10f7a4f97b2f7839899e5b7b361a541bc09e
|
| 3 |
-
size 9114736920
|
|
|
|
|
|
|
|
|
|
|
|
model-00013-of-000064.safetensors
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:b36c6e7cab59e48796861493c2dc9a882bb7760f953ed03073e03b9de25d5c1f
|
| 3 |
-
size 9114736920
|
|
|
|
|
|
|
|
|
|
|
|
model-00014-of-000064.safetensors
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:76b0c3e519a5feb3075b5dc680f41562db007714ace98173273dd75fe877aee5
|
| 3 |
-
size 9114736920
|
|
|
|
|
|
|
|
|
|
|
|
model-00015-of-000064.safetensors
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:f7357d842cd0d694e9399f8e7db62937df3e1b3809f1d088b01a3d44070e5bc7
|
| 3 |
-
size 9114736920
|
|
|
|
|
|
|
|
|
|
|
|
model-00016-of-000064.safetensors
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:d2ffdf8da26b403ff8a8fa752a518fa0694cbfaef17058d9a28b8f51a89c7e53
|
| 3 |
-
size 9114736920
|
|
|
|
|
|
|
|
|
|
|
|
model-00017-of-000064.safetensors
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:08214aa54833d00928396ec6eb70c7b71bdd58e6b65ef1b27c215ea3a06e2435
|
| 3 |
-
size 9114736920
|
|
|
|
|
|
|
|
|
|
|
|
model-00018-of-000064.safetensors
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:208752b9b90321185382f3b14a1d1342e1a9685c6ed8cb8442e5938078bd4501
|
| 3 |
-
size 9114736920
|
|
|
|
|
|
|
|
|
|
|
|
model-00019-of-000064.safetensors
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:b93a375b79942e9ac9a9bf6e3ecf91b73d54cea2115ed004f18d5e1cdb5375a5
|
| 3 |
-
size 9114736920
|
|
|
|
|
|
|
|
|
|
|
|
model-00020-of-000064.safetensors
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:e9774b9bf6ae32dc9f60a9b58ea5adf7d7b3945b791dd6669503803541f50248
|
| 3 |
-
size 9114736920
|
|
|
|
|
|
|
|
|
|
|
|
model-00021-of-000064.safetensors
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:07654fa139729369a7a203ab15555c325d120d7038fac9f299c8ca74fab418f4
|
| 3 |
-
size 9114736920
|
|
|
|
|
|
|
|
|
|
|
|
model-00022-of-000064.safetensors
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:acb233668aaff95058d799e1abc483be2637f49f2e5b7273b1642f793a3532a6
|
| 3 |
-
size 9114736920
|
|
|
|
|
|
|
|
|
|
|
|
model-00023-of-000064.safetensors
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:f13506e0d94830420bc75d055951dcec273d4537f7f7ee977b59c96d7186b8c9
|
| 3 |
-
size 9114736920
|
|
|
|
|
|
|
|
|
|
|
|
model-00024-of-000064.safetensors
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:8085b0dc101c1fa518bd636177406ea3c4d304550aeb6f1b03c22c59341b83d8
|
| 3 |
-
size 9114736920
|
|
|
|
|
|
|
|
|
|
|
|
model-00025-of-000064.safetensors
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:2ee7ae7ebad2da178db97fabb5a2ae03d663e2db4989ab9f5150ff3308db9708
|
| 3 |
-
size 9114736920
|
|
|
|
|
|
|
|
|
|
|
|
model-00026-of-000064.safetensors
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:f746b8ee6b753af9f7bb11f7e758c6bf7ffa7546fbe4a7422580c9ba655f126a
|
| 3 |
-
size 9114736920
|
|
|
|
|
|
|
|
|
|
|
|
model-00027-of-000064.safetensors
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:a14452550a57fb827895effa3c82c17ac2259837282a6a47b52a13c06fc4a743
|
| 3 |
-
size 9114736920
|
|
|
|
|
|
|
|
|
|
|
|
model-00028-of-000064.safetensors
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:6baa181d5df23a9d8e70151926e9c79d2e05d503ac9e161a8693617a59750fdc
|
| 3 |
-
size 9114736920
|
|
|
|
|
|
|
|
|
|
|
|
model-00029-of-000064.safetensors
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:40cced8605c485ef5ee66fb617c6bd4df4e2a9f7ae510509f2b968ed17af5a6f
|
| 3 |
-
size 9114736920
|
|
|
|
|
|
|
|
|
|
|
|
model-00030-of-000064.safetensors
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:55a56be4f9e9a81dbeb99ab9a385bda0547effc1d01e28868fefb4ee97a6cbef
|
| 3 |
-
size 9114736920
|
|
|
|
|
|
|
|
|
|
|
|
model-00031-of-000064.safetensors
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:1a95284a6578de16065728e91dd07464427f428b797020a2ef0dded4b9451b87
|
| 3 |
-
size 9114736920
|
|
|
|
|
|
|
|
|
|
|
|
model-00032-of-000064.safetensors
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:a0b02a36f460ffaa06323cb767b88d8d5e743be1a060ac1d84e99bb6daec777e
|
| 3 |
-
size 9114736920
|
|
|
|
|
|
|
|
|
|
|
|
model-00033-of-000064.safetensors
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:034a2dee202adf1cb268c2365202da57536f815d5cc26aa87cc83b6d6f2b83fb
|
| 3 |
-
size 9114736920
|
|
|
|
|
|
|
|
|
|
|
|
model-00034-of-000064.safetensors
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:d2b58dcec2ffbe076c62237b4c94382dc32e57bbb31f6eca3c0605032384c976
|
| 3 |
-
size 9114736920
|
|
|
|
|
|
|
|
|
|
|
|
model-00035-of-000064.safetensors
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:be9e39dda10bcb91633cccc93a83a6237ae1899b7745e07ec8f2504bfe096ca1
|
| 3 |
-
size 9114736920
|
|
|
|
|
|
|
|
|
|
|
|
model-00036-of-000064.safetensors
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:806a960d868eb92fa5174580302afe63a7dfed806a0b7d6f9a1d618fb90594e9
|
| 3 |
-
size 9114736920
|
|
|
|
|
|
|
|
|
|
|
|
model-00037-of-000064.safetensors
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:986674ec5294e8c569ea17753e1f3cba35b0350dfaa543b55b47a1b7aeaf69c8
|
| 3 |
-
size 9114736920
|
|
|
|
|
|
|
|
|
|
|
|
model-00038-of-000064.safetensors
DELETED
|
@@ -1,3 +0,0 @@
|
|
| 1 |
-
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:689a00a1528f0f882ea887f836758e87cab18ec990c49485bd61e44419d5afcc
|
| 3 |
-
size 9114736920
|
|
|
|
|
|
|
|
|
|
|
|