What did QQ Music and NetEase Cloud do when you press “Shuffle”?

After get off work, I walked into a familiar subway station again and listened to the sound of the subway track that has been heard countless times. You suddenly feel that every day is a bit boring and monotonous, just like the sun rises from the east and sets from the west every day .

Put on your headphones and open your favorite playlist, just like you always do. You click the button of random play, hoping to give control to the player and the algorithm, so that they can bring you a bit of unknown freshness.

Have you ever wondered how the random play algorithm presents us a random playlist?

"True random" or "pseudo random"

The most classic random music player in history should be the iPod Shuffle.

In 2005, Apple launched the classic iPod Shuffle. The iPod Shuffle was an outlier at the time. At that time, the music players (in the era when they were called MP3) basically had a display On the music information screen, users can freely choose their favorite music, and even some MP3s can also play videos. For example, the miniplayer M6 launched by Meizu in 2006 is already equipped with a 2.4-inch display.

The iPod Shuffle does not have a screen, and is generally simpler than Apple's own iPad Nano. But the biggest question is, how do users choose their favorite songs?

The answer is a random list. You can sync your favorite music through iTunes, or you can directly sync a playlist you like, but on the iPod Shuffle, the biggest feeling you can get is "the charm of random play."

In fact, there are two common ways of "shuffle play", one is called "Shuffle" and the other is called "Random".

▲ Shuffle algorithm. Picture from: 9to5Mac

Shuffle is generally called "shuffling algorithm". Its principle is like poker shuffling. Randomly arrange different numbers of playing cards to get a disorderly order. The same is true for random playlists. The songs in this list will be shuffled each time they are played, so as to obtain a random play, which is a "pseudo-random" algorithm.

Random is a real random play, that is to say, every time you switch music, it is an independent unknown number, and different music will be randomly selected. Just like "lottery", it has no concept of a list, so there is no previous and next song. The first concept is a "true random" algorithm.

How to judge whether it is "true random" or "pseudo-random", in fact, just press "previous" to know, if you switch to the one you just heard, it is the "pseudo-random" shuffling algorithm. If you switch to different songs every time, then it is a "true random" algorithm.

▲ The essence of shuffling algorithm comes from shuffling playing cards. Picture from: Phys.org

Which of these two methods is better? For current users, the shuffling algorithm should be more acceptable. In theory, it is more controllable, can meet the user's requirements for out-of-order playback, and can prevent the possibility of repeating a song.

At present, the "shuffle algorithm" is used more frequently in major music apps. For example, players such as NetEase Cloud Music and QQ Music, which have a large number of users, are in use.

What should a good random algorithm look like

But even if the "shuffle algorithm" itself has enough advantages, the original "shuffle algorithm" can no longer meet the growing demand for listening to songs, or in other words, there are situations where the player gets worse and worse. For example, in Zhihu's question, many people feel that NetEase Cloud Music's random algorithm has a big problem. For example, only a small number of fixed songs are played, and some songs never seem to be random. Some users even said that a song they deleted can still be randomly arrived.

In fact, the app intervenes in this "random list" instead of simply shuffling the cards, but in terms of the results, whether the user's perception is good or bad depends on the understanding and design of the "shuffle algorithm". Up. Although there are many users who complain about NetEase Cloud Algorithm, it does not affect popular functions such as recommended playlists and comments.

According to the answer of Liu Yanbin, a user who knows the profile as the product manager of QQ Music, more big data algorithm interventions will be added to the shuffling algorithm:

According to the research of the product team, what users want is not real "shuffle play", but users don't know which song to listen to, and more difficult to choose, hoping to help me make a decision. Moreover, try to fit my current mood as much as possible.

Random algorithm can solve the difficulty of selection, but it cannot really solve the mood of the user's needs, because the "shuffle algorithm" does not know what the user wants. But music applications can actually do this. In the case of large enough personal music data samples and big data research, the algorithm can make some judgments about which songs users want to listen to at the moment.

▲ QQ Music. Picture from: YouTube

To give a simple example, for example, when the random play is turned on in the dead of the night, it is very likely that the user does not want to listen to too noisy music such as metal and rock. Combining the user's past listening history, this time the random algorithm is According to the user's current environment time, more random to light music.

Otherwise, you think the reports of listening to the songs are so detailed, and it is clear how many times you cycle without sleeping at night which song.

Liu Yanbin, product manager of QQ Music, also summarized several characteristics that a good random algorithm should have:

  • Record my local or recent music listening records, try not to recommend them when random, to ensure random freshness
  • The shuffling algorithm is done well, as far as possible to separate a certain singer, a certain album, so that the user feels like a random list from the senses
  • You can record user operations locally, such as the number of skipped songs, downgrade or filter songs that users are not interested in, and select random pools
  • After the song tags are enriched, there are more things that can be done. For example, according to the current scene, recommending local songs suitable for listening to be played first and randomly, all of which help users perceive intelligence.

▲ Random playback of Spotify. Picture from: REGENDUS

Of course, it’s not just QQ Music that is investigating the shuffle algorithm. The streaming music service Spotify, which has always been known for its recommendation algorithm, also has a deeper thinking about the "shuffle algorithm", and they even wrote on the official website how to improve the shuffle algorithm.

Even for streaming music like Spotify, many users still feel that random playback is not "random". Of course, Spotify's shuffle algorithm is random, but they start to think about why users feel that way.

Basically, Spotify has used the Fisher-Yates shuffling algorithm from the beginning of the service. They think this shuffling algorithm is the best.

▲ If different colors are used to represent different singers, it means that when it is completely random, both upper and lower lists may appear

However, Spotify did not understand what users meant by "not random" at the beginning, but after researching, it was found that the core idea of ​​users is not to want a singer to appear repeatedly in a short time, but here the user is actually caught in a The classic "gambler's fallacy" is that when people fail to win the lottery several times in a row, they will think that their chances of winning the next lottery will increase, but in fact each time the probability is independent and the same.

But if users continue to hear a certain singer's work, they will rudely feel that this algorithm is "problematic."

The conclusion is that users do not like "perfect randomness."

Users prefer "balance" to "perfect"

So what is "Imperfect Random"?

In Martin Fiedler's blog post "The Art of Shuffle Music" , he showed why a completely random list is bad.

Suppose there are three different genres of music in your player: A, B, and C. A has 10 songs, and B and C have 11 songs, a total of 32 songs. What happens if you use a truly random algorithm to shuffle the cards? maybe:


Among them, there has been a continuous C genre, and there is no B genre in a quarter of the time. For users, repeating a single genre is undoubtedly bad. The absolute random algorithm is likely to generate such a bad playlist in most cases, because absolute random also means "unbalanced".

▲ Picture from: Marie Claire

A better random list is to satisfy the user’s inability to make a decision but want to get a sense of freshness. At this time, repetition and monotony should be avoided as much as possible, so the following playlist is more suitable:


A very stable playlist, without any "abnormalities", Martin Fidler called it "balanced shuffle". In order to achieve a more balanced playlist shuffling, Martin Fidler invented a more complex shuffling algorithm. If you are interested in the specific implementation, you can also move directly to this blog.

Spotify borrowed this algorithm, but modified it to a more suitable way, and at the same time borrowed from the dithering algorithm (such as Floyd-Steinberg dithering), and finally spread the songs more evenly and evenly into the playlist.

That's it. Today, although most of the random play algorithms of various companies are based on the "shuffle algorithm" model, they also have their own "secret seasoning recipe". Some users will like it, and some who do it badly will be constantly complained by users. of.

But in essence, the focus of the random play algorithm is not "random", but a psychological game between the product and the user, and even they will gradually develop as you listen to songs, and they are also changing random. The weighting tendency of the playlist.

The more you listen, the better they will understand you.

#Welcome to follow Aifaner's official WeChat account: Aifaner (WeChat ID: ifanr), more exciting content will be provided to you as soon as possible.

Ai Faner | Original link · View comments · Sina Weibo