Archived
kld: --kld-lora-sources PREFIX, an adapter for some documents and the base for the rest, in the same steps
This commit is contained in:
1 parent
e419c1acc3
commit
63e6d01394
5 files changed
+13
-2
No files matched your search
@@ -236,6 +236,8 @@ static const Flag g_flags[] = {
|
||||
{ "--kld-corpus", "FILE", "JSONL, one {\"prompt\", \"score_from\"?, \"source\"?} a line; --kld-record only" },
|
||||
{ "--kld-out", "FILE", "the --kld-ref report as JSON, and every position's numbers in FILE.rows" },
|
||||
{ "--kld-lora", "NAME", "run --kld-record / --kld-ref through the --lora adapter NAME" },
|
||||
{ "--kld-lora-sources", "PREFIX", "--kld-lora only for documents whose source starts with PREFIX; the\n"
|
||||
" rest run as the base, in the same steps (a mixed batch)" },
|
||||
|
||||
{ "--debug-graph", nullptr, "print the entire declared graph and exit-quality detail" },
|
||||
{ "--debug-selection", nullptr, "print the selection table" },
|
||||
@@ -782,6 +784,7 @@ int config_parse(int argc, char** argv, Config* c) {
|
||||
else if (S("--kld-corpus")) { if (!(v = need(i))) return RAD_E_INVAL; c->kld_corpus = v; }
|
||||
else if (S("--kld-out")) { if (!(v = need(i))) return RAD_E_INVAL; c->kld_out = v; }
|
||||
else if (S("--kld-lora")) { if (!(v = need(i))) return RAD_E_INVAL; c->kld_lora = v; }
|
||||
else if (S("--kld-lora-sources")) { if (!(v = need(i))) return RAD_E_INVAL; c->kld_lora_sources = v; }
|
||||
else if (S("--debug-graph")) { c->debug_graph = true; c->debug_selection = true; }
|
||||
else if (S("--debug-selection")) c->debug_selection = true;
|
||||
else if (S("--debug-placement")) c->debug_placement = true;
|
||||
@@ -1036,6 +1039,7 @@ const ShowRow kShow[] = {
|
||||
{ "--kld-corpus", [](const Config& c) { return or_none(c.kld_corpus, "none"); } },
|
||||
{ "--kld-out", [](const Config& c) { return or_none(c.kld_out, "none"); } },
|
||||
{ "--kld-lora", [](const Config& c) { return or_none(c.kld_lora, "none (the base)"); } },
|
||||
{ "--kld-lora-sources", [](const Config& c) { return or_none(c.kld_lora_sources, "every document"); } },
|
||||
{ "--debug-graph", [](const Config& c) { return onoff(c.debug_graph); } },
|
||||
{ "--debug-selection", [](const Config& c) { return onoff(c.debug_selection); } },
|
||||
{ "--debug-placement", [](const Config& c) { return onoff(c.debug_placement); } },
|
||||
|
||||
+5
-2
@@ -124,8 +124,11 @@ int Engine::run_kld() {
|
||||
r->ignore_eos = true;
|
||||
r->sp.temp = 0.0f;
|
||||
r->score = true;
|
||||
r->lora_slot = lora_slot;
|
||||
r->lora_uid = lora_uid;
|
||||
/* --kld-lora-sources: the other documents run as the base, in the same steps. */
|
||||
const bool via = cfg_.kld_lora_sources.empty() ||
|
||||
kld_->source(d).rfind(cfg_.kld_lora_sources, 0) == 0;
|
||||
r->lora_slot = via ? lora_slot : -1;
|
||||
r->lora_uid = via ? lora_uid : 0;
|
||||
r->sink = sinks[d].get();
|
||||
sinks[d]->id = r->id;
|
||||
reqs[d] = std::move(r);
|
||||
|
||||
@@ -78,6 +78,7 @@ public:
|
||||
const std::string& model);
|
||||
|
||||
size_t n_docs() const { return docs_.size(); }
|
||||
const std::string& source(size_t d) const { return docs_[d].source; }
|
||||
/* Document d's tokens, and the request id the engine submits it under: d + 1. */
|
||||
std::vector<int32_t> tokens(size_t d) const;
|
||||
int64_t n_rows() const { return n_rows_; }
|
||||
|
||||
@@ -817,6 +817,7 @@ struct Config {
|
||||
std::string kld_record; /* --kld-record DIR */
|
||||
std::string kld_ref; /* --kld-ref DIR */
|
||||
std::string kld_lora; /* --kld-lora NAME: score through this --lora adapter */
|
||||
std::string kld_lora_sources; /* --kld-lora-sources PREFIX: only documents whose source starts so */
|
||||
std::string kld_corpus; /* --kld-corpus FILE, read by --kld-record only */
|
||||
std::string kld_out; /* --kld-out FILE: the report as JSON, rows beside it */
|
||||
bool kld() const { return !kld_record.empty() || !kld_ref.empty(); }
|
||||
|
||||
@@ -413,6 +413,8 @@ const std::map<std::string, std::vector<std::string>>& legal_values() {
|
||||
{ "--lora", { "a=/adapters/a" } }, { "--max-loras", { "2" } },
|
||||
{ "--max-lora-rank", { "32" } }, { "--lora-target-modules", { "q_proj,v_proj" } },
|
||||
{ "--kld-lora", { "a", "--lora", "a=/adapters/a", "--kld-ref", "/r" } },
|
||||
{ "--kld-lora-sources", { "doc/", "--kld-lora", "a", "--lora", "a=/adapters/a",
|
||||
"--kld-ref", "/r" } },
|
||||
};
|
||||
return v;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user