Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
fengmingfeng opened this issue Jul 28, 2024 · 6 comments
Open

Comments

@fengmingfeng
Copy link

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
Copy link

老哥,请问你解决了吗?

@dragon1god
Copy link

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

@syuan-Boom
Copy link

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

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

@hiyamgh
Copy link

hiyamgh commented Sep 22, 2024

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
Copy link

hiyamgh commented Sep 22, 2024

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

This made it, thank you!

@syuan-Boom
Copy link

syuan-Boom commented Sep 23, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants