Skip to content

Commit 3ca1717

Browse files
committed
Remove use of strcasecmp, help fixes
1 parent 28800f8 commit 3ca1717

File tree

1 file changed

+32
-32
lines changed

1 file changed

+32
-32
lines changed

examples/common.cpp

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -113,34 +113,34 @@ void seqrep_sampler_params_dump(FILE * fp, llama_sampler_seqrep_params * params)
113113
void seqrep_sampler_help() {
114114
llama_sampler_seqrep_params p;
115115
seqrep_sampler_params_init(&p);
116-
fprintf(stderr, "==== Sequence Repetition Sampler Help ====\n\n");
117-
fprintf(stderr, " The sequence repetition sampler takes a configuration string in the format:\n");
118-
fprintf(stderr, " arg1:arg2:argN\n");
119-
fprintf(stderr, " A colon separated argument can be a key value pair like xyz=1 or flag like xyz\n");
120-
fprintf(stderr, "\n- Available key/value arguments\n");
121-
fprintf(stderr, " * repetition_mode=REPEAT_PENALTY\n emulates the repetition penalty sampler. warning: 1.0 disables penalties since this preset enables flag_divide_by_penalty. using 0.0 is probably not what you want\n");
122-
fprintf(stderr, " * presence_mode=PRESENCE_PENALTY\n emulates the presence penalty sampler\n");
123-
fprintf(stderr, " * frequency_mode=FREQUENCY_PENALTY\n Emulates the repetition penalty sampler\n");
124-
fprintf(stderr, " * last_n\n last n tokens to consider for sequence penalizing (default: %d, 0 = disabled, -1 = ctx_size)\n", p.last_n);
125-
fprintf(stderr, " * min_length\n minimum matching sequence length (default: %zd, < 2 = disabled)\n", p.min_length);
126-
fprintf(stderr, " * presence_penalty\n presence penalty for tokens that can continue a sequence (default: %f, 0.0 = disabled)\n", p.presence_penalty);
127-
fprintf(stderr, " * length_penalty\n penalty for tokens that can continue a sequence, multiplied by length (default: %f, 0.0 = disabled)\n", p.length_penalty);
128-
fprintf(stderr, " * tolerance\n tolerance for fuzzy matching sequences (default: %f, 0 = disabled)\n", p.tolerance);
129-
fprintf(stderr, " * mid_word_scale\n scale penalty when for mid-word tokens. 1.0 would mean apply the full penalty (default: %f, 1.0 = disabled)\n", p.mid_word_scale);
130-
fprintf(stderr, " * tolerance_match_credit\n credit tolerance on matched tokens (default: %f, 0.0 = disabled)\n", p.tolerance_match_credit);
131-
fprintf(stderr, " * tolerance_half_step_cost\n advanced option to adjust tolerance cost for failed matches within a half step of a match (default: %f, 1.0 = normal)\n", p.tolerance_half_step_cost);
132-
fprintf(stderr, "\n- Available flags arguments (currently all default to disabled)\n");
133-
fprintf(stderr, " * flag_immediate_wildcard\n when tolerance is consumed, by default it doesn't count as a match until a real match is found\n");
134-
fprintf(stderr, " * flag_tolerance_no_consecutive\n do not allow using tolerance consecutively\n");
135-
fprintf(stderr, " * flag_tolerance_no_first\n do not allow using tolerance before the first match\n");
136-
fprintf(stderr, " * flag_tolerance_cap_initial\n only meaningful with match credit, prevents match credit adjusting tolerance higher than the initial value\n");
137-
fprintf(stderr, " * flag_penalize_length_max_seen\n when applying length_penalty, use the maximum seen sequence length rather than the total length of seen sequences\n");
138-
fprintf(stderr, " * flag_divide_by_penalty\n divide the logit by when applying a penalty rather than subtracting it. warning: when this flag is enabled, 1.0 disables penalties not 0.0. 0.0 is probably not what you want\n");
139-
fprintf(stderr, "\n- Examples:\n");
140-
fprintf(stderr, " * repetition_mode=1.2:last_n=32\n same as --repeat-last-n 32 --repeat-penalty 1.2\n");
141-
fprintf(stderr, " * presence_mode=.2:last_n=32\n same as --repeat-last-n 32 --presence-penalty .2\n");
142-
fprintf(stderr, " * frequency_mode=.2:last_n=32\n same as --repeat-last-n 32 --frequency-penalty .2\n");
143-
fprintf(stderr, " * min_length=3:tolerance=1:length_penalty=.2:last_n=-1\n match repeated sequences of at least 3 tokens within the entire context and apply a penalty of 0.2*total_length to the token that would continue the sequence. allow one non-matching token in matched sequences.\n");
116+
fprintf(stdout, "==== Sequence Repetition Sampler Help ====\n\n");
117+
fprintf(stdout, " The sequence repetition sampler takes a configuration string in the format:\n");
118+
fprintf(stdout, " arg1:arg2:argN\n");
119+
fprintf(stdout, " A colon separated argument can be a key value pair like xyz=1 or flag like xyz\n");
120+
fprintf(stdout, "\n- Available key/value arguments\n");
121+
fprintf(stdout, " * repetition_mode=REPEAT_PENALTY\n emulates the repetition penalty sampler. warning: 1.0 disables penalties since this preset enables flag_divide_by_penalty. using 0.0 is probably not what you want\n");
122+
fprintf(stdout, " * presence_mode=PRESENCE_PENALTY\n emulates the presence penalty sampler\n");
123+
fprintf(stdout, " * frequency_mode=FREQUENCY_PENALTY\n Emulates the repetition penalty sampler\n");
124+
fprintf(stdout, " * last_n\n last n tokens to consider for sequence penalizing (default: %d, 0 = disabled, -1 = ctx_size)\n", p.last_n);
125+
fprintf(stdout, " * min_length\n minimum matching sequence length (default: %zd, < 2 = disabled)\n", p.min_length);
126+
fprintf(stdout, " * presence_penalty\n presence penalty for tokens that can continue a sequence (default: %f, 0.0 = disabled)\n", p.presence_penalty);
127+
fprintf(stdout, " * length_penalty\n penalty for tokens that can continue a sequence, multiplied by length (default: %f, 0.0 = disabled)\n", p.length_penalty);
128+
fprintf(stdout, " * tolerance\n tolerance for fuzzy matching sequences (default: %f, 0 = disabled)\n", p.tolerance);
129+
fprintf(stdout, " * mid_word_scale\n scale penalty when for mid-word tokens. 1.0 would mean apply the full penalty (default: %f, 1.0 = disabled)\n", p.mid_word_scale);
130+
fprintf(stdout, " * tolerance_match_credit\n credit tolerance on matched tokens (default: %f, 0.0 = disabled)\n", p.tolerance_match_credit);
131+
fprintf(stdout, " * tolerance_half_step_cost\n advanced option to adjust tolerance cost for failed matches within a half step of a match (default: %f, 1.0 = normal)\n", p.tolerance_half_step_cost);
132+
fprintf(stdout, "\n- Available flags arguments (currently all default to disabled)\n");
133+
fprintf(stdout, " * flag_immediate_wildcard\n when tolerance is consumed, by default it doesn't count as a match until a real match is found\n");
134+
fprintf(stdout, " * flag_tolerance_no_consecutive\n do not allow using tolerance consecutively\n");
135+
fprintf(stdout, " * flag_tolerance_no_first\n do not allow using tolerance before the first match\n");
136+
fprintf(stdout, " * flag_tolerance_cap_initial\n only meaningful with match credit, prevents match credit adjusting tolerance higher than the initial value\n");
137+
fprintf(stdout, " * flag_penalize_length_max_seen\n when applying length_penalty, use the maximum seen sequence length rather than the total length of seen sequences\n");
138+
fprintf(stdout, " * flag_divide_by_penalty\n divide the logit when applying a penalty rather than subtracting it. warning: when this flag is enabled, 1.0 disables penalties not 0.0. 0.0 is probably not what you want\n");
139+
fprintf(stdout, "\n- Examples:\n");
140+
fprintf(stdout, " * repetition_mode=1.2:last_n=32\n same as --repeat-last-n 32 --repeat-penalty 1.2\n");
141+
fprintf(stdout, " * presence_mode=.2:last_n=32\n same as --repeat-last-n 32 --presence-penalty .2\n");
142+
fprintf(stdout, " * frequency_mode=.2:last_n=32\n same as --repeat-last-n 32 --frequency-penalty .2\n");
143+
fprintf(stdout, " * min_length=3:tolerance=1:length_penalty=.2:last_n=-1\n match repeated sequences of at least 3 tokens within the entire context and apply a penalty of 0.2*total_length to the token that would continue the sequence. allow one non-matching token in matched sequences.\n");
144144
}
145145

146146
bool seqrep_sampler_params_parse(char * s, llama_sampler_seqrep_params * params) {
@@ -396,15 +396,15 @@ bool gpt_params_parse(int argc, char ** argv, gpt_params & params) {
396396
invalid_param = true;
397397
break;
398398
}
399-
if (strcasecmp(argv[i], "help") == 0) {
399+
if (std::strcmp(argv[i], "help") == 0) {
400400
seqrep_sampler_help();
401401
exit(0);
402402
}
403403
llama_sampler_seqrep_params sr_params;
404404
seqrep_sampler_params_init(&sr_params);
405-
invalid_param = !seqrep_sampler_params_parse(argv[i], &sr_params);
406-
if (invalid_param) {
407-
break;
405+
if (!seqrep_sampler_params_parse(argv[i], &sr_params)) {
406+
seqrep_sampler_help();
407+
exit(1);
408408
}
409409
if (sr_params.last_n != 0 && sr_params.min_length > 0
410410
&& (sr_params.presence_penalty != 0.0f || sr_params.length_penalty != 0.0f)) {

0 commit comments

Comments
 (0)