@@ -201,7 +201,7 @@ static void print_sample_weights(TransformerWeights *w){
201
201
202
202
// ////////////////////////////////////// ggml structs and functions required to load models, configs and save the model.
203
203
204
- struct llama_vocab {
204
+ struct my_llama_vocab {
205
205
using id = int32_t ;
206
206
using token = std::string;
207
207
using ttype = llama_token_type;
@@ -525,7 +525,7 @@ static std::string llama_escape_whitespaces(const std::string & text) {
525
525
return out.str ();
526
526
}
527
527
528
- static void load_vocab (const char * filename, const Config * config, struct llama_vocab * vocab) {
528
+ static void load_vocab (const char * filename, const Config * config, struct my_llama_vocab * vocab) {
529
529
if (is_ggml_file (filename)) {
530
530
LOG_INF (" %s: Loading vocabulary from gguf file %s\n " , __func__, filename);
531
531
struct ggml_context * ctx_data = NULL ;
@@ -583,13 +583,13 @@ static void load_vocab(const char * filename, const Config * config, struct llam
583
583
const int n_vocab = config->vocab_size ;
584
584
/* uint32_t max_token_length = */ file.read_u32 (); // unused
585
585
vocab->id_to_token .resize (n_vocab);
586
- for (llama_vocab ::id id=0 ; id<n_vocab; ++id) {
586
+ for (my_llama_vocab ::id id=0 ; id<n_vocab; ++id) {
587
587
float_t score = file.read_f32 ();
588
588
uint32_t len = file.read_u32 ();
589
589
std::string text = file.read_string (len);
590
590
591
591
unsigned char byte_val;
592
- llama_vocab ::ttype type = LLAMA_TOKEN_TYPE_NORMAL;
592
+ my_llama_vocab ::ttype type = LLAMA_TOKEN_TYPE_NORMAL;
593
593
if (id == UNKNOWN_TOKEN_ID) {
594
594
text = " <unk>" ;
595
595
type = LLAMA_TOKEN_TYPE_UNKNOWN;
@@ -631,7 +631,7 @@ static void convert_weights_ak_to_gg(struct ggml_tensor * gg_weights, const floa
631
631
}
632
632
633
633
static void save_as_llama_model (
634
- struct llama_vocab * vocab, struct my_llama_model * model, TransformerWeights* w, const char * filename
634
+ struct my_llama_vocab * vocab, struct my_llama_model * model, TransformerWeights* w, const char * filename
635
635
) {
636
636
// convert AK weights into GG weights one by one.
637
637
// w->token_embedding_table -> model->tok_embeddings
@@ -671,7 +671,7 @@ static void save_as_llama_model(
671
671
std::vector<const char *> tokens;
672
672
std::vector<float > scores;
673
673
std::vector<llama_token_type> token_types;
674
- for (const llama_vocab ::token_data & token_data : vocab->id_to_token ) {
674
+ for (const my_llama_vocab ::token_data & token_data : vocab->id_to_token ) {
675
675
tokens.push_back (token_data.text .c_str ());
676
676
scores.push_back (token_data.score );
677
677
token_types.push_back (token_data.type );
@@ -905,7 +905,7 @@ int main(int argc, char ** argv) {
905
905
fclose (file);
906
906
}
907
907
908
- struct llama_vocab vocab;
908
+ struct my_llama_vocab vocab;
909
909
load_vocab (params.fn_vocab_model , &config, &vocab);
910
910
911
911
struct my_llama_model model;
0 commit comments