Skip to content

Commit 1320897

Browse files
committed
Remove new APIs
1 parent d8485ad commit 1320897

File tree

5 files changed

+12
-29
lines changed

5 files changed

+12
-29
lines changed

common/common.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1748,11 +1748,6 @@ std::string common_token_to_piece(const struct llama_vocab * vocab, llama_token
17481748
return piece;
17491749
}
17501750

1751-
bool can_be_detokenized(const struct llama_context * ctx, const std::vector<llama_token> & tokens) {
1752-
const llama_model * model = llama_get_model(ctx);
1753-
const llama_vocab * vocab = llama_model_get_vocab(model);
1754-
return can_detokenize(vocab, tokens.data(), (int32_t) tokens.size());
1755-
}
17561751

17571752
std::string common_detokenize(const struct llama_context * ctx, const std::vector<llama_token> & tokens, bool special) {
17581753
const llama_model * model = llama_get_model(ctx);

common/common.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -593,10 +593,6 @@ size_t common_lcs(const llama_tokens & a, const llama_tokens & b);
593593
// Vocab utils
594594
//
595595

596-
bool can_be_detokenized(
597-
const struct llama_context * ctx,
598-
const std::vector<llama_token> & tokens);
599-
600596
// tokenizes a string into a vector of tokens
601597
// should work similar to Python's `tokenizer.encode`
602598
std::vector<llama_token> common_tokenize(

examples/server/server.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2040,6 +2040,18 @@ struct server_context {
20402040
return ret;
20412041
}
20422042

2043+
bool can_be_detokenized(const struct llama_context * ctx, const std::vector<llama_token> & tokens) {
2044+
const llama_model * model = llama_get_model(ctx);
2045+
const llama_vocab * vocab = llama_model_get_vocab(model);
2046+
const int32_t n_vocab = llama_vocab_n_tokens(vocab);
2047+
for (const auto& token : tokens) {
2048+
if (token < 0 || token >= n_vocab) {
2049+
return false;
2050+
}
2051+
}
2052+
return true;
2053+
}
2054+
20432055
bool launch_slot_with_task(server_slot & slot, const server_task & task) {
20442056
slot.reset();
20452057
slot.id_task = task.id;

src/llama-vocab.cpp

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1279,7 +1279,6 @@ struct llama_vocab::impl {
12791279

12801280
std::string type_name() const;
12811281

1282-
bool is_valid (llama_token id) const;
12831282
bool is_normal (llama_token id) const;
12841283
bool is_unknown (llama_token id) const;
12851284
bool is_control (llama_token id) const;
@@ -2069,11 +2068,6 @@ std::string llama_vocab::impl::type_name() const{
20692068
}
20702069
}
20712070

2072-
bool llama_vocab::impl::is_valid(llama_token id) const {
2073-
GGML_ASSERT(type != LLAMA_VOCAB_TYPE_NONE);
2074-
return 0 <= id && id < (int32_t) id_to_token.size();
2075-
}
2076-
20772071
bool llama_vocab::impl::is_normal(llama_token id) const {
20782072
GGML_ASSERT(type != LLAMA_VOCAB_TYPE_NONE);
20792073
return id_to_token[id].attr & LLAMA_TOKEN_ATTR_NORMAL;
@@ -2766,10 +2760,6 @@ std::string llama_vocab::type_name() const{
27662760
return pimpl->type_name();
27672761
}
27682762

2769-
bool llama_vocab::is_valid(llama_token id) const {
2770-
return pimpl->is_valid(id);
2771-
}
2772-
27732763
bool llama_vocab::is_normal(llama_token id) const {
27742764
return pimpl->is_normal(id);
27752765
}
@@ -3271,12 +3261,3 @@ int32_t llama_detokenize(
32713261
bool unparse_special) {
32723262
return vocab->detokenize(tokens, n_tokens, text, text_len_max, remove_special, unparse_special);
32733263
}
3274-
3275-
bool can_detokenize(const struct llama_vocab * vocab, const llama_token * tokens, int32_t n_tokens) {
3276-
for (int32_t i = 0; i < n_tokens; ++i) {
3277-
if (!vocab->is_valid(tokens[i])) {
3278-
return false;
3279-
}
3280-
}
3281-
return true;
3282-
}

src/llama-vocab.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ struct llama_vocab {
2929

3030
std::string type_name() const;
3131

32-
bool is_valid (llama_token id) const;
3332
bool is_normal (llama_token id) const;
3433
bool is_unknown (llama_token id) const;
3534
bool is_control (llama_token id) const;

0 commit comments

Comments
 (0)