Giter VIP home page Giter VIP logo

Comments (3)

Aml-Hassan-Abd-El-hamid avatar Aml-Hassan-Abd-El-hamid commented on June 2, 2024

I tried to pass preds[0] to the tokenizer instead of just preds: decoded_preds = tokenizer.batch_decode(preds[0], skip_special_tokens=True)
But I got the following error: TypeError: argument 'ids': 'float' object cannot be interpreted as an integer

from transformers.

Aml-Hassan-Abd-El-hamid avatar Aml-Hassan-Abd-El-hamid commented on June 2, 2024

I tried to turn the floats into integers so it became: decoded_preds = tokenizer.batch_decode(preds[0].astype('int32'), skip_special_tokens=True) but I got the following error:

File "/home/ubuntu/Aml/utils.py", line 82, in compute_metrics
    decoded_preds = tokenizer.batch_decode(preds[0].astype('int32'), skip_special_tokens=True)
  File "/home/ubuntu/Aml/venv/lib/python3.10/site-packages/transformers/tokenization_utils_base.py", line 3771, in batch_decode
    return [
  File "/home/ubuntu/Aml/venv/lib/python3.10/site-packages/transformers/tokenization_utils_base.py", line 3772, in <listcomp>
    self.decode(
  File "/home/ubuntu/Aml/venv/lib/python3.10/site-packages/transformers/tokenization_utils_base.py", line 3811, in decode
    return self._decode(
  File "/home/ubuntu/Aml/venv/lib/python3.10/site-packages/transformers/tokenization_utils_fast.py", line 625, in _decode
    text = self._tokenizer.decode(token_ids, skip_special_tokens=skip_special_tokens)
OverflowError: out of range integral type conversion attempted

from transformers.

ArthurZucker avatar ArthurZucker commented on June 2, 2024

Hey! Would recommend you to ask on the forum as you are using custom code.
However note that printing / debugging to get what you pass the tokenizer is usually a good practice. The decode function expects ints, and ints that are not too big. OverflowError: out of range integral type conversion attempted means you gave it a HUGE integer! 🤗

from transformers.

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.