You might’ve noticed that you can now make your Instagram feed look a little different. Instead of seeing posts in an order determined by Instagram’s algorithm, you now have the option to scroll posts chronologically or filter your feed so you only see photos from hand-selected favorite people who you follow. Try it out by tapping on the Instagram logo in the top left corner of your home page and selecting “Following” or “Favorites.”
Some people bristled at the fact that the homepage still defaults to the algorithmic feed, showing you a ranked feed that includes suggested accounts to follow and presenting ads that are relevant to your interests. You have to opt-in to see your “deterministic chronological field,” Adam Mosseri, head of Instagram, explained in an announcement video posted Wednesday.
When Instagram first launched in 2010, the feed was a single stream of photos presented chronologically. In 2016, Instagram switched it up and “introduced a Feed that ranked posts based on what you care about most,” Adam wrote in a blog in June 2021.
Since then, Instagram’s personalization has become a keystone of the product, and a wellspring of data for the company to research. Not everyone was happy with the change, which is one reason why Instagram brought back the stripped-down chronological feed.
If you’re interested in programming, you might be wondering: What’s going on behind-the-scenes of a social media algorithm shift like this? There’s a lot that’s under wraps, but here’s what you need to know about the technical difference between a deterministic chronological feed and one that’s ranked.
Chronological sorting is relatively easy
Sorting is a common function in lots of programming languages that allows you to organize data in the order that you want it. Through sorting, you can take data and create an array, or a collection of elements in an order — like chronologically or reverse chronologically.
Using photos as an example, you’d need meta fields (additional data that is used to describe a document) that include data on when the photo was taken in order to sort posts chronologically. “It’s easy to do if you know the language syntax,” says Kenny Lin, Codecademy’s Domain Manager.
Fun fact: Instagram was originally written in the programming language Python. Want to learn Python? Check out our beginner-friendly course Learn Python 3, for hands-on experience utilizing tools like control flow and Boolean logic. Once you have a basic grasp on Python, Learn Sorting Algorithms with Python is a great next step to learn how to implement sorting algorithms to parse through data.
Algorithms that involve ranking are more challenging to make
Instagram’s ranking system that decides which photos get priority in a user’s feed is really “a variety of algorithms, classifiers, and processes, each with its own purpose,” Adam wrote in a 2021 blog post.
To go back to that photo example: If you want to sort chronologically, you just need the timestamp for each photo. If you want to sort the images using a ranked system, you’d need multiple types of data for each photo. Then, you’d write an algorithm in which the various data points are all weighed differently so that certain categories influence the order of the photos more than others.
And although Instagram’s algorithm is proprietary, it’s not as elusive as it seems. There’s a detailed explanation of the machine learning tactics that Instagram uses on the Meta AI blog. Simply put, Instagram’s ranking system is a group of machine learning models, AI systems, and non-AI technologies.
The exact order of your Instagram feed is based on five key interactions: “how likely you are to spend a few seconds on a post, comment on it, like it, save it, and tap on the profile photo,” Adam wrote in the 2021 blog. “The more likely you are to take an action, and the more heavily we weigh that action, the higher up you’ll see the post.”
Using this data, Instagram assigns an A.I. “score” to all unseen content from your connections, including things like shopping posts and Reels (though, according to Meta, they’re all weighted fairly so that one type of post doesn’t take over your feed). There’s also a key step in this process that weeds out posts containing misinformation or ones that violate Instagram’s community guidelines.
“The ranking algorithm aims at personalization ultimately — and it’s what makes our feeds interesting (or addictive),” explains Nitya Mandyam, Senior Curriculum Developer at Codecademy.
As you can see, there’s a lot more data that needs to go into building an algorithm like Instagram’s. “Recommendation systems are inherently a difficult problem in AI, as validating them is non-trivial unlike other predictive machine learning algorithms where there is one correct answer (say predicting fraud: it’s either a yes or no!),” Nitya says.
So, a lot of attention is paid to fine tuning an algorithm so it presents the right balance of randomness and specificity: When algorithms do poorly (like, they don’t capture your interests or tastes) it can be irritating, Nitya says. “When they do too well, they can be ‘creepy.’”
How you can learn the skills needed to build algorithms
But this is just one example of how machine learning and AI can have a profound effect on our daily lives. If you want to understand more about how social media filters are built, and the vast applications of machine learning, check out Codecademy’s Machine Learning courses.
Our Build a Recommender System skill path will walk you through the fundamentals of data analysis and machine learning as you learn how to build your own recommendation engines. And if you’re already familiar with the basics, you can start building right away in our free course Learn Recommender Systems.
The Pro skill path Get started with Machine Learning will teach you how to use Python to clean and manipulate data and use predictive models to make recommendations. For a beginner-friendly option, try our Machine Learning Fundamentals skill path. And if you need to be briefed on what a Machine Learning Engineer does, we have you covered.