Skip to content

Sentence Transformer model inference with PHP and HuggingFace candle ML framework wrapper

Notifications You must be signed in to change notification settings

manticoresoftware/php-ext-model

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

php-ext-model

This extension enable you the power of rust and HuggingFace candle framework to run any setence-transformers model form the PHP with lighting speed.

How to Use

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

How to Build

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)

About

Sentence Transformer model inference with PHP and HuggingFace candle ML framework wrapper

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages