Skip to content

Commit 3164856

Browse files
committed
Fix logits processors tests
1 parent 9f491b9 commit 3164856

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

tests/utils/logits_process.test.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,17 @@ describe("Logits Processors", () => {
3535
async () => {
3636
const text_input = "hello";
3737

38-
const generated_text_target = " Bert explicit wed digasset";
38+
const generated_text_target = "\uff0d Giuseppeitte natoud";
3939
const text_target = [{ generated_text: text_input + generated_text_target }];
4040

4141
const output = await pipe(text_input, {
4242
max_new_tokens: 5,
4343
bad_words_ids: [
44-
// default: [22172n, 18547n, 8136n, 16012n, 28064n, 11361n]
44+
// default: [1n, 22172n, 18547n, 8143n, 22202n, 9456n, 17213n]
4545
[18547],
4646

47-
// block #1: [22172n, 16662n, 6261n, 18916n, 29109n, 799n]
48-
[6261, 18916],
47+
// block #1: [1n, 22172n, 31583n, 18824n, 16621n, 8136n, 16012n]
48+
[18824, 16621],
4949
],
5050
});
5151
compare(output, text_target);
@@ -58,22 +58,22 @@ describe("Logits Processors", () => {
5858
async () => {
5959
const text_input = "hello";
6060

61-
const generated_text_target = "erdingsdeletearus)?nor";
61+
const generated_text_target = "erdingsdelete войsequ族";
6262
const text_target = [{ generated_text: text_input + generated_text_target }];
6363

6464
// Construct long list of bad words
6565
const bad_words_ids = [];
66-
// default: [22172n, 18547n, 8136n, 16012n, 28064n, 11361n]
66+
// default: [1n, 22172n, 18547n, 8143n, 22202n, 9456n, 17213n]
6767
for (let i = 0; i < 100000; ++i) {
6868
bad_words_ids.push([i * 2]); // block all even numbers
6969
}
70-
// block #1: [22172n, 18547n, 8143n, 30327n, 20061n, 18193n]
70+
// block #1: [1n, 22172n, 18547n, 8143n, 30327n, 624n, 2806n, 2004n]
7171
bad_words_ids.push([8143, 30327]);
7272

73-
// block #2: [22172n, 18547n, 8143n, 29485n, 3799n, 29331n]
73+
// block #2: [1n, 22172n, 18547n, 8143n, 29485n, 3799n, 29331n]
7474
bad_words_ids.push([18547, 8143, 29485]);
7575

76-
// block #3: [22172n, 18547n, 8143n, 26465n, 6877n, 15459n]
76+
// block #3: [1n, 22172n, 18547n, 8143n, 7587n, 6831n, 30999n]
7777
const output = await pipe(text_input, { max_new_tokens: 5, bad_words_ids });
7878
compare(output, text_target);
7979
},
@@ -85,19 +85,19 @@ describe("Logits Processors", () => {
8585
async () => {
8686
const text_input = "this is a test";
8787

88-
const generated_text_target = "кт México constructed lake user";
88+
const generated_text_target = "кт México constructed lake års";
8989
const text_target = [{ generated_text: text_input + generated_text_target }];
9090

9191
const output = await pipe(text_input, {
9292
max_new_tokens: 5,
9393
bad_words_ids: [
94-
// default: [445n, 338n, 263n, 1243n, 3931n, 14756n, 7811n, 21645n, 16426n]
94+
// default: [1n, 445n, 338n, 263n, 1243n, 3931n, 14756n, 7811n, 21645n, 31252n]
9595
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3931], // should never trigger (longer than input sequence)
9696

97-
// block #1: [445n, 338n, 263n, 1243n, 3931n, 14756n, 7811n, 21645n, 16426n]
97+
// block #1: [1n, 445n, 338n, 263n, 1243n, 3931n, 14756n, 7811n, 21645n, 31252n]
9898
[3931, 14756, 7811],
9999

100-
// result: [445n, 338n, 263n, 1243n, 3931n, 14756n, 13319n, 19437n, 1404n]
100+
// result: [445n, 338n, 263n, 1243n, 3931n, 14756n, 13319n, 19437n, 21948n]
101101
],
102102
});
103103
compare(output, text_target);

0 commit comments

Comments
 (0)