lyogavin / airllm

AirLLM 70B inference with single 4GB GPU
Apache License 2.0
4.04k stars 334 forks source link

TypeError: not a string #3

Closed kulame closed 1 year ago

kulame commented 1 year ago

跑inference代码的时候报错

CUDA SETUP: Loading binary /usr/local/lib/python3.10/dist-packages/bitsandbytes/libbitsandbytes_cuda121.so...

╭───────────────────── Traceback (most recent call last) ──────────────────────╮
│ /srv/chat/Anima/infer.py:9 in <module>                                       │
│                                                                              │
│    6                                                                         │
│    7 # create tokenizer                                                      │
│    8 base_model = "timdettmers/guanaco-33b-merged"                           │
│ ❱  9 tokenizer = LlamaTokenizer.from_pretrained(base_model)                  │
│   10                                                                         │
│   11 # base model                                                            │
│   12 model = LlamaForCausalLM.from_pretrained(                               │
│                                                                              │
│ /usr/local/lib/python3.10/dist-packages/transformers/tokenization_utils_base │
│ .py:1825 in from_pretrained                                                  │
│                                                                              │
│   1822 │   │   │   else:                                                     │
│   1823 │   │   │   │   logger.info(f"loading file {file_path} from cache at  │
│   1824 │   │                                                                 │
│ ❱ 1825 │   │   return cls._from_pretrained(                                  │
│   1826 │   │   │   resolved_vocab_files,                                     │
│   1827 │   │   │   pretrained_model_name_or_path,                            │
│   1828 │   │   │   init_configuration,                                       │
│                                                                              │
│ /usr/local/lib/python3.10/dist-packages/transformers/tokenization_utils_base │
│ .py:1988 in _from_pretrained                                                 │
│                                                                              │
│   1985 │   │                                                                 │
│   1986 │   │   # Instantiate tokenizer.                                      │
│   1987 │   │   try:                                                          │
│ ❱ 1988 │   │   │   tokenizer = cls(*init_inputs, **init_kwargs)              │
│   1989 │   │   except OSError:                                               │
│   1990 │   │   │   raise OSError(                                            │
│   1991 │   │   │   │   "Unable to load vocabulary from file. "               │
│                                                                              │
│ /usr/local/lib/python3.10/dist-packages/transformers/models/llama/tokenizati │
│ on_llama.py:96 in __init__                                                   │
│                                                                              │
│    93 │   │   self.add_bos_token = add_bos_token                             │
│    94 │   │   self.add_eos_token = add_eos_token                             │
│    95 │   │   self.sp_model = spm.SentencePieceProcessor(**self.sp_model_kwa │
│ ❱  96 │   │   self.sp_model.Load(vocab_file)                                 │
│    97 │                                                                      │
│    98 │   def __getstate__(self):                                            │
│    99 │   │   state = self.__dict__.copy()                                   │
│                                                                              │
│ /usr/local/lib/python3.10/dist-packages/sentencepiece/__init__.py:905 in     │
│ Load                                                                         │
│                                                                              │
│    902 │   │   raise RuntimeError('model_file and model_proto must be exclus │
│    903 │     if model_proto:                                                 │
│    904 │   │   return self.LoadFromSerializedProto(model_proto)              │
│ ❱  905 │     return self.LoadFromFile(model_file)                            │
│    906                                                                       │
│    907                                                                       │
│    908 # Register SentencePieceProcessor in _sentencepiece:                  │
│                                                                              │
│ /usr/local/lib/python3.10/dist-packages/sentencepiece/__init__.py:310 in     │
│ LoadFromFile                                                                 │
│                                                                              │
│    307 │   │   return _sentencepiece.SentencePieceProcessor_serialized_model │
│    308 │                                                                     │
│    309 │   def LoadFromFile(self, arg):                                      │
│ ❱  310 │   │   return _sentencepiece.SentencePieceProcessor_LoadFromFile(sel │
│    311 │                                                                     │
│    312 │   def _EncodeAsIds(self, text, enable_sampling, nbest_size, alpha,  │
│    313 │   │   return _sentencepiece.SentencePieceProcessor__EncodeAsIds(sel │
╰──────────────────────────────────────────────────────────────────────────────╯
TypeError: not a string

这是什么原因?

lyogavin commented 1 year ago

https://colab.research.google.com/drive/1tl5vBc7u77bzzNdUD-nxwpvVXUyQB4Cn?usp=sharing

我试了一下在新环境是可以的。

感觉是版本的问题?你的装的版本是什么?是用requirements.txt装的packages吗?

Transformers更新太快了,很多时候容易有版本冲突. 更新一下环境试一下?

kulame commented 1 year ago

的确是, 升级了一下依赖库就没问题了, 感谢回答