-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModelInterface.php
More file actions
65 lines (56 loc) · 1.53 KB
/
ModelInterface.php
File metadata and controls
65 lines (56 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
declare(strict_types=1);
namespace Codewithkyrian\Tokenizers\Contracts;
interface ModelInterface
{
/**
* Tokenize a list of pre-tokenized words into subwords.
*
* @param string[] $tokens
*
* @return string[]
*/
public function tokenize(array $tokens): array;
/**
* Encode a list of tokens to a list of token IDs.
*
* @param string[] $tokens
*
* @return int[]
*/
public function encode(array $tokens): array;
/**
* Decode a list of token IDs to a list of tokens.
*
* @param int[] $ids
*
* @return string[]
*/
public function decode(array $ids): array;
/**
* Get the vocabulary of the model.
*
* @return array<int, string>
*/
public function getVocab(): array;
/**
* Get the size of the vocabulary.
*/
public function getVocabSize(): int;
/**
* Add a token to the vocabulary.
*
* @param string $token The token content
* @param int $id The token ID
*/
public function addToken(string $token, int $id): void;
/**
* Get configuration value(s).
*
* @param null|string $key The configuration key (e.g., 'dropout'). If null, returns all config.
* @param mixed $default The default value if the key doesn't exist (ignored when $key is null)
*
* @return mixed the configuration value, or full config array if $key is null
*/
public function getConfig(?string $key = null, mixed $default = null): mixed;
}