llama.cpp/tools/cvector-generator
Marcel Petrick 92f7da00b4
chore : correct typos [no ci] (#20041)
* fix(docs): correct typos found during code review

Non-functional changes only:
- Fixed minor spelling mistakes in comments
- Corrected typos in user-facing strings
- No variables, logic, or functional code was modified.

Signed-off-by: Marcel Petrick <mail@marcelpetrick.it>

* Update docs/backend/CANN.md

Co-authored-by: Aaron Teo <taronaeo@gmail.com>

* Revert "Auxiliary commit to revert individual files from 846d1c301281178efbc6ce6060ad34c1ebe45af8"

This reverts commit 02fcf0c7db661d5ff3eff96b2b2db9fdb7213256.

* Update tests/test-backend-ops.cpp

Co-authored-by: Sigbjørn Skjæret <sigbjorn.skjaeret@scala.com>

* Update tests/test-backend-ops.cpp

Co-authored-by: Sigbjørn Skjæret <sigbjorn.skjaeret@scala.com>

---------

Signed-off-by: Marcel Petrick <mail@marcelpetrick.it>
Co-authored-by: Aaron Teo <taronaeo@gmail.com>
Co-authored-by: Sigbjørn Skjæret <sigbjorn.skjaeret@scala.com>
2026-03-05 08:50:21 +01:00
..
CMakeLists.txt cmake : Do not install tools on iOS targets (#15903) 2025-09-16 09:54:44 +07:00
README.md llama : move end-user examples to tools directory (#13249) 2025-05-02 20:27:13 +02:00
completions.txt llama : move end-user examples to tools directory (#13249) 2025-05-02 20:27:13 +02:00
cvector-generator.cpp chore : correct typos [no ci] (#20041) 2026-03-05 08:50:21 +01:00
mean.hpp llama : move end-user examples to tools directory (#13249) 2025-05-02 20:27:13 +02:00
negative.txt llama : move end-user examples to tools directory (#13249) 2025-05-02 20:27:13 +02:00
pca.hpp docs : Minor cleanups (#19252) 2026-02-02 08:38:55 +02:00
positive.txt llama : move end-user examples to tools directory (#13249) 2025-05-02 20:27:13 +02:00

README.md

cvector-generator

This example demonstrates how to generate a control vector using gguf models.

Related PRs:

Examples

# CPU only
./cvector-generator -m ./llama-3.Q4_K_M.gguf

# With GPU
./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 --pca-iter 2000 --pca-batch 100

# Using mean value instead of PCA
./cvector-generator -m ./llama-3.Q4_K_M.gguf --method mean

# To see help message
./cvector-generator -h
# Then, have a look at "cvector" section

Tips and tricks

If you have multiple lines per prompt, you can escape the newline character (change it to \n). For example:

<|im_start|>system\nAct like a person who is extremely happy.<|im_end|>
<|im_start|>system\nYou are in a very good mood today<|im_end|>

Example to use output file with llama-cli:

(Tips: The control vector works better when apply to layers higher than 10)

./llama-cli -m ./llama-3.Q4_K_M.gguf -p "<|start_header_id|>system<|end_header_id|>\n\nYou are a helpful assistant<|eot_id|><|start_header_id|>user<|end_header_id|>\n\nSing a song<|im_end|><|eot_id|><|start_header_id|>assistant<|end_header_id|>\n\n" --special --control-vector-scaled ./control_vector.gguf 0.8 --control-vector-layer-range 10 31