Views
No views yet
chatglm-6b-csc-zh-lora evaluate test data:| prefix | input_text | target_text | pred |
|---|---|---|---|
| 对下面中文拼写纠错: | 少先队员因该为老人让坐。 | 少先队员应该为老人让座。 | 少先队员应该为老人让座。\n错误字:因,坐 |
pip install -U textgen1from textgen import GptModel
2model = GptModel("chatglm", "THUDM/chatglm-6b", peft_name="shibing624/chatglm-6b-csc-zh-lora")
3r = model.predict(["对下面中文拼写纠错:\n少先队员因该为老人让坐。\n答:"])
4print(r) # ['少先队员应该为老人让座。\n错误字:因,坐']pip install transformers 1import sys
2from peft import PeftModel
3from transformers import AutoModel, AutoTokenizer
4
5sys.path.append('..')
6
7model = AutoModel.from_pretrained("THUDM/chatglm-6b", trust_remote_code=True, device_map='auto')
8model = PeftModel.from_pretrained(model, "shibing624/chatglm-6b-csc-zh-lora")
9model = model.half().cuda() # fp16
10tokenizer = AutoTokenizer.from_pretrained("THUDM/chatglm-6b", trust_remote_code=True)
11
12sents = ['对下面中文拼写纠错:\n少先队员因该为老人让坐。\n答:',
13 '对下面中文拼写纠错:\n下个星期,我跟我朋唷打算去法国玩儿。\n答:']
14for s in sents:
15 response = model.chat(tokenizer, s, max_length=128, eos_token_id=tokenizer.eos_token_id)
16 print(response)1('少先队员应该为老人让座。\n错误字:因,坐', [('对下面中文拼写纠错:\n少先队员因该为老人让坐。\n答:', '少先队员应该为老人让座。\n错误字:因,坐')])
2('下个星期,我跟我朋友打算去法国玩儿。\n错误字:唷', [('对下面中文拼写纠错:\n下个星期,我跟我朋唷打算去法国玩儿。\n答:', '下个星期,我跟我朋友打算去法国玩儿。\n错误字:唷')])chatglm-6b-csc-zh-lora
├── adapter_config.json
└── adapter_model.bin1@software{textgen,
2 author = {Xu Ming},
3 title = {textgen: Implementation of language model finetune},
4 year = {2021},
5 url = {https://github.com/shibing624/textgen},
6}