Score each role's closeness to the agent's CV, let the judge also read the 50 closest the score leaves out, and order CV match's unjudged roles by it
The CV is cut into chunks inside e5's window, embedded like a prompt and cached per agent under a hash of the model, chunking and text. A role's cv_fit (scores.cv_fit, migration 31) is its best chunk cosine, scaled with its own calibration band: fit's clipped 88 of agent 2's ungated roles to 1. It is no term of the Agent match score. judge_cv_top (default 50) sits beside judge_top and judge_min on the agents page and card. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b481cb5692
commit
c23594507a
23 files changed
+603
-85
No files matched your search
@@ -77,6 +77,62 @@ def intent_text(model: str, intent: str) -> str:
|
||||
return f"query: {intent}" if wants_e5_prefix(model) else intent
|
||||
|
||||
|
||||
#: The most of a CV one vector reads. multilingual-e5-small reads 512 tokens
|
||||
#: and cuts the rest; on the owner's English CV a paragraph runs about four
|
||||
#: characters a token (1,896 characters were 471 tokens with "query: "), so
|
||||
#: 1,200 characters stay inside the window with room for a denser language.
|
||||
CV_CHUNK_CHARS = 1200
|
||||
|
||||
#: The version of `cv_chunks`, part of the CV vectors' cache key
|
||||
#: (`score.cv_key`): a change to how a CV is cut embeds every CV again.
|
||||
CV_CHUNKING = 1
|
||||
|
||||
#: Where a long paragraph is cut, coarsest first, and what joins its pieces
|
||||
#: again: lines, then sentences.
|
||||
_CUTS = ((re.compile(r"\n+"), "\n"), (re.compile(r"(?<=[.!?;])\s+"), " "))
|
||||
|
||||
|
||||
def _pieces(text: str, limit: int) -> list[str]:
|
||||
"""`text` cut to pieces of at most `limit` characters: by line, then by
|
||||
sentence, then at the last space before the limit, else at the limit."""
|
||||
if len(text) <= limit:
|
||||
return [text]
|
||||
for pattern, glue in _CUTS:
|
||||
parts = [p.strip() for p in pattern.split(text) if p.strip()]
|
||||
if len(parts) > 1:
|
||||
return _merge([piece for part in parts for piece in _pieces(part, limit)],
|
||||
limit, glue)
|
||||
cut = text.rfind(" ", 0, limit + 1)
|
||||
cut = cut if cut > 0 else limit
|
||||
return [text[:cut].strip(), *_pieces(text[cut:].strip(), limit)]
|
||||
|
||||
|
||||
def _merge(pieces: list[str], limit: int, glue: str) -> list[str]:
|
||||
"""Neighbouring pieces joined with `glue` while the join fits `limit`."""
|
||||
merged: list[str] = []
|
||||
for piece in pieces:
|
||||
if merged and len(merged[-1]) + len(glue) + len(piece) <= limit:
|
||||
merged[-1] += glue + piece
|
||||
else:
|
||||
merged.append(piece)
|
||||
return merged
|
||||
|
||||
|
||||
def cv_chunks(cv_text: str, limit: int | None = None) -> list[str]:
|
||||
"""A CV as the texts its vectors are made from: its paragraphs (blank
|
||||
lines apart), a longer one cut by line, then by sentence, and neighbours
|
||||
joined again while they fit `limit` (`CV_CHUNK_CHARS`), so a heading
|
||||
travels with what follows it and no chunk runs past what the model
|
||||
reads."""
|
||||
limit = limit or CV_CHUNK_CHARS
|
||||
pieces = []
|
||||
for paragraph in re.split(r"\n\s*\n", cv_text):
|
||||
lines = "\n".join(" ".join(line.split()) for line in paragraph.splitlines()).strip()
|
||||
if lines:
|
||||
pieces += _pieces(lines, limit)
|
||||
return _merge(pieces, limit, "\n\n")
|
||||
|
||||
|
||||
def load_embedder(model: str) -> embedding.Embedder:
|
||||
"""The encoder. A seam of its own so a test hands in a fake and nothing
|
||||
downloads a model; `score` loads through it too."""
|
||||
|
||||
Reference in new issue
Block a user