From 9fc14f75419a02467595d1be1aebab709bc123ca Mon Sep 17 00:00:00 2001 From: FuexFollets Date: Thu, 8 Feb 2024 11:50:46 -0500 Subject: [PATCH] Added word vector addition methods to text completer --- src/lexocraft/llm/text_completion.hpp | 2 -- .../llm/text_completion_interface.hpp | 29 +++++++++++++++++-- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/src/lexocraft/llm/text_completion.hpp b/src/lexocraft/llm/text_completion.hpp index 16bfc86..15a09f7 100644 --- a/src/lexocraft/llm/text_completion.hpp +++ b/src/lexocraft/llm/text_completion.hpp @@ -410,8 +410,6 @@ namespace lc { TextCompleter& add_word_vector(const std::string& word, const Eigen::VectorXf& vector); TextCompleter& add_word_vector(const std::string& word, bool random = false); - TextCompleter& remove_word_vector(const std::string& word); - TextCompleter& save_file(const std::filesystem::path& filepath); TextCompleter& load_file(const std::filesystem::path& filepath); diff --git a/src/lexocraft/llm/text_completion_interface.hpp b/src/lexocraft/llm/text_completion_interface.hpp index b4dfdb0..b83f23f 100644 --- a/src/lexocraft/llm/text_completion_interface.hpp +++ b/src/lexocraft/llm/text_completion_interface.hpp @@ -31,8 +31,6 @@ namespace lc { TextCompleter& add_word_vector(const std::string& word, const Eigen::VectorXf& vector); TextCompleter& add_word_vector(const std::string& word, bool random = false); - TextCompleter& remove_word_vector(const std::string& word); - TextCompleter& save_file(const std::filesystem::path& filepath); TextCompleter& load_file(const std::filesystem::path& filepath); @@ -48,6 +46,33 @@ namespace lc { } */ + TextCompleter& TextCompleter::add_word_vector(const WordVector& added_word_vector) { + vector_database.add_word(added_word_vector); + return create_vector_subdatabases(); + } + + TextCompleter& + TextCompleter::add_word_vector(const std::vector& added_word_vectors) { + for (const auto& word_vector: added_word_vectors) { + vector_database.add_word(word_vector); + } + + return create_vector_subdatabases(); + } + + TextCompleter& TextCompleter::add_word_vector(const std::string& word, + const Eigen::VectorXf& vector) { + vector_database.add_word(WordVector(word, vector)); + + return create_vector_subdatabases(); + } + + TextCompleter& TextCompleter::add_word_vector(const std::string& word, bool random) { + vector_database.add_word(WordVector(word, random)); + + return create_vector_subdatabases(); + } + // -------------------------- Ephermal Memory Accumulator -------------------------- TextCompleter& TextCompleter::set_ephemeral_memory_accumulator_layer_sizes( const BinaryLayerSizeVectorGenerator_t& binary_layer_size_vector_generator,