| Marc Kupietz | 50de14a | 2026-07-31 14:48:02 +0900 | [diff] [blame] | 1 | /* Writes the memory mappable form of an already trained model, so that |
| 2 | * derekovecs does not have to build it itself on its first start. dereko2vec |
| 3 | * does this right after training, this tool is for models that were trained |
| 4 | * before, or whose converted files were lost. |
| 5 | */ |
| 6 | |
| 7 | #include <stdio.h> |
| 8 | #include <string.h> |
| 9 | |
| 10 | #include "mmap_vecs.h" |
| 11 | |
| 12 | int main(int argc, char **argv) { |
| 13 | int i; |
| 14 | |
| 15 | if (argc < 2 || strcmp(argv[1], "-h") == 0) { |
| 16 | printf("usage: %s <model.vecs> [<model.vecs> ...]\n\n" |
| 17 | "Writes <model.vecs>.vecs and <model.vecs>.words, the memory\n" |
| 18 | "mappable form derekovecs uses.\n", argv[0]); |
| 19 | return argc < 2 ? 1 : 0; |
| 20 | } |
| 21 | |
| 22 | for (i = 1; i < argc; i++) { |
| 23 | printf("Converting %s to memory mappable structures\n", argv[i]); |
| 24 | fflush(stdout); |
| 25 | if (convert_vecs_to_mmap(argv[i]) != 0) |
| 26 | return 1; |
| 27 | } |
| 28 | return 0; |
| 29 | } |