Skip to content

Avoid hardcoding a space at the beginning of the prompt. #1315

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions examples/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,6 @@ int main(int argc, char ** argv) {
return 0;
}

// Add a space in front of the first character to match OG llama tokenizer behavior
params.prompt.insert(0, 1, ' ');

std::string path_session = params.path_session;
std::vector<llama_token> session_tokens;

Expand Down Expand Up @@ -215,9 +212,6 @@ int main(int argc, char ** argv) {
params.interactive = true;
}

// determine newline token
auto llama_token_newline = ::llama_tokenize(ctx, "\n", false);

if (params.verbose_prompt) {
fprintf(stderr, "\n");
fprintf(stderr, "%s: prompt: '%s'\n", __func__, params.prompt.c_str());
Expand Down Expand Up @@ -456,7 +450,7 @@ int main(int argc, char ** argv) {

// replace end of text token with newline token when in interactive mode
if (id == llama_token_eos() && params.interactive && !params.instruct) {
id = llama_token_newline.front();
id = llama_token_nl();
if (params.antiprompt.size() != 0) {
// tokenize and inject first reverse prompt
const auto first_antiprompt = ::llama_tokenize(ctx, params.antiprompt.front(), false);
Expand Down