Git Product home page Git Product logo

Comments (9)

SumitDasTR avatar SumitDasTR commented on August 29, 2024 4

tried the above options both in colab and local jupyter notebook. But giving the same error:

TypeError: argument of type 'NoneType' is not iterable

``
! pip install ecco

! pip uninstall numpy -y
! pip install numpy==1.21.5

import ecco

lm = ecco.from_pretrained('t5-small')
review="""Denis Villeneuve's Dune looks and sounds amazing -- and once the
(admittedly slow-building) story gets you hooked, you'll be on the edge
of your seat for the sequel."""

output = lm.generate(f"sst2 sentence: {review}", generate=1, do_sample=False)
``

TypeError Traceback (most recent call last)
/tmp/ipykernel_912/1601604474.py in
6 of your seat for the sequel."""
7
----> 8 output = lm.generate(f"sst2 sentence: {review}", generate=1, do_sample=False)

~/miniconda3/envs/py3.8/lib/python3.8/site-packages/ecco/lm.py in generate(self, input_str, max_length, temperature, top_k, top_p, do_sample, attribution, generate, beam_size, **generate_kwargs)
202 assert len(input_ids.size()) == 2 # will break otherwise
203 if version.parse(transformers.version) >= version.parse('4.13'):
--> 204 decoder_input_ids = self.model._prepare_decoder_input_ids_for_generation(input_ids.shape[0], None, None)
205 else:
206 decoder_input_ids = self.model._prepare_decoder_input_ids_for_generation(input_ids, None, None)

~/miniconda3/envs/py3.8/lib/python3.8/site-packages/transformers/generation/utils.py in _prepare_decoder_input_ids_for_generation(self, batch_size, model_input_name, model_kwargs, decoder_start_token_id, bos_token_id, device)
654 if model_kwargs is not None and "decoder_input_ids" in model_kwargs:
655 decoder_input_ids = model_kwargs.pop("decoder_input_ids")
--> 656 elif "input_ids" in model_kwargs and model_input_name != "input_ids":
657 decoder_input_ids = model_kwargs.pop("input_ids")
658 else:

TypeError: argument of type 'NoneType' is not iterable

from ecco.

BiEchi avatar BiEchi commented on August 29, 2024 2

Just fixed the issue. Downgrading your transformers to 4.13.0 solves the problem. This is due to an API update from transformers update.

@SumitDasTR @Peter-Zhoutuanjie
cc @jalammar

from ecco.

SumitDasTR avatar SumitDasTR commented on August 29, 2024

I updated numpy using the command
pip install -U numpy

Then tried to run the notebook cell

import ecco

lm = ecco.from_pretrained('t5-small')
review="""Denis Villeneuve's Dune looks and sounds amazing -- and once the
(admittedly slow-building) story gets you hooked, you'll be on the edge
of your seat for the sequel."""

output = lm.generate(f"sst2 sentence: {review}", generate=1, do_sample=False)

But its giving the following error

TypeError Traceback (most recent call last)
in <cell line: 8>()
6 of your seat for the sequel."""
7
----> 8 output = lm.generate(f"sst2 sentence: {review}", generate=1, do_sample=False)

1 frames
/usr/local/lib/python3.10/dist-packages/transformers/generation/utils.py in _prepare_decoder_input_ids_for_generation(self, batch_size, model_input_name, model_kwargs, decoder_start_token_id, bos_token_id, device)
654 if model_kwargs is not None and "decoder_input_ids" in model_kwargs:
655 decoder_input_ids = model_kwargs.pop("decoder_input_ids")
--> 656 elif "input_ids" in model_kwargs and model_input_name != "input_ids":
657 decoder_input_ids = model_kwargs.pop("input_ids")
658 else:

TypeError: argument of type 'NoneType' is not iterable

from ecco.

neelgandhi108 avatar neelgandhi108 commented on August 29, 2024

Fixed
!pip uninstall numpy -y
!pip install numpy==1.21.5

from ecco.

LAKan233 avatar LAKan233 commented on August 29, 2024

I solved this problem by

pip install -U numpy

and the , the most important thing, you must restart your notebook kernel

from ecco.

Peter-Zhoutuanjie avatar Peter-Zhoutuanjie commented on August 29, 2024

SumitDasTR

Same

from ecco.

BiEchi avatar BiEchi commented on August 29, 2024

Yeah the pip install numpy==1.21.5 solution does not work for me either. Has anyone solved this problem?

lm = ecco.from_pretrained('valhalla/t5-small-qa-qg-hl')#, gpu=False)
output = lm.generate(text, generate=20, do_sample=True, attribution=['ig', 'grad_x_input'])

gives

---> 14 output = lm.generate(text, generate=20, do_sample=True, attribution=['ig', 'grad_x_input'])
     16 output.primary_attributions(attr_method='ig')

File [/opt/conda/envs/ecco/lib/python3.9/site-packages/ecco/lm.py:204](https://vscode-remote+ssh-002dremote-002bec2-002d34-002d204-002d44-002d163-002ecompute-002d1-002eamazonaws-002ecom.vscode-resource.vscode-cdn.net/opt/conda/envs/ecco/lib/python3.9/site-packages/ecco/lm.py:204), in LM.generate(self, input_str, max_length, temperature, top_k, top_p, do_sample, attribution, generate, beam_size, **generate_kwargs)
    202 assert len(input_ids.size()) == 2 # will break otherwise
    203 if version.parse(transformers.__version__) >= version.parse('4.13'):
--> 204     decoder_input_ids = self.model._prepare_decoder_input_ids_for_generation(input_ids.shape[0], None, None)
    205 else:
    206     decoder_input_ids = self.model._prepare_decoder_input_ids_for_generation(input_ids, None, None)

File [/opt/conda/envs/ecco/lib/python3.9/site-packages/transformers/generation/utils.py:662](https://vscode-remote+ssh-002dremote-002bec2-002d34-002d204-002d44-002d163-002ecompute-002d1-002eamazonaws-002ecom.vscode-resource.vscode-cdn.net/opt/conda/envs/ecco/lib/python3.9/site-packages/transformers/generation/utils.py:662), in GenerationMixin._prepare_decoder_input_ids_for_generation(self, batch_size, model_input_name, model_kwargs, decoder_start_token_id, bos_token_id, device)
    660 if model_kwargs is not None and "decoder_input_ids" in model_kwargs:
    661     decoder_input_ids = model_kwargs.pop("decoder_input_ids")
--> 662 elif "input_ids" in model_kwargs and model_input_name != "input_ids":
    663     decoder_input_ids = model_kwargs.pop("input_ids")
    664 else:

TypeError: argument of type 'NoneType' is not iterable

from ecco.

BiEchi avatar BiEchi commented on August 29, 2024

Note that this solution is a quick fix. If you want to use models like OPT, LLAMA, etc., you still need to fix the code from source to make it work.

from ecco.

martin12333 avatar martin12333 commented on August 29, 2024

Maybe another solution is:
Weeks ago, I made the ecco *.ipynb mostly work in Python 3.10, with transformers 4.29.2

Locally. In a conda env with many other programs.
I dimly remember having problems with version numbers of dependencies. I had to edit the req file(s) of ecco: as a false-beginner, I edited both setup.py, and requirements.txt

My notes are at
https://github.com/martin12333/marti-onedrive/blob/main2/AI/pip----31pip310ecco.e.f8.sh

My files setup.py, and requirements.txt are at
https://github.com/martin12333/marti-onedrive/tree/main2/AI/Jalammar


EDIT: additional info is at #102 (comment)

from ecco.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.