This extension enable you the power of rust and HuggingFace candle framework to run any setence-transformers model form the PHP with lighting speed.
Here's an example of how to use it:
<?php
use Manticore\Ext\Model;
// One from https://huggingface.co/sentence-transformers
$model = Model::create("sentence-transformers/all-MiniLM-L12-v2");
var_dump($model->predict("Hello world"));
This will display the flatten tensor as list of floats
You need to have cargo
installed to build.
cargo build --release
After the build is complete, you can use the extension with PHP as usual.
$ php -d extension=target/release/libphp_ext_model.so -r 'var_dump(class_exists("Manticore\Ext\Model"));'
bool(true)