forked from AdamBien/lightmetal
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlmprobe
More file actions
executable file
·53 lines (47 loc) · 2.05 KB
/
Copy pathlmprobe
File metadata and controls
executable file
·53 lines (47 loc) · 2.05 KB
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
#!/usr/bin/env -S java --enable-native-access=ALL-UNNAMED --source 25 -cp ./zbo/lightmetal.jar:./lightmetal.jar
import module java.base;
import lm.catalog.boundary.ModelCatalog;
import lm.configuration.control.ZCfg;
import lm.inspection.boundary.Inspector;
void main(String... args) {
ZCfg.load("lightmetal");
var fileName = args.length > 0 ? args[0] : ZCfg.string("model");
if (fileName == null) {
System.err.println("lmprobe: no model (pass file name as arg or set model= in ~/.lightmetal/app.properties)");
System.exit(1);
}
var modelPath = ModelCatalog.resolve(fileName);
if (!Files.exists(modelPath)) {
System.err.println("lmprobe: model not found at " + modelPath);
System.exit(1);
}
var meta = Inspector.inspect(modelPath);
IO.println("model: " + meta.name().orElse("?"));
IO.println("arch: " + meta.architecture().orElse("?"));
IO.println("bos: " + meta.bosTokenId().orElse(-1));
IO.println("eos: " + meta.eosTokenId().orElse(-1));
IO.println("add_bos: " + meta.addBosToken().orElse(null));
IO.println();
var tokens = meta.kvs().get("tokenizer.ggml.tokens");
var tokenTypes = meta.kvs().get("tokenizer.ggml.token_type");
if (tokens instanceof Object[] arr) {
IO.println("tokens near 31 (vocab size " + arr.length + "):");
var types = tokenTypes instanceof Object[] t ? t : null;
for (var i = Math.max(0, 25); i < Math.min(arr.length, 40); i++) {
var typeStr = types != null && i < types.length ? " type=" + types[i] : "";
IO.println(" [" + i + "]" + typeStr + " " + arr[i]);
}
} else {
IO.println("tokenizer.ggml.tokens: " + (tokens == null ? "<absent>" : tokens.getClass()));
}
IO.println();
var jinja = meta.chatTemplate().orElse(null);
if (jinja == null) {
IO.println("tokenizer.chat_template: <absent>");
} else {
IO.println("tokenizer.chat_template (" + jinja.length() + " chars):");
IO.println("---");
IO.println(jinja);
IO.println("---");
}
}