Skip to content

Commit 9f7c0d2

Browse files
committed
Webui stuff
1 parent ab85a84 commit 9f7c0d2

File tree

10 files changed

+37
-11
lines changed

10 files changed

+37
-11
lines changed

common/common.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,12 @@ struct common_params_sampling {
136136
float min_p = 0.05f; // 0.0 = disabled
137137
float xtc_probability = 0.00f; // 0.0 = disabled
138138
float xtc_threshold = 0.10f; // > 0.5 disables XTC
139+
float smoothing_factor = 0.0f; // controls the quadratic adjustment in smooth / quadratic sampling (0.0 = disabled)
140+
float smoothing_curve = 1.0f; // controls the cubic transformation curve for smoothing / quadratic sampling.
139141
float typ_p = 1.00f; // typical_p, 1.0 = disabled
140142
float temp = 0.80f; // <= 0.0 to sample greedily, 0.0 to not output probabilities
141143
float dynatemp_range = 0.00f; // 0.0 = disabled
142144
float dynatemp_exponent = 1.00f; // controls how entropy maps to temperature in dynamic temperature sampler
143-
float smoothing_factor = 0.0f; // controls the quadratic adjustment in smooth / quadratic sampling (0.0 = disabled)
144-
float smoothing_curve = 1.0f; // controls the quadratic adjustment in smooth / quadratic sampling
145145
int32_t penalty_last_n = 64; // last n tokens to penalize (0 = disable penalty, -1 = context size)
146146
float penalty_repeat = 1.00f; // 1.0 = disabled
147147
float penalty_freq = 0.00f; // 0.0 = disabled

tools/main/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ By performing a non-linear transformation on token logits, we can effectively av
309309

310310
`smoothing curve` is a second hyperparameter that adds a cubic transformation on top of the original quadratic one, and can "help make lower `smoothing factor` values work if the curve is set higher. A smoothing curve value of `1.0` is equivalant of using just quadratic transformation.
311311

312-
This sampler is not mutually exclusive with Temperature, they can be used together.
312+
This sampler is not mutually exclusive with Temperature, they can be used together.
313313

314314
### Top-nσ Sampling
315315

tools/server/README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ The project is under active development, and we are [looking for feedback and co
105105

106106
| Argument | Explanation |
107107
| -------- | ----------- |
108-
| `--samplers SAMPLERS` | samplers that will be used for generation in the order, separated by ';'<br/>(default: penalties;dry;top_n_sigma;top_k;typ_p;top_p;min_p;xtc;temperature) |
108+
| `--samplers SAMPLERS` | samplers that will be used for generation in the order, separated by ';'<br/>(default: penalties;dry;top_n_sigma;top_k;typ_p;top_p;min_p;xtc;smoothing;temperature) |
109109
| `-s, --seed SEED` | RNG seed (default: -1, use random seed for -1) |
110110
| `--sampling-seq, --sampler-seq SEQUENCE` | simplified sequence for samplers that will be used (default: edskypmxt) |
111111
| `--ignore-eos` | ignore end of stream token and continue generating (implies --logit-bias EOS-inf) |
@@ -483,7 +483,7 @@ These words will not be included in the completion, so make sure to add them to
483483

484484
`return_tokens`: Return the raw generated token ids in the `tokens` field. Otherwise `tokens` remains empty. Default: `false`
485485

486-
`samplers`: The order the samplers should be applied in. An array of strings representing sampler type names. If a sampler is not set, it will not be used. If a sampler is specified more than once, it will be applied multiple times. Default: `["dry", "top_k", "typ_p", "top_p", "min_p", "xtc", "temperature"]` - these are all the available values.
486+
`samplers`: The order the samplers should be applied in. An array of strings representing sampler type names. If a sampler is not set, it will not be used. If a sampler is specified more than once, it will be applied multiple times. Default: `["dry", "top_k", "typ_p", "top_p", "min_p", "xtc", "smoothing", "temperature"]` - these are all the available values.
487487

488488
`timings_per_token`: Include prompt processing and text generation speed information in each response. Default: `false`
489489

@@ -732,6 +732,8 @@ This endpoint is public (no API key check). By default, it is read-only. To make
732732
"min_p": 0.05000000074505806,
733733
"xtc_probability": 0.0,
734734
"xtc_threshold": 0.10000000149011612,
735+
"smoothing_factor": 0.0,
736+
"smoothing_curve": 1.0,
735737
"typical_p": 1.0,
736738
"repeat_last_n": 64,
737739
"repeat_penalty": 1.0,
@@ -766,6 +768,7 @@ This endpoint is public (no API key check). By default, it is read-only. To make
766768
"top_p",
767769
"min_p",
768770
"xtc",
771+
"smoothing",
769772
"temperature"
770773
],
771774
"speculative.n_max": 16,
@@ -878,6 +881,8 @@ Example:
878881
"min_p": 0.05000000074505806,
879882
"xtc_probability": 0.0,
880883
"xtc_threshold": 0.10000000149011612,
884+
"smoothing_factor": 0.0,
885+
"smoothing_curve": 1.0,
881886
"typical_p": 1.0,
882887
"repeat_last_n": 64,
883888
"repeat_penalty": 1.0,
@@ -912,6 +917,7 @@ Example:
912917
"top_p",
913918
"min_p",
914919
"xtc",
920+
"smoothing",
915921
"temperature"
916922
],
917923
"speculative.n_max": 16,

tools/server/public/index.html.gz

6.3 KB
Binary file not shown.

tools/server/public_legacy/index-new.html

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848
min_p: 0.05, // 0 = disabled; recommended for non-english: ~ 0.4
4949
xtc_probability: 0.0, // 0 = disabled;
5050
xtc_threshold: 0.1, // > 0.5 disables XTC;
51+
smoothing_factor: 0.0, // 0 = disabled;
52+
smoothing_curve: 1.0, // > 0.5 = disabled
5153
typical_p: 1.0, // 1.0 = disabled
5254
presence_penalty: 0.0, // 0.0 = disabled
5355
frequency_penalty: 0.0, // 0.0 = disabled
@@ -841,6 +843,8 @@
841843
${FloatField({ label: "Typical-P", title: "Activates local typical sampling, a method used to limit the prediction of tokens that are atypical in the current context. The parameter p controls the strength of this limitation. A value of 1.0 means that this function is deactivated.", max: 1.0, min: 0.0, name: "typical_p", step: 0.01, value: params.value.typical_p })}
842844
${FloatField({ label: "XTC probability", title: "Sets the chance for token removal (checked once on sampler start)", max: 1.0, min: 0.0, name: "xtc_probability", step: 0.01, value: params.value.xtc_probability })}
843845
${FloatField({ label: "XTC threshold", title: "Sets a minimum probability threshold for tokens to be removed", max: 0.5, min: 0.0, name: "xtc_threshold", step: 0.01, value: params.value.xtc_threshold })}
846+
${FloatField({ label: "Smoothing Factor", max: 10.0, min: 0.0, name: "smoothing_factor", step: 0.01, value: params.value.smoothing_factor })}
847+
${FloatField({ label: "Smoothing Curve", max: 10.0, min: 0.0, name: "smoothing_curve", step: 0.01, value: params.value.smoothing_curve })}
844848
${FloatField({ label: "DRY Penalty Multiplier", title: "Set the DRY repetition penalty multiplier. Default is 0.0, which disables DRY.", max: 5.0, min: 0.0, name: "dry_multiplier", step: 0.01, value: params.value.dry_multiplier })}
845849
${FloatField({ label: "DRY Base", title: "Set the DRY repetition penalty base value. Default is 1.75", max: 3.0, min: 1.0, name: "dry_base", step: 0.01, value: params.value.dry_base })}
846850
${IntField({ label: "DRY Allowed Length", title: "Tokens that extend repetition beyond this receive exponentially increasing penalty. Default is 2", max: 10, min: 1, step: 1, name: "dry_allowed_length", value: params.value.dry_allowed_length })}
@@ -1143,6 +1147,8 @@ <h2>llama.cpp</h2>
11431147
min_p: { snapValue: 0.05, snapRangeMultiplier: 2 },
11441148
xtc_probability: { snapValue: 0.0, snapRangeMultiplier: 4 },
11451149
xtc_threshold: { snapValue: 0.5, snapRangeMultiplier: 4 },
1150+
smoothing_factor: { snapValue: 0.0, snapRangeMultiplier: 4 },
1151+
smoothing_curve: { snapValue: 0.0, snapRangeMultiplier: 4 },
11461152
top_p: { snapValue: 1.0, snapRangeMultiplier: 4 },
11471153
typical_p: { snapValue: 1.0, snapRangeMultiplier: 4 },
11481154
repeat_penalty: { snapValue: 1.0, snapRangeMultiplier: 4 },

tools/server/public_legacy/index.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,8 @@
312312
min_p: 0.05, // 0 = disabled
313313
xtc_probability: 0.0, // 0 = disabled;
314314
xtc_threshold: 0.1, // > 0.5 disables XTC;
315+
smoothing_factor: 0.0, // 0 = disabled;
316+
smoothing_curve: 1.0, // > 0.5 = disabled
315317
typical_p: 1.0, // 1.0 = disabled
316318
presence_penalty: 0.0, // 0.0 = disabled
317319
frequency_penalty: 0.0, // 0.0 = disabled
@@ -1021,6 +1023,8 @@
10211023
${IntField({ label: "DRY Penalty Last N", max: 2048, min: -1, step: 16, name: "dry_penalty_last_n", value: params.value.dry_penalty_last_n })}
10221024
${FloatField({ label: "XTC probability", max: 1.0, min: 0.0, name: "xtc_probability", step: 0.01, value: params.value.xtc_probability })}
10231025
${FloatField({ label: "XTC threshold", max: 0.5, min: 0.0, name: "xtc_threshold", step: 0.01, value: params.value.xtc_threshold })}
1026+
${FloatField({ label: "Smoothing Factor", max: 10.0, min: 0.0, name: "smoothing_factor", step: 0.01, value: params.value.smoothing_factor })}
1027+
${FloatField({ label: "Smoothing Curve", max: 10.0, min: 0.0, name: "smoothing_curve", step: 0.01, value: params.value.smoothing_curve })}
10241028
</fieldset>
10251029
<hr />
10261030
<fieldset class="three">

tools/server/server.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,14 +144,14 @@ struct slot_params {
144144
{"temperature", sampling.temp},
145145
{"dynatemp_range", sampling.dynatemp_range},
146146
{"dynatemp_exponent", sampling.dynatemp_exponent},
147-
{"smoothing_factor", sampling.smoothing_factor},
148-
{"smoothing_curve", sampling.smoothing_curve},
149147
{"top_k", sampling.top_k},
150148
{"top_p", sampling.top_p},
151149
{"min_p", sampling.min_p},
152150
{"top_n_sigma", sampling.top_n_sigma},
153151
{"xtc_probability", sampling.xtc_probability},
154152
{"xtc_threshold", sampling.xtc_threshold},
153+
{"smoothing_factor", sampling.smoothing_factor},
154+
{"smoothing_curve", sampling.smoothing_curve},
155155
{"typical_p", sampling.typ_p},
156156
{"repeat_last_n", sampling.penalty_last_n},
157157
{"repeat_penalty", sampling.penalty_repeat},
@@ -255,12 +255,12 @@ struct server_task {
255255
params.sampling.top_n_sigma = json_value(data, "top_n_sigma", defaults.sampling.top_n_sigma);
256256
params.sampling.xtc_probability = json_value(data, "xtc_probability", defaults.sampling.xtc_probability);
257257
params.sampling.xtc_threshold = json_value(data, "xtc_threshold", defaults.sampling.xtc_threshold);
258+
params.sampling.smoothing_factor = json_value(data, "smoothing_factor", defaults.sampling.smoothing_factor);
259+
params.sampling.smoothing_curve = json_value(data, "smoothing_curve", defaults.sampling.smoothing_curve);
258260
params.sampling.typ_p = json_value(data, "typical_p", defaults.sampling.typ_p);
259261
params.sampling.temp = json_value(data, "temperature", defaults.sampling.temp);
260262
params.sampling.dynatemp_range = json_value(data, "dynatemp_range", defaults.sampling.dynatemp_range);
261263
params.sampling.dynatemp_exponent = json_value(data, "dynatemp_exponent", defaults.sampling.dynatemp_exponent);
262-
params.sampling.smoothing_factor = json_value(data, "smoothing_factor", defaults.sampling.smoothing_factor);
263-
params.sampling.smoothing_curve = json_value(data, "smoothing_curve", defaults.sampling.smoothing_curve);
264264
params.sampling.penalty_last_n = json_value(data, "repeat_last_n", defaults.sampling.penalty_last_n);
265265
params.sampling.penalty_repeat = json_value(data, "repeat_penalty", defaults.sampling.penalty_repeat);
266266
params.sampling.penalty_freq = json_value(data, "frequency_penalty", defaults.sampling.penalty_freq);

tools/server/webui/src/Config.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export const CONFIG_DEFAULT = {
1717
showThoughtInProgress: false,
1818
excludeThoughtOnReq: true,
1919
// make sure these default values are in sync with `common.h`
20-
samplers: 'edkypmxt',
20+
samplers: 'edkypmxqt',
2121
temperature: 0.8,
2222
dynatemp_range: 0.0,
2323
dynatemp_exponent: 1.0,
@@ -26,6 +26,8 @@ export const CONFIG_DEFAULT = {
2626
min_p: 0.05,
2727
xtc_probability: 0.0,
2828
xtc_threshold: 0.1,
29+
smoothing_factor: 0.0,
30+
smoothing_curve: 1.0,
2931
typical_p: 1.0,
3032
repeat_last_n: 64,
3133
repeat_penalty: 1.0,
@@ -44,7 +46,7 @@ export const CONFIG_INFO: Record<string, string> = {
4446
apiKey: 'Set the API Key if you are using --api-key option for the server.',
4547
systemMessage: 'The starting message that defines how model should behave.',
4648
samplers:
47-
'The order at which samplers are applied, in simplified way. Default is "dkypmxt": dry->top_k->typ_p->top_p->min_p->xtc->temperature',
49+
'The order at which samplers are applied, in simplified way. Default is "dkypmxqt": dry->top_k->typ_p->top_p->min_p->xtc->smoothing->temperature',
4850
temperature:
4951
'Controls the randomness of the generated text by affecting the probability distribution of the output tokens. Higher = more random, lower = more focused.',
5052
dynatemp_range:
@@ -60,6 +62,10 @@ export const CONFIG_INFO: Record<string, string> = {
6062
'XTC sampler cuts out top tokens; this parameter controls the chance of cutting tokens at all. 0 disables XTC.',
6163
xtc_threshold:
6264
'XTC sampler cuts out top tokens; this parameter controls the token probability that is required to cut that token.',
65+
smoothing_factor:
66+
'Controls the quadratic adjustment in smooth / quadratic sampler',
67+
smoothing_curve:
68+
'Controls the cubic transformation curve for smoothing / quadratic sampler.',
6369
typical_p:
6470
'Sorts and limits tokens based on the difference between log-probability and entropy.',
6571
repeat_last_n: 'Last n tokens to consider for penalizing repetition',

tools/server/webui/src/components/SettingDialog.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ const SAMPLER_KEYS: SettKey[] = [
2929
'typical_p',
3030
'xtc_probability',
3131
'xtc_threshold',
32+
'smoothing_factor',
33+
'smoothing_curve',
3234
];
3335
const PENALTY_KEYS: SettKey[] = [
3436
'repeat_last_n',

tools/server/webui/src/utils/app.context.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,8 @@ export const AppContextProvider = ({
219219
typical_p: config.typical_p,
220220
xtc_probability: config.xtc_probability,
221221
xtc_threshold: config.xtc_threshold,
222+
smoothing_factor: config.smoothing_factor,
223+
smoothing_curve: config.smoothing_curve,
222224
repeat_last_n: config.repeat_last_n,
223225
repeat_penalty: config.repeat_penalty,
224226
presence_penalty: config.presence_penalty,

0 commit comments

Comments
 (0)