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

使用ptyhon进行模型自我认知微调失败,问答结果依旧为qwen的回答 #919

Closed
l23abc0 opened this issue May 13, 2024 · 3 comments
Assignees

Comments

@l23abc0
Copy link

l23abc0 commented May 13, 2024

环境说明

  • torch:2.3.0+cu121
  • swift:2.1.0.dev0 (由git clone https://github.com/modelscope/swift.git命令进行安装)

我所运行的代码

# Experimental environment: A10, 3090, V100, ...
# 22GB GPU memory
import os

os.environ['CUDA_VISIBLE_DEVICES'] = '0'

from swift.llm import DatasetName, SftArguments, sft_main, InferArguments, infer_main, merge_lora, ModelType
import torch

model_type = ModelType.qwen1half_0_5b_chat

sft_args = SftArguments(
    model_type=model_type,
    dataset=[DatasetName.self_cognition, f'{DatasetName.ms_bench}#1000'],
    logging_steps=60,
    max_length=1024,
    warmup_ratio=0.4,
    output_dir='output',
    lora_target_modules=['ALL'],
    model_name=['小黄', 'Xiao Huang'],
    model_author=['魔搭', 'ModelScope'])
output = sft_main(sft_args)
best_model_checkpoint = output['best_model_checkpoint']
print(f'地址: {best_model_checkpoint, output}')

infer_args = InferArguments(ckpt_dir=best_model_checkpoint,
                            val_dataset_sample=10,
                            load_dataset_config=True)
infer_main(infer_args)

torch.cuda.empty_cache()

运行结果

image

@l23abc0
Copy link
Author

l23abc0 commented May 13, 2024

相反我是用pip的方法安装的swift,虽然用法有些不同,但是在微调之后的推理问答中回复正常,反而注册以后就似乎遗忘了训练结果

@l23abc0
Copy link
Author

l23abc0 commented May 13, 2024

我尝试使用文档中的完整代码,只是修改model_type = ModelType.qwen1half_0_5b_chat,训练依旧失败。是swift的版本问题导致吗?正确应该安装哪个版本?

@Jintao-Huang
Copy link
Collaborator

增加自我认知的采样数就好了 f'{DatasetName.self_cognition}#500'

@Jintao-Huang Jintao-Huang self-assigned this May 13, 2024
@l23abc0 l23abc0 closed this as completed May 14, 2024
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

No branches or pull requests

2 participants