mirror of
https://gitlab.com/niansa/anyproc.git
synced 2025-03-06 20:49:24 +01:00
Updated libjustlm
This commit is contained in:
parent
27f5efe369
commit
f2602926d8
2 changed files with 19 additions and 11 deletions
|
@ -6,13 +6,15 @@
|
|||
#include <unordered_map>
|
||||
#include <string_view>
|
||||
#include <utility>
|
||||
#include <memory>
|
||||
#include <functional>
|
||||
|
||||
#include <justlm.hpp>
|
||||
|
||||
|
||||
|
||||
class PyEval : LM::Inference {
|
||||
class PyEval {
|
||||
std::unique_ptr<LM::Inference> i;
|
||||
std::string buffer = "Python 3.9.2 (default, Feb 28 2021, 17:03:44)\n"
|
||||
"[GCC 10.2.1 20210110] on linux\n"
|
||||
"Type \"help\", \"copyright\", \"credits\" or \"license\" for more information.\n"
|
||||
|
@ -55,8 +57,9 @@ public:
|
|||
return p;
|
||||
}
|
||||
|
||||
PyEval(const std::string& weights_path, const Params& p = get_recommended_params())
|
||||
: LM::Inference(weights_path, p) {}
|
||||
PyEval(const std::string& weights_path, const LM::Inference::Params& p = get_recommended_params()) {
|
||||
i.reset(LM::Inference::construct(weights_path, p));
|
||||
}
|
||||
|
||||
auto& begin() {
|
||||
buffer += ">>> ";
|
||||
|
@ -83,9 +86,9 @@ public:
|
|||
|
||||
auto run(const std::function<bool (float)> &on_append_tick = nullptr, const std::function<bool (const char *generated)>& on_generation_tick = nullptr) {
|
||||
buffer += "\n";
|
||||
append(buffer, on_append_tick);
|
||||
i->append(buffer, on_append_tick);
|
||||
buffer.clear();
|
||||
return LM::Inference::run("\n", on_generation_tick);
|
||||
return i->run("\n", on_generation_tick);
|
||||
}
|
||||
void example(std::string_view response = "") {
|
||||
buffer += "\n";
|
||||
|
@ -93,15 +96,19 @@ public:
|
|||
if (!response.empty()) buffer += "\n";
|
||||
}
|
||||
|
||||
void create_savestate(Savestate &sv, const std::function<bool (float)> &on_append_tick = nullptr) {
|
||||
void create_savestate(LM::Inference::Savestate &sv, const std::function<bool (float)> &on_append_tick = nullptr) {
|
||||
if (!buffer.empty()) {
|
||||
append(buffer, on_append_tick);
|
||||
i->append(buffer, on_append_tick);
|
||||
buffer.clear();
|
||||
}
|
||||
LM::Inference::create_savestate(sv);
|
||||
i->create_savestate(sv);
|
||||
}
|
||||
void restore_savestate(const Savestate &sv) {
|
||||
LM::Inference::restore_savestate(sv);
|
||||
void restore_savestate(const LM::Inference::Savestate &sv) {
|
||||
i->restore_savestate(sv);
|
||||
}
|
||||
|
||||
LM::Inference& get_inference() {
|
||||
return *i;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -157,6 +164,7 @@ public:
|
|||
p.top_k = 5;
|
||||
p.top_p = 0.2f;
|
||||
p.temp = 0.1f;
|
||||
p.eos_ignores = 1;
|
||||
return p;
|
||||
}
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit aad1bd9ae45bde142ade077724deed0eb3ba5c4e
|
||||
Subproject commit bfcda5a3bf2352ef7bc0372f5fd6fa1eb0de2168
|
Loading…
Add table
Reference in a new issue