Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 7 additions & 0 deletions flutter/cpp/datasets/ifeval.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ IFEval::IFEval(Backend* backend, const std::string& input_tfrecord,
std::vector<int> input_tokens;
sp_processor->Encode(input_formatted.c_str(), &input_tokens).ok();

// input token sanity check
if (input_tokens.size() > input_token_limit_) {
LOG(WARNING) << "Input token limit exceeded for entry "
<< std::to_string(i) << ". Ignoring.";
continue;
}

auto sample = std::make_unique<ifeval::Sample>();
sample->key = key;
sample->prompt = prompt;
Expand Down
1 change: 1 addition & 0 deletions flutter/cpp/datasets/ifeval.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class IFEval : public Dataset {
std::unordered_set<size_t> used_sample_ids_;
std::set<int> loaded_sample_ids_;
std::unique_ptr<sentencepiece::SentencePieceProcessor> sp_processor;
static constexpr int input_token_limit_ = 1024;
static constexpr int token_limit_ = 1024;
};

Expand Down
7 changes: 7 additions & 0 deletions flutter/cpp/datasets/mmlu_gen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ MmluGen::MmluGen(Backend* backend, const std::string& input_tfrecord,
std::vector<int> input_tokens;
sp_processor->Encode(input.c_str(), &input_tokens).ok();

// input token sanity check
if (input_tokens.size() > input_token_limit_) {
LOG(WARNING) << "Input token limit exceeded for entry "
<< std::to_string(i) << ". Ignoring.";
continue;
}

auto sample = std::make_unique<PromptSample>();
sample->input = input;
sample->input_tokens = input_tokens;
Expand Down
1 change: 1 addition & 0 deletions flutter/cpp/datasets/mmlu_gen.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ class MmluGen : public Dataset {
std::unordered_set<size_t> used_sample_ids_;
std::set<int> loaded_sample_ids_;
std::unique_ptr<sentencepiece::SentencePieceProcessor> sp_processor;
static constexpr int input_token_limit_ = 1024;
static constexpr int token_limit_ = 4;
};

Expand Down
4 changes: 2 additions & 2 deletions mobile_back_tflite/cpp/backend_tflite/llm_pipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ struct LLMBackendData {
kv_cache_t kv_cache;
std::vector<int> prompt_tokens;
std::vector<int> output_tokens;
uint8_t threads = 2;
int max_output_tokens = 1024;
uint8_t threads = 8;
int max_output_tokens = 128;
std::unordered_set<int> stop_token_ids{128001, 128008, 128009};

LLMBackendData() {}
Expand Down
Loading