Skip to content
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

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open

add support for Qwen #129

wants to merge 15 commits into from

Conversation

cjw-d
Copy link

@cjw-d cjw-d commented Jun 3, 2024

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

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:
Copy link
Collaborator

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,
Copy link
Collaborator

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模型

Copy link
Author

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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

训练不需要ntk,只有推理需要,如果只考虑训练的话这里是否有可能简化?

Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants