Skip to content

Commit bcbcd46

Browse files
committed
Disable top-k/top-p by default, remove derived constants from Open WebUI valves
Set top_k=0 and top_p=1.0 across config, all deployments, and Open WebUI filter so the full vocabulary is available to entropy-driven selection by default. Remove population_mean, population_std, and uniform_clamp_epsilon from the Open WebUI filter valves since these are mathematical constants derived from the byte distribution, not user-tunable parameters.
1 parent a01aadd commit bcbcd46

9 files changed

Lines changed: 21 additions & 36 deletions

File tree

deployments/_template/.env.example

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ QR_FALLBACK_MODE=system
3636
QR_SAMPLE_COUNT=20480
3737
QR_TEMPERATURE_STRATEGY=fixed
3838
QR_FIXED_TEMPERATURE=0.7
39-
QR_TOP_K=50
40-
QR_TOP_P=0.9
39+
QR_TOP_K=0
40+
QR_TOP_P=1.0
4141
QR_LOG_LEVEL=summary
4242

4343
# --- Ports (host-side) ---

deployments/_template/docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ services:
5252
QR_SAMPLE_COUNT: "${QR_SAMPLE_COUNT:-20480}"
5353
QR_TEMPERATURE_STRATEGY: "${QR_TEMPERATURE_STRATEGY:-fixed}"
5454
QR_FIXED_TEMPERATURE: "${QR_FIXED_TEMPERATURE:-0.7}"
55-
QR_TOP_K: "${QR_TOP_K:-50}"
56-
QR_TOP_P: "${QR_TOP_P:-0.9}"
55+
QR_TOP_K: "${QR_TOP_K:-0}"
56+
QR_TOP_P: "${QR_TOP_P:-1.0}"
5757
QR_LOG_LEVEL: "${QR_LOG_LEVEL:-summary}"
5858

5959
# --- Hugging Face model ---

deployments/firefly-1/.env.example

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ QR_FALLBACK_MODE=system
3232
QR_SAMPLE_COUNT=13312
3333
QR_TEMPERATURE_STRATEGY=fixed
3434
QR_FIXED_TEMPERATURE=0.7
35-
QR_TOP_K=50
36-
QR_TOP_P=0.9
35+
QR_TOP_K=0
36+
QR_TOP_P=1.0
3737
QR_LOG_LEVEL=summary
3838

3939
# --- Ports (host-side) ---

deployments/firefly-1/docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ services:
3636
QR_SAMPLE_COUNT: "${QR_SAMPLE_COUNT:-13312}"
3737
QR_TEMPERATURE_STRATEGY: "${QR_TEMPERATURE_STRATEGY:-fixed}"
3838
QR_FIXED_TEMPERATURE: "${QR_FIXED_TEMPERATURE:-0.7}"
39-
QR_TOP_K: "${QR_TOP_K:-50}"
40-
QR_TOP_P: "${QR_TOP_P:-0.9}"
39+
QR_TOP_K: "${QR_TOP_K:-0}"
40+
QR_TOP_P: "${QR_TOP_P:-1.0}"
4141
QR_LOG_LEVEL: "${QR_LOG_LEVEL:-summary}"
4242

4343
# --- Hugging Face model ---

deployments/urandom/.env.example

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ QR_FALLBACK_MODE=system
2626
QR_SAMPLE_COUNT=20480
2727
QR_TEMPERATURE_STRATEGY=fixed
2828
QR_FIXED_TEMPERATURE=0.7
29-
QR_TOP_K=50
30-
QR_TOP_P=0.9
29+
QR_TOP_K=0
30+
QR_TOP_P=1.0
3131
QR_LOG_LEVEL=summary
3232

3333
# --- Ports (host-side) ---

deployments/urandom/docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ services:
4646
QR_SAMPLE_COUNT: "${QR_SAMPLE_COUNT:-20480}"
4747
QR_TEMPERATURE_STRATEGY: "${QR_TEMPERATURE_STRATEGY:-fixed}"
4848
QR_FIXED_TEMPERATURE: "${QR_FIXED_TEMPERATURE:-0.7}"
49-
QR_TOP_K: "${QR_TOP_K:-50}"
50-
QR_TOP_P: "${QR_TOP_P:-0.9}"
49+
QR_TOP_K: "${QR_TOP_K:-0}"
50+
QR_TOP_P: "${QR_TOP_P:-1.0}"
5151
QR_LOG_LEVEL: "${QR_LOG_LEVEL:-summary}"
5252

5353
# --- Hugging Face model ---

examples/open-webui/qr_sampler_filter.py

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ class Valves(BaseModel):
5555

5656
# --- Token selection ---
5757
top_k: int = Field(
58-
default=50,
58+
default=0,
5959
description="Top-k filtering: keep only the k most probable tokens (0 disables).",
6060
)
6161
top_p: float = Field(
62-
default=0.9,
62+
default=1.0,
6363
description="Nucleus sampling threshold (1.0 disables).",
6464
)
6565

@@ -98,18 +98,6 @@ class Valves(BaseModel):
9898
default=20480,
9999
description="Number of entropy bytes to fetch per token.",
100100
)
101-
population_mean: float = Field(
102-
default=127.5,
103-
description="Null-hypothesis mean of byte values {0..255}.",
104-
)
105-
population_std: float = Field(
106-
default=73.61215932167728,
107-
description="Population std for continuous uniform [0, 255].",
108-
)
109-
uniform_clamp_epsilon: float = Field(
110-
default=1e-10,
111-
description="Clamp u to (epsilon, 1-epsilon) to avoid degenerate CDF.",
112-
)
113101

114102
# --- Logging ---
115103
log_level: str = Field(
@@ -130,9 +118,6 @@ def __init__(self) -> None:
130118
{
131119
"signal_amplifier_type",
132120
"sample_count",
133-
"population_mean",
134-
"population_std",
135-
"uniform_clamp_epsilon",
136121
"temperature_strategy",
137122
"fixed_temperature",
138123
"edt_base_temp",

src/qr_sampler/config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,11 @@ class QRSamplerConfig(BaseSettings):
182182
# --- Token Selection (per-request overridable) ---
183183

184184
top_k: int = Field(
185-
default=50,
185+
default=0,
186186
description="Top-k filtering (<=0 disables)",
187187
)
188188
top_p: float = Field(
189-
default=0.9,
189+
default=1.0,
190190
description="Nucleus sampling threshold (1.0 disables)",
191191
)
192192

tests/test_config.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ def test_temperature_defaults(self, default_config: QRSamplerConfig) -> None:
5858
assert default_config.edt_max_temp == 2.0
5959

6060
def test_selection_defaults(self, default_config: QRSamplerConfig) -> None:
61-
assert default_config.top_k == 50
62-
assert default_config.top_p == 0.9
61+
assert default_config.top_k == 0
62+
assert default_config.top_p == 1.0
6363

6464
def test_logging_defaults(self, default_config: QRSamplerConfig) -> None:
6565
assert default_config.log_level == "summary"
@@ -134,7 +134,7 @@ def test_grpc_api_key_header_env_var(self) -> None:
134134
def test_non_qr_env_vars_ignored(self) -> None:
135135
with patch.dict(os.environ, {"OTHER_TOP_K": "999"}):
136136
config = QRSamplerConfig(_env_file=None) # type: ignore[call-arg]
137-
assert config.top_k == 50 # Unchanged default
137+
assert config.top_k == 0 # Unchanged default
138138

139139

140140
# ---------------------------------------------------------------------------
@@ -177,7 +177,7 @@ def test_multiple_overrides(self, default_config: QRSamplerConfig) -> None:
177177

178178
def test_original_unchanged(self, default_config: QRSamplerConfig) -> None:
179179
resolve_config(default_config, {"qr_top_k": 100})
180-
assert default_config.top_k == 50 # Original unchanged
180+
assert default_config.top_k == 0 # Original unchanged
181181

182182
def test_mixed_qr_and_non_qr_keys(self, default_config: QRSamplerConfig) -> None:
183183
result = resolve_config(
@@ -378,7 +378,7 @@ def test_model_copy_creates_new_instance(self, default_config: QRSamplerConfig)
378378
copy = default_config.model_copy(update={"top_k": 200})
379379
assert copy is not default_config
380380
assert copy.top_k == 200
381-
assert default_config.top_k == 50
381+
assert default_config.top_k == 0
382382

383383
def test_model_copy_preserves_unmodified(self, default_config: QRSamplerConfig) -> None:
384384
copy = default_config.model_copy(update={"top_k": 200})

0 commit comments

Comments
 (0)