File size: 969 Bytes
81bf9b4
 
 
 
 
 
 
 
 
 
46c2bfc
81bf9b4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#include "embd-input.h"
#include <stdlib.h>
#include <random>
#include <string.h>

int main(int argc, char** argv) {

    auto mymodel = create_mymodel(argc, argv);
    int N = 10;
    int max_tgt_len = 500;
    int n_embd = llama_n_embd(llama_get_model(mymodel->ctx));

    // add random float embd to test evaluation
    float * data = new float[N*n_embd];
    std::default_random_engine e;
    std::uniform_real_distribution<float>  u(0,1);
    for (int i=0;i<N*n_embd;i++) {
        data[i] = u(e);
    }

    eval_string(mymodel, "user: what is the color of the flag of UN?");
    eval_float(mymodel, data, N);
    eval_string(mymodel, "assistant:");
    eval_string(mymodel, mymodel->params.prompt.c_str());
    const char* tmp;
    for (int i=0; i<max_tgt_len; i++) {
        tmp = sampling(mymodel);
        if (strcmp(tmp, "</s>")==0) break;
        printf("%s", tmp);
        fflush(stdout);
    }
    printf("\n");
    free_mymodel(mymodel);
    return 0;
}