thunlp / OpenPrompt

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

ModuleNotFoundError: No module named 'transformers.generation_utils' #316

Open fengmingfeng opened 3 months ago

fengmingfeng commented 3 months ago

Code: import numpy as np from sklearn.model_selection import KFold

import tensorflow as tf

from sklearn import metrics from sklearn.metrics import accuracy_score from sklearn.metrics import f1_score from sklearn.metrics import precision_score from sklearn.metrics import recall_score

from torch.utils.data import Dataset, DataLoader,SubsetRandomSampler from sklearn.metrics import precision_recall_fscore_support from transformers import AdamW, get_linear_schedule_with_warmup from openprompt import PromptDataLoader from torch import nn import os

error: ModuleNotFoundError Traceback (most recent call last) Cell In[10], line 14 12 from sklearn.metrics import precision_recall_fscore_support 13 from transformers import AdamW, get_linear_schedule_with_warmup ---> 14 from openprompt import PromptDataLoader 15 from torch import nn 16 import os

File ~/miniconda3/lib/python3.8/site-packages/openprompt/init.py:2 1 version = "1.0.1" ----> 2 from .pipeline_base import PromptDataLoader, PromptModel, PromptForClassification, PromptForGeneration 3 from .utils import * 4 from .prompt_base import Template, Verbalizer

File ~/miniconda3/lib/python3.8/site-packages/openprompt/pipeline_base.py:4 2 from torch.utils.data.sampler import RandomSampler 3 from transformers.configuration_utils import PretrainedConfig ----> 4 from transformers.generation_utils import GenerationMixin 5 import torch 6 import torch.nn as nn

ModuleNotFoundError: No module named 'transformers.generation_utils'

dragon1god commented 2 months ago

老哥,请问你解决了吗?

dragon1god commented 2 months ago

已解决,我本来安装的是transformers=4.41.2版本,将其版本改为4.27.1版本即可

syuan-Boom commented 1 month ago

已解决,我本来安装的是transformers=4.41.2版本,将其版本改为4.27.1版本即可

谢谢!同样的问题解决了!

hiyamgh commented 1 month ago

Hello, I am facing the same issue. Is it resolved or did anyone find a solution? I tried with Python 3.10 and 3.9 and it still persists...

hiyamgh commented 1 month ago

已解决,我本来安装的是transformers=4.41.2版本,将其版本改为4.27.1版本即可

This made it, thank you!

syuan-Boom commented 1 month ago

Good luck! From: "Hiyam @.> Date: Sun, Sep 22, 2024, 23:13 Subject: [External] Re: [thunlp/OpenPrompt] ModuleNotFoundError: No module named 'transformers.generation_utils' (Issue #316) To: @.> Cc: @.>, "Comment"< @.>

已解决,我本来安装的是transformers=4.41.2版本,将其版本改为4.27.1版本即可

This made it, thank you!

— Reply to this email directly, view it on GitHub https://github.com/thunlp/OpenPrompt/issues/316#issuecomment-2366831249, or unsubscribe https://github.com/notifications/unsubscribe-auth/BKQ3K2OKPQNKARCS3ZOPJDTZX3NBBAVCNFSM6AAAAABLSNOYFSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNRWHAZTCMRUHE . You are receiving this because you commented.Message ID: @.***>