keras-team / keras-io

Keras documentation, hosted live at keras.io
Apache License 2.0
2.75k stars 2.03k forks source link

GPT text generation with KerasNLP Example error #1031

Closed ygModesto closed 1 month ago

ygModesto commented 2 years ago

Hello, in the GPT text generation example with KerasNLP (https://keras.io/examples/nlp/text_generation_gpt/) when executing the code associated with # Train tokenizer vocabulary the following error is thrown: AttributeError: module 'keras_nlp.tokenizers' has no attribute 'compute_word_piece_vocabulary'

I have tried with several versions of keras-nlp but I have not fixed the error.

aflah02 commented 2 years ago

@ygModesto Actually the error is caused because the latest release of KerasNLP doesn't yet have the compute_word_piece_vocabulary function. If you want to run it you can install KerasNLP from github directly using this syntax - pip install git+https://github.com/user/repo.git@branch

aflah02 commented 2 years ago

@Alpes-ai Hey that was just a placeholder should've been more clearer :( Instead of that link use the link from the KerasNLP repository with the master branch, hope that sorts it!

Simon-PSR commented 2 years ago

Same here am getting the error when I pip install []pip install git+https://github.com/user/repo.git@branch) fatal: could not read Username for 'https://github.com/': No such device or address

NareshSandrugu commented 2 years ago

yeah, now the model is loaded, thanks for your support.

NareshSandrugu commented 2 years ago

use this command its working: pip install git+https://github.com/keras-team/keras-nlp.git

Simon-PSR commented 2 years ago

Hi, also I tried installing using [,](pip install git+https://github.com/keras-team/keras-nlp.git), but I still get the same error. is there a workaround or a solution? the error is like: AttributeError: module 'keras_nlp.tokenizers' has no attribute 'compute_word_piece_vocabulary'

Simon-PSR commented 2 years ago

Thanks

Hi, tried installing using [,](pip install git+ https://github.com/keras-team/keras-nlp.git), but I still get the same error. when training the tokenizer, is there a workaround or a solution? the error is like: AttributeError: module 'keras_nlp.tokenizers' has no attribute 'compute_word_piece_vocabulary'

regards

On Sat, Aug 27, 2022 at 7:51 AM Naresh Sandrugu @.***> wrote:

use this command its working: pip install git+ https://github.com/keras-team/keras-nlp.git

— Reply to this email directly, view it on GitHub https://github.com/keras-team/keras-io/issues/1031#issuecomment-1229129929, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKDRARVRNRXLCDQ7UJHWBPTV3GUELANCNFSM56UYI4GQ . You are receiving this because you commented.Message ID: @.***>

--

--

DISCLAIMER This message and any attachments are confidential and intended solely for the addressee. The following link will display the full disclaimer: http://www.ul.ac.za/disclaimer.jpg http://www.ul.ac.za/disclaimer.jpg 

--

https://www.ul.ac.za/index.php?Entity=c_events&TheS=970#start https://www.ul.ac.za/index.php?Entity=c_events&TheS=970#start

Simon-PSR commented 2 years ago

Thanks, It worked after importing 'compute_word_piece_vocabulary' 👍 [from keras_nlp.tokenizers.word_piece_tokenizer_trainer import ( compute_word_piece_vocabulary,].

But now it complains when executing #StartEndPacker [ TypeError: Exception encountered when calling layer "start_end_packer_1" (type StartEndPacker).

in user code:

    File "/usr/local/lib/python3.7/dist-packages/keras_nlp/layers/start_end_packer.py", line 123, in call  *
        batch_size = tf.shape(inputs)[0]](url)

Please help.

Simon-PSR commented 2 years ago

Exactly the same problem I have Naresh, any help, please🤔

On Sat, Aug 27, 2022 at 1:48 PM Naresh Sandrugu @.***> wrote:

am sturck at this point with error any one can help, for reference purpose screen shot below [image: image] https://user-images.githubusercontent.com/59958507/187028860-711c901e-81af-492e-ae4a-9c5f57ac8486.png

— Reply to this email directly, view it on GitHub https://github.com/keras-team/keras-io/issues/1031#issuecomment-1229177581, or unsubscribe https://github.com/notifications/unsubscribe-auth/AKDRARR7VBH53ZWQUEQO3I3V3H6BPANCNFSM56UYI4GQ . You are receiving this because you commented.Message ID: @.***>

--

--

DISCLAIMER This message and any attachments are confidential and intended solely for the addressee. The following link will display the full disclaimer: http://www.ul.ac.za/disclaimer.jpg http://www.ul.ac.za/disclaimer.jpg 

--

https://www.ul.ac.za/index.php?Entity=c_events&TheS=970#start https://www.ul.ac.za/index.php?Entity=c_events&TheS=970#start

NareshSandrugu commented 2 years ago

yeah, also facing the same issue with start_end_packer function, even i tried with simple examples from keras link like: https://keras.io/api/keras_nlp/layers/start_end_packer/

the below are error,any one can help this image

abheesht17 commented 2 years ago

@ygModesto, @Simon-PSR, @NareshSandrugu, linking a comment here, which will solve your issue: https://github.com/keras-team/keras-nlp/issues/301#issuecomment-1221337946. Hope this works! Colab has an older version of TensorFlow pre-installed...so, it has to be uninstalled first.

NareshSandrugu commented 2 years ago

Thanks Abheesht, start_end_packer issue resolved.

jbischof commented 1 year ago

@fchollet we an close this issue

sachinprasadhs commented 2 months ago

The example has been updated to work with Keras 3 and it is working well, please find the example link here for the code and details https://keras.io/examples/generative/text_generation_gpt/

github-actions[bot] commented 2 months ago

This issue is stale because it has been open for 14 days with no activity. It will be closed if no further activity occurs. Thank you.

github-actions[bot] commented 1 month ago

This issue was closed because it has been inactive for 28 days. Please reopen if you'd like to work on this further.

github-actions[bot] commented 1 month ago

Are you satisfied with the resolution of your issue? Yes No