Facico / Chinese-Vicuna

Chinese-Vicuna: A Chinese Instruction-following LLaMA-based Model —— 一个中文低资源的llama+lora方案,结构参考alpaca
https://github.com/Facico/Chinese-Vicuna
Apache License 2.0
4.15k stars 428 forks source link

finetune_chat 运行错误 #190

Open lucasjinreal opened 1 year ago

lucasjinreal commented 1 year ago
│   154 │   │   lens = len(data_point['input'])                                                    │
│   155 │   │   for i in range(lens-1):                                                            │
│   156 │   │   │   user_prompt += self.prompt_history.format_map({'input':data_point['input'][i   │
│ ❱ 157 │   │   user_prompt += self.prompt_post.format_map({'input':data_point['input'][-1].stri   │
│   158 │   │                                                                                      │
│   159 │   │   len_user_prompt_tokens = len(self.tokenizer(                                       │
│   160 │   │   │   user_prompt,                                                                   │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
IndexError: string index out of range
python finetune_chat.py --data_path guanaco_belle_merge_v1.0/merge.json --model_path llama-7b-hf --micro_batch 1
Facico commented 1 year ago

你那个数据文件有数据吗。你可以看看这个“data_point”是不是空的

lucasjinreal commented 1 year ago
❱ 113 assert train_tokenizer.eos_token_id == 2, "Tokenizer eos is wrong!!!"                      │
│   114 # unk. we want this to be different from the eos token                                     │
│   115 train_tokenizer.pad_token_id = 0                                                           │
│   116 # cannot use eos in generation!   

下载数据后出现新的错误

lucasjinreal commented 1 year ago

貌似新的transformers已经不兼容depera那个tokenizer model了。

我看finetune.py 没有这个assertion, finetune_chat里面有:

assert train_tokenizer.eos_token_id == 2, "Tokenizer eos is wrong!!!"

是不是意味着finentune训的已经崩了? 因为deppera那个tokenizer返回的eos已经是空了

lucasjinreal commented 1 year ago

@Facico chat 根本无法训练:

│ 245 │ │ user_prompt += self.prompt_post.format_map( │ │ ❱ 246 │ │ │ {"input": data_point["input"][-1].strip()} │ │ 247 │ │ ) │ │ 248 │ │ │ │ 249 │ │ len_user_prompt_tokens = ( │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────╯ IndexError: string index out of range

你的merge.json input是一个string,而且是 "" ,怎么index的?

Facico commented 1 year ago

@lucasjinreal decapoda那个model要用我们requirements.txt里面固定的transformers版本就没问题。只要推理的时候能输出eos就没问题。deppera那个tokenizer虽然是空的,但是tokenizer.model里面是有的,当时的代码默认用的是那个。 现在是如果用最新的transformers可以用yahma的模型,老版本的可以用decapoda的模型。

merge.json每个input应该是json格式的,可以参考这里,https://github.com/Facico/Chinese-Vicuna/blob/master/sample/chat/data_sample.jsonl

Facico commented 1 year ago

对了,如果用finetune_chat的话,用这个数据:https://huggingface.co/datasets/Chinese-Vicuna/instruct_chat_50k.jsonl

原本的instruct数据确实是没有input

cyc00518 commented 1 year ago

@Facico 請教一下finetune_chat、finetune、finetune_deepspeed這三個檔案的差別是什麼?

lucasjinreal commented 1 year ago

@Facico 非常感谢,已经解决了。

另外想请教一下这个版本训练的chat finetune多轮对话能力如何,相较于BiLLa和PandaLM或者是Chinese-Llama?

Facico commented 1 year ago

@cyc00518 finetune_chat是调对话型的数据的,多轮对话的能力会强一点,finetune就是普通的指令微调,finetune_deepspeed是用于fp16的(现在改名为finetune_fp16)