-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(embedding): add createEmbedding method to LLamaCPP class
feat(embedding): add llama_n_embd and llama_get_embeddings methods to LLamaCPPFFI class test(LLamaCPPTest.php): add testCreateEmbedding method to test createEmbedding function in LLamaCPP class
- Loading branch information
Showing
4 changed files
with
94 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
require_once __DIR__ . '/../vendor/autoload.php'; | ||
|
||
use Kambo\LLamaCPP\LLamaCPP; | ||
use Kambo\LLamaCPP\Context; | ||
use Kambo\LLamaCPP\Parameters\ModelParameters; | ||
use Kambo\LLamaCPP\Parameters\GenerationParameters; | ||
|
||
$template = "You are a programmer, write PHP class that will add two numbers and print the result. Stop at class end."; | ||
$context = Context::createWithParameter( | ||
new ModelParameters( | ||
modelPath:__DIR__ .'/models/ggjt-model.bin', | ||
embedding: true, | ||
) | ||
); | ||
$llama = new LLamaCPP($context); | ||
|
||
$embeddings = $llama->createEmbedding($template); | ||
|
||
var_dump($embeddings); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters