See why a post ranked where it did
findRelatedScored gives you the scores. explainRelated shows which words earned them, so you can check a strange match instead of guessing.
explain.ts
model.explainRelated("science-books-space", "science-books-autumn");
univers · 6.67latest · 3.81physic · 3.73dark · 2.83us · 2.35
Works with Astro content collections
getRelated("posts", entry, { limit: 3 }) reads the collection when the page renders. It works with static output and with on-demand rendering.
const related = await getRelated("posts", entry,
{ limit: 3 });
return related;
Topics from a fixed list
classify(topics, text) matches text against topic descriptions you write. You don't train anything or ship a model file, and the text never leaves your process.
const topics = [{ tag: "space", description }];
const best = classify(topics, text);