b9154d267a772a3f23a8288ab2101c6e604fe9f2d7598fe0d4abf46faa2793ba
Browse files- README.md +85 -0
- config.json +103 -0
- configuration_minicpm.py +195 -0
- generation_config.json +11 -0
- smash_config.json +35 -0
README.md
ADDED
@@ -0,0 +1,85 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
thumbnail: "https://assets-global.website-files.com/646b351987a8d8ce158d1940/64ec9e96b4334c0e1ac41504_Logo%20with%20white%20text.svg"
|
3 |
+
base_model: openbmb/MiniCPM3-4B
|
4 |
+
metrics:
|
5 |
+
- memory_disk
|
6 |
+
- memory_inference
|
7 |
+
- inference_latency
|
8 |
+
- inference_throughput
|
9 |
+
- inference_CO2_emissions
|
10 |
+
- inference_energy_consumption
|
11 |
+
tags:
|
12 |
+
- pruna-ai
|
13 |
+
---
|
14 |
+
<!-- header start -->
|
15 |
+
<!-- 200823 -->
|
16 |
+
<div style="width: auto; margin-left: auto; margin-right: auto">
|
17 |
+
<a href="https://docs.pruna.ai/en/latest/setup/pip.html" target="_blank" rel="noopener noreferrer">
|
18 |
+
<img src="https://imgur.com/rVAgqMY.png" alt="PrunaAI" style="width: 100%; min-width: 400px; display: block; margin: auto;">
|
19 |
+
</a>
|
20 |
+
</div>
|
21 |
+
<!-- header end -->
|
22 |
+
|
23 |
+
[![Twitter](https://img.shields.io/twitter/follow/PrunaAI?style=social)](https://twitter.com/PrunaAI)
|
24 |
+
[![GitHub](https://img.shields.io/github/followers/PrunaAI?label=Follow%20%40PrunaAI&style=social)](https://github.com/PrunaAI)
|
25 |
+
[![LinkedIn](https://img.shields.io/badge/LinkedIn-Connect-blue)](https://www.linkedin.com/company/93832878/admin/feed/posts/?feedType=following)
|
26 |
+
[![Discord](https://img.shields.io/badge/Discord-Join%20Us-blue?style=social&logo=discord)](https://discord.gg/rskEr4BZJx)
|
27 |
+
|
28 |
+
# Simply make AI models cheaper, smaller, faster, and greener!
|
29 |
+
|
30 |
+
- Give a thumbs up if you like this model!
|
31 |
+
- Contact us and tell us which model to compress next [here](https://www.pruna.ai/contact).
|
32 |
+
- Request access to easily compress your *own* AI models [here](https://z0halsaff74.typeform.com/pruna-access?typeform-source=www.pruna.ai).
|
33 |
+
- Read the documentations to know more [here](https://pruna-ai-pruna.readthedocs-hosted.com/en/latest/)
|
34 |
+
- Join Pruna AI community on Discord [here](https://discord.gg/CP4VSgck) to share feedback/suggestions or get help.
|
35 |
+
|
36 |
+
## Results
|
37 |
+
|
38 |
+
![image info](./plots.png)
|
39 |
+
|
40 |
+
**Frequently Asked Questions**
|
41 |
+
- ***How does the compression work?*** The model is compressed with llm-int8.
|
42 |
+
- ***How does the model quality change?*** The quality of the model output might vary compared to the base model.
|
43 |
+
- ***How is the model efficiency evaluated?*** These results were obtained with configuration described in `model/smash_config.json` and are obtained after a hardware warmup. The smashed model is directly compared to the original base model. Efficiency results may vary in other settings (e.g. other hardware, image size, batch size, ...). We recommend to directly run them in the use-case conditions to know if the smashed model can benefit you.
|
44 |
+
- ***What is the model format?*** We use safetensors.
|
45 |
+
- ***What calibration data has been used?*** If needed by the compression method, we used WikiText as the calibration data.
|
46 |
+
- ***What is the naming convention for Pruna Huggingface models?*** We take the original model name and append "turbo", "tiny", or "green" if the smashed model has a measured inference speed, inference memory, or inference energy consumption which is less than 90% of the original base model.
|
47 |
+
- ***How to compress my own models?*** You can request premium access to more compression methods and tech support for your specific use-cases [here](https://z0halsaff74.typeform.com/pruna-access?typeform-source=www.pruna.ai).
|
48 |
+
- ***What are "first" metrics?*** Results mentioning "first" are obtained after the first run of the model. The first run might take more memory or be slower than the subsequent runs due cuda overheads.
|
49 |
+
- ***What are "Sync" and "Async" metrics?*** "Sync" metrics are obtained by syncing all GPU processes and stop measurement when all of them are executed. "Async" metrics are obtained without syncing all GPU processes and stop when the model output can be used by the CPU. We provide both metrics since both could be relevant depending on the use-case. We recommend to test the efficiency gains directly in your use-cases.
|
50 |
+
|
51 |
+
## Setup
|
52 |
+
|
53 |
+
You can run the smashed model with these steps:
|
54 |
+
|
55 |
+
0. Check requirements from the original repo openbmb/MiniCPM3-4B installed. In particular, check python, cuda, and transformers versions.
|
56 |
+
1. Make sure that you have installed quantization related packages.
|
57 |
+
```bash
|
58 |
+
pip install transformers accelerate bitsandbytes>0.37.0
|
59 |
+
```
|
60 |
+
2. Load & run the model.
|
61 |
+
```python
|
62 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
63 |
+
|
64 |
+
|
65 |
+
model = AutoModelForCausalLM.from_pretrained("PrunaAI/openbmb-MiniCPM3-4B-bnb-8bit-smashed", trust_remote_code=True, device_map='auto')
|
66 |
+
tokenizer = AutoTokenizer.from_pretrained("openbmb/MiniCPM3-4B")
|
67 |
+
|
68 |
+
input_ids = tokenizer("What is the color of prunes?,", return_tensors='pt').to(model.device)["input_ids"]
|
69 |
+
|
70 |
+
outputs = model.generate(input_ids, max_new_tokens=216)
|
71 |
+
tokenizer.decode(outputs[0])
|
72 |
+
```
|
73 |
+
|
74 |
+
## Configurations
|
75 |
+
|
76 |
+
The configuration info are in `smash_config.json`.
|
77 |
+
|
78 |
+
## Credits & License
|
79 |
+
|
80 |
+
The license of the smashed model follows the license of the original model. Please check the license of the original model openbmb/MiniCPM3-4B before using this model which provided the base model. The license of the `pruna-engine` is [here](https://pypi.org/project/pruna-engine/) on Pypi.
|
81 |
+
|
82 |
+
## Want to compress other models?
|
83 |
+
|
84 |
+
- Contact us and tell us which model to compress next [here](https://www.pruna.ai/contact).
|
85 |
+
- Do it by yourself [here](https://docs.pruna.ai/en/latest/setup/pip.html).
|
config.json
ADDED
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_name_or_path": "/covalent/.cache/models/tmpoel8etc5a80hfd_0",
|
3 |
+
"architectures": [
|
4 |
+
"MiniCPM3ForCausalLM"
|
5 |
+
],
|
6 |
+
"attention_bias": false,
|
7 |
+
"attention_dropout": 0.0,
|
8 |
+
"auto_map": {
|
9 |
+
"AutoConfig": "configuration_minicpm.MiniCPM3Config",
|
10 |
+
"AutoModel": "openbmb/MiniCPM3-4B--modeling_minicpm.MiniCPM3Model",
|
11 |
+
"AutoModelForCausalLM": "openbmb/MiniCPM3-4B--modeling_minicpm.MiniCPM3ForCausalLM",
|
12 |
+
"AutoModelForSeq2SeqLM": "openbmb/MiniCPM3-4B--modeling_minicpm.MiniCPM3ForCausalLM",
|
13 |
+
"AutoModelForSequenceClassification": "openbmb/MiniCPM3-4B--modeling_minicpm.MiniCPM3ForSequenceClassification"
|
14 |
+
},
|
15 |
+
"bos_token_id": 1,
|
16 |
+
"dim_model_base": 256,
|
17 |
+
"eos_token_id": [
|
18 |
+
2,
|
19 |
+
73440
|
20 |
+
],
|
21 |
+
"head_dim": 96,
|
22 |
+
"hidden_act": "silu",
|
23 |
+
"hidden_size": 2560,
|
24 |
+
"initializer_range": 0.1,
|
25 |
+
"intermediate_size": 6400,
|
26 |
+
"kv_lora_rank": 256,
|
27 |
+
"max_position_embeddings": 32768,
|
28 |
+
"model_type": "minicpm3",
|
29 |
+
"num_attention_heads": 40,
|
30 |
+
"num_hidden_layers": 62,
|
31 |
+
"num_key_value_heads": 40,
|
32 |
+
"pretraining_tp": 1,
|
33 |
+
"q_lora_rank": 768,
|
34 |
+
"qk_nope_head_dim": 64,
|
35 |
+
"qk_rope_head_dim": 32,
|
36 |
+
"quantization_config": {
|
37 |
+
"_load_in_4bit": false,
|
38 |
+
"_load_in_8bit": true,
|
39 |
+
"bnb_4bit_compute_dtype": "bfloat16",
|
40 |
+
"bnb_4bit_quant_storage": "uint8",
|
41 |
+
"bnb_4bit_quant_type": "fp4",
|
42 |
+
"bnb_4bit_use_double_quant": false,
|
43 |
+
"llm_int8_enable_fp32_cpu_offload": false,
|
44 |
+
"llm_int8_has_fp16_weight": false,
|
45 |
+
"llm_int8_skip_modules": [
|
46 |
+
"lm_head"
|
47 |
+
],
|
48 |
+
"llm_int8_threshold": 6.0,
|
49 |
+
"load_in_4bit": false,
|
50 |
+
"load_in_8bit": true,
|
51 |
+
"quant_method": "bitsandbytes"
|
52 |
+
},
|
53 |
+
"rms_norm_eps": 1e-05,
|
54 |
+
"rope_scaling": {
|
55 |
+
"long_factor": [
|
56 |
+
1.0591234137867171,
|
57 |
+
1.1241891283591912,
|
58 |
+
1.2596935748670968,
|
59 |
+
1.5380380402321725,
|
60 |
+
2.093982484148734,
|
61 |
+
3.1446935121267696,
|
62 |
+
4.937952647693647,
|
63 |
+
7.524541999994549,
|
64 |
+
10.475458000005451,
|
65 |
+
13.062047352306353,
|
66 |
+
14.85530648787323,
|
67 |
+
15.906017515851266,
|
68 |
+
16.461961959767827,
|
69 |
+
16.740306425132907,
|
70 |
+
16.87581087164081,
|
71 |
+
16.940876586213285
|
72 |
+
],
|
73 |
+
"original_max_position_embeddings": 32768,
|
74 |
+
"short_factor": [
|
75 |
+
1.0591234137867171,
|
76 |
+
1.1241891283591912,
|
77 |
+
1.2596935748670968,
|
78 |
+
1.5380380402321725,
|
79 |
+
2.093982484148734,
|
80 |
+
3.1446935121267696,
|
81 |
+
4.937952647693647,
|
82 |
+
7.524541999994549,
|
83 |
+
10.475458000005451,
|
84 |
+
13.062047352306353,
|
85 |
+
14.85530648787323,
|
86 |
+
15.906017515851266,
|
87 |
+
16.461961959767827,
|
88 |
+
16.740306425132907,
|
89 |
+
16.87581087164081,
|
90 |
+
16.940876586213285
|
91 |
+
],
|
92 |
+
"type": "longrope"
|
93 |
+
},
|
94 |
+
"rope_theta": 10000.0,
|
95 |
+
"scale_depth": 1.4,
|
96 |
+
"scale_emb": 12,
|
97 |
+
"torch_dtype": "float16",
|
98 |
+
"transformers_version": "4.46.2",
|
99 |
+
"use_cache": true,
|
100 |
+
"v_head_dim": 64,
|
101 |
+
"vocab_size": 73448,
|
102 |
+
"api_key": null
|
103 |
+
}
|
configuration_minicpm.py
ADDED
@@ -0,0 +1,195 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# coding=utf-8
|
2 |
+
# Copyright 2024 The OpenBMB team and the HuggingFace Inc. team. All rights reserved.
|
3 |
+
#
|
4 |
+
# This code is based on EleutherAI's GPT-NeoX library and the GPT-NeoX
|
5 |
+
# and OPT implementations in this library. It has been modified from its
|
6 |
+
# original forms to accommodate minor architectural differences compared
|
7 |
+
# to GPT-NeoX and OPT used by the Meta AI team that trained the model.
|
8 |
+
#
|
9 |
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
10 |
+
# you may not use this file except in compliance with the License.
|
11 |
+
# You may obtain a copy of the License at
|
12 |
+
#
|
13 |
+
# http://www.apache.org/licenses/LICENSE-2.0
|
14 |
+
#
|
15 |
+
# Unless required by applicable law or agreed to in writing, software
|
16 |
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
17 |
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
18 |
+
# See the License for the specific language governing permissions and
|
19 |
+
# limitations under the License.
|
20 |
+
""" MiniCPM model configuration"""
|
21 |
+
|
22 |
+
from transformers.configuration_utils import PretrainedConfig
|
23 |
+
from transformers.utils import logging
|
24 |
+
|
25 |
+
|
26 |
+
logger = logging.get_logger(__name__)
|
27 |
+
|
28 |
+
MINICPM_PRETRAINED_CONFIG_ARCHIVE_MAP = {}
|
29 |
+
|
30 |
+
|
31 |
+
class MiniCPM3Config(PretrainedConfig):
|
32 |
+
r"""
|
33 |
+
This is the configuration class to store the configuration of a [`MiniCPMModel`]. It is used to instantiate an MiniCPM
|
34 |
+
model according to the specified arguments, defining the model architecture. Instantiating a configuration with the
|
35 |
+
defaults will yield a similar configuration to that of the MiniCPM-7B.
|
36 |
+
|
37 |
+
Configuration objects inherit from [`PretrainedConfig`] and can be used to control the model outputs. Read the
|
38 |
+
documentation from [`PretrainedConfig`] for more information.
|
39 |
+
|
40 |
+
|
41 |
+
Args:
|
42 |
+
vocab_size (`int`, *optional*, defaults to 32000):
|
43 |
+
Vocabulary size of the MiniCPM model. Defines the number of different tokens that can be represented by the
|
44 |
+
`inputs_ids` passed when calling [`MiniCPMModel`]
|
45 |
+
hidden_size (`int`, *optional*, defaults to 4096):
|
46 |
+
Dimension of the hidden representations.
|
47 |
+
intermediate_size (`int`, *optional*, defaults to 11008):
|
48 |
+
Dimension of the MLP representations.
|
49 |
+
num_hidden_layers (`int`, *optional*, defaults to 32):
|
50 |
+
Number of hidden layers in the Transformer decoder.
|
51 |
+
num_attention_heads (`int`, *optional*, defaults to 32):
|
52 |
+
Number of attention heads for each attention layer in the Transformer decoder.
|
53 |
+
num_key_value_heads (`int`, *optional*):
|
54 |
+
This is the number of key_value heads that should be used to implement Grouped Query Attention. If
|
55 |
+
`num_key_value_heads=num_attention_heads`, the model will use Multi Head Attention (MHA), if
|
56 |
+
`num_key_value_heads=1 the model will use Multi Query Attention (MQA) otherwise GQA is used. When
|
57 |
+
converting a multi-head checkpoint to a GQA checkpoint, each group key and value head should be constructed
|
58 |
+
by meanpooling all the original heads within that group. For more details checkout [this
|
59 |
+
paper](https://arxiv.org/pdf/2305.13245.pdf). If it is not specified, will default to
|
60 |
+
`num_attention_heads`.
|
61 |
+
hidden_act (`str` or `function`, *optional*, defaults to `"silu"`):
|
62 |
+
The non-linear activation function (function or string) in the decoder.
|
63 |
+
max_position_embeddings (`int`, *optional*, defaults to 2048):
|
64 |
+
The maximum sequence length that this model might ever be used with. MiniCPM 1 supports up to 2048 tokens,
|
65 |
+
MiniCPM 2 up to 4096, CodeMiniCPM up to 16384.
|
66 |
+
initializer_range (`float`, *optional*, defaults to 0.02):
|
67 |
+
The standard deviation of the truncated_normal_initializer for initializing all weight matrices.
|
68 |
+
rms_norm_eps (`float`, *optional*, defaults to 1e-06):
|
69 |
+
The epsilon used by the rms normalization layers.
|
70 |
+
use_cache (`bool`, *optional*, defaults to `True`):
|
71 |
+
Whether or not the model should return the last key/values attentions (not used by all models). Only
|
72 |
+
relevant if `config.is_decoder=True`.
|
73 |
+
pad_token_id (`int`, *optional*):
|
74 |
+
Padding token id.
|
75 |
+
bos_token_id (`int`, *optional*, defaults to 1):
|
76 |
+
Beginning of stream token id.
|
77 |
+
eos_token_id (`int`, *optional*, defaults to 2):
|
78 |
+
End of stream token id.
|
79 |
+
pretraining_tp (`int`, *optional*, defaults to 1):
|
80 |
+
Experimental feature. Tensor parallelism rank used during pretraining. Please refer to [this
|
81 |
+
document](https://huggingface.co/docs/transformers/parallelism) to understand more about it. This value is
|
82 |
+
necessary to ensure exact reproducibility of the pretraining results. Please refer to [this
|
83 |
+
issue](https://github.com/pytorch/pytorch/issues/76232).
|
84 |
+
tie_word_embeddings (`bool`, *optional*, defaults to `False`):
|
85 |
+
Whether to tie weight embeddings
|
86 |
+
rope_theta (`float`, *optional*, defaults to 10000.0):
|
87 |
+
The base period of the RoPE embeddings.
|
88 |
+
rope_scaling (`Dict`, *optional*):
|
89 |
+
Dictionary containing the scaling configuration for the RoPE embeddings. Currently supports two scaling
|
90 |
+
strategies: linear and dynamic. Their scaling factor must be a float greater than 1. The expected format is
|
91 |
+
`{"type": strategy name, "factor": scaling factor}`. When using this flag, don't update
|
92 |
+
`max_position_embeddings` to the expected new maximum. See the following thread for more information on how
|
93 |
+
these scaling strategies behave:
|
94 |
+
https://www.reddit.com/r/LocalMiniCPM/comments/14mrgpr/dynamically_scaled_rope_further_increases/. This is an
|
95 |
+
experimental feature, subject to breaking API changes in future versions.
|
96 |
+
attention_bias (`bool`, defaults to `False`, *optional*, defaults to `False`):
|
97 |
+
Whether to use a bias in the query, key, value and output projection layers during self-attention.
|
98 |
+
attention_dropout (`float`, *optional*, defaults to 0.0):
|
99 |
+
The dropout ratio for the attention probabilities.
|
100 |
+
|
101 |
+
```python
|
102 |
+
>>> from transformers import MiniCPMModel, MiniCPMConfig
|
103 |
+
|
104 |
+
>>> # Initializing a MiniCPM minicpm-7b style configuration
|
105 |
+
>>> configuration = MiniCPMConfig()
|
106 |
+
|
107 |
+
>>> # Initializing a model from the minicpm-7b style configuration
|
108 |
+
>>> model = MiniCPMModel(configuration)
|
109 |
+
|
110 |
+
>>> # Accessing the model configuration
|
111 |
+
>>> configuration = model.config
|
112 |
+
```"""
|
113 |
+
|
114 |
+
model_type = "minicpm3"
|
115 |
+
keys_to_ignore_at_inference = ["past_key_values"]
|
116 |
+
|
117 |
+
def __init__(
|
118 |
+
self,
|
119 |
+
vocab_size=32000,
|
120 |
+
hidden_size=4096,
|
121 |
+
intermediate_size=11008,
|
122 |
+
num_hidden_layers=32,
|
123 |
+
num_attention_heads=32,
|
124 |
+
num_key_value_heads=None,
|
125 |
+
qk_nope_head_dim=64,
|
126 |
+
qk_rope_head_dim=32,
|
127 |
+
q_lora_rank=768,
|
128 |
+
kv_lora_rank=256,
|
129 |
+
v_head_dim=None,
|
130 |
+
head_dim=None,
|
131 |
+
hidden_act="silu",
|
132 |
+
max_position_embeddings=2048,
|
133 |
+
initializer_range=0.02,
|
134 |
+
rms_norm_eps=1e-6,
|
135 |
+
use_cache=True,
|
136 |
+
pad_token_id=None,
|
137 |
+
bos_token_id=1,
|
138 |
+
eos_token_id=2,
|
139 |
+
pretraining_tp=1,
|
140 |
+
tie_word_embeddings=True,
|
141 |
+
rope_theta=10000.0,
|
142 |
+
rope_scaling=None,
|
143 |
+
attention_bias=False,
|
144 |
+
attention_dropout=0.0,
|
145 |
+
scale_emb=1,
|
146 |
+
dim_model_base=1,
|
147 |
+
scale_depth=1,
|
148 |
+
**kwargs,
|
149 |
+
):
|
150 |
+
self.vocab_size = vocab_size
|
151 |
+
self.max_position_embeddings = max_position_embeddings
|
152 |
+
self.hidden_size = hidden_size
|
153 |
+
self.intermediate_size = intermediate_size
|
154 |
+
self.num_hidden_layers = num_hidden_layers
|
155 |
+
self.num_attention_heads = num_attention_heads
|
156 |
+
self.qk_nope_head_dim = qk_nope_head_dim
|
157 |
+
self.qk_rope_head_dim = qk_rope_head_dim
|
158 |
+
self.q_lora_rank = q_lora_rank
|
159 |
+
self.kv_lora_rank = kv_lora_rank
|
160 |
+
|
161 |
+
if v_head_dim is None:
|
162 |
+
v_head_dim = qk_nope_head_dim
|
163 |
+
self.v_head_dim = v_head_dim
|
164 |
+
|
165 |
+
# for backward compatibility
|
166 |
+
if num_key_value_heads is None:
|
167 |
+
num_key_value_heads = num_attention_heads
|
168 |
+
|
169 |
+
self.num_key_value_heads = num_key_value_heads
|
170 |
+
self.hidden_act = hidden_act
|
171 |
+
self.initializer_range = initializer_range
|
172 |
+
self.rms_norm_eps = rms_norm_eps
|
173 |
+
self.pretraining_tp = pretraining_tp
|
174 |
+
self.use_cache = use_cache
|
175 |
+
self.rope_theta = rope_theta
|
176 |
+
self.rope_scaling = rope_scaling
|
177 |
+
self.attention_bias = attention_bias
|
178 |
+
self.attention_dropout = attention_dropout
|
179 |
+
self.scale_emb = scale_emb
|
180 |
+
self.dim_model_base = dim_model_base
|
181 |
+
self.scale_depth = scale_depth
|
182 |
+
self.head_dim = self.qk_nope_head_dim + self.qk_rope_head_dim
|
183 |
+
|
184 |
+
super().__init__(
|
185 |
+
pad_token_id=pad_token_id,
|
186 |
+
bos_token_id=bos_token_id,
|
187 |
+
eos_token_id=eos_token_id,
|
188 |
+
tie_word_embeddings=tie_word_embeddings,
|
189 |
+
**kwargs,
|
190 |
+
)
|
191 |
+
try:
|
192 |
+
import flash_attn
|
193 |
+
self._attn_implementation = "flash_attention_2"
|
194 |
+
except:
|
195 |
+
pass
|
generation_config.json
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"bos_token_id": 1,
|
3 |
+
"do_sample": true,
|
4 |
+
"eos_token_id": [
|
5 |
+
2,
|
6 |
+
73440
|
7 |
+
],
|
8 |
+
"temperature": 0.8,
|
9 |
+
"top_p": 0.8,
|
10 |
+
"transformers_version": "4.46.2"
|
11 |
+
}
|
smash_config.json
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"comp_cgenerate_active": false,
|
3 |
+
"comp_ctranslate_active": false,
|
4 |
+
"comp_cwhisper_active": false,
|
5 |
+
"comp_diffusers2_active": false,
|
6 |
+
"comp_ifw_active": false,
|
7 |
+
"comp_onediff_active": false,
|
8 |
+
"comp_step_caching_active": false,
|
9 |
+
"comp_torch_compile_active": false,
|
10 |
+
"comp_ws2t_active": false,
|
11 |
+
"comp_x-fast_active": false,
|
12 |
+
"prune_torch-structured_active": false,
|
13 |
+
"quant_aqlm_active": false,
|
14 |
+
"quant_awq_active": false,
|
15 |
+
"quant_gptq_active": false,
|
16 |
+
"quant_half_active": false,
|
17 |
+
"quant_hqq_active": false,
|
18 |
+
"quant_llm-int8_active": true,
|
19 |
+
"quant_quanto_active": false,
|
20 |
+
"quant_torch_dynamic_active": false,
|
21 |
+
"quant_torch_static_active": false,
|
22 |
+
"quant_llm-int8_compute_dtype": "bfloat16",
|
23 |
+
"quant_llm-int8_double_quant": false,
|
24 |
+
"quant_llm-int8_enable_fp32_cpu_offload": false,
|
25 |
+
"quant_llm-int8_has_fp16_weight": false,
|
26 |
+
"quant_llm-int8_quant_type": "fp4",
|
27 |
+
"quant_llm-int8_threshold": 6.0,
|
28 |
+
"quant_llm-int8_weight_bits": 8,
|
29 |
+
"max_batch_size": 1,
|
30 |
+
"device": "cuda",
|
31 |
+
"cache_dir": "/covalent/.cache/models/tmpoel8etc5",
|
32 |
+
"task": "",
|
33 |
+
"save_load_fn": "bitsandbytes",
|
34 |
+
"save_load_fn_args": {}
|
35 |
+
}
|