cui-llama.rn 1.4.0 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/src/main/jni.cpp +9 -9
- package/cpp/common.cpp +163 -60
- package/cpp/common.h +43 -12
- package/cpp/ggml-alloc.c +1042 -1037
- package/cpp/ggml-backend-impl.h +255 -256
- package/cpp/ggml-backend-reg.cpp +582 -582
- package/cpp/ggml-backend.cpp +2002 -2002
- package/cpp/ggml-backend.h +354 -352
- package/cpp/ggml-common.h +1853 -1853
- package/cpp/ggml-cpp.h +39 -39
- package/cpp/ggml-cpu-aarch64.cpp +4247 -4247
- package/cpp/ggml-cpu-aarch64.h +8 -8
- package/cpp/ggml-cpu-impl.h +386 -386
- package/cpp/ggml-cpu-quants.c +10920 -10839
- package/cpp/ggml-cpu-traits.cpp +36 -36
- package/cpp/ggml-cpu-traits.h +38 -38
- package/cpp/ggml-cpu.c +329 -60
- package/cpp/ggml-cpu.cpp +10 -2
- package/cpp/ggml-cpu.h +135 -135
- package/cpp/ggml-impl.h +567 -567
- package/cpp/ggml-metal-impl.h +17 -17
- package/cpp/ggml-metal.m +4884 -4884
- package/cpp/ggml-quants.c +5238 -5238
- package/cpp/ggml-threading.h +14 -14
- package/cpp/ggml.c +6514 -6448
- package/cpp/ggml.h +2194 -2163
- package/cpp/gguf.cpp +1329 -1325
- package/cpp/gguf.h +202 -202
- package/cpp/json-schema-to-grammar.cpp +1045 -1045
- package/cpp/json-schema-to-grammar.h +8 -8
- package/cpp/json.hpp +24766 -24766
- package/cpp/llama-adapter.cpp +347 -346
- package/cpp/llama-adapter.h +74 -73
- package/cpp/llama-arch.cpp +1487 -1434
- package/cpp/llama-arch.h +400 -395
- package/cpp/llama-batch.cpp +368 -368
- package/cpp/llama-batch.h +88 -88
- package/cpp/llama-chat.cpp +578 -567
- package/cpp/llama-chat.h +52 -51
- package/cpp/llama-context.cpp +1775 -1771
- package/cpp/llama-context.h +128 -128
- package/cpp/llama-cparams.cpp +1 -1
- package/cpp/llama-cparams.h +37 -37
- package/cpp/llama-cpp.h +30 -30
- package/cpp/llama-grammar.cpp +1139 -1139
- package/cpp/llama-grammar.h +143 -143
- package/cpp/llama-hparams.cpp +71 -71
- package/cpp/llama-hparams.h +139 -140
- package/cpp/llama-impl.cpp +167 -167
- package/cpp/llama-impl.h +61 -61
- package/cpp/llama-kv-cache.cpp +718 -718
- package/cpp/llama-kv-cache.h +218 -218
- package/cpp/llama-mmap.cpp +2 -1
- package/cpp/llama-mmap.h +67 -67
- package/cpp/llama-model-loader.cpp +1124 -1011
- package/cpp/llama-model-loader.h +167 -158
- package/cpp/llama-model.cpp +3997 -2202
- package/cpp/llama-model.h +370 -391
- package/cpp/llama-sampling.cpp +2408 -2406
- package/cpp/llama-sampling.h +32 -48
- package/cpp/llama-vocab.cpp +3247 -1982
- package/cpp/llama-vocab.h +125 -182
- package/cpp/llama.cpp +416 -2886
- package/cpp/llama.h +1323 -1285
- package/cpp/log.cpp +401 -401
- package/cpp/log.h +121 -121
- package/cpp/rn-llama.hpp +18 -12
- package/cpp/sampling.cpp +505 -500
- package/cpp/sgemm.cpp +2597 -2597
- package/cpp/speculative.cpp +277 -274
- package/cpp/speculative.h +28 -28
- package/cpp/unicode.cpp +2 -3
- package/package.json +1 -1
package/cpp/llama-vocab.h
CHANGED
@@ -1,182 +1,125 @@
|
|
1
|
-
#pragma once
|
2
|
-
|
3
|
-
#include "llama.h"
|
4
|
-
|
5
|
-
#include <string>
|
6
|
-
#include <vector>
|
7
|
-
#include <
|
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
|
-
std::
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
bool
|
78
|
-
bool
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
llama_token llama_token_eom_impl(const struct llama_vocab & vocab);
|
127
|
-
llama_token llama_token_cls_impl(const struct llama_vocab & vocab);
|
128
|
-
llama_token llama_token_sep_impl(const struct llama_vocab & vocab);
|
129
|
-
llama_token llama_token_nl_impl (const struct llama_vocab & vocab);
|
130
|
-
llama_token llama_token_pad_impl(const struct llama_vocab & vocab);
|
131
|
-
|
132
|
-
llama_token llama_token_prefix_impl(const struct llama_vocab & vocab);
|
133
|
-
llama_token llama_token_middle_impl(const struct llama_vocab & vocab);
|
134
|
-
llama_token llama_token_suffix_impl(const struct llama_vocab & vocab);
|
135
|
-
|
136
|
-
llama_token llama_token_fim_pre_impl(const struct llama_vocab & vocab);
|
137
|
-
llama_token llama_token_fim_suf_impl(const struct llama_vocab & vocab);
|
138
|
-
llama_token llama_token_fim_mid_impl(const struct llama_vocab & vocab);
|
139
|
-
llama_token llama_token_fim_pad_impl(const struct llama_vocab & vocab);
|
140
|
-
llama_token llama_token_fim_rep_impl(const struct llama_vocab & vocab);
|
141
|
-
llama_token llama_token_fim_sep_impl(const struct llama_vocab & vocab);
|
142
|
-
|
143
|
-
bool llama_add_bos_token_impl(const struct llama_vocab & vocab);
|
144
|
-
bool llama_add_eos_token_impl(const struct llama_vocab & vocab);
|
145
|
-
|
146
|
-
int32_t llama_tokenize_impl(
|
147
|
-
const struct llama_vocab & vocab,
|
148
|
-
const char * text,
|
149
|
-
int32_t text_len,
|
150
|
-
llama_token * tokens,
|
151
|
-
int32_t n_tokens_max,
|
152
|
-
bool add_special,
|
153
|
-
bool parse_special);
|
154
|
-
|
155
|
-
// does not write null-terminator to buf
|
156
|
-
int32_t llama_token_to_piece_impl(
|
157
|
-
const struct llama_vocab & vocab,
|
158
|
-
llama_token token,
|
159
|
-
char * buf,
|
160
|
-
int32_t length,
|
161
|
-
int32_t lstrip,
|
162
|
-
bool special);
|
163
|
-
|
164
|
-
// check if token0 is contained as a prefix in token1
|
165
|
-
bool llama_token_is_prefix_impl(
|
166
|
-
const struct llama_vocab & vocab,
|
167
|
-
llama_token token0,
|
168
|
-
llama_token token1);
|
169
|
-
|
170
|
-
int32_t llama_detokenize_impl(
|
171
|
-
const struct llama_vocab & vocab,
|
172
|
-
const llama_token * tokens,
|
173
|
-
int32_t n_tokens,
|
174
|
-
char * text,
|
175
|
-
int32_t text_len_max,
|
176
|
-
bool remove_special,
|
177
|
-
bool unparse_special);
|
178
|
-
|
179
|
-
std::string llama_detokenize(
|
180
|
-
const struct llama_vocab & vocab,
|
181
|
-
const std::vector<llama_token> & tokens,
|
182
|
-
bool special);
|
1
|
+
#pragma once
|
2
|
+
|
3
|
+
#include "llama.h"
|
4
|
+
|
5
|
+
#include <string>
|
6
|
+
#include <vector>
|
7
|
+
#include <memory>
|
8
|
+
|
9
|
+
struct LLM_KV;
|
10
|
+
struct llama_model_loader;
|
11
|
+
|
12
|
+
struct llama_vocab {
|
13
|
+
struct token_data {
|
14
|
+
std::string text;
|
15
|
+
float score;
|
16
|
+
llama_token_attr attr;
|
17
|
+
};
|
18
|
+
|
19
|
+
llama_vocab();
|
20
|
+
~llama_vocab();
|
21
|
+
|
22
|
+
void load(llama_model_loader & ml, const LLM_KV & kv);
|
23
|
+
|
24
|
+
enum llama_vocab_type get_type() const;
|
25
|
+
enum llama_vocab_pre_type get_pre_type() const;
|
26
|
+
|
27
|
+
uint32_t n_tokens() const;
|
28
|
+
uint32_t n_token_types() const;
|
29
|
+
|
30
|
+
std::string type_name() const;
|
31
|
+
|
32
|
+
bool is_normal (llama_token id) const;
|
33
|
+
bool is_unknown (llama_token id) const;
|
34
|
+
bool is_control (llama_token id) const;
|
35
|
+
bool is_byte (llama_token id) const;
|
36
|
+
bool is_user_defined(llama_token id) const;
|
37
|
+
bool is_unused (llama_token id) const;
|
38
|
+
bool is_eog (llama_token id) const;
|
39
|
+
|
40
|
+
uint8_t token_to_byte(llama_token id) const;
|
41
|
+
llama_token byte_to_token(uint8_t ch) const;
|
42
|
+
|
43
|
+
llama_token text_to_token(const std::string & text) const;
|
44
|
+
|
45
|
+
const token_data & get_token_data(llama_token id) const;
|
46
|
+
|
47
|
+
const char * token_get_text (llama_token id) const;
|
48
|
+
float token_get_score(llama_token id) const;
|
49
|
+
llama_token_attr token_get_attr (llama_token id) const;
|
50
|
+
|
51
|
+
llama_token token_bos() const;
|
52
|
+
llama_token token_eos() const;
|
53
|
+
llama_token token_eot() const;
|
54
|
+
llama_token token_eom() const;
|
55
|
+
llama_token token_unk() const;
|
56
|
+
llama_token token_sep() const;
|
57
|
+
llama_token token_nl () const;
|
58
|
+
llama_token token_pad() const;
|
59
|
+
|
60
|
+
llama_token token_prefix() const;
|
61
|
+
llama_token token_middle() const;
|
62
|
+
llama_token token_suffix() const;
|
63
|
+
|
64
|
+
llama_token token_fim_pre() const;
|
65
|
+
llama_token token_fim_suf() const;
|
66
|
+
llama_token token_fim_mid() const;
|
67
|
+
llama_token token_fim_pad() const;
|
68
|
+
llama_token token_fim_rep() const;
|
69
|
+
llama_token token_fim_sep() const;
|
70
|
+
|
71
|
+
bool get_add_space_prefix () const;
|
72
|
+
bool get_add_bos () const;
|
73
|
+
bool get_add_eos () const;
|
74
|
+
bool get_ignore_merges () const;
|
75
|
+
bool get_clean_spaces () const;
|
76
|
+
bool get_remove_extra_whitespaces () const;
|
77
|
+
bool get_escape_whitespaces () const;
|
78
|
+
bool get_treat_whitespace_as_suffix() const;
|
79
|
+
|
80
|
+
int max_token_len() const;
|
81
|
+
|
82
|
+
int find_bpe_rank(const std::string & token_left, const std::string & token_right) const;
|
83
|
+
|
84
|
+
int32_t tokenize(
|
85
|
+
const char * text,
|
86
|
+
int32_t text_len,
|
87
|
+
llama_token * tokens,
|
88
|
+
int32_t n_tokens_max,
|
89
|
+
bool add_special,
|
90
|
+
bool parse_special) const;
|
91
|
+
|
92
|
+
std::vector<llama_token> tokenize(
|
93
|
+
const std::string & raw_text,
|
94
|
+
bool add_special,
|
95
|
+
bool parse_special = false) const;
|
96
|
+
|
97
|
+
// does not write null-terminator to buf
|
98
|
+
int32_t token_to_piece(
|
99
|
+
llama_token token,
|
100
|
+
char * buf,
|
101
|
+
int32_t length,
|
102
|
+
int32_t lstrip,
|
103
|
+
bool special) const;
|
104
|
+
|
105
|
+
// use cached data
|
106
|
+
const std::string & token_to_piece(llama_token token) const;
|
107
|
+
|
108
|
+
int32_t detokenize(
|
109
|
+
const llama_token * tokens,
|
110
|
+
int32_t n_tokens,
|
111
|
+
char * text,
|
112
|
+
int32_t text_len_max,
|
113
|
+
bool remove_special,
|
114
|
+
bool unparse_special) const;
|
115
|
+
|
116
|
+
std::string detokenize(
|
117
|
+
const std::vector<llama_token> & tokens,
|
118
|
+
bool special) const;
|
119
|
+
|
120
|
+
void print_info() const;
|
121
|
+
|
122
|
+
private:
|
123
|
+
struct impl;
|
124
|
+
std::unique_ptr<impl> pimpl;
|
125
|
+
};
|