solve process prompt bug
fix #6823 for example ``` What credit card company is on the banner in the background?\nAnswer the question using a single word or phrase. ``` notice the different tokenization result of '\n' before fix, the verbose-prompt result is: ``` 2061 -> 'What' 3884 -> ' credit' 2657 -> ' card' 1664 -> ' company' 318 -> ' is' 319 -> ' on' 262 -> ' the' 17625 -> ' banner' 287 -> ' in' 262 -> ' the' 4469 -> ' background' 30 -> '?' 59 -> '\' 77 -> 'n' 33706 -> 'Answer' 262 -> ' the' 1808 -> ' question' 1262 -> ' using' 257 -> ' a' 2060 -> ' single' 1573 -> ' word' 393 -> ' or' 9546 -> ' phrase' 13 -> '.' ``` after fix: ``` 2061 -> 'What' 3884 -> ' credit' 2657 -> ' card' 1664 -> ' company' 318 -> ' is' 319 -> ' on' 262 -> ' the' 17625 -> ' banner' 287 -> ' in' 262 -> ' the' 4469 -> ' background' 30 -> '?' 198 -> ' ' 33706 -> 'Answer' 262 -> ' the' 1808 -> ' question' 1262 -> ' using' 257 -> ' a' 2060 -> ' single' 1573 -> ' word' 393 -> ' or' 9546 -> ' phrase' 13 -> '. ```
This commit is contained in:
parent
1c570d8bee
commit
3176c2f561
1 changed files with 11 additions and 1 deletions
|
@ -272,6 +272,15 @@ static void llama_log_callback_logTee(ggml_log_level level, const char * text, v
|
|||
LOG_TEE("%s", text);
|
||||
}
|
||||
|
||||
static std::string replaceWithN(std::string& input) {
|
||||
size_t pos = 0;
|
||||
while ((pos = input.find("\\n", pos)) != std::string::npos) {
|
||||
input.replace(pos, 2, "\n");
|
||||
pos += 1;
|
||||
}
|
||||
return input;
|
||||
}
|
||||
|
||||
int main(int argc, char ** argv) {
|
||||
ggml_time_init();
|
||||
|
||||
|
@ -310,6 +319,7 @@ int main(int argc, char ** argv) {
|
|||
}
|
||||
|
||||
// process the prompt
|
||||
params.prompt = replaceWithN(params.prompt);
|
||||
process_prompt(ctx_llava, image_embed, ¶ms, params.prompt);
|
||||
|
||||
llama_print_timings(ctx_llava->ctx_llama);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue