Skip to content

Commit d41c719

Browse files
committed
bring back n_completions
1 parent 446da90 commit d41c719

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

examples/control-vector-generator/control-vector-generator.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <algorithm>
1919
#include <iostream>
2020
#include <fstream>
21+
#include <climits>
2122

2223

2324
//////////////////////////////////////////////////
@@ -244,7 +245,7 @@ struct train_context {
244245

245246
struct ctrl_params {
246247
/* default meta parameters */
247-
int n_completions = 64;
248+
int n_completions = INT_MAX;
248249
int n_pca_batch = 5;
249250
int n_pca_iterations = 1000;
250251

@@ -538,7 +539,7 @@ static int prepare_entries(ctrl_params & cparams) {
538539
return persona + " " + suffix; // entry in positive/negative.txt must already be formatted i.e. "[INST] Act as if you're extremely happy. [/INST]"
539540
};
540541
for (size_t i = 0; i < positive_prompts.size(); ++i) {
541-
for (size_t j = 0; j < completions.size() && j < cparams.n_completions; ++j) {
542+
for (int j = 0; j < std::min((int) completions.size(), cparams.n_completions); ++j) {
542543
// TODO replicate the truncations done by the python implementation
543544
cparams.positive_entries.push_back(format_template(positive_prompts[i], completions[j]));
544545
cparams.negative_entries.push_back(format_template(negative_prompts[i], completions[j]));
@@ -606,7 +607,7 @@ int main(int argc, char ** argv) {
606607
cb_data.n_tokens = t.max_seq_len;
607608

608609
printf("Evaluating prompt[%ld/%ld]: \"%s\" - \"%s\" (%ld tokens)\n",
609-
i+1, t.tokens_pos.size(),
610+
i+1, cparams.positive_entries.size(),
610611
tokens_to_str(ctx, t.tokens_pos.cbegin(), t.tokens_pos.cend()).c_str(),
611612
tokens_to_str(ctx, t.tokens_neg.cbegin(), t.tokens_neg.cend()).c_str(),
612613
t.max_seq_len);

0 commit comments

Comments
 (0)