diff options
author | vvhg1 <94630311+vvhg1@users.noreply.github.com> | 2023-10-10 09:31:21 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-10 10:31:21 +0300 |
commit | 11ea5c7d96f2c28e1c99659e08ec0a44574056e2 (patch) | |
tree | 2ab7b5099157439bce85929ce544ec7a971e3b31 /examples/server/server.cpp | |
parent | 95bd60a0a69f57e9a2ff1269667ea484a1a9bb40 (diff) |
infill. : fix tokenization (#3508)
* infill tokens correction
* serverinfill tokens correction
* removing any leading whitespace from infill suffix and removing leeading space token from suffix when params.escape
* removing any leading whitespace from infill suffix and removing leeading space token from suffix when params.escape
* only rm when params.escape, rm space if possible which is added back or rm added space token
* only rm when params.escape, rm space if possible which is added back or rm added space token
* Revert "only rm when params.escape, rm space if possible which is added back or rm added space token"
This reverts commit 63ba0b621f21077c0e3bc6ba6a327534123cb738.
* fix interactive prompt escaping and fix server infill leading space handling
* rm unnecessary bool check
Diffstat (limited to 'examples/server/server.cpp')
-rw-r--r-- | examples/server/server.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/examples/server/server.cpp b/examples/server/server.cpp index c53a6486..8c5318c6 100644 --- a/examples/server/server.cpp +++ b/examples/server/server.cpp @@ -344,9 +344,20 @@ struct llama_server_context void loadInfill() { - auto prefix_tokens = tokenize(params.input_prefix, true); // always add BOS - auto suffix_tokens = tokenize(params.input_suffix, true); // always add BOS + bool suff_rm_leading_spc = true; + if (params.input_suffix.find_first_of(" ") == 0 && params.input_suffix.size() > 1) { + params.input_suffix.erase(0, 1); + suff_rm_leading_spc = false; + } + + auto prefix_tokens = tokenize(params.input_prefix, false); + auto suffix_tokens = tokenize(params.input_suffix, false); + const int space_token = 29871; + if (suff_rm_leading_spc && suffix_tokens[0] == space_token) { + suffix_tokens.erase(suffix_tokens.begin()); + } prefix_tokens.insert(prefix_tokens.begin(), llama_token_prefix(ctx)); + prefix_tokens.insert(prefix_tokens.begin(), llama_token_bos(ctx)); // always add BOS prefix_tokens.insert(prefix_tokens.end(), llama_token_suffix(ctx)); prefix_tokens.insert(prefix_tokens.end(), suffix_tokens.begin(), suffix_tokens.end()); prefix_tokens.push_back(llama_token_middle(ctx)); |