diff options
author | 44670 <44670@users.noreply.github.com> | 2023-05-04 23:41:12 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-04 18:41:12 +0300 |
commit | 2edbdb0f99336cb41f0995061c7602ed54beb863 (patch) | |
tree | 07ab5cb105543166c1ddc50864ba04d8d4e06f30 /examples/main | |
parent | 20fbf2a2a08d8edefe9b3435fa86f8b2f63f8588 (diff) |
main : add --in-suffix option (#1318)
* adding --in-suffix option
* print input suffix before generation
Diffstat (limited to 'examples/main')
-rw-r--r-- | examples/main/README.md | 8 | ||||
-rw-r--r-- | examples/main/main.cpp | 9 |
2 files changed, 17 insertions, 0 deletions
diff --git a/examples/main/README.md b/examples/main/README.md index 6b7facb..35f87bc 100644 --- a/examples/main/README.md +++ b/examples/main/README.md @@ -112,6 +112,14 @@ The `--in-prefix` flag is used to add a prefix to your input, primarily, this is ./main -r "User:" --in-prefix " " ``` +### In-Suffix + +The `--in-suffix` flag is used to add a suffix after your input. This is useful for adding an "Assistant:" prompt after the user's input. It's added after the new-line character (`\n`) that's automatically added to the end of the user's input. Here's an example of how to use the `--in-suffix` flag in conjunction with the `--reverse-prompt` flag: + +```sh +./main -r "User:" --in-prefix " " --in-suffix "Assistant:" +``` + ### Instruction Mode Instruction mode is particularly useful when working with Alpaca models, which are designed to follow user instructions for specific tasks: diff --git a/examples/main/main.cpp b/examples/main/main.cpp index 17a5a90..43dca8e 100644 --- a/examples/main/main.cpp +++ b/examples/main/main.cpp @@ -260,6 +260,10 @@ int main(int argc, char ** argv) { if (!params.input_prefix.empty()) { fprintf(stderr, "Input prefix: '%s'\n", params.input_prefix.c_str()); } + + if (!params.input_suffix.empty()) { + fprintf(stderr, "Input suffix: '%s'\n", params.input_suffix.c_str()); + } } fprintf(stderr, "sampling: repeat_last_n = %d, repeat_penalty = %f, presence_penalty = %f, frequency_penalty = %f, top_k = %d, tfs_z = %f, top_p = %f, typical_p = %f, temp = %f, mirostat = %d, mirostat_lr = %f, mirostat_ent = %f\n", params.repeat_last_n, params.repeat_penalty, params.presence_penalty, params.frequency_penalty, params.top_k, params.tfs_z, params.top_p, params.typical_p, params.temp, params.mirostat, params.mirostat_eta, params.mirostat_tau); @@ -567,6 +571,11 @@ int main(int argc, char ** argv) { // Add tokens to embd only if the input buffer is non-empty // Entering a empty line lets the user pass control back if (buffer.length() > 1) { + // append input suffix if any + if (!params.input_suffix.empty()) { + buffer += params.input_suffix; + printf("%s", params.input_suffix.c_str()); + } // instruct mode: insert instruction prefix if (params.instruct && !is_antiprompt) { |