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.
Full Changelog: https://github.com/CodeWithKyrian/transformers-php/compare/0.6.1...0.6.2
Full Changelog: https://github.com/CodeWithKyrian/transformers-php/compare/0.6.0...0.6.1
MaxLength, MaxTime, and Interruptable for more flexible generation control.PretrainedConfig to reduce code repetition across model files and improve maintainability.AutoModel resolution to prioritize generic model selection when no task-specific class is found.Gemma, Gemma2, Gemma3, Qwen3, and Phi3, with their respective causal language models.eos and last_token pooling strategies in the FeatureExtractionPipeline.BPEModel with better compatibility via JSON-encoded token pair mapping.PretrainedModel::$sessions array to streamline model session handling across subclasses.Tensor::slice() error during generation.RepetitionPenaltyLogitsProcessor to properly apply penalties based on generated tokens.HubTest for Windows paths by using DIRECTORY_SEPARATOR.BPEModel when null value encountered in merge map.Samplerate, Sndfile, and other FFI wrappers to use instance-based invocation.PretrainedMixin → AutoModelBase, etc.)Full Changelog: https://github.com/CodeWithKyrian/transformers-php/compare/0.5.3...0.6.0
This release brings new features, critical bug fixes, and improvements to enhance the functionality and performance of the package. Below is a summary of the changes.
random by @CodeWithKyrian in https://github.com/CodeWithKyrian/transformers-php/commit/0564dd1609db203d4665a4c040cf1b55e4503ac9I encourage everyone to update to this latest version and explore the new features. As always, feel free to report any issues or contribute to the project.
Full Changelog: https://github.com/CodeWithKyrian/transformers-php/compare/0.5.2...0.5.3
Full Changelog: https://github.com/CodeWithKyrian/transformers-php/compare/0.5.1...0.5.2
magnitude, sqrt and cosSimilarity added.rokka/vips from dev back to normal dependencies. Since vips binaries are bundled by default, use of vips is now encouraged.Full Changelog: https://github.com/CodeWithKyrian/transformers-php/compare/0.5.0...0.5.1
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 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.
$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, ..."
// ]
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
Full Changelog: https://github.com/CodeWithKyrian/transformers-php/compare/0.4.3...0.4.4
Full Changelog: https://github.com/CodeWithKyrian/transformers-php/compare/0.4.2...0.4.3
Full Changelog: https://github.com/CodeWithKyrian/transformers-php/compare/0.4.1...0.4.2
Full Changelog: https://github.com/CodeWithKyrian/transformers-php/compare/0.4.0...0.4.1
This release marks a significant milestone in enhancing the performance and functionality of the Tensor class while introducing convenient tools to streamline the installation of essential dependencies. These improvements not only optimize existing operations but also pave the way for future enhancements and expanded capabilities within the project.
topk, divide, and slice, have been added to the Tensor class, along with corresponding changes to existing implementations to leverage these methods.stack method in the Tensor class has been refactored for enhanced performance.Transformers class, it can be set directly on the Image class, allowing it to be used independently.onnxruntime, openblas, and rindow-matlib, during the Composer install process.install command back to serve as an alternative way of getting the shared libraries if it fails for any reason during composer install.Full Changelog: https://github.com/CodeWithKyrian/transformers-php/compare/0.3.1...0.4.0
Full Changelog: https://github.com/CodeWithKyrian/transformers-php/compare/0.3.0...0.3.1
Full Changelog: https://github.com/CodeWithKyrian/transformers-php/compare/0.2.2...0.3.0
Full Changelog: https://github.com/CodeWithKyrian/transformers-php/compare/0.2.1...0.2.2
WordPieceTokenizer on case-sensitive operating systems in https://github.com/CodeWithKyrian/transformers-php/commit/0f1fc8bda91fb3df9492057a4224b171d2e3f2d5Full Changelog: https://github.com/CodeWithKyrian/transformers-php/compare/0.2.0...0.2.1
PretrainedModel on case-sensitive operating systems by @CodeWithKyrian in https://github.com/CodeWithKyrian/transformers-php/pull/4Full Changelog: https://github.com/CodeWithKyrian/transformers-php/compare/0.1.0...0.2.0
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.
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
For a comprehensive guide on how to use Transformers PHP, including detailed examples and configuration options, visit our documentation.
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>
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.
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.
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.
How can I help you explore Laravel packages today?