Filtering removes candidates that should not be recommended, regardless of how relevant they might be. In a four-stage recommender, retrieval gathers candidates, filtering applies eligibility rules, scoring estimates relevance, and ordering produces the final list. Keeping rules separate from scoring lets teams change them without retraining a model. section 1.4.1 section 1.4.2
Choose rules according to the domain:
- Remove unavailable or prohibited items, such as out-of-stock products, regionally unavailable titles, or age-restricted content. section 1.4.1 section 2.2.3
- Remove previously consumed items when repetition is unwanted, such as watched movies or read news articles. Do not apply that rule blindly: listeners replay favorite songs, and shoppers repurchase groceries. section 2.2.3
- For document retrieval in retrieval-augmented generation, remove outdated or low-quality sources before relevance scoring. section 1.4.2
Filtering watched movies
Retrieve 100 movies similar to a seed movie. Build a set of movie IDs from the user's ratings history, then retain only candidates whose IDs are absent from that set. In one test, 28 of the 100 candidates were removed, leaving 72 to score and rank. section 2.2.3
Listing 2.5 Filtering watched movies
def get_user_history(user_id): #A
user_movies = ratings[ratings['userId'] == user_id]['movieId'].values
return set(int(mid) for mid in user_movies)
def filter_watched(candidates, user_id): #B
user_history = get_user_history(user_id)
filtered = [
item for item in candidates
if item['movie_id'] not in user_history
]
return filtered
The listing shows the history lookup and candidate-membership check used by the watched-movie filter. section 2.2.3
Evaluate filtering as a correctness requirement, not primarily with ranking metrics. Spot-check results and automate tests for consumed items, regional availability, and age restrictions. A rule failure may barely change aggregate precision while being immediately visible to affected users. Test the filter independently by supplying candidates and checking which ones survive. section 4.6.5 section 2.2.8


































