Skip to content

Commit e8f9021

Browse files
committed
fix: grammar test, ref #57
-- allow space in the beginning of the generation
1 parent 467fc03 commit e8f9021

File tree

1 file changed

+32
-32
lines changed

1 file changed

+32
-32
lines changed

test/t-integration.cpp

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -352,79 +352,79 @@ TEST_CASE("control_vector") {
352352
}
353353

354354
// commented out because it relies on specific calc
355-
//TEST_CASE("grammar") {
355+
// TEST_CASE("grammar") {
356356
// auto model = resourceCache.getModel({.gguf = Model_117m_q6_k, .params = {}});
357357
// CHECK(!!model->lmodel());
358-
//
358+
359359
// auto& params = model->params();
360360
// CHECK(params.gpu);
361361
// CHECK_FALSE(params.vocabOnly);
362-
//
362+
363363
// CHECK(model->trainCtxLength() == 1024);
364364
// CHECK_FALSE(model->shouldAddBosToken());
365365
// CHECK_FALSE(model->hasEncoder());
366-
//
367-
// SUBCASE("Numbers 6-9 only") {
366+
367+
// SUBCASE("Numbers 0-9") {
368368
// ac::llama::Instance::InitParams iparams;
369369
// iparams.grammar = R""""(
370-
//root ::= en-char+ ([ \t\n] en-char+)*
371-
//en-char ::= digit | letter
372-
//letter ::= [a-zA-Z]
373-
//digit ::= [6-9]
370+
// root ::= ([ \t\n])* en-char+ ([ \t\n] en-char+)*
371+
// en-char ::= digit | letter
372+
// letter ::= [a-zA-Z]
373+
// digit ::= [0-9]
374374
// )"""";
375-
//
375+
376376
// ac::llama::Instance inst(*model, iparams);
377377
// inst.warmup(); // should be safe
378-
//
378+
379379
// auto& s = inst.startSession({});
380-
// std::vector<ac::llama::Token> tokens = model->vocab().tokenize("My name is Daniel and my age is", true, true);
380+
// std::vector<ac::llama::Token> tokens = model->vocab().tokenize("My name is Daniel and my age (with digits) is", true, true);
381381
// s.setInitialPrompt(tokens);
382382
// std::string text;
383383
// for (int i = 0; i < 5; ++i) {
384384
// auto t = s.getToken();
385385
// REQUIRE(t != ac::llama::Token_Invalid);
386386
// text += model->vocab().tokenToString(t);
387387
// }
388-
//
389-
// CHECK(text == "s about 9 years old");
388+
389+
// CHECK(text == " 14 and my parents are");
390390
// }
391-
//
391+
392392
// SUBCASE("Numbers 1-5 only") {
393393
// ac::llama::Instance::InitParams iparams;
394394
// iparams.grammar = R""""(
395-
//root ::= en-char+ ([ \t\n] en-char+)*
396-
//en-char ::= digit | letter
397-
//letter ::= [a-zA-Z]
398-
//digit ::= [1-5]
395+
// root ::= ([ \t\n])* en-char+ ([ \t\n] en-char+)*
396+
// en-char ::= digit | letter
397+
// letter ::= [a-zA-Z]
398+
// digit ::= [5-9]
399399
// )"""";
400-
//
400+
401401
// ac::llama::Instance inst(*model, iparams);
402402
// inst.warmup(); // should be safe
403-
//
403+
404404
// auto& s = inst.startSession({});
405-
// std::vector<ac::llama::Token> tokens = model->vocab().tokenize("My name is Daniel and my age is", true, true);
405+
// std::vector<ac::llama::Token> tokens = model->vocab().tokenize("My name is Daniel and my age (with digits) is", true, true);
406406
// s.setInitialPrompt(tokens);
407407
// std::string text;
408408
// for (int i = 0; i < 5; ++i) {
409409
// auto t = s.getToken();
410410
// REQUIRE(t != ac::llama::Token_Invalid);
411411
// text += model->vocab().tokenToString(t);
412412
// }
413-
//
414-
// CHECK(text == "54 and I am an");
413+
414+
// CHECK(text == " about seven years old and");
415415
// }
416-
//
416+
417417
// SUBCASE("All capital letters") {
418418
// ac::llama::Instance::InitParams iparams;
419419
// iparams.grammar = R""""(
420-
//root ::= en-char+ ([ \t\n] en-char+)*
421-
//en-char ::= letter
422-
//letter ::= [A-Z]
420+
// root ::= ([ \t\n])* en-char+ ([ \t\n] en-char+)*
421+
// en-char ::= letter
422+
// letter ::= [A-Z]
423423
// )"""";
424-
//
424+
425425
// ac::llama::Instance inst(*model, iparams);
426426
// inst.warmup(); // should be safe
427-
//
427+
428428
// auto& s = inst.startSession({});
429429
// std::vector<ac::llama::Token> tokens = model->vocab().tokenize("My name is Daniel and my age is", true, true);
430430
// s.setInitialPrompt(tokens);
@@ -434,10 +434,10 @@ TEST_CASE("control_vector") {
434434
// REQUIRE(t != ac::llama::Token_Invalid);
435435
// text += model->vocab().tokenToString(t);
436436
// }
437-
//
437+
438438
// CHECK(text == "ELLIE JONES");
439439
// }
440-
//}
440+
// }
441441

442442
TEST_CASE("embedding") {
443443
const char* Model_bge_small_en = AC_TEST_DATA_LLAMA_DIR "/bge-small-en-v1.5-f16.gguf";

0 commit comments

Comments
 (0)