Views
No views yet
| 模型链接 | 训练的数据量 | 模型版本 | 备注 |
|---|---|---|---|
| https://huggingface.co/yuanzhoulvpi/chinese_bloom_7b_chat | 15w中文指令数据 | v1 | |
| https://huggingface.co/yuanzhoulvpi/chinese_bloom_7b_chat_v2 | 150w条中文指令数据 | v2 | 目前已经测试过效果,相较于v1,效果有所提升 |
| https://huggingface.co/yuanzhoulvpi/chinese_bloom_7b_chat_v3 | 420w条中文指令数据 | v3 | 目前效果还没测试,欢迎大家测试 |
bloom-7b模型做了sft,本次版本为V2版本(使用了150w条有监督数据做sft),相较于V1版本,效果更好!!!1from transformers import AutoModelForCausalLM, AutoTokenizer
2
3
4checkpoint = "yuanzhoulvpi/chinese_bloom_7b_chat_v2"#"bigscience/bloomz-3b" #"bigscience/bloom-7b1"# "output_dir/checkpoint-8260"#
5tokenizer = AutoTokenizer.from_pretrained(checkpoint)
6model = AutoModelForCausalLM.from_pretrained(checkpoint).half().cuda()
7
8PROMPT_DICT = {
9 "prompt_input": (
10 "Below is an instruction that describes a task, paired with an input that provides further context. "
11 "Write a response that appropriately completes the request.\n\n"
12 "### Instruction:\n{instruction}\n\n### Input:\n{input}\n\n### Response:"
13 ),
14 "prompt_no_input": (
15 "Below is an instruction that describes a task. "
16 "Write a response that appropriately completes the request.\n\n"
17 "### Instruction:\n{instruction}\n\n### Response:"
18 ),
19}
20
21from typing import Optional
22def generate_input(instruction:Optional[str]= None, input_str:Optional[str] = None) -> str:
23 if input_str is None:
24 return PROMPT_DICT['prompt_no_input'].format_map({'instruction':instruction})
25 else:
26 return PROMPT_DICT['prompt_input'].format_map({'instruction':instruction, 'input':input_str})
27
28
29for i in range(5):
30 print("*"*80)
31
32 inputs = tokenizer.encode(generate_input(instruction="你是谁"), return_tensors="pt")
33 outputs = model.generate(inputs,num_beams=3,
34 max_new_tokens=512,
35 do_sample=False,
36 top_k=10,
37 penalty_alpha=0.6,
38 temperature=0.8,
39 repetition_penalty=1.2)
40 print(tokenizer.decode(outputs[0]))