Skip to content

Commit 55c088f

Browse files
committed
add_special option for server tokenize endpoint
1 parent 60325fa commit 55c088f

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

examples/server/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ Notice that each `probs` is an array of length `n_probs`.
319319

320320
`content`: Set the text to tokenize.
321321

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

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

examples/server/server.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3632,7 +3632,8 @@ int main(int argc, char ** argv) {
36323632

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

0 commit comments

Comments
 (0)