thunlp / OpenPrompt

An Open-Source Framework for Prompt-Learning.
https://thunlp.github.io/OpenPrompt/
Apache License 2.0
4.37k stars 455 forks source link

list index out of range in OpenPrompt/tutorial/1.2_soft_verbalizers.py #276

Open MrZmj77 opened 1 year ago

MrZmj77 commented 1 year ago

IndexError Traceback (most recent call last) Cell In[1], line 42 36 import torch 38 # for example the verbalizer contains multiple label words in each class 39 # myverbalizer = SoftVerbalizer(tokenizer, plm, num_classes=4, 40 # label_words=["politics", "sports", "business", "technology"]) 41 # or without label words ---> 42 myverbalizer = SoftVerbalizer(tokenizer, plm, num_classes=4) 45 from openprompt import PromptForClassification 47 use_cuda = True

File ~/miniconda3/envs/pytorch/lib/python3.8/site-packages/openprompt-1.0.1-py3.8.egg/openprompt/prompts/soft_verbalizer.py:55, in SoftVerbalizer.init(self, tokenizer, model, classes, num_classes, label_words, prefix, multi_token_handler) 53 last_layer_full_name = [] 54 for i in range(max_loop): ---> 55 last_layer_name = [n for n,c in module.named_children()][-1] 56 last_layer_full_name.append(last_layer_name) 57 parent_module = module

IndexError: list index out of range