Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change algorithm of follow recommendations #28314

Merged
merged 8 commits into from
Dec 19, 2023
Merged

Conversation

Gargron
Copy link
Member

@Gargron Gargron commented Dec 11, 2023

Replace "past interactions" algorithm with "friends of friends" while respecting the "show follows and followers" and "feature profile in discovery algorithms" privacy settings. Cleans up a lot of the code surrounding follow recommendations. We can avoid maintaining sorted sets per language for global follow recommendations in Redis when the materialized view query is fast enough.


Fixes MAS-171

@Gargron Gargron added the new user experience Features for attracting and onboarding new users label Dec 11, 2023
@Gargron Gargron force-pushed the feature-follow-recommendations branch 3 times, most recently from 17eccfb to cdba643 Compare December 12, 2023 04:08
Copy link

codecov bot commented Dec 12, 2023

Codecov Report

Attention: 15 lines in your changes are missing coverage. Please review.

Comparison is base (8b1eeb2) 83.67% compared to head (c012e5f) 83.70%.
Report is 5 commits behind head on main.

❗ Current head c012e5f differs from pull request most recent head 7e19344. Consider uploading reports for the commit 7e19344 to get more accurate results

Files Patch % Lines
...els/account_suggestions/similar_profiles_source.rb 57.89% 8 Missing ⚠️
app/controllers/api/v2/suggestions_controller.rb 71.42% 2 Missing ⚠️
app/models/account_suggestions.rb 93.75% 0 Missing and 1 partial ⚠️
...s/account_suggestions/friends_of_friends_source.rb 83.33% 1 Missing ⚠️
app/models/concerns/account/search.rb 0.00% 0 Missing and 1 partial ⚠️
app/models/follow_recommendation_filter.rb 50.00% 1 Missing ⚠️
app/services/account_search_service.rb 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #28314      +/-   ##
==========================================
+ Coverage   83.67%   83.70%   +0.02%     
==========================================
  Files        1038     1039       +1     
  Lines       28255    28221      -34     
  Branches     4555     4549       -6     
==========================================
- Hits        23642    23622      -20     
+ Misses       3485     3470      -15     
- Partials     1128     1129       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Gargron Gargron force-pushed the feature-follow-recommendations branch 2 times, most recently from b692dfb to e11b233 Compare December 12, 2023 09:42
@Gargron Gargron force-pushed the feature-follow-recommendations branch 2 times, most recently from b722fa3 to 5bb804d Compare December 12, 2023 20:47
@Gargron Gargron marked this pull request as ready for review December 12, 2023 20:59
@Gargron Gargron force-pushed the feature-follow-recommendations branch 3 times, most recently from e63510c to 3fc259d Compare December 12, 2023 22:01
Copy link
Contributor

@ClearlyClaire ClearlyClaire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems sensible overall, but I have a hard time evaluating the actual algorithms. On my single-user instance:

  • AccountSuggestions::FriendsOfFriendsSource does not return a single suggestion
  • AccountSuggestions::SimilarProfilesSource does return suggestions, but no one I would follow if I weren't following them already (as pointed out in inline comments, the must_not_clauses filtering them out are not actually used in the final query)

From my own perspective (single-user server with around 250 follows), those recommendations perform worse than the existing ones in that it doesn't recommend people I would actually consider following. That being said, I do not use this feature either way.

Also, this PR requires re-indexing accounts, this needs to be mentioned.

app/models/account_suggestions.rb Outdated Show resolved Hide resolved
Copy link
Contributor

@ClearlyClaire ClearlyClaire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition to the inline comment, there's an API design issue I'm wondering about: the API returns, along with suggestions, which source they're from. However, there is no way to select or filter them, which makes the source classification much less useful imho.

db/schema.rb Outdated Show resolved Hide resolved
@Gargron
Copy link
Member Author

Gargron commented Dec 14, 2023

The source is not intended to filter, but to provide transparency about why a suggestion appears.

@ClearlyClaire ClearlyClaire added the build-image Build a container image for this PR label Dec 15, 2023
app/services/favourite_service.rb Outdated Show resolved Hide resolved
app/services/reblog_service.rb Outdated Show resolved Hide resolved
spec/requests/api/v1/suggestions_spec.rb Show resolved Hide resolved
spec/requests/api/v1/suggestions_spec.rb Show resolved Hide resolved
Copy link
Contributor

This pull request has merge conflicts that must be resolved before it can be merged.

@Gargron Gargron force-pushed the feature-follow-recommendations branch from ba14b61 to 5ddcf67 Compare December 19, 2023 05:23
@Gargron Gargron force-pushed the feature-follow-recommendations branch from 5ddcf67 to c012e5f Compare December 19, 2023 05:26
Copy link
Contributor

This pull request has resolved merge conflicts and is ready for review.

ClearlyClaire
ClearlyClaire previously approved these changes Dec 19, 2023
Copy link
Contributor

@ClearlyClaire ClearlyClaire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems fine overall, although I'm still not sure about the quality of the recommendations, especially on small servers.

Also, this requires re-indexing accounts for the “similar profiles” source to work, we'll need to remember to add that to the release notes.

app/services/favourite_service.rb Outdated Show resolved Hide resolved
app/services/reblog_service.rb Outdated Show resolved Hide resolved
@Gargron Gargron added this pull request to the merge queue Dec 19, 2023
Merged via the queue into main with commit b5ac61b Dec 19, 2023
46 checks passed
@Gargron Gargron deleted the feature-follow-recommendations branch December 19, 2023 11:06
@vmstan
Copy link
Sponsor Contributor

vmstan commented Dec 19, 2023

Seems fine overall, although I'm still not sure about the quality of the recommendations, especially on small servers.

Also, this requires re-indexing accounts for the “similar profiles” source to work, we'll need to remember to add that to the release notes.

Is this re-indexing in ES or something else?

@ClearlyClaire
Copy link
Contributor

ES. You need to run tootctl search deploy --only=accounts basically

@outlaw-dame
Copy link

I do believe for minorities that have opted into discovery, there should be a bump that allows those accounts better options to be found.

@ocdtrekkie
Copy link

@outlaw-dame I don't have an issue with this, but I suspect the implementation would be messy. Presumably you'd either need to skim profile data for specific keywords you wanted to bump, or you'd need to add profile options for users to self-claim that they should be included (which would need to be federated, since you don't want to only recommend local users). I'm guessing it would probably be preferable to base it on profile data so there isn't a check box people can just check for growth hacking, but then someone would need to maintain a list of key words or phrases that should trigger such a bump.

@tribela
Copy link
Contributor

tribela commented Dec 31, 2023

Blocked persons(individual block + server block) are listed on follow suggestion by "friends_of_friends"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build-image Build a container image for this PR new user experience Features for attracting and onboarding new users
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants