paper_firehose.processors.st_ranker

Sentence-Transformers based ranking processor.

Minimal implementation: computes cosine similarity between a topic query and entry texts, and returns scores suitable for writing into papers.db (rank_score).

This module is intentionally lean and resilient: if sentence-transformers is not available or the model cannot be loaded, it logs and returns an empty result so callers can decide how to proceed.

Classes

STRanker([model_name])

class paper_firehose.processors.st_ranker.STRanker(model_name='all-MiniLM-L6-v2')[source]

Bases: object

Parameters:

model_name (str)

available()[source]

Return True when the embedding model loaded successfully.

Return type:

bool

score_entries(query, entries, *, use_summary=False)[source]

Compute similarity scores for entries.

Parameters:
  • query (str) – Natural-language ranking query

  • entries (Iterable[Tuple[str, str, str]]) – Iterable of (entry_id, topic, text) where text is typically the title

  • use_summary (bool) – If True, the provided text should include summary; default False

Return type:

List[Tuple[str, str, float]]

Returns:

List of (entry_id, topic, score) tuples