A content-based recommender suggests entities by comparing their attributes. On a job site, it can rank jobs against a user’s desired title, industry, salary range, experience, and skills. On a product page, it can suggest items whose categories or descriptions resemble the item being viewed. Unlike recommendations driven by shared user behavior, these matches can be made from the available content. section 9.2.1 section 1.2.2
Choose what to compare based on the recommendation task:
- User to item: match profile or résumé attributes to job attributes, then rank the matching jobs. section 9.2.1
- Item to item: start with an item of interest and find others with related attributes. A viewed detergent might lead to fabric softener and dryer sheets through a shared laundry category and similar descriptions. section 9.2.1
Document text can also become a recommendation query. A semantic knowledge graph (SKG) scores phrases from a starting document against its topic. Keep the strongly related phrases, use their relatedness scores as query boosts, and search the index for related documents. This offers a domain-aware route when there are too few user interactions for collaborative filtering. section 5.4.6 section 5.6
Listing 5.9 Generating a recommendation query from scored phrases
def get_scored_terms(traversal):
return {term: data["relatedness"]
for term, data in traversal["graph"][0]["values"]["star wars"] \
["traversals"][0]["values"].items()}
rec_query = " ".join(f'"{term}"^{score}'
for term, score in get_scored_terms(traversal).items()
if score > 0.25)
print(f"Expanded Query:\n{rec_query}")
The Python listing turns scored document phrases into a boosted search query, retaining only phrases with relatedness above 0.25. section 5.4.6
From a document to related results
For a document classified as “star wars,” the SKG scores phrases including “luke,” “force,” and “darth vader” highly, while unrelated words score poorly or negatively. Searching with the retained, boosted phrases returns related question titles. The starting document supplies the context; the scored query determines which other documents rank highest. section 5.4.6
The choice of attributes matters: a content match can emphasize features users do not care about. Behavioral signals can improve ranking when sufficient interactions exist, but cannot support items with little interaction history. A hybrid recommender can therefore use content matching as a baseline and give collaborative filtering more influence where signals are plentiful. section 4.1.1 section 9.2.3


