avoid printing too much newlines in baby-llama-text

This commit is contained in:
xaedes 2023-05-14 20:57:47 +02:00
parent c054079fb8
commit d9b5268728
No known key found for this signature in database
GPG key ID: 30030EDD817EA2B1

View file

@ -969,9 +969,16 @@ void print_tokens(struct llama_context* ctx, struct ggml_tensor * tokens) {
void print_tokens_batch(struct llama_context* ctx, struct ggml_tensor * tokens) { void print_tokens_batch(struct llama_context* ctx, struct ggml_tensor * tokens) {
for (int i1=0; i1<tokens->ne[1]; ++i1) { for (int i1=0; i1<tokens->ne[1]; ++i1) {
int num_newline = 0;
for (int i0=0; i0<tokens->ne[0]; ++i0) { for (int i0=0; i0<tokens->ne[0]; ++i0) {
int token = ggml_get_i32_1d(tokens, i0 + i1*tokens->ne[0]); int token = ggml_get_i32_1d(tokens, i0 + i1*tokens->ne[0]);
print_token(ctx, token); bool isnl = (token == llama_token_nl());
if (isnl) {
++num_newline;
}
if (!isnl || (num_newline < 2)) {
print_token(ctx, token);
}
} }
printf("\n--\n"); printf("\n--\n");
} }