NetEase-FuXi / EET

Easy and Efficient Transformer : Scalable Inference Solution For Large NLP model
Apache License 2.0
261 stars 46 forks source link

gpt2 generation example bug #5

Closed C00reNUT closed 2 years ago

C00reNUT commented 2 years ago

Hello,

when running

python example/python/models/gpt2_transformers_example.py

I get the

  File "/mnt/2287294e-32c7-437b-84bd-452a29548b1a/conda_env/EET/lib/python3.8/site-packages/eet/pipelines/generation.py", line 12, in <module>
    from transformers.generation_beam_constraints import Constraint, DisjunctiveConstraint, PhrasalConstraint
ModuleNotFoundError: No module named 'transformers.generation_beam_constraints'

There is probably wrong import statement, I will try to look into it

dingjingzhen commented 2 years ago

If you are running gpt2_transformers_example.py, there should be no pipelines, can you give more information? And if you have a special or urgent need, you can communicate with me more quickly via email,dingjingzhen@corp.netease.com

C00reNUT commented 2 years ago

The following error also happens when I run, provided example

import torch
from eet import pipeline
us_fairseq_model = True
us_thansformers_model = True

if us_fairseq_model:
    # 参考Readme,首先需要生成vocab.txt和config.json文件,并且你的pt文件名必须是checkpoint_best.pt,这个将会在后续版本做优化
    nlp = pipeline("text-generation",model = '../resource', data_type = torch.float16)
    out = nlp(["我 叫 小 天 ,这 是","这 里 是 中 国 ,不 是"])
    print(out)

if us_thansformers_model:
    nlp = pipeline("text-generation", data_type = torch.float16)
    out = nlp("My name is")
    print(out)
ModuleNotFoundError                       Traceback (most recent call last)
Input In [3], in <cell line: 2>()
      1 import torch
----> 2 from eet import pipeline
      3 us_fairseq_model = True
      4 us_thansformers_model = True

File /mnt/2287294e-32c7-437b-84bd-452a29548b1a/conda_env/EET/lib/python3.8/site-packages/eet/__init__.py:1, in <module>
----> 1 from .fairseq import *
      2 from .transformers import *
      3 from .utils import *

File /mnt/2287294e-32c7-437b-84bd-452a29548b1a/conda_env/EET/lib/python3.8/site-packages/eet/fairseq/__init__.py:1, in <module>
----> 1 from .transformer import *
      2 from .config import *

File /mnt/2287294e-32c7-437b-84bd-452a29548b1a/conda_env/EET/lib/python3.8/site-packages/eet/fairseq/transformer.py:21, in <module>
     18 from fairseq import utils
     19 from fairseq.data.dictionary import Dictionary
---> 21 from ..pipelines.generation import GenerationMixin_EET
     22 from transformers.file_utils import ModelOutput
     23 from transformers import GPT2Config

File /mnt/2287294e-32c7-437b-84bd-452a29548b1a/conda_env/EET/lib/python3.8/site-packages/eet/pipelines/generation.py:12, in <module>
     10 from typing import Any, Callable, Dict, Iterable, List, Optional, Tuple, Union
     11 from transformers.generation_utils import GenerationMixin
---> 12 from transformers.generation_beam_constraints import Constraint, DisjunctiveConstraint, PhrasalConstraint
     13 from transformers.generation_beam_search import BeamScorer, BeamSearchScorer, ConstrainedBeamSearchScorer
     14 from transformers.generation_logits_process import (
     15     LogitsProcessorList,
     16     MinLengthLogitsProcessor,
     17     TemperatureLogitsWarper,
     18     TopKLogitsWarper,
     19 )

ModuleNotFoundError: No module named 'transformers.generation_beam_constraints'

My conda env setup

# packages in environment at /mnt/2287294e-32c7-437b-84bd-452a29548b1a/conda_env/EET:
#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                 conda_forge    conda-forge
_openmp_mutex             4.5                  2_kmp_llvm    conda-forge
antlr-python-runtime      4.8                pyhd8ed1ab_3    conda-forge
anyio                     3.5.0            py38h578d9bd_0    conda-forge
argon2-cffi               21.3.0             pyhd8ed1ab_0    conda-forge
argon2-cffi-bindings      21.2.0           py38h0a891b7_2    conda-forge
asttokens                 2.0.5              pyhd8ed1ab_0    conda-forge
attrs                     21.4.0             pyhd8ed1ab_0    conda-forge
babel                     2.9.1              pyh44b312d_0    conda-forge
backcall                  0.2.0              pyh9f0ad1d_0    conda-forge
backports                 1.0                        py_2    conda-forge
backports.functools_lru_cache 1.6.4              pyhd8ed1ab_0    conda-forge
beautifulsoup4            4.11.1             pyha770c72_0    conda-forge
binutils_impl_linux-64    2.36.1               h193b22a_2    conda-forge
binutils_linux-64         2.36                 hf3e587d_9    conda-forge
blas                      2.114                       mkl    conda-forge
blas-devel                3.9.0            14_linux64_mkl    conda-forge
bleach                    5.0.0              pyhd8ed1ab_0    conda-forge
brotlipy                  0.7.0           py38h0a891b7_1004    conda-forge
bzip2                     1.0.8                h7f98852_4    conda-forge
ca-certificates           2021.10.8            ha878542_0    conda-forge
certifi                   2021.10.8        py38h578d9bd_2    conda-forge
cffi                      1.15.0           py38h3931269_0    conda-forge
charset-normalizer        2.0.12             pyhd8ed1ab_0    conda-forge
click                     8.1.2            py38h578d9bd_0    conda-forge
cloudpickle               2.0.0              pyhd8ed1ab_0    conda-forge
colorama                  0.4.4              pyh9f0ad1d_0    conda-forge
cryptography              36.0.2           py38h2b5fc30_1    conda-forge
cudatoolkit               11.3.1               ha36c431_9    nvidia
cython                    0.29.28          py38hfa26641_2    conda-forge
dataclasses               0.8                pyhc8e2a94_3    conda-forge
debugpy                   1.6.0            py38hfa26641_0    conda-forge
decorator                 5.1.1              pyhd8ed1ab_0    conda-forge
defusedxml                0.7.1              pyhd8ed1ab_0    conda-forge
dlib                      19.23.1          py38he2161a6_0    conda-forge
eet                       1.0                      pypi_0    pypi
entrypoints               0.4                pyhd8ed1ab_0    conda-forge
executing                 0.8.3              pyhd8ed1ab_0    conda-forge
fairseq                   0.10.2           py38h51da96c_0    conda-forge
filelock                  3.6.0              pyhd8ed1ab_0    conda-forge
flit-core                 3.7.1              pyhd8ed1ab_0    conda-forge
gcc_impl_linux-64         11.2.0              h82a94d6_16    conda-forge
gcc_linux-64              11.2.0               h39a9532_9    conda-forge
gettext                   0.19.8.1          h73d1719_1008    conda-forge
gxx_impl_linux-64         11.2.0              h82a94d6_16    conda-forge
gxx_linux-64              11.2.0               hacbe6df_9    conda-forge
huggingface_hub           0.5.1              pyhd8ed1ab_0    conda-forge
hydra-core                1.1.1              pyhd8ed1ab_0    conda-forge
idna                      3.3                pyhd8ed1ab_0    conda-forge
importlib-metadata        4.11.3           py38h578d9bd_1    conda-forge
importlib_metadata        4.11.3               hd8ed1ab_1    conda-forge
importlib_resources       5.7.1              pyhd8ed1ab_0    conda-forge
ipykernel                 6.13.0           py38h7f3c49e_0    conda-forge
ipython                   8.2.0            py38h578d9bd_0    conda-forge
ipython_genutils          0.2.0                      py_1    conda-forge
ipywidgets                7.7.0              pyhd8ed1ab_0    conda-forge
jedi                      0.18.1           py38h578d9bd_1    conda-forge
jinja2                    3.1.1              pyhd8ed1ab_0    conda-forge
joblib                    1.1.0              pyhd8ed1ab_0    conda-forge
jpeg                      9e                   h166bdaf_1    conda-forge
json5                     0.9.5              pyh9f0ad1d_0    conda-forge
jsonschema                4.4.0              pyhd8ed1ab_0    conda-forge
jupyter_client            7.2.2              pyhd8ed1ab_1    conda-forge
jupyter_core              4.9.2            py38h578d9bd_0    conda-forge
jupyter_server            1.16.0             pyhd8ed1ab_1    conda-forge
jupyterlab                3.3.4              pyhd8ed1ab_0    conda-forge
jupyterlab_pygments       0.2.2              pyhd8ed1ab_0    conda-forge
jupyterlab_server         2.13.0             pyhd8ed1ab_1    conda-forge
jupyterlab_widgets        1.1.0              pyhd8ed1ab_0    conda-forge
kernel-headers_linux-64   2.6.32              he073ed8_15    conda-forge
ld_impl_linux-64          2.36.1               hea4e1c9_2    conda-forge
libblas                   3.9.0            14_linux64_mkl    conda-forge
libcblas                  3.9.0            14_linux64_mkl    conda-forge
libffi                    3.4.2                h7f98852_5    conda-forge
libgcc-devel_linux-64     11.2.0              h0952999_16    conda-forge
libgcc-ng                 11.2.0              h1d223b6_16    conda-forge
libgfortran-ng            11.2.0              h69a702a_16    conda-forge
libgfortran5              11.2.0              h5c6108e_16    conda-forge
libgomp                   11.2.0              h1d223b6_16    conda-forge
libidn2                   2.3.2                h7f98852_0    conda-forge
liblapack                 3.9.0            14_linux64_mkl    conda-forge
liblapacke                3.9.0            14_linux64_mkl    conda-forge
libnsl                    2.0.0                h7f98852_0    conda-forge
libpng                    1.6.37               h21135ba_2    conda-forge
libsanitizer              11.2.0              he4da1e4_16    conda-forge
libsodium                 1.0.18               h36c2ea0_1    conda-forge
libstdcxx-devel_linux-64  11.2.0              h0952999_16    conda-forge
libstdcxx-ng              11.2.0              he4da1e4_16    conda-forge
libunistring              0.9.10               h7f98852_0    conda-forge
libuuid                   2.32.1            h7f98852_1000    conda-forge
libuv                     1.43.0               h7f98852_0    conda-forge
libzlib                   1.2.11            h166bdaf_1014    conda-forge
llvm-openmp               13.0.1               he0ac6c6_1    conda-forge
markupsafe                2.1.1            py38h0a891b7_1    conda-forge
matplotlib-inline         0.1.3              pyhd8ed1ab_0    conda-forge
mistune                   0.8.4           py38h497a2fe_1005    conda-forge
mkl                       2022.0.1           h8d4b97c_803    conda-forge
mkl-devel                 2022.0.1           ha770c72_804    conda-forge
mkl-include               2022.0.1           h8d4b97c_803    conda-forge
nbclassic                 0.3.7              pyhd8ed1ab_0    conda-forge
nbclient                  0.6.0              pyhd8ed1ab_0    conda-forge
nbconvert                 6.5.0              pyhd8ed1ab_0    conda-forge
nbconvert-core            6.5.0              pyhd8ed1ab_0    conda-forge
nbconvert-pandoc          6.5.0              pyhd8ed1ab_0    conda-forge
nbformat                  5.3.0              pyhd8ed1ab_0    conda-forge
ncurses                   6.3                  h27087fc_1    conda-forge
nest-asyncio              1.5.5              pyhd8ed1ab_0    conda-forge
notebook                  6.4.11             pyha770c72_0    conda-forge
notebook-shim             0.1.0              pyhd8ed1ab_0    conda-forge
numpy                     1.22.3           py38h1d589f8_2    conda-forge
omegaconf                 2.1.1            py38h578d9bd_1    conda-forge
openssl                   1.1.1n               h166bdaf_0    conda-forge
packaging                 21.3               pyhd8ed1ab_0    conda-forge
pandoc                    2.18                 ha770c72_0    conda-forge
pandocfilters             1.5.0              pyhd8ed1ab_0    conda-forge
parso                     0.8.3              pyhd8ed1ab_0    conda-forge
pexpect                   4.8.0              pyh9f0ad1d_2    conda-forge
pickleshare               0.7.5                   py_1003    conda-forge
pillow                    9.1.0                    pypi_0    pypi
pip                       22.0.4             pyhd8ed1ab_0    conda-forge
portalocker               2.4.0            py38h578d9bd_0    conda-forge
prometheus_client         0.14.1             pyhd8ed1ab_0    conda-forge
prompt-toolkit            3.0.29             pyha770c72_0    conda-forge
psutil                    5.9.0            py38h0a891b7_1    conda-forge
ptyprocess                0.7.0              pyhd3deb0d_0    conda-forge
pure_eval                 0.2.2              pyhd8ed1ab_0    conda-forge
pycparser                 2.21               pyhd8ed1ab_0    conda-forge
pygments                  2.11.2             pyhd8ed1ab_0    conda-forge
pyopenssl                 22.0.0             pyhd8ed1ab_0    conda-forge
pyparsing                 3.0.8              pyhd8ed1ab_0    conda-forge
pyrsistent                0.18.1           py38h0a891b7_1    conda-forge
pysocks                   1.7.1            py38h578d9bd_5    conda-forge
python                    3.8.13          h582c2e5_0_cpython    conda-forge
python-dateutil           2.8.2              pyhd8ed1ab_0    conda-forge
python-fastjsonschema     2.15.3             pyhd8ed1ab_0    conda-forge
python_abi                3.8                      2_cp38    conda-forge
pytorch                   1.11.0          py3.8_cuda11.3_cudnn8.2.0_0    pytorch
pytorch-mutex             1.0                        cuda    pytorch
pytz                      2022.1             pyhd8ed1ab_0    conda-forge
pyyaml                    6.0              py38h0a891b7_4    conda-forge
pyzmq                     22.3.0           py38hfc09fa9_2    conda-forge
readline                  8.1                  h46c0cb4_0    conda-forge
regex                     2022.3.15        py38h0a891b7_1    conda-forge
requests                  2.27.1             pyhd8ed1ab_0    conda-forge
sacrebleu                 2.0.0              pyhd8ed1ab_0    conda-forge
sacremoses                0.0.49             pyhd8ed1ab_0    conda-forge
send2trash                1.8.0              pyhd8ed1ab_0    conda-forge
setuptools                62.1.0           py38h578d9bd_0    conda-forge
six                       1.16.0             pyh6c4a22f_0    conda-forge
sniffio                   1.2.0            py38h578d9bd_3    conda-forge
soupsieve                 2.3.1              pyhd8ed1ab_0    conda-forge
sqlite                    3.38.2               h4ff8645_0    conda-forge
stack_data                0.2.0              pyhd8ed1ab_0    conda-forge
sysroot_linux-64          2.12                he073ed8_15    conda-forge
tabulate                  0.8.9              pyhd8ed1ab_0    conda-forge
tbb                       2021.5.0             h924138e_1    conda-forge
terminado                 0.13.3           py38h578d9bd_1    conda-forge
tinycss2                  1.1.1              pyhd8ed1ab_0    conda-forge
tk                        8.6.12               h27826a3_0    conda-forge
tokenizers                0.10.3           py38hb63a372_1    conda-forge
tornado                   6.1              py38h0a891b7_3    conda-forge
tqdm                      4.64.0             pyhd8ed1ab_0    conda-forge
traitlets                 5.1.1              pyhd8ed1ab_0    conda-forge
transformers              4.16.2             pyhd8ed1ab_0    conda-forge
typing                    3.10.0.0           pyhd8ed1ab_0    conda-forge
typing-extensions         4.2.0                hd8ed1ab_1    conda-forge
typing_extensions         4.2.0              pyha770c72_1    conda-forge
urllib3                   1.26.9             pyhd8ed1ab_0    conda-forge
wcwidth                   0.2.5              pyh9f0ad1d_2    conda-forge
webencodings              0.5.1                      py_1    conda-forge
websocket-client          1.3.2              pyhd8ed1ab_0    conda-forge
wget                      1.20.3               ha56f1ee_1    conda-forge
wheel                     0.37.1             pyhd8ed1ab_0    conda-forge
widgetsnbextension        3.6.0            py38h578d9bd_0    conda-forge
xz                        5.2.5                h516909a_1    conda-forge
yaml                      0.2.5                h7f98852_2    conda-forge
zeromq                    4.3.4                h9c3ff4c_1    conda-forge
zipp                      3.8.0              pyhd8ed1ab_0    conda-forge
zlib                      1.2.11            h166bdaf_1014    conda-forge
C00reNUT commented 2 years ago

There was problem with transformers version lower than 4.18.0 which was installed default by conda when making dependency check. It works fine with transformer=4.18.0

Husamx commented 1 year ago

This issue exists with transformers=4.25.1. I had to downgrade to 4.18.0