BM25Index (core/retrieval.py)

ScienceClaw · packages/scienceclaw/scienceclaw/core/retrieval.py · python · MIT
search, tag:knn-classified

Retrieve(D_t; S_r) and Retrieve(D_t; O_r): lexical top-k retrieval of Skills and Operators (paper Eq. 6). The retriever ranks the components of an :class:`~scienceclaw.core.program.AgentProgram` against the *episode query* — the objective, task type, tags, discipline and required

# Source: https://github.com/beita6969/ScienceClaw | License: MIT | Copyright 2025 Peter Steinberger
# Provided via justclaw.it.com; keep this notice with the code.
"""Retrieve(D_t; S_r) and Retrieve(D_t; O_r): lexical top-k retrieval of Skills and Operators (paper Eq. 6).

The retriever ranks the components of an :class:`~scienceclaw.core.program.AgentProgram` against the
*episode query* — the objective, task type, tags, discipline and required-output type of the episode —
with a small pure-Python Okapi BM25 over ``Skill.search_text()`` / ``OperatorSpec.search_text()``, plus a
tag / applicability bonus:

* discipline match (skill tag or operator ``contract.applicability["disciplines"]`` / tags),
* task-type match (same sources, ``applicability["task_types"]`` for operators),
* episode-tag

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key