cui-llama.rn 1.3.4 → 1.3.5

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.
@@ -58,6 +58,7 @@ using llama_grammar_rules = std::vector<llama_grammar_rule>;
58
58
  using llama_grammar_stacks = std::vector<llama_grammar_stack>;
59
59
  using llama_grammar_candidates = std::vector<llama_grammar_candidate>;
60
60
 
61
+ // TODO: remove, needed for tests atm
61
62
  const llama_grammar_rules & llama_grammar_get_rules (const struct llama_grammar * grammar);
62
63
  llama_grammar_stacks & llama_grammar_get_stacks( struct llama_grammar * grammar);
63
64
 
@@ -65,11 +66,7 @@ const llama_grammar_rules & llama_grammar_get_rules (const struct llama_grammar
65
66
  // be positioned at a character range (see `llama_grammar_advance_stack`), and
66
67
  // produces the N possible stacks if the given char is accepted at those
67
68
  // positions
68
- void llama_grammar_accept(
69
- const llama_grammar_rules & rules,
70
- const llama_grammar_stacks & stacks,
71
- uint32_t chr,
72
- llama_grammar_stacks & stacks_new);
69
+ void llama_grammar_accept(struct llama_grammar * grammar, uint32_t chr);
73
70
 
74
71
  std::vector<llama_grammar_candidate> llama_grammar_reject_candidates_for_stack(
75
72
  const llama_grammar_rules & rules,
@@ -1657,7 +1657,7 @@ bool llama_token_is_control_impl(const struct llama_vocab & vocab, llama_token t
1657
1657
  }
1658
1658
 
1659
1659
  llama_token llama_token_bos_impl(const struct llama_vocab & vocab) {
1660
- return vocab.special_bos_id;
1660
+ return vocab.type != LLAMA_VOCAB_TYPE_WPM ? vocab.special_bos_id : vocab.special_cls_id;
1661
1661
  }
1662
1662
 
1663
1663
  llama_token llama_token_eos_impl(const struct llama_vocab & vocab) {
@@ -1867,6 +1867,10 @@ int32_t llama_detokenize_impl(
1867
1867
  int32_t text_len_max,
1868
1868
  bool remove_special,
1869
1869
  bool unparse_special) {
1870
+ if (vocab.type == LLAMA_VOCAB_TYPE_NONE) {
1871
+ return 0;
1872
+ }
1873
+
1870
1874
  LM_GGML_ASSERT(vocab.tokenizer && "Tokenizer not initialized. Call llama_vocab::init_tokenizer() first.");
1871
1875
 
1872
1876
  int32_t avail = text_len_max;
package/cpp/llama-vocab.h CHANGED
@@ -45,7 +45,7 @@ struct llama_vocab {
45
45
  id special_unk_id = 0;
46
46
  id special_sep_id = LLAMA_TOKEN_NULL;
47
47
  id special_pad_id = LLAMA_TOKEN_NULL;
48
- id special_cls_id = LLAMA_TOKEN_NULL;
48
+ id special_cls_id = LLAMA_TOKEN_NULL; // TODO: revisit if this is really needed https://github.com/ggerganov/llama.cpp/pull/10930
49
49
  id special_mask_id = LLAMA_TOKEN_NULL;
50
50
 
51
51
  id linefeed_id = 13;