Skip to content

Codewithkyrian\Transformers\Models\Pretrained\PretrainedModel::__construct(): Argument #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 of 4 tasks
takielias opened this issue May 20, 2024 · 3 comments · Fixed by #39
Closed
1 of 4 tasks
Assignees
Labels
bug Something isn't working

Comments

@takielias
Copy link
Contributor

System Info

Im using wsl2 and ddev

PHP 8.3 & Laravel 11 with FFI support => enabled

taki@built-in-ai-web:/var/www/html$ php -v
PHP 8.3.7 (cli) (built: May 13 2024 15:28:16) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.7, Copyright (c) Zend Technologies
    with Zend OPcache v8.3.7, Copyright (c), by Zend Technologies

PHP Version

8.3.7

Environment/Platform

  • Command-line application
  • Web application
  • Serverless
  • Other (please specify)

Description

when I execute the command below, I got the errors

./vendor/bin/transformers download Xenova/LaMini-Flan-T5-783M

taki@built-in-ai-web:/var/www/html$ ./vendor/bin/transformers download Xenova/LaMini-Flan-T5-783M
✔ Initializing download...
✔ Downloading tokenizer.json : [••••••••••••••••••••••••••••] 100%
✔ Downloading tokenizer_config.json : [••••••••••••••••••••••••••••] 100%
✔ Downloading config.json : [••••••••••••••••••••••••••••] 100%
✔ Downloading encoder_model_quantized.onnx : [••••••••••••••••••••••••••••] 100%
✔ Downloading decoder_model_merged_quantized.onnx : [••••••••••••••••••••••••••••] 100%
PHP Fatal error:  Uncaught TypeError: Codewithkyrian\Transformers\Models\Pretrained\PretrainedModel::__construct(): Argument #3 ($modelArchitecture) must be of type Codewithkyrian\
Transformers\Models\ModelArchitecture, Codewithkyrian\Transformers\OnnxRuntime\InferenceSession given, called in /var/www/html/vendor/codewithkyrian/transformers/src/Models/Pretrained/PretrainedModel.php on line 194 and defined in /var/www/html/vendor/codewithkyrian/transformers/src/Models/Pretrained/PretrainedModel.php:47
Stack trace:
#0 /var/www/html/vendor/codewithkyrian/transformers/src/Models/Pretrained/PretrainedModel.php(194): Codewithkyrian\Transformers\Models\Pretrained\PretrainedModel->__construct()    
#1 /var/www/html/vendor/codewithkyrian/transformers/src/Models/Auto/PretrainedMixin.php(62): Codewithkyrian\Transformers\Models\Pretrained\PretrainedModel::fromPretrained()        
#2 /var/www/html/vendor/codewithkyrian/transformers/src/Commands/DownloadModelCommand.php(89): Codewithkyrian\Transformers\Models\Auto\PretrainedMixin::fromPretrained()
#3 /var/www/html/vendor/symfony/console/Command/Command.php(279): Codewithkyrian\Transformers\Commands\DownloadModelCommand->execute()
#4 /var/www/html/vendor/symfony/console/Application.php(1031): Symfony\Component\Console\Command\Command->run()
#5 /var/www/html/vendor/symfony/console/Application.php(318): Symfony\Component\Console\Application->doRunCommand()
#6 /var/www/html/vendor/symfony/console/Application.php(169): Symfony\Component\Console\Application->doRun()
#7 /var/www/html/vendor/codewithkyrian/transformers/bin/transformers(18): Symfony\Component\Console\Application->run()
#8 /var/www/html/vendor/bin/transformers(119): include('...')
#9 {main}
  thrown in /var/www/html/vendor/codewithkyrian/transformers/src/Models/Pretrained/PretrainedModel.php on line 47

Fatal error: Uncaught TypeError: Codewithkyrian\Transformers\Models\Pretrained\PretrainedModel::__construct(): Argument #3 ($modelArchitecture) must be of type Codewithkyrian\Trans
formers\Models\ModelArchitecture, Codewithkyrian\Transformers\OnnxRuntime\InferenceSession given, called in /var/www/html/vendor/codewithkyrian/transformers/src/Models/Pretrained/PretrainedModel.php on line 194 and defined in /var/www/html/vendor/codewithkyrian/transformers/src/Models/Pretrained/PretrainedModel.php:47
Stack trace:
#0 /var/www/html/vendor/codewithkyrian/transformers/src/Models/Pretrained/PretrainedModel.php(194): Codewithkyrian\Transformers\Models\Pretrained\PretrainedModel->__construct()    
#1 /var/www/html/vendor/codewithkyrian/transformers/src/Models/Auto/PretrainedMixin.php(62): Codewithkyrian\Transformers\Models\Pretrained\PretrainedModel::fromPretrained()        
#2 /var/www/html/vendor/codewithkyrian/transformers/src/Commands/DownloadModelCommand.php(89): Codewithkyrian\Transformers\Models\Auto\PretrainedMixin::fromPretrained()
#3 /var/www/html/vendor/symfony/console/Command/Command.php(279): Codewithkyrian\Transformers\Commands\DownloadModelCommand->execute()
#4 /var/www/html/vendor/symfony/console/Application.php(1031): Symfony\Component\Console\Command\Command->run()
#5 /var/www/html/vendor/symfony/console/Application.php(318): Symfony\Component\Console\Application->doRunCommand()
#6 /var/www/html/vendor/symfony/console/Application.php(169): Symfony\Component\Console\Application->doRun()
#7 /var/www/html/vendor/codewithkyrian/transformers/bin/transformers(18): Symfony\Component\Console\Application->run()
#8 /var/www/html/vendor/bin/transformers(119): include('...')
#9 {main}
  thrown in /var/www/html/vendor/codewithkyrian/transformers/src/Models/Pretrained/PretrainedModel.php on line 47

Reproduction

Execute the following command

./vendor/bin/transformers download Xenova/LaMini-Flan-T5-783M

@takielias takielias added the bug Something isn't working label May 20, 2024
@CodeWithKyrian
Copy link
Owner

Hello @takielias,

I apologize for the inconvenience. It turns out there's a bug in the system's ability to correctly resolve the appropriate model class when a task is not explicitly provided. If you try to run your usual scripts in PHP now that the files have been downloaded, you'll notice that they work fine because you might use something like:

$generator = pipeline('text2text-generation', 'Xenova/LaMini-Flan-T5-783M');

However, when downloading the model, if you don't provide the task, the system tries to infer the task associated with the model and download all related configurations. Due to the bug, this process isn't working perfectly at the moment.

To avoid any issues and ensure smooth model downloads using the CLI, please include the task explicitly like this:

./vendor/bin/transformers download Xenova/LaMini-Flan-T5-783M text2text-generation

I'll be working on fixing this bug and will notify you once it's resolved. Thanks for your patience.

@CodeWithKyrian CodeWithKyrian self-assigned this May 20, 2024
@takielias
Copy link
Contributor Author

@CodeWithKyrian

image

I just got this error. Could you please share a available list of Models (For docs) that we can use for this library?

@CodeWithKyrian
Copy link
Owner

Please note: It's important to open new issues for separate problems to ensure that they are properly tracked and addressed. Posting new issues as comments in existing issues can cause them to be overlooked. I almost missed this one as I was about to close the original issue.

Regarding the issue at hand:

Firstly, I want to clarify that the error is not due to the model being unsupported. The model you are trying to use is based on the M2_M100 architecture, which is indeed supported in TransformersPHP. For your reference, you can check the list of supported model architectures in the documentation.

Sometimes, the model name alone may not clearly indicate its architecture. To verify the architecture, you can follow these steps:

  1. Go to the model's repository on the HuggingFace Hub.
  2. Open the config.json file.
  3. Look for the model_type key to identify the architecture.

Now from the screenshot you provided, it seems that the issue might be related to a network problem. Please ensure that your network connection is stable and try downloading the model again.

If the problem persists after verifying your network connection, please let me know so we can further investigate the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants