Skip to content

Commit b9c1aef

Browse files
committed
Do not process prompts containing binary data for escapes
Adopts code from ikawrakow/ik_llama.cpp#33 to fix the broken llama-perplexity.
1 parent b049315 commit b9c1aef

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

common/arg.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -969,7 +969,9 @@ static bool common_params_parse_ex(int argc, char ** argv, common_params_context
969969
}
970970

971971
if (params.escape) {
972-
string_process_escapes(params.prompt);
972+
if (!params.prompt_is_binary) {
973+
string_process_escapes(params.prompt);
974+
}
973975
string_process_escapes(params.input_prefix);
974976
string_process_escapes(params.input_suffix);
975977
for (auto & antiprompt : params.antiprompt) {
@@ -1503,6 +1505,7 @@ common_params_context common_params_parser_init(common_params & params, llama_ex
15031505
"prompt to start generation with; for system message, use -sys",
15041506
[](common_params & params, const std::string & value) {
15051507
params.prompt = value;
1508+
params.prompt_is_binary = false;
15061509
}
15071510
).set_excludes({LLAMA_EXAMPLE_SERVER}));
15081511
add_opt(common_arg(
@@ -1530,6 +1533,7 @@ common_params_context common_params_parser_init(common_params & params, llama_ex
15301533
if (!params.prompt.empty() && params.prompt.back() == '\n') {
15311534
params.prompt.pop_back();
15321535
}
1536+
params.prompt_is_binary = false;
15331537
}
15341538
).set_excludes({LLAMA_EXAMPLE_SERVER}));
15351539
add_opt(common_arg(
@@ -1567,6 +1571,7 @@ common_params_context common_params_parser_init(common_params & params, llama_ex
15671571
ss << file.rdbuf();
15681572
params.prompt = ss.str();
15691573
fprintf(stderr, "Read %zu bytes from binary file %s\n", params.prompt.size(), value.c_str());
1574+
params.prompt_is_binary = true;
15701575
}
15711576
).set_excludes({LLAMA_EXAMPLE_SERVER}));
15721577
add_opt(common_arg(

common/common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,7 @@ struct common_params {
330330

331331
bool multiple_choice = false; // compute TruthfulQA score over random tasks from datafile supplied in prompt
332332
size_t multiple_choice_tasks = 0; // number of tasks to use when computing the TruthfulQA score. If 0, all tasks will be computed
333+
bool prompt_is_binary = false; // don't fool around when the prompt contains binary data (as it is for multiple choice)
333334

334335
bool kl_divergence = false; // compute KL divergence
335336

0 commit comments

Comments
 (0)