How Facebook’s Graph Search works…sort of

facebook graph search icon

Even though Graph Search hasn’t been rolled out to everyone yet, it has managed to become the talk of Facebook lately; and for good reason. For those unfamiliar, Graph Search is Facebook’s answer to the personalized results you can get from search engines like Google and Bing – just far more contextualized and with way more specific data about your social circle (and your social circle’s social circle).

How exactly Graph Search works has remained a bit of a mystery, but recently Facebook’s Engineering blog gave a no-holds-barred look at what makes Graph Search’s gears turn.

By comparison, Facebook’s older search engine (called PPS) was elementary. Keywords were the only factors that PPS used to generate results . Even its “Search Filter” was rudimentary, narrowing down results based on broad topics like People, Groups, and Pages, to name a few.

Now let’s dig into Graph Search. Over the past few years, Facebook has been slowly integrating new features that would eventually feed Graph Search. Take, for example, “Typehead,” which is essentially Facebook’s answer to Google’s Autocomplete. As you type a query, the search engine makes an educated guess as to what you’re searching for and suggests results in a dropdown box. Typehead introduced in 2009 – long before Graph Search was introduced – but it wasn’t as sophisticated then as it is now inside Graph Search.

This is where things start to get complicated. To conceptualize how Graph Search works, think of the bigger picture of relationships between friends, pages, photos, posts and groups as a vast web. Friends have a relationship to friends, pages and photos via likes and comments. And these pages, photos and groups have a relationship with each other.

fbid graph search

Facebook’s engineers shared the above diagram to try to break things down a little bit. Picture the large dots, which we’ll call nodes, as nouns – they could be friends, pages, groups, posts and even your name. How these nouns are related to each other are represented by the arrows (which include relationship attributes like “Friend,” “Tagged,” “Photo,” “Event,” “Likes,” and so forth) called “Edges.” So, what you see in this diagram is how user Sriram Sankar would be related to the page titled “Breville.” In this case, the relationship is via a “like.”

Taking a step back and looking at the bigger picture, you might be astonished at how Facebook has managed to map out a network piggybacking on our social nature. It even knows the relationship between Queen Elizabeth and George VI and the history of Star Wars, says Facebook Engineer Sriram Sankar.

To make the experience for users more search engine-like, Facebook moved away from solely relying on keyword searches for Graph Search and decided on natural language processing. This means you can type searches the way you naturally speak and Graph Search’s algorithm will look at every single word you’ve typed and determine what you’re looking for.

The concept seems easy enough, but apparently executing it was easier said than done. With Facebook’s original search engine (1.0), actions on Facebook – check ins, likes, comments, your personal info, etc. – were only used to rank results.  With version 2.0, Graph Search indexes all of these actions to figure out the relationship between the words you’ve typed. For instance, if you search for “Mark Zuckerberg,” Graph Search needs to know that “Mark” and “Zuckerberg” refers to Facebook’s CEO, not people who happen to share the first name “Mark” and last name “Zuckerberg.” Programming Graph Search to know the difference wasn’t easy – and that’s where “Unicorn” enters the picture.

Simply put, Unicorn tags each node with numbers and uses it to decipher what you’re searching for contextually. Take a look at the following index, which was noted in the blog post as an example.

If Facebook were to index the names Mark Zuckerberg (fbid: 4), Randi Zuckerberg (fbid: 13755), Mark David Johnson (fbid: 1001) Randi Johnson (fbid: 5542), and David Johnson (fbid: 10003), the following  is how it might look. It’s a bunch of names and numbers and graphs right now, but you’ll understand what it means in just a minute (for reference: fbid refers to Facebook ID). 

mark → 4

zuck → 4

randi → 13755

zuck → 13755

mark → 1001

david → 1001

johnson → 1001

randi → 5542

johnson →5542

david → 10003

johnson → 10003

The name Mark Zuckerberg (Zuck) is tagged with fbid 4, Randi Zuckerberg is tagged with 13755, and so forth. This organization is applied without regard to the space between the names since the names are related. Potentially, a name like Mark could have as few as one entry (fbid number) or millions.

fb graph search unicorn

This is important because Graph Search treats a name like “David Johnson” as a search for “David” and “Johnson.” But, as the grid above illustrates, Graph Search seeks to understand that relationship between the two names.

To figure out which “Johnson” you might be searching for, Facebook uses what it calls “importance” to pull results that Unicorn thinks are the most important to you.. To visualize how Unicorn would decipher what you’re looking for, look at the three dots under “Johnson.”  Of the possible results, the one that Facebook will spit back at you is the one considered most relevant. Facebook doesn’t get into the specifics of importance metric however, so there’s little light we can shed on how it works.

And there you have it. Now you should have a pretty good idea on how Facebook Graph Search works for you to impress your friends with, or to bring up in a bar conversation.

Emerging Tech

Will we ever fly supersonic again? Unraveling the concorde’s complex legacy

In a new book, Last Days of the Concorde, journalist and author Samme Chittum delves into the mindset that inspired engineers to design this marvel, the series of events that led to its fatal crash, and the possibility that commercial SSTs…
Cars

Hold on to your butts: These are the fastest cars in the world

Think your car is unbelievably fast? Think again. From wind-cheating bodywork to powerful engines, these cars were designed for the singular pursuit of speed (and it shows).
Cars

Watch this 1,000-horsepower Jeep Trackhawk scorch supercars in the quarter mile

The Jeep Grand Cherokee Trackhawk is pretty quick out of the box, but Texas tuner Hennessey Performance Engineering never settles for stock. Its HPE1200 Trackhawk boasts over 1,000 horsepower.
Movies & TV

The best new movie trailers: ‘Glass,’ ‘Mortal Engines,’ ‘Pet Sematary’ and more

Everyone loves a good trailer, but keeping up with what's new isn't easy. To simplify things, we round up the best ones each week. On tap this week: New trailers for Pet Sematary, Glass, Mortal Engines, and other upcoming films.
Social Media

These are the best ways to make an animated GIF

Love sharing GIFs with your friends and peers, but wish you could make your own? Here's how to do so in Photoshop, or using a few other methods that don't require you to shell out a premium fee with each calendar year.
Social Media

Instagram says its A.I. can track down bullying in photos

Instagram is turning to artificial intelligence to help it root out bullying on its platform. Following similar efforts to target bullying in comments, the company now has systems capable of detecting bullying in photos, too.
Social Media

Snapchat is using VR to let you step inside its new original shows

Tuning in to your favorite shows not enough? Snap Originals will allow viewers to set into a virtual set. The new exclusive shows debut today with three different shows. Snap Originals are vertical, short, and exclusive to the platform.
Social Media

3D Facebook photos jump out of the newsfeed, no glasses needed

You're not seeing things -- that photo in your Facebook newsfeed is 3D. Launching today, 3D Facebook Photos use the depth maps from dual-lens smartphones to add dimension to an image as you move your phone.
Social Media

Instagram is testing a new way for you to look through your feed

Instagram is constantly tweaking its app to help give its users the best experience possible, so how do you like the sound of tapping — instead of swiping — to look through your feed?
Computing

Was your Facebook account hacked in the latest breach? Here’s how to find out

Facebook now reports that its latest data breach affected only 30 million users, down from an initial estimate of 50 million accounts. You can also find out if hackers had accessed your account by visiting a dedicated portal.
Mobile

Hinge's new feature wants to know who you've gone out on dates with

With its new "We Met" feature, Hinge wants to learn how your dates are going with matches in its app. That way, it can inject the information into its algorithm to provide future recommendations that better suit its users' preferences.
Social Media

Like a pocketable personal stylist, Pinterest overhauls shopping tools

Pinterest shopping just got a bit better with a trio of updates now rolling out to Pinterest. The first replaces Buyable Pins with Product Pins for more features, including knowing whether or not a product is in stock.
Smart Home

Facebook’s new Portal device can collect your data to target your ads

Facebook confirmed that its new Portal smart displays, designed to enable Messenger-enabled video calls, technically have the capability to gather data on users via the camera and mic onboard.
Social Media

YouTube is back after crashing for users around the world

It's rare to see YouTube suffer serious issues, but the site went down around the world for a period of time on October 16. It's back now, and we can confirm it's loading normally on desktop and mobile.