Skip to content
Merged
Changes from 3 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
24 changes: 19 additions & 5 deletions common/arg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,8 @@ static bool common_params_parse_ex(int argc, char ** argv, common_params_context
}
};

std::set<std::string> seen_args;

for (int i = 1; i < argc; i++) {
const std::string arg_prefix = "--";

Expand All @@ -430,6 +432,10 @@ static bool common_params_parse_ex(int argc, char ** argv, common_params_context
if (arg_to_options.find(arg) == arg_to_options.end()) {
throw std::invalid_argument(string_format("error: invalid argument: %s", arg.c_str()));
}
if (seen_args.count(arg) > 0) {
Comment thread
ServeurpersoCom marked this conversation as resolved.
Outdated
LOG_WRN("DEPRECATED: argument '%s' specified multiple times, use comma-separated values instead (only last value will be used)\n", arg.c_str());
}
seen_args.insert(arg);
auto & tmp = arg_to_options[arg];
auto opt = *tmp.first;
bool is_positive = tmp.second;
Expand Down Expand Up @@ -750,6 +756,8 @@ bool common_params_to_map(int argc, char ** argv, llama_example ex, std::map<com
}
};

std::set<std::string> seen_args;

for (int i = 1; i < argc; i++) {
const std::string arg_prefix = "--";

Expand All @@ -760,6 +768,10 @@ bool common_params_to_map(int argc, char ** argv, llama_example ex, std::map<com
if (arg_to_options.find(arg) == arg_to_options.end()) {
throw std::invalid_argument(string_format("error: invalid argument: %s", arg.c_str()));
}
if (seen_args.count(arg) > 0) {
LOG_WRN("DEPRECATED: argument '%s' specified multiple times, use comma-separated values instead (only last value will be used)\n", arg.c_str());
}
seen_args.insert(arg);
auto opt = *arg_to_options[arg];
std::string val;
if (opt.value_hint != nullptr) {
Expand Down Expand Up @@ -2192,12 +2204,14 @@ common_params_context common_params_parser_init(common_params & params, llama_ex
}
));
add_opt(common_arg(
{"--override-kv"}, "KEY=TYPE:VALUE",
"advanced option to override model metadata by key. may be specified multiple times.\n"
"types: int, float, bool, str. example: --override-kv tokenizer.ggml.add_bos_token=bool:false",
{"--override-kv"}, "KEY=TYPE:VALUE,...",
"advanced option to override model metadata by key. to specify multiple overrides, either use comma-separated or repeat this argument.\n"
"types: int, float, bool, str. example: --override-kv tokenizer.ggml.add_bos_token=bool:false,tokenizer.ggml.add_eos_token=bool:false",
[](common_params & params, const std::string & value) {
if (!string_parse_kv_override(value.c_str(), params.kv_overrides)) {
throw std::runtime_error(string_format("error: Invalid type for KV override: %s\n", value.c_str()));
for (const auto & kv_override : string_split<std::string>(value, ',')) {
if (!string_parse_kv_override(kv_override.c_str(), params.kv_overrides)) {
throw std::runtime_error(string_format("error: Invalid type for KV override: %s\n", kv_override.c_str()));
}
}
}
));
Expand Down
Loading