1
+ <!DOCTYPE html>
2
+ < html lang ="en ">
3
+ < head >
4
+ < meta charset ="UTF-8 ">
5
+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
6
+ < title > Llama.cpp Control Vector Command Generator</ title >
7
+ < script src ="https://cdn.tailwindcss.com "> </ script >
8
+ </ head >
9
+ < body class ="bg-gray-100 p-8 ">
10
+ < div class ="max-w-4xl mx-auto bg-white p-6 rounded-lg shadow-md ">
11
+ < h1 class ="text-2xl font-bold mb-4 "> Llama.cpp Control Vector Command Generator</ h1 >
12
+
13
+ < div class ="mb-4 ">
14
+ < label for ="controlVectorPath " class ="block mb-2 "> Control Vector Path:</ label >
15
+ < input type ="text " id ="controlVectorPath " class ="w-full p-2 border rounded " placeholder ="/path/to/control/vectors ">
16
+ </ div >
17
+
18
+ < div class ="mb-4 ">
19
+ < label for ="modelVectorName " class ="block mb-2 "> Model Vector Name:</ label >
20
+ < input type ="text " id ="modelVectorName " class ="w-full p-2 border rounded " placeholder ="e.g., wizard-lm-2:8x22b ">
21
+ </ div >
22
+
23
+ < div id ="sliders " class ="space-y-4 "> </ div >
24
+
25
+ < div class ="mt-6 ">
26
+ < h2 class ="text-xl font-semibold mb-2 "> Generated Command:</ h2 >
27
+ < pre id ="output " class ="bg-gray-200 p-4 rounded overflow-x-auto whitespace-pre-wrap "> </ pre >
28
+ </ div >
29
+ </ div >
30
+
31
+ < script >
32
+ const controlVectors = [
33
+ { name : "character_focus" , options : [ "dialogue" , "narration" ] } ,
34
+ { name : "compassion_vs_sadism" , options : [ "compassion" , "sadism" ] } ,
35
+ { name : "empathy_vs_sociopathy" , options : [ "empathy" , "sociopathy" ] } ,
36
+ { name : "honesty_vs_machiavellianism" , options : [ "honesty" , "machiavellianism" ] } ,
37
+ { name : "humility_vs_narcissism" , options : [ "humility" , "narcissism" ] } ,
38
+ { name : "language" , options : [ "ornate" , "simple" ] } ,
39
+ { name : "optimism_vs_nihilism" , options : [ "optimism" , "nihilism" ] } ,
40
+ { name : "storytelling" , options : [ "descriptive" , "explicit" ] }
41
+ ] ;
42
+
43
+ const slidersContainer = document . getElementById ( 'sliders' ) ;
44
+ const outputElement = document . getElementById ( 'output' ) ;
45
+ const controlVectorPathInput = document . getElementById ( 'controlVectorPath' ) ;
46
+ const modelVectorNameInput = document . getElementById ( 'modelVectorName' ) ;
47
+
48
+ controlVectors . forEach ( vector => {
49
+ const sliderContainer = document . createElement ( 'div' ) ;
50
+ sliderContainer . innerHTML = `
51
+ <div class="flex items-center mb-2">
52
+ <input type="checkbox" id="${ vector . name } -active" class="mr-2" onchange="updateOutput()">
53
+ <label class="mr-4">${ vector . name . replace ( / _ / g, ' ' ) } </label>
54
+ <span id="${ vector . name } -value" class="ml-auto">0</span>
55
+ <button id="${ vector . name } -reset" class="ml-2 px-2 py-1 bg-gray-200 rounded" onclick="resetSlider('${ vector . name } ')">Reset</button>
56
+ </div>
57
+ <input type="range" min="-100" max="100" value="0" class="w-full"
58
+ id="${ vector . name } " oninput="updateSliderValue('${ vector . name } ')">
59
+ ` ;
60
+ slidersContainer . appendChild ( sliderContainer ) ;
61
+ } ) ;
62
+
63
+ function updateSliderValue ( vectorName ) {
64
+ const slider = document . getElementById ( vectorName ) ;
65
+ const value = parseFloat ( slider . value ) / 100 ;
66
+ document . getElementById ( `${ vectorName } -value` ) . textContent = value . toFixed ( 2 ) ;
67
+ updateOutput ( ) ;
68
+ }
69
+
70
+ function resetSlider ( vectorName ) {
71
+ const slider = document . getElementById ( vectorName ) ;
72
+ slider . value = 0 ;
73
+ document . getElementById ( `${ vectorName } -value` ) . textContent = '0' ;
74
+ updateOutput ( ) ;
75
+ }
76
+
77
+ function updateOutput ( ) {
78
+ const controlVectorPath = controlVectorPathInput . value . trim ( ) ;
79
+ const modelVectorName = modelVectorNameInput . value . trim ( ) ;
80
+ let command = '' ;
81
+
82
+ controlVectors . forEach ( vector => {
83
+ const isActive = document . getElementById ( `${ vector . name } -active` ) . checked ;
84
+ if ( ! isActive ) return ;
85
+
86
+ const slider = document . getElementById ( vector . name ) ;
87
+ const value = parseFloat ( slider . value ) / 100 ;
88
+
89
+ command += `--control-vector ${ controlVectorPath } /${ modelVectorName } -${ vector . name } __debias.gguf \\\n` ;
90
+
91
+ if ( value !== 0 ) {
92
+ const option = value > 0 ? vector . options [ 0 ] : vector . options [ 1 ] ;
93
+ const absValue = Math . abs ( value ) ;
94
+ command += `--control-vector-scaled ${ controlVectorPath } /${ modelVectorName } -${ vector . name } __${ option } .gguf ${ absValue . toFixed ( 2 ) } \\\n` ;
95
+ }
96
+ } ) ;
97
+
98
+ outputElement . textContent = command ? command . trim ( ) : 'No control vectors selected' ;
99
+ }
100
+
101
+ controlVectorPathInput . addEventListener ( 'input' , updateOutput ) ;
102
+ modelVectorNameInput . addEventListener ( 'input' , updateOutput ) ;
103
+
104
+ updateOutput ( ) ;
105
+ </ script >
106
+ </ body >
107
+ </ html >
0 commit comments