-
Notifications
You must be signed in to change notification settings - Fork 6
/
test.js
74 lines (52 loc) · 1.46 KB
/
test.js
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
const { dirname } = require('path');
const __root = dirname(require.main.filename);
const { Language: LanguageModel } = require('./models');
const DefaultDataset = require(`${__root}/training/datasets/Default`);
const withDataset = async (dataset, query) => {
const agent = await LanguageModel({
dataset
});
console.log(`query: ${query}`);
// Log next token prediction
console.log(
'getTokenPrediction >>',
`query: ${query}`,
agent.getTokenPrediction(query)
);
};
const withBootstrap = async query => {
// Bootstrap with a default dataset
const agent = await LanguageModel({
bootstrap: true
});
// Log completions
console.log(
'getCompletions >>',
`query: ${query}`,
agent.getCompletions(query)
);
};
const withFiles = async (files, query) => {
const agent = await LanguageModel({
files
});
// Log completion
console.log(
'complete >>',
`query: ${query}`,
agent.complete(query)
);
};
const runTests = async () => {
// Unit: Run different queries in isolation
// with different datasets
await withDataset(DefaultDataset, 'luckily');
await withDataset(DefaultDataset, 'with all');
await withDataset(DefaultDataset, 'grass');
await withDataset(DefaultDataset, 'unless');
// e2e: Run training on user provided files
await withFiles(['the-phantom-of-the-opera'], 'eloquence');
// e2e: Run training from bootstrap then query
await withBootstrap('people');
};
runTests();