diff --git a/alembic/versions/0033_suggestion_threshold_default_070.py b/alembic/versions/0033_suggestion_threshold_default_070.py new file mode 100644 index 0000000..652cf44 --- /dev/null +++ b/alembic/versions/0033_suggestion_threshold_default_070.py @@ -0,0 +1,48 @@ +"""suggestion_threshold default 0.50 → 0.70 + +Revision ID: 0033 +Revises: 0032 +Create Date: 2026-06-02 + +Operator-flagged 2026-06-02 — the 0.50 default (set on 2026-06-01) is +too noisy in practice; raise to 0.70 for both suggestion categories. + +Only conditionally updates singletons whose current value is still the +2026-06-01 default (0.50). Operators who deliberately tuned their row +to some other value (0.55, 0.65, 0.80, etc. via the Settings UI) keep +their pick — the migration only catches the unchanged-default case. +""" +from typing import Sequence, Union + +from alembic import op + +revision: str = "0033" +down_revision: Union[str, None] = "0032" +branch_labels: Union[str, Sequence[str], None] = None +depends_on: Union[str, Sequence[str], None] = None + + +def upgrade() -> None: + op.execute( + "UPDATE ml_settings " + "SET suggestion_threshold_character = 0.70 " + "WHERE id = 1 AND suggestion_threshold_character = 0.50" + ) + op.execute( + "UPDATE ml_settings " + "SET suggestion_threshold_general = 0.70 " + "WHERE id = 1 AND suggestion_threshold_general = 0.50" + ) + + +def downgrade() -> None: + op.execute( + "UPDATE ml_settings " + "SET suggestion_threshold_character = 0.50 " + "WHERE id = 1 AND suggestion_threshold_character = 0.70" + ) + op.execute( + "UPDATE ml_settings " + "SET suggestion_threshold_general = 0.50 " + "WHERE id = 1 AND suggestion_threshold_general = 0.70" + ) diff --git a/backend/app/models/ml_settings.py b/backend/app/models/ml_settings.py index de4e476..5c3e858 100644 --- a/backend/app/models/ml_settings.py +++ b/backend/app/models/ml_settings.py @@ -16,13 +16,14 @@ class MLSettings(Base): id: Mapped[int] = mapped_column(Integer, primary_key=True) suggestion_threshold_character: Mapped[float] = mapped_column( - Float, nullable=False, default=0.50 + Float, nullable=False, default=0.70 ) - # Default lowered 0.95 → 0.50 on 2026-06-01 — operator-flagged that - # 0.95 hid most general suggestions. Operator-tunable via Settings → - # ML if too noisy. + # Default raised 0.50 → 0.70 on 2026-06-02 — operator-flagged 0.50 + # surfaced too many low-confidence picks; 0.70 keeps the rail + # signal-rich while still surfacing more than the original 0.95 + # which hid almost everything. Operator-tunable via Settings → ML. suggestion_threshold_general: Mapped[float] = mapped_column( - Float, nullable=False, default=0.50 + Float, nullable=False, default=0.70 ) centroid_similarity_threshold: Mapped[float] = mapped_column( Float, nullable=False, default=0.55