cui-llama.rn 1.2.0 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/README.md +2 -0
  2. package/android/src/main/CMakeLists.txt +2 -2
  3. package/android/src/main/java/com/rnllama/LlamaContext.java +31 -9
  4. package/android/src/main/java/com/rnllama/RNLlama.java +39 -0
  5. package/android/src/newarch/java/com/rnllama/RNLlamaModule.java +5 -0
  6. package/android/src/oldarch/java/com/rnllama/RNLlamaModule.java +5 -0
  7. package/cpp/common.cpp +36 -1
  8. package/cpp/common.h +5 -1
  9. package/cpp/ggml-aarch64.c +2 -11
  10. package/cpp/ggml-alloc.h +1 -1
  11. package/cpp/ggml-backend-impl.h +151 -78
  12. package/cpp/{ggml-backend.c → ggml-backend.cpp} +565 -269
  13. package/cpp/ggml-backend.h +147 -62
  14. package/cpp/ggml-impl.h +15 -0
  15. package/cpp/ggml-metal.h +8 -9
  16. package/cpp/ggml-metal.m +2428 -2111
  17. package/cpp/ggml-quants.c +2 -2
  18. package/cpp/ggml-quants.h +0 -4
  19. package/cpp/ggml.c +799 -1121
  20. package/cpp/ggml.h +79 -72
  21. package/cpp/llama-vocab.cpp +189 -106
  22. package/cpp/llama-vocab.h +18 -9
  23. package/cpp/llama.cpp +736 -341
  24. package/cpp/llama.h +9 -4
  25. package/cpp/unicode-data.cpp +6 -4
  26. package/cpp/unicode-data.h +4 -4
  27. package/cpp/unicode.cpp +14 -7
  28. package/lib/commonjs/NativeRNLlama.js.map +1 -1
  29. package/lib/commonjs/index.js +4 -0
  30. package/lib/commonjs/index.js.map +1 -1
  31. package/lib/module/NativeRNLlama.js.map +1 -1
  32. package/lib/module/index.js +3 -0
  33. package/lib/module/index.js.map +1 -1
  34. package/lib/typescript/NativeRNLlama.d.ts +6 -0
  35. package/lib/typescript/NativeRNLlama.d.ts.map +1 -1
  36. package/lib/typescript/index.d.ts +2 -1
  37. package/lib/typescript/index.d.ts.map +1 -1
  38. package/package.json +1 -1
  39. package/src/NativeRNLlama.ts +7 -0
  40. package/src/index.ts +5 -0
package/cpp/llama-vocab.h CHANGED
@@ -8,6 +8,8 @@
8
8
  #include <map>
9
9
  #include <set>
10
10
 
11
+ struct llm_tokenizer;
12
+
11
13
  struct llama_vocab {
12
14
  using id = llama_token;
13
15
  using token = std::string;
@@ -38,17 +40,17 @@ struct llama_vocab {
38
40
  id special_bos_id = 1;
39
41
  id special_eos_id = 2;
40
42
  id special_unk_id = 0;
41
- id special_sep_id = -1;
42
- id special_pad_id = -1;
43
- id special_cls_id = -1;
44
- id special_mask_id = -1;
43
+ id special_sep_id = LLAMA_TOKEN_NULL;
44
+ id special_pad_id = LLAMA_TOKEN_NULL;
45
+ id special_cls_id = LLAMA_TOKEN_NULL;
46
+ id special_mask_id = LLAMA_TOKEN_NULL;
45
47
 
46
48
  id linefeed_id = 13;
47
- id special_prefix_id = -1;
48
- id special_suffix_id = -1;
49
- id special_middle_id = -1;
50
- id special_eot_id = -1; // TODO: move above after "eos_id", and here add "file separator" token
51
- id special_eom_id = -1;
49
+ id special_prefix_id = LLAMA_TOKEN_NULL;
50
+ id special_suffix_id = LLAMA_TOKEN_NULL;
51
+ id special_middle_id = LLAMA_TOKEN_NULL;
52
+ id special_eot_id = LLAMA_TOKEN_NULL; // TODO: move above after "eos_id", and here add "file separator" token
53
+ id special_eom_id = LLAMA_TOKEN_NULL;
52
54
 
53
55
  // set of all tokens that cause "end of generation"
54
56
  std::set<id> special_eog_ids;
@@ -65,7 +67,14 @@ struct llama_vocab {
65
67
 
66
68
  std::vector<char> precompiled_charsmap;
67
69
 
70
+ llm_tokenizer * tokenizer = nullptr;
71
+
72
+ llama_vocab() = default;
73
+ ~llama_vocab();
74
+
68
75
  int find_bpe_rank(const std::string & token_left, const std::string & token_right) const;
76
+
77
+ void init_tokenizer();
69
78
  };
70
79
 
71
80
  //