Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .changeset/prospects-shortlist-learns.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
"@launchstack/pipelines": minor
---

The Prospects fit check learns as it goes, and a run keeps what it learned.

- The shortlist's fit check asks about ten companies a round, where it asked
about two per open place (fifty in the first round of the default 25-place
shortlist). After each round `fillShortlist` re-ranks everyone not checked
yet from the verdicts so far (`createShortlistLearner`: LinUCB over the
candidates' embeddings) and asks about the highest ranked next. Before any
verdict the learner's prediction is the fixed relevance ranking; from the
first round on it adds a bonus for companies unlike the ones already asked
about, so the first round is close to the fixed order, not equal to it.
Companies matched by shared words (no embedding model) are checked in the
fixed order and rounds as before.
- Verdicts are kept in the new table `distribution_fit_verdicts`, one row per
company and segment (`saveFitVerdicts`, `listFitExamples`). The next run's
ranking starts from them and from the stage people moved the segment's
deals to (`fitDecision`). The fit check's verdicts are kept under the
question they answered (`segmentKey`: offering, categories, constraints,
buyer kinds and area, as the run narrowed them), so a segment that was
rewritten or moved starts afresh. The check after research asks about the
one kind of buyer and the one area a company was filed under: its yes is
kept under the run's key, its no under that narrower question's own key
(`researchVerdictKey`), so on a segment with several kinds or areas a no to
one of them is not taken for the segment's answer. People's decisions
always count.
- A fit check that breaks off part-way no longer leaves a shortlist of only
the companies it got through: the places it left open go to the next
companies down the ranking, unchecked. A company named outside the
segment's area that the check never read stays out, as it does with no fit
check at all. The run's warning says which of the three happened: nothing
was checked, part of the list is unchecked, or the list holds only the
companies that were read.
- `RunSummary.fitCheck` (optional) says how many companies the fit check read,
in how many rounds, how many it turned away, how many earlier verdicts the
ranking started from and whether it broke off (`incomplete`). `Relevance`
gains optional `vectors` and `measure`.

The table comes with the app's migration
`20261129231658_distribution_fit_verdicts`. A failure to read or keep verdicts
never stops a run: it learns from its own verdicts alone. When the learner
cannot be built, or cannot rank, the fixed ranking takes over.
112 changes: 112 additions & 0 deletions apps/web/__tests__/prospects/adapter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,118 @@ describe("runs", () => {
expect(sources.children!.map(c => c.status)).toEqual(["done", "skipped", "done"]);
});

/** A completed run's summary, before any fit check is counted in it. */
const summary = {
sources: [{ source: "web" as const, queries: 4, results: 60, status: "ok" as const }],
mentions: 60,
resolved: 51,
excluded: 0,
shortlisted: 25,
enriched: 25,
gateRejections: 0,
budgetExhausted: 0,
screened: 0,
flagged: 0,
published: 0,
degraded: false,
warnings: [],
tokens: { input: 0, output: 0, total: 0 },
};

it("says under the shortlist what the fit check read and what the ranking already knew", () => {
const shortlist = (fitCheck?: {
checked: number;
rounds: number;
rejected: number;
learning: boolean;
startedFrom: number;
incomplete?: boolean;
}) =>
toRunDto(
run({
status: "completed",
summary: { ...summary, ...(fitCheck ? { fitCheck } : {}) },
})
).steps.find(s => s.id === "shortlist")!;

// A run without a fit check, and every run from before it was counted: no row.
expect(shortlist().children).toBeUndefined();

const first = shortlist({
checked: 34,
rounds: 4,
rejected: 9,
learning: true,
startedFrom: 0,
}).children!;
expect(first.map(c => [c.id, c.label, c.detail, c.right, c.status])).toEqual([
["fit-check", "Fit check", "34 read, 9 turned away", null, "done"],
]);
expect(first[0]!.detailCopy).toEqual({
key: "growth.server.runs.fitRead",
values: { checked: "34", rejected: "9" },
});

const later = shortlist({
checked: 30,
rounds: 3,
rejected: 5,
learning: true,
startedFrom: 35,
}).children![0]!;
expect(later.right).toBe("35 earlier verdicts");
// A number, so the catalogue can say "1 earlier verdict".
expect(later.rightCopy).toEqual({
key: "growth.server.runs.fitStartedFrom",
values: { count: 35 },
});
const one = shortlist({
checked: 30,
rounds: 3,
rejected: 5,
learning: true,
startedFrom: 1,
}).children![0]!;
expect(one.right).toBe("1 earlier verdict");
});

it("shows a fit check that broke off as failed, with what it got through", () => {
const row = (checked: number, rejected: number) =>
toRunDto(
run({
status: "completed",
summary: {
...summary,
fitCheck: {
checked,
rounds: checked > 0 ? 1 : 0,
rejected,
learning: true,
startedFrom: 0,
incomplete: true,
},
},
})
).steps.find(s => s.id === "shortlist")!.children![0]!;

// The model failed on its second round: ten were read.
const stopped = row(10, 8);
expect([stopped.label, stopped.detail, stopped.status]).toEqual([
"Fit check",
"stopped after 10 read",
"failed",
]);
expect(stopped.detailCopy).toEqual({
key: "growth.server.runs.fitStopped",
values: { checked: "10" },
});

// It failed at once: no tick over "0 read, 0 turned away".
const never = row(0, 0);
expect([never.detail, never.status]).toEqual(["could not run", "failed"]);
expect(never.detailCopy).toEqual({ key: "growth.server.runs.fitNotRun" });
});

it("lists every source, lookalikes included, before a run has a summary", () => {
const dto = toRunDto(
run({ status: "gathering", options: { maxCandidates: 25, mode: "live" } })
Expand Down
Loading
Loading