Spaces:
Sleeping
Sleeping
Hemanth Kunta commited on
Commit ·
ae0d0fa
1
Parent(s): ab076fb
final phase 2 task score normalization
Browse files- inference.py +10 -10
inference.py
CHANGED
|
@@ -29,7 +29,7 @@ MAX_TOKENS = 1000
|
|
| 29 |
MAX_AUDIT_STEPS = 9
|
| 30 |
FIX_STEPS = 3
|
| 31 |
WALL_LIMIT = 15 * 60
|
| 32 |
-
SCORE_EPS =
|
| 33 |
|
| 34 |
SYSTEM_PROMPT = """You are a SQL Data Auditor.
|
| 35 |
|
|
@@ -104,7 +104,7 @@ def emit_block(kind: str, **fields) -> None:
|
|
| 104 |
if isinstance(value, bool):
|
| 105 |
text = "true" if value else "false"
|
| 106 |
elif isinstance(value, float):
|
| 107 |
-
text = f"{value:.
|
| 108 |
else:
|
| 109 |
text = str(value)
|
| 110 |
parts.append(f"{key}={text}")
|
|
@@ -112,21 +112,21 @@ def emit_block(kind: str, **fields) -> None:
|
|
| 112 |
|
| 113 |
|
| 114 |
def strict_score(value: float | int | str | None, default: float = SCORE_EPS) -> float:
|
| 115 |
-
"""Clamp score
|
| 116 |
try:
|
| 117 |
v = float(value)
|
| 118 |
except Exception:
|
| 119 |
v = float(default)
|
| 120 |
-
if
|
| 121 |
-
|
| 122 |
-
if
|
| 123 |
-
|
| 124 |
-
return v
|
| 125 |
|
| 126 |
|
| 127 |
def score_text(value: float | int | str | None, default: float = SCORE_EPS) -> str:
|
| 128 |
-
"""
|
| 129 |
-
return f"{strict_score(value, default=default):.
|
| 130 |
|
| 131 |
|
| 132 |
def parse_action(text: str) -> dict:
|
|
|
|
| 29 |
MAX_AUDIT_STEPS = 9
|
| 30 |
FIX_STEPS = 3
|
| 31 |
WALL_LIMIT = 15 * 60
|
| 32 |
+
SCORE_EPS = 0.1
|
| 33 |
|
| 34 |
SYSTEM_PROMPT = """You are a SQL Data Auditor.
|
| 35 |
|
|
|
|
| 104 |
if isinstance(value, bool):
|
| 105 |
text = "true" if value else "false"
|
| 106 |
elif isinstance(value, float):
|
| 107 |
+
text = f"{value:.1f}"
|
| 108 |
else:
|
| 109 |
text = str(value)
|
| 110 |
parts.append(f"{key}={text}")
|
|
|
|
| 112 |
|
| 113 |
|
| 114 |
def strict_score(value: float | int | str | None, default: float = SCORE_EPS) -> float:
|
| 115 |
+
"""Clamp score to one decimal strictly between 0 and 1 (practical range 0.1..0.9)."""
|
| 116 |
try:
|
| 117 |
v = float(value)
|
| 118 |
except Exception:
|
| 119 |
v = float(default)
|
| 120 |
+
if v < 0.1:
|
| 121 |
+
v = 0.1
|
| 122 |
+
if v > 0.9:
|
| 123 |
+
v = 0.9
|
| 124 |
+
return round(v, 1)
|
| 125 |
|
| 126 |
|
| 127 |
def score_text(value: float | int | str | None, default: float = SCORE_EPS) -> str:
|
| 128 |
+
"""One-decimal score text format."""
|
| 129 |
+
return f"{strict_score(value, default=default):.1f}"
|
| 130 |
|
| 131 |
|
| 132 |
def parse_action(text: str) -> dict:
|