Skip to content

Commit

Permalink
add_special option for server tokenize endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
JohanAR committed May 3, 2024
1 parent 60325fa commit 55c088f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion examples/server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ Notice that each `probs` is an array of length `n_probs`.

`content`: Set the text to tokenize.

Note that a special `BOS` token is never inserted.
`add_special`: Boolean indicating if special tokens, i.e. `BOS`, should be inserted. Default: `false`

- **POST** `/detokenize`: Convert tokens to text.

Expand Down
3 changes: 2 additions & 1 deletion examples/server/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3632,7 +3632,8 @@ int main(int argc, char ** argv) {

std::vector<llama_token> tokens;
if (body.count("content") != 0) {
tokens = ctx_server.tokenize(body["content"], false);
const bool add_special = json_value(body, "add_special", false);
tokens = ctx_server.tokenize(body["content"], add_special);
}
const json data = format_tokenizer_response(tokens);
return res.set_content(data.dump(), "application/json; charset=utf-8");
Expand Down

0 comments on commit 55c088f

Please sign in to comment.