-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add support for Qwen #129
base: main
Are you sure you want to change the base?
add support for Qwen #129
Conversation
if freqs_cis is not None: | ||
query, key = apply_rotary_emb(query.transpose(1,2), key.transpose(1,2), freqs_cis=freqs_cis) | ||
if use_dynamic_ntk: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里建议可以封装一下
@@ -40,8 +49,8 @@ def __init__(self, args, layer_number=None): | |||
lora_params = args.lora_params | |||
|
|||
self.self_attn = MultiHeadedAttention( | |||
args.hidden_size, args.heads_num, attention_head_size, local_kv_heads_num, args.dropout, has_bias=has_bias, | |||
with_scale=with_scale, lora_params=lora_params, layer_number=layer_number | |||
args.hidden_size, args.heads_num, attention_head_size, local_kv_heads_num, args.dropout, self.max_seq_length, has_bias=has_bias, has_attention_bias = has_attention_bias, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
之前has_bias包含了attention_bias,这里重命名后是否有考虑对之前的兼容性? 比如T5模型
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
之前has_bias包含了attention_bias,这里重命名后是否有考虑对之前的兼容性? 比如T5模型
当创建q,k,v的linear_layers时,如果没有传入attention_bias,则会使用has_bias的值,应该是对之前的模型兼容。
@@ -16,6 +17,13 @@ def __init__(self, args, layer_number=None): | |||
self.relative_position_embedding = args.relative_position_embedding | |||
self.rotary_position_embedding = args.rotary_position_embedding | |||
self.has_residual_attention = args.has_residual_attention | |||
self.use_logn_attn = args.use_logn_attn | |||
self.max_seq_length = args.max_seq_length | |||
self.use_dynamic_ntk = args.use_dynamic_ntk |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
训练不需要ntk,只有推理需要,如果只考虑训练的话这里是否有可能简化?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
建议同时提供 互相转换脚本
convert_qwen_from_tencentpretrain_to_huggingface.py
convert
python3 scripts/convert_qwen_from_huggingface_to_tencentpretrain.py --input_model_path $Qwen_1_8B_FOLDER --output_model_path models/qwen-1_8b.bin --layers_num 24
test
python3 scripts/generate_lm.py --load_model_path models/qwen-1_8b.bin
--tokenizer qwen --vocab_path $Qwen_1_8B_FOLDER
--test_path beginning.txt --prediction_path generated_sentence.txt
--config_path models/qwen/1_8b_config.json