Skip to content

PHP Fatal error: Uncaught TypeError: Codewithkyrian\Transformers\Utils\AutoConfig::__construct(): Argument #1 ($config) must be of type array, null given #62

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

Open
Tinywan opened this issue Aug 23, 2024 · 3 comments
Labels
question Further information is requested

Comments

@Tinywan
Copy link

Tinywan commented Aug 23, 2024

Your question

sudo /usr/local/php-8.3.1/bin/php ./vendor/bin/transformers download openblas-linux-x86_64-0.3.27

✔ Initializing download...
PHP Fatal error: Uncaught TypeError: Codewithkyrian\Transformers\Utils\AutoConfig::__construct(): Argument #1 ($config) must be of type array, null given, called in /home/www/build/php8/vendor/codewithkyrian/transformers/src/Utils/AutoConfig.php on line 52 and defined in /home/www/build/php8/vendor/codewithkyrian/transformers/src/Utils/AutoConfig.php:25
Stack trace:
#0 /home/www/build/php8/vendor/codewithkyrian/transformers/src/Utils/AutoConfig.php(52): Codewithkyrian\Transformers\Utils\AutoConfig->__construct()
#1 /home/www/build/php8/vendor/codewithkyrian/transformers/src/Models/Auto/PretrainedMixin.php(52): Codewithkyrian\Transformers\Utils\AutoConfig::fromPretrained()
#2 /home/www/build/php8/vendor/codewithkyrian/transformers/src/Commands/DownloadModelCommand.php(89): Codewithkyrian\Transformers\Models\Auto\PretrainedMixin::fromPretrained()
#3 /home/www/build/php8/vendor/symfony/console/Command/Command.php(279): Codewithkyrian\Transformers\Commands\DownloadModelCommand->execute()
#4 /home/www/build/php8/vendor/symfony/console/Application.php(1029): Symfony\Component\Console\Command\Command->run()
#5 /home/www/build/php8/vendor/symfony/console/Application.php(316): Symfony\Component\Console\Application->doRunCommand()
#6 /home/www/build/php8/vendor/symfony/console/Application.php(167): Symfony\Component\Console\Application->doRun()
#7 /home/www/build/php8/vendor/codewithkyrian/transformers/bin/transformers(18): Symfony\Component\Console\Application->run()
#8 /home/www/build/php8/vendor/bin/transformers(119): include('...')
#9 {main}
thrown in /home/www/build/php8/vendor/codewithkyrian/transformers/src/Utils/AutoConfig.php on line 25

Context (optional)

PHP Version

/usr/local/php-8.3.1/bin/php -v
PHP 8.3.1 (cli) (built: Dec 25 2023 21:14:50) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.1, Copyright (c) Zend Technologies

Reference (optional)

No response

@Tinywan Tinywan added the question Further information is requested label Aug 23, 2024
@Tinywan Tinywan mentioned this issue Aug 23, 2024
4 tasks
@RBFraphael
Copy link

RBFraphael commented Oct 9, 2024

Also having this problem. Did you found a solution?

In my case, I'm facing the same exception, but when running the code (not downloading model).

<?php

use function Codewithkyrian\Transformers\Pipelines\pipeline;

require_once __DIR__ . "/vendor/autoload.php";

$textGenerator = pipeline('text-generation', 'meta-llama/Llama-3.2-1B', quantized: false);
$input = <<<INPUT
Generate a text talking about trees in Central Park.
INPUT;

$data = $textGenerator($input);

var_dump($data);

When running with php main.php, the following exception is thrown in terminal:

PHP Fatal error:  Uncaught TypeError: Codewithkyrian\Transformers\Utils\AutoConfig::__construct(): Argument #1 ($config) must be of type array, null given, called in /home/raphael/Projects/AI/llama/vendor/codewithkyrian/transformers/src/Utils/AutoConfig.php on line 52 and defined in /home/raphael/Projects/AI/llama/vendor/codewithkyrian/transformers/src/Utils/AutoConfig.php:25
Stack trace:
#0 /home/raphael/Projects/AI/llama/vendor/codewithkyrian/transformers/src/Utils/AutoConfig.php(52): Codewithkyrian\Transformers\Utils\AutoConfig->__construct()
#1 /home/raphael/Projects/AI/llama/vendor/codewithkyrian/transformers/src/Models/Auto/PretrainedMixin.php(52): Codewithkyrian\Transformers\Utils\AutoConfig::fromPretrained()
#2 /home/raphael/Projects/AI/llama/vendor/codewithkyrian/transformers/src/Pipelines/Task.php(180): Codewithkyrian\Transformers\Models\Auto\PretrainedMixin::fromPretrained()
#3 /home/raphael/Projects/AI/llama/vendor/codewithkyrian/transformers/src/Pipelines/Pipeline.php(80): Codewithkyrian\Transformers\Pipelines\Task->autoModel()
#4 /home/raphael/Projects/AI/llama/main.php(7): Codewithkyrian\Transformers\Pipelines\pipeline()
#5 {main}
  thrown in /home/raphael/Projects/AI/llama/vendor/codewithkyrian/transformers/src/Utils/AutoConfig.php on line 25

Here's my PHP version:

PHP 8.3.12 (cli) (built: Sep 27 2024 03:53:05) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.12, Copyright (c) Zend Technologies
    with Zend OPcache v8.3.12, Copyright (c), by Zend Technologies
    with Xdebug v3.3.2, Copyright (c) 2002-2024, by Derick Rethans

Important to mention that I've manually downloaded the meta-llama/Llama-3.2-1B from HuggingFace, and converted to onnx using the conversion script. When testing without specifying a model, it works as expected. So, maybe there's a problem when you specify a model that is already downloaded.


EDIT

Also tested with other model (Xenova/gpt-3.5-turbo ) and ran into the same issue.

$textGenerator = pipeline('text-generation', 'Xenova/gpt-3.5-turbo');

@BillyGeat
Copy link

Maybe you have the same issue I had? You are trying the whole thing on a system without SSL enabled for CURL in PHP?

This answer here helps how to do this: https://stackoverflow.com/questions/28858351/php-ssl-certificate-error-unable-to-get-local-issuer-certificate

@swanghao
Copy link

Your question

sudo /usr/local/php-8.3.1/bin/php ./vendor/bin/transformers download openblas-linux-x86_64-0.3.27

✔ Initializing download... PHP Fatal error: Uncaught TypeError: Codewithkyrian\Transformers\Utils\AutoConfig::__construct(): Argument #1 ($config) must be of type array, null given, called in /home/www/build/php8/vendor/codewithkyrian/transformers/src/Utils/AutoConfig.php on line 52 and defined in /home/www/build/php8/vendor/codewithkyrian/transformers/src/Utils/AutoConfig.php:25 Stack trace: #0 /home/www/build/php8/vendor/codewithkyrian/transformers/src/Utils/AutoConfig.php(52): Codewithkyrian\Transformers\Utils\AutoConfig->__construct() #1 /home/www/build/php8/vendor/codewithkyrian/transformers/src/Models/Auto/PretrainedMixin.php(52): Codewithkyrian\Transformers\Utils\AutoConfig::fromPretrained() #2 /home/www/build/php8/vendor/codewithkyrian/transformers/src/Commands/DownloadModelCommand.php(89): Codewithkyrian\Transformers\Models\Auto\PretrainedMixin::fromPretrained() #3 /home/www/build/php8/vendor/symfony/console/Command/Command.php(279): Codewithkyrian\Transformers\Commands\DownloadModelCommand->execute() #4 /home/www/build/php8/vendor/symfony/console/Application.php(1029): Symfony\Component\Console\Command\Command->run() #5 /home/www/build/php8/vendor/symfony/console/Application.php(316): Symfony\Component\Console\Application->doRunCommand() #6 /home/www/build/php8/vendor/symfony/console/Application.php(167): Symfony\Component\Console\Application->doRun() #7 /home/www/build/php8/vendor/codewithkyrian/transformers/bin/transformers(18): Symfony\Component\Console\Application->run() #8 /home/www/build/php8/vendor/bin/transformers(119): include('...') #9 {main} thrown in /home/www/build/php8/vendor/codewithkyrian/transformers/src/Utils/AutoConfig.php on line 25

Context (optional)

PHP Version

/usr/local/php-8.3.1/bin/php -v
PHP 8.3.1 (cli) (built: Dec 25 2023 21:14:50) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.1, Copyright (c) Zend Technologies

Reference (optional)

No response

I had the same problem. Did you solve it? How to solve?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants