美文网首页
书生·浦语大模型实战营笔记-第二课作业

书生·浦语大模型实战营笔记-第二课作业

作者: 银河星尘 | 来源:发表于2024-02-10 18:11 被阅读0次

    《第二课作业》

    第二课作业比较简单,按照文档里说明一步步执行就可以了。 只购买了1小时算力开发机就够Demo使用了。

    不过终端模式下有问题

    用最新代码时报错:

    =============Welcome to InternLM chatbot, type 'exit' to exit.=============
    User  >>> hello
    robot >>> Hello! How can I assist you today?
    User  >>> who are you?
    robot >>> I am InternLM (书生·浦语), a conversational language model developed by Shanghai AI Laboratory. Is there anything I can help you with today?
    User  >>> can you speak chinese
    Traceback (most recent call last):
      File "/root/code/InternLM/cli_demo.py", line 25, in <module>
        response, history = model.chat(tokenizer, input_text, history=messages)
      File "/root/.conda/envs/internlm-demo/lib/python3.10/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context
        return func(*args, **kwargs)
      File "/root/.cache/huggingface/modules/transformers_modules/internlm-chat-7b/modeling_internlm.py", line 802, in chat
        inputs = self.build_inputs(tokenizer, query, history)
      File "/root/.cache/huggingface/modules/transformers_modules/internlm-chat-7b/modeling_internlm.py", line 787, in build_inputs
        return tokenizer([prompt], return_tensors="pt")
      File "/root/.conda/envs/internlm-demo/lib/python3.10/site-packages/transformers/tokenization_utils_base.py", line 2798, in __call__
        encodings = self._call_one(text=text, text_pair=text_pair, **all_kwargs)
      File "/root/.conda/envs/internlm-demo/lib/python3.10/site-packages/transformers/tokenization_utils_base.py", line 2884, in _call_one
        return self.batch_encode_plus(
      File "/root/.conda/envs/internlm-demo/lib/python3.10/site-packages/transformers/tokenization_utils_base.py", line 3075, in batch_encode_plus
        return self._batch_encode_plus(
      File "/root/.conda/envs/internlm-demo/lib/python3.10/site-packages/transformers/tokenization_utils.py", line 803, in _batch_encode_plus
        first_ids = get_input_ids(ids)
      File "/root/.conda/envs/internlm-demo/lib/python3.10/site-packages/transformers/tokenization_utils.py", line 770, in get_input_ids
        tokens = self.tokenize(text, **kwargs)
      File "/root/.conda/envs/internlm-demo/lib/python3.10/site-packages/transformers/tokenization_utils.py", line 617, in tokenize
        tokenized_text.extend(self._tokenize(token))
      File "/root/.cache/huggingface/modules/transformers_modules/internlm-chat-7b/tokenization_internlm.py", line 114, in _tokenize
        return self.sp_model.encode(text, out_type=str)
      File "/root/.conda/envs/internlm-demo/lib/python3.10/site-packages/sentencepiece/__init__.py", line 531, in Encode
        return self._EncodeAsPieces(input, enable_sampling, nbest_size,
      File "/root/.conda/envs/internlm-demo/lib/python3.10/site-packages/sentencepiece/__init__.py", line 316, in _EncodeAsPieces
        return _sentencepiece.SentencePieceProcessor__EncodeAsPieces(self, text, enable_sampling, nbest_size, alpha, add_bos, add_eos, reverse, emit_unk_piece)
    TypeError: not a string
    

    按教程要求切换代码版本 git checkout 3028f07cb79e5b1d7342f4ad8d11efad3fd13d17,运行后报错。在终端模式下删除汉字要按两下,否则会留下半个字符的空格。

    =============Welcome to InternLM chatbot, type 'exit' to exit.=============
    User  >>> 你有什么技能
    robot >>> I am an AI language model and can perform various tasks such as answering questions, providing definitions and explanations, translating text from one language to another, summarizing text, generating text, writing stories, analyzing sentiment, providing recommendations, developing algorithms, creating code, and many more. However, please note that I am not capable of performing tasks that require physical abilities or interacting with the physical world.
    User  >>> 说中文
    robot >>> 我能够理解和使用中文进行交流。请开始提问或说话。
    User  >>> 你有什么 技能
    Traceback (most recent call last):
      File "/root/code/InternLM/cli_demo.py", line 25, in <module>
        response, history = model.chat(tokenizer, input_text, history=messages)
      File "/root/.conda/envs/internlm-demo/lib/python3.10/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context
        return func(*args, **kwargs)
      File "/root/.cache/huggingface/modules/transformers_modules/internlm-chat-7b/modeling_internlm.py", line 802, in chat
        inputs = self.build_inputs(tokenizer, query, history)
      File "/root/.cache/huggingface/modules/transformers_modules/internlm-chat-7b/modeling_internlm.py", line 787, in build_inputs
        return tokenizer([prompt], return_tensors="pt")
      File "/root/.conda/envs/internlm-demo/lib/python3.10/site-packages/transformers/tokenization_utils_base.py", line 2798, in __call__
        encodings = self._call_one(text=text, text_pair=text_pair, **all_kwargs)
      File "/root/.conda/envs/internlm-demo/lib/python3.10/site-packages/transformers/tokenization_utils_base.py", line 2884, in _call_one
        return self.batch_encode_plus(
      File "/root/.conda/envs/internlm-demo/lib/python3.10/site-packages/transformers/tokenization_utils_base.py", line 3075, in batch_encode_plus
        return self._batch_encode_plus(
      File "/root/.conda/envs/internlm-demo/lib/python3.10/site-packages/transformers/tokenization_utils.py", line 803, in _batch_encode_plus
        first_ids = get_input_ids(ids)
      File "/root/.conda/envs/internlm-demo/lib/python3.10/site-packages/transformers/tokenization_utils.py", line 770, in get_input_ids
        tokens = self.tokenize(text, **kwargs)
      File "/root/.conda/envs/internlm-demo/lib/python3.10/site-packages/transformers/tokenization_utils.py", line 617, in tokenize
        tokenized_text.extend(self._tokenize(token))
      File "/root/.cache/huggingface/modules/transformers_modules/internlm-chat-7b/tokenization_internlm.py", line 114, in _tokenize
        return self.sp_model.encode(text, out_type=str)
      File "/root/.conda/envs/internlm-demo/lib/python3.10/site-packages/sentencepiece/__init__.py", line 531, in Encode
        return self._EncodeAsPieces(input, enable_sampling, nbest_size,
      File "/root/.conda/envs/internlm-demo/lib/python3.10/site-packages/sentencepiece/__init__.py", line 316, in _EncodeAsPieces
        return _sentencepiece.SentencePieceProcessor__EncodeAsPieces(self, text, enable_sampling, nbest_size, alpha, add_bos, add_eos, reverse, emit_unk_piece)
    TypeError: not a string
    

    相关文章

      网友评论

          本文标题:书生·浦语大模型实战营笔记-第二课作业

          本文链接:https://www.haomeiwen.com/subject/npzladtx.html