InternLM/tools/transformers
djsaber aaaf4d7b0e
fix(chat): fix stream_chat in modeling_internlm(hf) to avoid decode error (#560)
* fixed the issue that the HF model spontaneously conducted multiple rounds of Q&A and stream_chat method generates garbled characters

Signed-off-by: daijun1 <daijun1@eccom.com.cn>

* Update modeling_internlm.py

fixed the issue that the HF model spontaneously conducted multiple rounds of Q&A and stream_chat method generates garbled characters

* Update modeling_internlm.py

Correct spelling mistakes: chche -> cache

---------

Signed-off-by: daijun1 <daijun1@eccom.com.cn>
Co-authored-by: daijun1 <daijun1@eccom.com.cn>
2023-12-29 13:03:44 +08:00
..
README-zh-Hans.md doc(readme): update 7b/20b chat model information (#537) 2023-12-14 17:46:03 +08:00
README.md doc(readme): update 7b/20b chat model information (#537) 2023-12-14 17:46:03 +08:00
configuration_internlm.py doc(readme): update 7b/20b chat model information (#537) 2023-12-14 17:46:03 +08:00
convert2hf.py doc(readme): update 7b/20b chat model information (#537) 2023-12-14 17:46:03 +08:00
interface.py doc(readme): update 7b/20b chat model information (#537) 2023-12-14 17:46:03 +08:00
intern_moss_example.py doc(readme): update 7b/20b chat model information (#537) 2023-12-14 17:46:03 +08:00
internlm_sft_on_moss.py doc(readme): update 7b/20b chat model information (#537) 2023-12-14 17:46:03 +08:00
modeling_internlm.py fix(chat): fix stream_chat in modeling_internlm(hf) to avoid decode error (#560) 2023-12-29 13:03:44 +08:00
tokenization_internlm.py doc(readme): update 7b/20b chat model information (#537) 2023-12-14 17:46:03 +08:00

README.md

InternLM Transformers

English | 简体中文

This folder contains the InternLM model in transformers format.

Weight Conversion

convert2hf.py can convert saved training weights into the transformers format with a single command. Execute the command in the root directory of repository:

python tools/transformers/convert2hf.py --src_folder origin_ckpt/ --tgt_folder hf_ckpt/ --tokenizer ./tools/V7_sft.model

Then, you can load it using the from_pretrained interface:

>>> from transformers import AutoTokenizer, AutoModel
>>> model = AutoModel.from_pretrained("hf_ckpt/", trust_remote_code=True).cuda()

intern_moss_example.py demonstrates an example of how to use LoRA for fine-tuning on the fnlp/moss-moon-002-sft dataset.