首页 > 其他分享 >KeyError: 'Cache only has 0 layers, attempted to access layer with index 0'

KeyError: 'Cache only has 0 layers, attempted to access layer with index 0'

时间:2024-03-13 10:38:21浏览次数:13  
标签:layers index layer bigmodel envs py xiaoming File line

Traceback (most recent call last):
File "/disk2/xiaoming/Github/ChatHxk/chinese_alpaca_2_7b_16k_hf/hxk_demo.py", line 345, in gentask
ret = self.mfunc(callback=_callback, **self.kwargs)
File "/disk2/xiaoming/Github/ChatHxk/chinese_alpaca_2_7b_16k_hf/hxk_demo.py", line 545, in generate_with_callback
model.generate(**kwargs)
File "/home/xiaoming/miniconda3/envs/bigmodel/lib/python3.9/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context
return func(*args, **kwargs)
File "/home/xiaoming/miniconda3/envs/bigmodel/lib/python3.9/site-packages/transformers/generation/utils.py", line 1525, in generate
return self.sample(
File "/home/xiaoming/miniconda3/envs/bigmodel/lib/python3.9/site-packages/transformers/generation/utils.py", line 2622, in sample
outputs = self(
File "/home/xiaoming/miniconda3/envs/bigmodel/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "/home/xiaoming/miniconda3/envs/bigmodel/lib/python3.9/site-packages/transformers/models/llama/modeling_llama.py", line 1183, in forward
outputs = self.model(
File "/home/xiaoming/miniconda3/envs/bigmodel/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "/home/xiaoming/miniconda3/envs/bigmodel/lib/python3.9/site-packages/transformers/models/llama/modeling_llama.py", line 1070, in forward
layer_outputs = decoder_layer(
File "/home/xiaoming/miniconda3/envs/bigmodel/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "/home/xiaoming/miniconda3/envs/bigmodel/lib/python3.9/site-packages/transformers/models/llama/modeling_llama.py", line 798, in forward
hidden_states, self_attn_weights, present_key_value = self.self_attn(
File "/home/xiaoming/miniconda3/envs/bigmodel/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1501, in _call_impl
return forward_call(*args, **kwargs)
File "/disk2/xiaoming/Github/ChatHxk/chinese_alpaca_2_7b_16k_hf/attn_and_long_ctx_patches.py", line 53, in xformers_forward
past_kv_len = past_key_value[0].shape[-2]
File "/home/xiaoming/miniconda3/envs/bigmodel/lib/python3.9/site-packages/transformers/cache_utils.py", line 78, in __getitem__
raise KeyError(f"Cache only has {len(self)} layers, attempted to access layer with index {layer_idx}")
KeyError: 'Cache only has 0 layers, attempted to access layer with index 0'

原因:transformer版本问题

修改:pip install transformers==4.35.0

标签:layers,index,layer,bigmodel,envs,py,xiaoming,File,line
From: https://www.cnblogs.com/BlogLwc/p/18070038

相关文章

  • mysql show index from 语句详解
    在mysql数据库系统中,可以使用showindexfrom语句可以指定查看表的索引信息。语法:showindexfromtable_name;显示信息如下: Table:数据库表名Non_unique:表示是否为唯一索引,为0表示该索引是唯一索引,该列的值不允许重复;为1则该索引不是唯一索引。Key_name:表示索引名称Seq......
  • wpf datagrid row background color alternatively changed based on row index,Alter
    <Windowx:Class="WpfApp7.MainWindow"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:d="http://schemas.microsoft.c......
  • openlayers加载tms切片图层
    ol3舍弃了直接加载TMS服务的方法,但是可以通过类似于加载WMS瓦片的形式来加载TMS瓦片地图。参考:https://blog.csdn.net/Wxq666666/article/details/108527892谷歌TMS瓦片加载:newol.layer.Tile({source:newol.source.XYZ({tileUrlFunction:function(tileCoor......
  • openlayers2批量添加点
    //初始化地图initMap(){map=newMap({layers:[newTileLayer({source:newOSM(),}),],target:'map',view:newView({center:[116.403218,......
  • openlayers2
    参考:https://openlayers.org/two/支持说明:尽管Openlayers2继续工作并且仍在使用中,但开发工作集中在版本3上。建议OpenLayers用户升级到版本3。尽管偶尔会继续对存储库进行提交,但不再有定期发布。建议那些想要版本2的最新代码的人下载存储库中的master分支并使用它。即使不再有......
  • 关于Pyinstaller在打包Streamlit程序时遇到的IndexError:tuple index out of range
    如题,在使用Pyinstaller库打包过程中,如果遇到IndexError:tupleindexoutofrange,不必惊慌,本质上是库函数在传参过程中出现异常下面是解决方案:找到..\envs\steamlit\lib\dis.py这个文件。如果你是用的虚拟环境,比如conda,那这个文件位于anaconda的安装目录"E:\SOFTWARE\ANAC......
  • nn.Transformer Layers
    nn.TransformerEncoderLayerhttps://pytorch.org/docs/stable/generated/torch.nn.TransformerEncoder.html#torch.nn.TransformerEncoder 当使用这个层时,需要提供特定的输入数据。这些输入主要包括输入序列(src):这是主要的输入数据,通常是一个张量,其形状为 (S,N,E):S ......
  • @Indexed
    假设你有一个服务类,你希望Spring在启动时能够快速地识别并注册它:importorg.springframework.stereotype.Indexed;importorg.springframework.stereotype.Service;@Indexed@ServicepublicclassMyService{   //类的实现}在这个例子中,@Service注解标记这个类为一个服务组......
  • Kibana8.0怎么添加索引index至discover
    ELK7版本索引输入至elasticsearch后使用CreateIndexpattern添加索引至Kibana在ELK8版本添加方式有所不同左侧菜单选择Management选择Kibana-DataViews创建dataview查看Discover选择刚刚设置的索引名即可......
  • vue使用超图openlayers调用mapv实现蜂窝图
    在用超图openlayer开发的时候遇到问题,在此作为记录。文字描述不对的地方请多担待, 下载依赖,npmimapv 按需引入,因为官网例子是普通的html引入,{mapv}引入方式调用的是超图@supermap中的方法。DataSet是mapv的方法 import{Mapv} from'@supermap/iclient-ol/overla......