fix inverted vector

This commit is contained in:
ngxson 2024-06-23 00:33:59 +02:00
parent 8a52b546a0
commit bd989c21d4
3 changed files with 7 additions and 2 deletions

View file

@ -233,7 +233,7 @@ struct gpt_params {
bool compute_ppl = true; // whether to compute perplexity
// cvector-generator params
int n_pca_batch = 20;
int n_pca_batch = 100;
int n_pca_iterations = 1000;
std::string cvector_outfile = "control_vector.gguf";
std::string cvector_positive_file = "examples/cvector-generator/positive.txt";

View file

@ -17,7 +17,7 @@ Related PRs:
./cvector-generator -m ./llama-3.Q4_K_M.gguf -ngl 99
# With advanced options
./cvector-generator -m ./llama-3.Q4_K_M.gguf -ngl 99 --completions 128 --pca-iter 2000 --pca-batch 100
./cvector-generator -m ./llama-3.Q4_K_M.gguf -ngl 99 --pca-iter 2000 --pca-batch 100
# To see help message
./cvector-generator -h

View file

@ -298,6 +298,11 @@ static void power_iteration(
ggml_backend_tensor_get(last_eigenvector, output->data, 0, ggml_nbytes(last_eigenvector));
//print_debug_tensor(output);
ggml_gallocr_free(allocr);
// TODO @ngxson : The output vector is inverted. Don't know why, but here is quick fix
for (int i = 0; i < output->ne[0]; i++) {
ggml_set_f32_1d(output, i, -ggml_get_f32_1d(output, i));
}
}
static void run_pca(