Commit ·
460689f
1
Parent(s): 2740f73
Fix confidence score: truncate instead of round to prevent 99.95%+ showing as 100%
Browse filesThe previous %.1f formatting rounded 0.9999 → 100.0%. Added a custom Jinja2
filter that uses math.floor to truncate, so 0.9999 → 99.9% and only true 1.0
shows 100.0%.
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- app.py +11 -1
- templates/partials/paper_card.html +2 -2
app.py
CHANGED
|
@@ -3,6 +3,7 @@ FastAPI + HTMX app for browsing arxiv papers with new ML datasets.
|
|
| 3 |
Downloads Lance dataset from HuggingFace Hub and loads locally.
|
| 4 |
"""
|
| 5 |
|
|
|
|
| 6 |
import re
|
| 7 |
from datetime import date, timedelta
|
| 8 |
from functools import lru_cache
|
|
@@ -46,9 +47,18 @@ def highlight_search(text: str, search: str) -> Markup:
|
|
| 46 |
return Markup(highlighted)
|
| 47 |
|
| 48 |
|
| 49 |
-
# Register custom
|
| 50 |
templates.env.filters["highlight"] = highlight_search
|
| 51 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
# Dataset config
|
| 53 |
DATASET_REPO = "librarian-bots/arxiv-cs-papers-lance"
|
| 54 |
|
|
|
|
| 3 |
Downloads Lance dataset from HuggingFace Hub and loads locally.
|
| 4 |
"""
|
| 5 |
|
| 6 |
+
import math
|
| 7 |
import re
|
| 8 |
from datetime import date, timedelta
|
| 9 |
from functools import lru_cache
|
|
|
|
| 47 |
return Markup(highlighted)
|
| 48 |
|
| 49 |
|
| 50 |
+
# Register custom filters
|
| 51 |
templates.env.filters["highlight"] = highlight_search
|
| 52 |
|
| 53 |
+
|
| 54 |
+
def confidence_fmt(score):
|
| 55 |
+
"""Format confidence as percentage, truncating to 1 decimal to avoid rounding 99.95->100."""
|
| 56 |
+
pct = math.floor(score * 1000) / 10
|
| 57 |
+
return f"{pct:.1f}"
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
templates.env.filters["confidence"] = confidence_fmt
|
| 61 |
+
|
| 62 |
# Dataset config
|
| 63 |
DATASET_REPO = "librarian-bots/arxiv-cs-papers-lance"
|
| 64 |
|
templates/partials/paper_card.html
CHANGED
|
@@ -36,7 +36,7 @@
|
|
| 36 |
</span>
|
| 37 |
</span>
|
| 38 |
<span class="text-gray-400 inline-flex items-center gap-1">
|
| 39 |
-
{{
|
| 40 |
<span class="cursor-help" title="Model confidence this paper introduces a new dataset">
|
| 41 |
<svg class="w-3.5 h-3.5 text-gray-300" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
| 42 |
<circle cx="12" cy="12" r="10" stroke-width="1.5"></circle>
|
|
@@ -47,7 +47,7 @@
|
|
| 47 |
</span>
|
| 48 |
{% else %}
|
| 49 |
<span class="{% if paper.confidence_score < 0.8 %}text-gray-400{% else %}text-gray-500{% endif %} inline-flex items-center gap-1">
|
| 50 |
-
{{
|
| 51 |
<span class="cursor-help" title="Model confidence this paper introduces a new dataset">
|
| 52 |
<svg class="w-3.5 h-3.5 {% if paper.confidence_score < 0.8 %}text-gray-300{% else %}text-gray-400{% endif %}" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
| 53 |
<circle cx="12" cy="12" r="10" stroke-width="1.5"></circle>
|
|
|
|
| 36 |
</span>
|
| 37 |
</span>
|
| 38 |
<span class="text-gray-400 inline-flex items-center gap-1">
|
| 39 |
+
{{ paper.confidence_score|confidence }}% conf.
|
| 40 |
<span class="cursor-help" title="Model confidence this paper introduces a new dataset">
|
| 41 |
<svg class="w-3.5 h-3.5 text-gray-300" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
| 42 |
<circle cx="12" cy="12" r="10" stroke-width="1.5"></circle>
|
|
|
|
| 47 |
</span>
|
| 48 |
{% else %}
|
| 49 |
<span class="{% if paper.confidence_score < 0.8 %}text-gray-400{% else %}text-gray-500{% endif %} inline-flex items-center gap-1">
|
| 50 |
+
{{ paper.confidence_score|confidence }}% conf.
|
| 51 |
<span class="cursor-help" title="Model confidence this paper introduces a new dataset">
|
| 52 |
<svg class="w-3.5 h-3.5 {% if paper.confidence_score < 0.8 %}text-gray-300{% else %}text-gray-400{% endif %}" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
| 53 |
<circle cx="12" cy="12" r="10" stroke-width="1.5"></circle>
|