大模型全栈开发作业-1-Datawhale
由于gpu实例的terminal不能直接点击,使用了notebook执行


源代码报错如下:Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/streamlit/runtime/scriptrunner/script_runner.py", line 552, in _run_script
exec(code, module.dict)
File "/mnt/workspace/AICamp_yuan_baseline/Task 1:零基础玩转源大模型/web_demo_2b.py", line 57, in
outputs = model.generate(inputs, do_sample=False, max_length=1024) # 设置解码方式和最大生成长度
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/torch/utils/_contextlib.py", line 120, in decorate_context
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/transformers/generation/utils.py", line 2564, in generate
result = decoding_method(
^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/transformers/generation/utils.py", line 2784, in _sample
outputs = self(**model_inputs, return_dict=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1775, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1786, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/.cache/huggingface/modules/transformers_modules/Yuan2_hyphen_2B_hyphen_Mars_hyphen_hf/yuan_hf_model.py", line 984, in forward
outputs = self.model(
^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1775, in _wrapped_call_impl
return self._call_impl(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1786, in _call_impl
return forward_call(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/.cache/huggingface/modules/transformers_modules/Yuan2_hyphen_2B_hyphen_Mars_hyphen_hf/yuan_hf_model.py", line 752, in forward
past_key_values_length = past_key_values[0][0].shape[2]
^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'shape'`
在`outputs = model.generate(inputs, do_sample=False, max_length=1024) # 设置解码方式和最大生成长度`
加上, use_cache=False
outputs = model.generate(inputs, do_sample=False, max_length=1024, use_cache=False)
更多推荐
所有评论(0)