microsoft / nlp-recipes

Natural Language Processing Best Practices & Examples
MIT License
6.35k stars 915 forks source link

[ASK] transformers.abstractive_summarization_bertsum.py not importing transformers #625

Open neqkir opened 2 years ago

neqkir commented 2 years ago

Description

I run in Google Colab the following code

!pip install --upgrade 
!pip install -q git+https://github.com/microsoft/nlp-recipes.git
!pip install jsonlines
!pip install pyrouge
!pip install scrapbook

import os
import shutil
import sys
from tempfile import TemporaryDirectory
import torch
import nltk
from nltk import tokenize
import pandas as pd
import pprint
import scrapbook as sb

nlp_path = os.path.abspath("../../")
if nlp_path not in sys.path:
    sys.path.insert(0, nlp_path)

from utils_nlp import models
from utils_nlp.models import transformers 
from utils_nlp.models.transformers.abstractive_summarization_bertsum \
     import BertSumAbs, BertSumAbsProcessor

It breaks on the last line and I get the following error

/usr/local/lib/python3.7/dist-packages/utils_nlp/models/transformers/abstractive_summarization_bertsum.py in <module>()
     15 from torch.utils.data.distributed import DistributedSampler
     16 from tqdm import tqdm
---> 17 from transformers import AutoTokenizer, BertModel
     18 
     19 from utils_nlp.common.pytorch_utils import (

ModuleNotFoundError: No module named 'transformers'

In summary, the code in abstractive_summarization_bertsum.py doesn't resolve transformers where it is located in the transformer folder. Is it something to be fixed on your side?

gbot300 commented 2 years ago

I am getting the same issue after doing a pip install of the repo into google colab. It breaks on exactly the same place, also unable to find transfomers