Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Transformers Laravel Package

codewithkyrian/transformers

A Laravel-friendly transformers package for turning models, arrays, and API responses into consistent, reusable output. Define transformer classes, map fields, nest relations, and format data cleanly for JSON APIs, with minimal boilerplate and flexible customization.

View on GitHub
Deep Wiki
Context7
v0.6.0

What’s Changed

  • Add support for stopping criteria: MaxLength, MaxTime, and Interruptable for more flexible generation control.
  • Add PSR-3 logging support
  • Extend PretrainedConfig to reduce code repetition across model files and improve maintainability.
  • Restructure AutoModel resolution to prioritize generic model selection when no task-specific class is found.
  • Add support for new model families: Gemma, Gemma2, Gemma3, Qwen3, and Phi3, with their respective causal language models.
  • Add support for eos and last_token pooling strategies in the FeatureExtractionPipeline.
  • Add support for new merge format in BPEModel with better compatibility via JSON-encoded token pair mapping.
  • Introduce PretrainedModel::$sessions array to streamline model session handling across subclasses.
  • Simplify streamer implementation to improve clarity and flexibility.
  • Enhance image processing methods and VIPS integration.
  • Convert to a platform package with native shared library support for Linux, macOS, and Windows (x86_64 and ARM64).
  • Introduce dynamic shared library loading with platform-specific path resolution logic.
  • Update example configurations, docs, and usage instructions to reflect new architecture.
  • Add tests for image utilities and inference session logic.

Bug Fixes

  • Fix Tensor::slice() error during generation.
  • Fix logic in RepetitionPenaltyLogitsProcessor to properly apply penalties based on generated tokens.
  • Fix compatibility issues with PHP 8.1 and adjust dependency versions accordingly.
  • Fix bug in HubTest for Windows paths by using DIRECTORY_SEPARATOR.
  • Fix edge case in BPEModel when null value encountered in merge map.
  • Fix various doc inconsistencies and default constructor bugs in model subclasses.

Improvements

  • Refactor library architecture for improved platform compatibility and modularity.

  • Refactor Samplerate, Sndfile, and other FFI wrappers to use instance-based invocation.

  • Improve generation configuration merging logic and model resolution flow.

  • Unify code style across components and improve clarity of core components.

  • Update shared native dependencies:

    • onnxruntime β†’ 1.21.0
    • rindowmatlib β†’ 1.1.1
  • Clean up feature extractors and consolidate model session logic.

  • Improve error handling in FFI calls and utility classes.

  • Rename internal config and model mapping classes for better clarity (PretrainedMixin β†’ AutoModelBase, etc.)

New Contributors

Full Changelog: https://github.com/CodeWithKyrian/transformers-php/compare/0.5.3...0.6.0

0.6.1

What's New

  • feat: update Rindow Matlib macOS binaries for ARM64 and x86_64 architectures
  • fix: update darwin platform directory names
  • chore(ci): clean up distribution directory after artifact creation in release workflow

Full Changelog: https://github.com/CodeWithKyrian/transformers-php/compare/0.6.0...0.6.1

v0.4.4

What's Changed

New Contributors

Full Changelog: https://github.com/CodeWithKyrian/transformers-php/compare/0.4.3...0.4.4

v0.4.3

What's Changed

New Contributors

Full Changelog: https://github.com/CodeWithKyrian/transformers-php/compare/0.4.2...0.4.3

v0.4.2

What's Changed

Full Changelog: https://github.com/CodeWithKyrian/transformers-php/compare/0.4.1...0.4.2

v0.4.1

What's Changed

New Contributors

Full Changelog: https://github.com/CodeWithKyrian/transformers-php/compare/0.4.0...0.4.1

v0.3.1

What's Changed

Full Changelog: https://github.com/CodeWithKyrian/transformers-php/compare/0.3.0...0.3.1

v0.3.0

What's Changed

Breaking Changes

  • The install command no longer exists, as the required libraries are downloaded automatically on composer install.
  • New Image driver configuration settings added that required either GD, Imagick or Vips

New Contributors

Full Changelog: https://github.com/CodeWithKyrian/transformers-php/compare/0.2.2...0.3.0

v0.2.2

What's new

Full Changelog: https://github.com/CodeWithKyrian/transformers-php/compare/0.2.1...0.2.2

v0.2.1
v0.2.0

What's Changed

Full Changelog: https://github.com/CodeWithKyrian/transformers-php/compare/0.1.0...0.2.0

v0.1.0

Initial Release πŸŽ‰

We are thrilled to announce the launch of Transformers PHP, a groundbreaking library that brings the power of state-of-the-art machine learning to the PHP community. Inspired by the HuggingFace Transformers and Xenova Transformers.js, Transformers PHP aims to provide an easy-to-use, high-performance toolset for developers looking to integrate advanced NLP, and in future updates potentially more, capabilities into their PHP applications.

Key Features:

  • Seamless Integration: Designed to be functionally equivalent to its Python counterpart, making the transition and usage straightforward for developers familiar with the original Transformers library.
  • Performance Optimized: Utilizes ONNX Runtime for efficient model inference, ensuring high performance even in demanding scenarios.
  • Comprehensive Model Support: Access to thousands of pre-trained models across 100+ languages, covering a wide range of tasks including text generation, summarization, translation, sentiment analysis, and more.
  • Easy Model Conversion: With πŸ€— Optimum, easily convert PyTorch or TensorFlow models to ONNX format for use with Transformers PHP.
  • Developer Friendly: From installation to deployment, every aspect of Transformers PHP is designed with ease of use in mind, featuring extensive documentation and a streamlined API.

Getting Started:

Installation is a breeze with Composer:

composer require codewithkyrian/transformers


















And you must initialize the library to download neccesary libraries for ONNX

./vendor/bin/transformers install


















Checkout the Documentation

For a comprehensive guide on how to use Transformers PHP, including detailed examples and configuration options, visit our documentation.

Pre-Download Models:

To ensure a smooth user experience, especially with larger models, we recommend pre-downloading models before deployment. Transformers PHP includes a handy CLI tool for this purpose:

./vendor/bin/transformers download <model_identifier>


















What's Next?

This initial release lays the groundwork for a versatile machine learning toolkit within the PHP ecosystem. We are committed to continuous improvement and expansion of Transformers PHP, with future updates aimed at increasing supported tasks, enhancing functionality, and broadening the scope of models.

Get Involved!

We encourage feedback, contributions, and discussions from the community. Whether you're reporting bugs, requesting features, or contributing code, your input is invaluable in making Transformers PHP better for everyone.

Acknowledgments:

A huge thank you to Hugging Face for their incredible work on the Transformers library, to Xenova for inspiring this package, and to the broader machine learning community for their ongoing research and contributions. Transformers PHP stands on the shoulders of giants, and we are excited to see how it will empower PHP developers to push the boundaries of what's possible.

What's

Full Changelog: https://github.com/CodeWithKyrian/transformers-php/compare/0.2.0...0.2.1

TransformersPHP

I'm excited to announce the latest version of TransformersPHP, packed with new features, improvements, and bug fixes. This release brings powerful enhancements to your machine-learning-driven PHP applications, enabling more efficient and versatile operations.

New Features

  • New Pipeline: Audio Classification - Easily classify audio clips with a pre-trained model.

    $classifier = pipeline('audio-classification', 'Xenova/ast-finetuned-audioset-10-10-0.4593');
    $audioUrl = __DIR__ . '/../sounds/cat_meow.wav';
    $output = $classifier($audioUrl);
    // [
    //   [
    //     "label" => "Meow"
    //     "score" => 0.6109990477562
    //   ]
    // ]
    
    
    
    
    
    
    
    
  • New Pipeline: Automatic Speech Recognition (ASR) - Supports models like wav2vec and whisper for transcribing speech to text. If a specific model is not officially supported, please open an issue with a feature request.

    • Example:
      $transcriber = pipeline('asr', 'Xenova/whisper-tiny.en');
      $audioUrl = __DIR__ . '/../sounds/preamble.wav';
      $output = $transcriber($audioUrl, maxNewTokens: 256);
      // [
      //   "text" => "We, the people of the United States, ..."
      // ]
      
      
      
      
      
      
      
      

Enhancements

  • Shared Libraries Dependencies: - A revamped workflow for downloading shared libraries dependencies ensures they are versioned correctly, reducing download sizes. These binaries are now thoroughly tested on Apple Silicon, Intel Macs, Linux x86_64, Linux aarch64, and Windows platforms.

  • Transformers::setup Simplified - Transformers::setup() is now optional. Default settings are automatically applied if not called. The apply() method is no longer necessary, but still available for backward compatibility.

  • Immutable Image Utility - The Image utility class is now immutable. Each operation returns a new instance, allowing for method chaining and a more predictable workflow.

    $image = Image::read($url);
    $resizedImage = $image->resize(100, 100);
    // $image remains unchanged
    
    
    
    
    
    
    
    
  • New Tensor Operations - New operations were added: copyTo, log, exp, pow, sum, reciprocal, stdMean. Additionally, overall performance improvements have been made to Tensor operations.

  • TextStreamer Improvements - TextStreamer now prints to stdout by default. You can override this behavior using the onStream(callable $callback) method. Consequently, the StdoutStreamer class is now obsolete.

  • VIPS PHP Driver Update - The VIPS PHP driver is no longer bundled by default in composer.json. Detailed documentation is provided for installing the Vips PHP driver and setting up Vips on your machine.

  • ONNX Runtime Upgrade - Upgraded to version 1.19.0, bringing more performance and compatibility with newer models.

  • Bug Fixes & Performance Improvements - Various bug fixes have been implemented to enhance stability and performance across the package.

I hope you enjoy these updates and improvements. If you encounter any issues or have any suggestions, please don’t hesitate to reach out through our Issue Tracker

Full Changelog: https://github.com/CodeWithKyrian/transformers-php/compare/0.4.4...0.5.0

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
besmartand-pro/php-quality-config
sentix/ai-chatbot
terminal42/code-quality-tools
codifyo/ts-generator-bundle
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity