Skip to content

Problem with AutoConfig.php #18

Closed

Description

@CViniciusSDias

System Info

SO: Ubuntu (under WSL) - Linux NotebookG15 5.15.146.1-microsoft-standard-WSL2 #1 SMP Thu Jan 11 04:09:03 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux

PHP Version

8.3.6

Environment/Platform

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

Description

When trying to execute any simple code using TransformersPHP, I get the following error:

PHP Fatal error:  Uncaught TypeError: Codewithkyrian\Transformers\Utils\AutoConfig::__construct(): Argument #1 ($config) must be of type array, null given, called in /tmp/transformersphp/vendor/codewithkyrian/transformers/src/Utils/AutoConfig.php on line 53 and defined in /tmp/transformersphp/vendor/codewithkyrian/transformers/src/Utils/AutoConfig.php:26    
Stack trace:
#0 /tmp/transformersphp/vendor/codewithkyrian/transformers/src/Utils/AutoConfig.php(53): Codewithkyrian\Transformers\Utils\AutoConfig->__construct()
#1 /tmp/transformersphp/vendor/codewithkyrian/transformers/src/Models/Auto/PretrainedMixin.php(53): Codewithkyrian\Transformers\Utils\AutoConfig::fromPretrained()
#2 /tmp/transformersphp/vendor/codewithkyrian/transformers/src/Pipelines/Task.php(101): Codewithkyrian\Transformers\Models\Auto\PretrainedMixin::fromPretrained()
#3 /tmp/transformersphp/vendor/codewithkyrian/transformers/src/Pipelines/Pipeline.php(79): Codewithkyrian\Transformers\Pipelines\Task->pretrainedModel()
#4 /tmp/transformersphp/transformers.php(7): Codewithkyrian\Transformers\Pipelines\pipeline()
#5 {main}
  thrown in /tmp/transformersphp/vendor/codewithkyrian/transformers/src/Utils/AutoConfig.php on line 26

Reproduction

Run the following code:

<?php

use function Codewithkyrian\Transformers\Pipelines\pipeline;

require 'vendor/autoload.php';

$classifier = pipeline('sentiment-analysis');

var_dump($classifier('I love TransformersPHP!'));

Activity

  1. CViniciusSDias commented on Apr 13, 2024

    @CViniciusSDias
    ContributorAuthor

    src/Utils/Helpers.php:77 has the following line:

    return preg_replace('#/+#', '/', implode(DIRECTORY_SEPARATOR, $paths));
    

    This returns https:/huggingface.co/Xenova/distilbert-base-uncased-finetuned-sst-2-english/resolve/main/config.json, with https:/ instead of https://, which is incorrect.

  2. CodeWithKyrian commented on Apr 13, 2024

    @CodeWithKyrian
    Owner

    Thanks for bringing it to my attention. The PR has been merged but it'll be part of the upcoming v0.3.0 release in few hours

  3. Tinywan commented on Aug 22, 2024

    @Tinywan
    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
    

    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
    
  4. CodeWithKyrian commented on Aug 22, 2024

    @CodeWithKyrian
    Owner

    Hi @Tinywan,

    Please open a new issue if you encounter problems with the package, unless it's part of an ongoing discussion.

    Regarding your concern, the download command is specifically designed to download PreTrained models from the Huggingface hub or any custom host—not shared libraries. If your shared libraries aren't set up correctly, you can run the ./vendor/bin/transformers download command to re-download them and place them in the appropriate directories. For more detailed instructions, please refer to the documentation.

  5. Tinywan commented on Aug 23, 2024

    @Tinywan

    OK #62

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugSomething isn't working

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions