Comments (2)
Please install the correct transformers version as described in the readme and requirements file:
https://github.com/InternLM/InternLM#usages
Line 3 in bd57ff3
Lower versions of transformers cannot correctly identify the id set in added_tokens_decoder
from internlm.
yes, the final reason is added_tokens_decoder
. i resolved the problem by modifying tokenization_internlm2.py
class InternLM2Tokenizer(PreTrainedTokenizer):
"""
Construct a InternLM2 tokenizer. Based on byte-level Byte-Pair-Encoding.
Args:
vocab_file (`str`):
Path to the vocabulary file.
"""
vocab_files_names = VOCAB_FILES_NAMES
pretrained_vocab_files_map = PRETRAINED_VOCAB_FILES_MAP
model_input_names = ["input_ids", "attention_mask"]
_auto_class = "AutoTokenizer"
def __init__(
self,
vocab_file,
unk_token="<unk>",
bos_token="<s>",
eos_token="</s>",
pad_token="</s>",
sp_model_kwargs: Optional[Dict[str, Any]] = None,
add_bos_token=True,
add_eos_token=False,
decode_with_prefix_space=False,
clean_up_tokenization_spaces=False,
**kwargs,
):
self.sp_model_kwargs = {} if sp_model_kwargs is None else sp_model_kwargs
self.vocab_file = vocab_file
self.add_bos_token = add_bos_token
self.add_eos_token = add_eos_token
self.decode_with_prefix_space = decode_with_prefix_space
self.sp_model = spm.SentencePieceProcessor(**self.sp_model_kwargs)
self.sp_model.Load(vocab_file)
self._no_prefix_space_tokens = None
super().__init__(
bos_token=bos_token,
eos_token=eos_token,
unk_token=unk_token,
pad_token=pad_token,
clean_up_tokenization_spaces=clean_up_tokenization_spaces,
**kwargs,
)
# If a `added_tokens_decoder` is passed, we are loading from a saved tokenizer, we overwrite
# Modified from https://github.com/huggingface/transformers/blob/132852203a02e320049457316a63cffb64968aa1/src/transformers/tokenization_utils.py#L358-L360
added_tokens_decoder = {int(k):v["content"] for k, v in kwargs.pop("added_tokens_decoder", {}).items()}
added_tokens_encoder = {k:v for v, k in added_tokens_decoder.items()}
self.added_tokens_decoder = added_tokens_decoder
self.added_tokens_encoder = added_tokens_encoder
Thanks for reply!
from internlm.
Related Issues (20)
- [QA] 使用InternLM微调qa机器人,如何让它从训练资料中选择答案,而不是自己生成? HOT 2
- [Feature] convert2llama.py HOT 1
- [Bug] safetensors_rust.SafetensorError: Error while deserializing header: HeaderTooLarge HOT 5
- [QA] Question about phase 2 long context pretraining batch size HOT 3
- [QA] 请问如何在昇腾910上进行模型微调? HOT 3
- [Feature] 一个把internLM2 LoRA部分转换成llama风格的脚本 HOT 1
- [QA] 设置do_sample=False(贪婪解码),下的解码问题. HOT 1
- [QA] Multilingual ability HOT 2
- [Bug] ValueError: InternLM2ForCausalLM does not support Flash Attention 2.0 yet. HOT 4
- [Feature] Support Static Cache HOT 1
- [Bug] `rope_scaling` is `null` HOT 3
- [Feature] flash_attn not mandatory HOT 5
- [QA] 怎么接入ollama HOT 3
- [QA] 为什么使用internlm2-chat-7b模型,在实现流式输出时,使用model.chat和model.generate输出结果不一样 HOT 6
- [Bug] ModuleNotFoundError: No module named 'transformers_modules.InternLM2' HOT 1
- [Feature] Is there any plan to merge the modeling_internlm2.py into the Transformers library? HOT 2
- [Bug] internlm2_5-7b-chat使用lmdeploy serve api_server发布服务,调用出现重复生成现象 HOT 12
- 关于模型适配国产服务器等硬件的问题 HOT 3
- [QA] 7B-4bit量化显存占用21GB多,是正常的吗? HOT 2
- [QA] Qwen model can not use MLC LLM HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from internlm.