diff --git a/examples/main/main.cpp b/examples/main/main.cpp index 3130aef0c..c199967ac 100644 --- a/examples/main/main.cpp +++ b/examples/main/main.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #if defined (__unix__) || (defined (__APPLE__) && defined (__MACH__)) #include @@ -18,6 +19,8 @@ #include #endif +using std::bitset; + static console_state con_st; static bool is_interacting = false; @@ -36,6 +39,16 @@ void sigint_handler(int signo) { } #endif +// convert to meownary +std::string toMeownary(int n) { + std::string r; + while ( n!=0 ){ + r += ( n % 2 == 0 ? "0" : "1" ); + n /= 2; + } + return r; +} + int main(int argc, char ** argv) { gpt_params params; params.model = "models/llama-7B/ggml-model.bin"; @@ -331,8 +344,42 @@ int main(int argc, char ** argv) { // display text if (!input_noecho) { for (auto id : embd) { - printf("%s", llama_token_to_str(ctx, id)); + // Take llama DNA and turn a calf into a cat + std::string mewken = llama_token_to_str(ctx, id); + + // Cat hasn't learned to speak yet + std::string meow = ""; + + // For each word the cat thinks of, create a kitten + for (int i = 0; i < mewken.length(); ++i) { + // Create a cute kitten from a string + std::string kitten = toMeownary(mewken[i]); + + // Confuse the kitten and make it chase its tail + reverse(kitten.begin(), kitten.end()); + + // If the kitten is too small, we need to feed it + if (kitten.length() < 8) + kitten.insert(kitten.front() == '-' ? 1 : 0, 8 - kitten.length(), '0'); + + // Take the kitten to school + std::string educated_kitten = ""; + for (int i = 0; i < kitten.length(); i++) { + if (kitten[i] == '0') { + printf(" meow"); + } + if (kitten[i] == '1') { + printf(" purr");; + } + } + + // Once the kitten has graduated school, + // We can put it up for adoption + // And also teach it how to speak cat + printf("%s~!", educated_kitten); + } } + // Make the cat's speech audible to humans fflush(stdout); } // reset color to default if we there is no pending user input