better error handling
This commit is contained in:
parent
679f5137f8
commit
a2a5f1bfbd
1 changed files with 8 additions and 3 deletions
|
@ -284,7 +284,8 @@ static std::vector<std::string> ctrlvec_load_prompt_file(std::string path, bool
|
||||||
std::vector<std::string> output;
|
std::vector<std::string> output;
|
||||||
std::ifstream file(path);
|
std::ifstream file(path);
|
||||||
if (!file.is_open()) {
|
if (!file.is_open()) {
|
||||||
throw std::runtime_error("Unable to open file " + path);
|
fprintf(stderr, "error: unable to open file: %s\n", path.c_str());
|
||||||
|
exit(1);
|
||||||
}
|
}
|
||||||
std::string line;
|
std::string line;
|
||||||
while (std::getline(file, line)) {
|
while (std::getline(file, line)) {
|
||||||
|
@ -441,6 +442,7 @@ int main(int argc, char ** argv) {
|
||||||
std::cout << "n_total_tokens: " << n_total_tokens << std::endl;
|
std::cout << "n_total_tokens: " << n_total_tokens << std::endl;
|
||||||
|
|
||||||
for(size_t i = 0; i < ctx_train.positive_entries.size(); ++i) {
|
for(size_t i = 0; i < ctx_train.positive_entries.size(); ++i) {
|
||||||
|
bool success = false;
|
||||||
tokenized_prompt t = tokenized_prompts[i];
|
tokenized_prompt t = tokenized_prompts[i];
|
||||||
cb_data.n_layers = n_layers;
|
cb_data.n_layers = n_layers;
|
||||||
cb_data.n_tokens = t.max_seq_len;
|
cb_data.n_tokens = t.max_seq_len;
|
||||||
|
@ -452,9 +454,12 @@ int main(int argc, char ** argv) {
|
||||||
(int) t.max_seq_len);
|
(int) t.max_seq_len);
|
||||||
|
|
||||||
cb_data.is_eval_pos = true;
|
cb_data.is_eval_pos = true;
|
||||||
get_hidden_layers(ctx, t.tokens_pos);
|
success = get_hidden_layers(ctx, t.tokens_pos);
|
||||||
|
if (!success) break;
|
||||||
|
|
||||||
cb_data.is_eval_pos = false;
|
cb_data.is_eval_pos = false;
|
||||||
get_hidden_layers(ctx, t.tokens_neg);
|
success = get_hidden_layers(ctx, t.tokens_neg);
|
||||||
|
if (!success) break;
|
||||||
|
|
||||||
// calculate diff and remove all zero rows
|
// calculate diff and remove all zero rows
|
||||||
auto v_diff_filtered = cb_data.calc_diff();
|
auto v_diff_filtered = cb_data.calc_diff();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue