@@ -204,21 +204,17 @@ int main(int argc, char ** argv) {
204
204
GGML_ASSERT (llama_add_eos_token (model) != 1 );
205
205
LOG (" add_bos: %d\n " , add_bos);
206
206
207
- bool suff_rm_leading_spc = params.escape ;
208
- if (suff_rm_leading_spc && params.input_suffix .find_first_of (' ' ) == 0 && params.input_suffix .size () > 1 ) {
209
- params.input_suffix .erase (0 , 1 );
210
- suff_rm_leading_spc = false ;
211
- }
212
207
std::vector<llama_token> embd_inp;
213
208
std::vector<llama_token> embd_end;
214
209
std::vector<llama_token> inp_pfx = ::llama_tokenize (ctx, params.input_prefix , false );
215
210
std::vector<llama_token> inp_sfx = ::llama_tokenize (ctx, params.input_suffix , false );
216
- const int space_token = 29871 ;
217
- if (suff_rm_leading_spc && inp_sfx[ 0 ] == space_token) {
218
- inp_sfx. erase (inp_sfx. begin () );
219
- }
211
+
212
+ GGML_ASSERT ( llama_token_prefix (model) >= 0 );
213
+ GGML_ASSERT ( llama_token_suffix (model) >= 0 );
214
+
220
215
inp_pfx.insert (inp_pfx.begin (), llama_token_prefix (model));
221
216
inp_sfx.insert (inp_sfx.begin (), llama_token_suffix (model));
217
+
222
218
embd_inp = params.spm_infill ? inp_sfx : inp_pfx;
223
219
embd_end = params.spm_infill ? inp_pfx : inp_sfx;
224
220
if (add_bos) {
@@ -516,19 +512,14 @@ int main(int argc, char ** argv) {
516
512
string_process_escapes (params.input_prefix );
517
513
string_process_escapes (params.input_suffix );
518
514
}
519
- suff_rm_leading_spc = params.escape ;
520
- if (suff_rm_leading_spc && params.input_suffix .find_first_of (' ' ) == 0 && params.input_suffix .size () > 1 ) {
521
- params.input_suffix .erase (0 , 1 );
522
- suff_rm_leading_spc = false ;
523
- }
515
+
524
516
// tokenize new prefix and suffix
525
517
std::vector<llama_token> inp_pfx = ::llama_tokenize (ctx, params.input_prefix , false );
526
518
std::vector<llama_token> inp_sfx = ::llama_tokenize (ctx, params.input_suffix , false );
527
- if (suff_rm_leading_spc && inp_sfx[0 ] == space_token) {
528
- inp_sfx.erase (inp_sfx.begin ());
529
- }
519
+
530
520
inp_pfx.insert (inp_pfx.begin (), llama_token_prefix (model));
531
521
inp_sfx.insert (inp_sfx.begin (), llama_token_suffix (model));
522
+
532
523
embd_inp = params.spm_infill ? inp_sfx : inp_pfx;
533
524
embd_end = params.spm_infill ? inp_pfx : inp_sfx;
534
525
if (add_bos) {
0 commit comments