Decision making AI (JEV)system in your PHP project
You probably wondering how to define if email is spam or if tickets are duplicated or if some video / image contains forbidden content?
Now there is perfect classifier for this, it’s called JEV! This article describes how to use JEV directly on PHP (no python or external APIs calls needed).
JEV was introduced recently as a new powerful classifier, which can be used almost for any task! It requires much less tokens and much less computations. But still you may wonderig, how I can integrate it into my PHP project especially when full privacy is required (no data should leave your server).
Let me guide with a few simple steps how to do it on PHP:
1. Install AI composer package for PHP:
https://packagist.org/packages/php-loves-ai/multimodal-ai-runner
composer require php-loves-ai/multimodal-ai-runner2. Setup your JEV runner:
vendor/bin/loves-ai setup jev3. Pull JEV model you like the most:
vendor/bin/loves-ai pull akhilaaa3/Jev-Omni4. Now enjoy JEV on your server (or locally):
vendor/bin/loves-ai jev akhilaaa3/Jev-Omni "What is on the table?" "A cat" "A dog" "Nothing" --media=photo.jpgOr you can do the magic just right in your PHP code:
use PhpLovesAi\Runner\Jev;
// Finds the runner and the pulled model in the project's .local directory by itself.
$jev = new Jev();
$decision = $jev->decide(
model: 'akhilaaa3/Jev-Omni',
question: 'Has the meeting started?',
options: ['Yes', 'No'],
state: 'The meeting starts at 10 AM. It is now 9 AM.',
);
$decision->prediction; // 'No'
$decision->index; // 1
$decision->confidence; // 0.986
$decision->probabilities; // ['Yes' => 0.014, 'No' => 0.986]
$mood = $jev->decide(
model: 'akhilaaa3/Jev-Omni',
question: 'How does the caller sound?',
options: ['Happy', 'Neutral', 'Upset'],
mediaPath: storage_path('app/call.m4a'),
);Now you everything is set and you can run any JEV model you like.
Explore more:
https://phplovesai.com/docs/jev
How it works?
It uses python pre-compiled binaries on the low backend level, it doesn’t do any API calls or so. When you run “setup jev” it just pulling model puller and runner binaries for JEV. After you can pull and run any JEV models from hugging face.
That’s it. Enjoy JEV! :D
