feat(summarizer): score articles in the map phase, brief only the important ones

The map prompt now grades every article 0-100 against an explicit rubric as
the first line of its block; the summarizer parses Score:, falls back to the
Importance: label when the line is missing, ranks blocks best-first and passes
only score >= SUMMARY_MIN_SCORE (capped at SUMMARY_TOP_N) to the reduce phase.

- new pure helpers in intel.py: parse_map_scores(), select_graded(), join_blocks()
- reduce prompts drop the 'fill the brief with minor incidents and crime'
  filler instructions and the 'fill ticker with medium then low' clause
- new article_scores table (ensure_tables + alembic 012) persists every grade
  with selected/summary_id/model so thresholds can be tuned from data
- SUMMARY_MIN_SCORE (60), SUMMARY_TOP_N (12), SUMMARY_FALLBACK_TOP (3) env knobs
This commit is contained in:
hermes-backend 2026-11-13 21:47:30 -05:00
commit 853e87b7c5
8 changed files with 775 additions and 37 deletions

View file

@ -98,6 +98,13 @@ NOUS_BASE_URL=https://inference-api.nousresearch.com/v1
# Hermes-4.3-36B remains after a Postgres miss. Env wins when set.
# SUMMARY_MODEL=
NEWS_BATCH_SIZE=50
# Map-phase grading: the map model scores each article 0-100, and only blocks
# with score >= SUMMARY_MIN_SCORE reach the reduce brief (best first).
# If nothing clears the bar, the top SUMMARY_FALLBACK_TOP blocks are used
# (0 = honour the threshold and pass an empty DATA section instead).
SUMMARY_MIN_SCORE=60
SUMMARY_TOP_N=12
SUMMARY_FALLBACK_TOP=3
SUMMARY_WINDOW_MINUTES=15
# Futures/markets coupling from the upstream pipeline is OFF by default
# (irrelevant to OSINT). Set INCLUDE_FUTURES=1 + install yfinance to enable.