GSoC 2019: Recording Similarity Indexing for AcousticBrainz

For Starters… Who Am I?

My name is Aidan Lawford-Wickham, better known as aidanlw17 on IRC, and I’m entering my second year of undergraduate study in Engineering Science at the University of Toronto. This summer, I had the opportunity to participate in my first Google Summer of Code with the MetaBrainz Foundation. Working on the AcousticBrainz project under the mentorship of Alastair Porter (alastairp), I used previous work on measuring track to track similarity as the basis for a similarity pipeline using the entire AB database.

How Did I Get Involved?

When I started applying for GSoC, I needed to find an organization that paired a challenging learning environment with a project of personal interest. Given my own passion for listening to music, playing music, and exploring its overlap with culture, MetaBrainz quickly became my top priority. I jumped on the #metabrainz IRC channel for the first time, and I’ve been active daily ever since!

From there, the whole community welcomed me with open arms and responded thoughtfully to my questions about setting up my local development environment. I made my first pull request for AcousticBrainz, AB-387, which added the ability to include dataset and class descriptions when importing datasets as CSV files. This allowed me to work alongside my soon-to-be mentor for the first time and further acquaint myself with the acousticbrainz-server source code.

I was excited about my first PR and wanted to contribute more. Not only was this a project related to my passions, but it had already begun to teach me about technologies that I hadn’t used before. I was struck by the possibility to contribute more, and work with great people on a non-profit, open source project. I quickly decided that MetaBrainz was the only place I would apply for GSoC and began to think about proposals. I read through the previous work on recording similarity done by Philip Tovstogan, which was based upon a PostgreSQL solution with shortcomings in terms of speed. With a strong supporting background, high community interest, and my own dreams of the possibilities to come from predicting similar tracks, I created a proposal to build a similarity pipeline using Spotify’s nearest neighbours library, Annoy. The timeline and tasks shown on the full proposal were adjusted throughout the summer, but the general objectives were maintained. Looking back on the summer now, the basic requirements for the project were as such:

  • Using the previous work, define metrics for measuring similarity that will translate recording features from the AB database into vectors. Compute and store these vectors for every recording in the database.
  • Create an Annoy index for each of these metrics, adding the metric’s vector for each recording to the index.
  • Develop methods of querying an index, such as outputting nearest neighbours (similar recordings) to a specific recording or many recordings, or finding the similarity between two recordings.
  • Allow users to query the indices via an API.
  • Create an evaluation that allows us to measure the success of our indices in the public eye, fine tune our parameters, and display index queries via a graphical user interface.

Community Bonding Period

After losing sleep before the announcement, and a huge sigh of relief on May 6th, I was ecstatic to get started.

There was plenty of required reading, and I familiarized myself with the different elements of building similarity into AB. After discussing with Rob (ruaok) and Alastair and cementing our decision to use Annoy as the nearest neighbours algorithm of choice, I took to reading through Annoy documentation and making a small implementation to grasp the concepts. Annoy works blazing fast, and uses small, static files – these are points that would prove advantageous for us in terms of querying indices many times, as quickly as possible. Static index files allow for them to be shared across processes and could potentially make them simple to redistribute to others in the future – a major benefit for further similarity research.

I studied Philip’s previous work, gained an understanding of the metrics he used in his thesis, and reimplemented all of his code to better grasp the concepts and use them as a basis for the summer. Much of Philip’s work was built to be easily expandable, and flexible to different types of metrics. Notably, when integrating it with a full pipeline including Annoy, priorities like speed meant that we lost some of this flexibility. I found this to be an interesting contrast between the code structure for an ongoing research purpose, and the code ready to be deployed in production on a website.

All the while, I kept a frequent dialogue with Alastair to gel as a team, clarify issues with the codebase, and further develop our plans for the pipeline. To build on my development skills, learn more about contributing guidelines and source control, and improve the site, I worked on some exciting PRs during the bonding period. Most notably, I completed AB-406 over a series of 3 PRs, which allowed us to introduce a submission offset column in the low-level table to handle multiple submissions of a single recording. This reduced the need for complexity in queries to the API, decreasing the load on the server. Additionally, I added some documentation related to contributions and created an API endpoint that would allow users to only select specific features rather than an entire low-level document for a recording – aiming at reducing server load.

Last but not least, I got really involved with the weekly meetings at MB! We have meetings every Monday on #metabrainz to give reviews of the last week, and discuss any other important community topics. I love this aspect of the community. Working remotely, it creates a strong team atmosphere and brings us all a bit closer together – even if we’re living time zones apart. During one meeting, we discussed whether or not past GSoC proposals should be available to students. What do you think? This prompted me to share my own experience with the application process at MetaBrainz and look into if/how we could improve it.

… And so it began, we dove into the first coding period.

The Key Components, a Deeper Look

Computing Similarity Metrics

Having explored the previous similarity work from Philip, I used his definitions of metric classes and focused on developing a script to compute metrics for each recording in the database incrementally. Recognizing that we would also need a method of computing metrics for a single recording on submission, I made this script as open ended as possible. After successfully computing all metrics for the first time, we went through an iterative process of altering the logic and methodology to dramatically improve its speed. Ultimately, we used a query to get the batch of low-level recordings that haven’t had similarity computations, complete with their low-level data and all high-level models. Though we revised and found bugs in this script time and time again, I’m confident in saying that with perseverance we finally got it working.

Prior to the beginning of the project I had limited experience working with SQL databases, and this objective pushed me to develop new ways to approach problems, and gave me a much deeper understanding of PostgreSQL.

Building Annoy Indices

With all that vectorized recording data from the metrics computation, nothing sounds better than adding it to an ultra-fast index built for querying nearest neighbours! Feeding the data into an index and watching it output similar recordings in milliseconds became the most satisfying feeling. The Annoy library is a platform for nearest neighbours of all sorts, and it is generally simple: define the index, add items with an identifier and a vector, built the index, save it for later use, load it up, and then use its built-in methods to query for similar items. Easy, right? The added challenge is making this interface with recordings from our database as items, and meeting our needs in terms of speed and alterability when new items are added. Annoy is built without checks in many places, and we required a custom cycle of building, loading, and saving indices to ensure they were operable for our purposes (once an index is built, new items may not be added). At this point, the index model is open to saving new indices with different parameters, which allows us to tune as we further develop the pipeline.

After wrapping the index in a class that interfaced with our needs, we added scripts to build all indices and save them, and scripts to remove indices if need be. Currently, the project has 12 indices, one for each metric in use:

  • MFCCs
  • Weighted MFCCs
  • GFCCs
  • Weighted GFCCs
  • BPM
  • Key
  • Onset Rate
  • Moods
  • Instruments
  • Dortmund
  • Rosamerica
  • Tzanetakis

API Endpoints

Making API endpoints available was a high priority activity and was an exciting aspect of the project since it would allow users to interact with the data provided by a similarity pipeline. Using the index model, I created three API endpoints:

  • Get the n most similar recordings to a recording specified by an (MBID, offset) combination.
  • Get the n most similar recordings to a number of recordings that are specified (bulk endpoint).
  • Get the distance between two recordings.

For each endpoint, a parameter indicates the metric in question, determining which index should be used. Currently, the endpoints also allow varying index parameters, such as the distance type (method of distance calculation) and number of trees used in building the index (precision increases with trees, while speed decreases).

A full explanation of the API endpoints is documented in the source code.

Baseline Evaluation

As I said, an index can be altered using multiple parameters that impact the build speed, query speed, and precision in finding nearest neighbours. Assessing the query results from our indices with public opinion is a top priority, since it gives us valuable data for understanding the quality of similarity predictions. With the evaluation we will be able to collect feedback from the community on a set of similar recordings – do they seem accurate, or should a recording have been more or less similar? What recording do you think is the most similar? With this sort of feedback, we can measure the success of different parameters for Annoy, eventually optimizing our results.

Moreover, this form of evaluation provides a graphical user interface to interact with similar recordings, as a user-friendly alternative to the API endpoints. Written using React, it feels snappy and fast, and I feel that it provides a pleasing display of similar recordings. At this point in the project I was glad to accept a frontend challenge which differed from the bulk of my work thus far.

Documentation and Project Links

Similarity pipeline related:

Additional work:

Going Forward

This summer allowed for us to build on previous similarity work to the point of developing a fast, full pipeline. At this point, there is still a vast amount of work to be continued on the pipeline and I am eager to see it through. In the upcoming year I plan to continue contributing to AcousticBrainz and the MetaBrainz Foundation as a whole. These are areas that I’m interested in continuing to develop for the recording similarity pipeline:

  • Parameter tuning on Annoy indices
  • Adding more metrics to cover other recording features
  • Adding support for hybrid metrics that consider multiple features (this was started by Philip and should be integrated to provide more holistic similarity)
  • Making indices available for offline use
  • Creating statistics and visualizations of vectors for each metric

Wrapping Up

To say the least, this has been a highly rewarding experience. MetaBrainz is a community full of extraordinary, thoughtful, and friendly developers and enthusiasts. I will be forever thankful for this opportunity and the lessons that I gained this summer. I am so excited to meet everyone at the summit this September! I’d like to personally thank my mentor, Alastair Porter (alastairp), for his perceptive guidance, his support, his friendship, and his own contributions to the project. Thanks to Robert Kaye (ruaok) for his support, thoughts, and enthusiasm towards this project, as well as for his dedication to MetaBrainz. Thanks to Google for making this all possible – SoC is a highly unique opportunity to learn about open source software and make new connections! Cheers.

GSOC 2019: Add Edit Previews to Non‐Release Entities in MusicBrainz

I am Anirudh Jain (Cyna on IRC), an undergraduate student at Bharati Vidyapeeth’s College of Engineering, New Delhi, India. I’ve been working on the MusicBrainz project of the MetaBrainz Foundation as a participant in Google Summer of Code 2019. This year marks the beginning of me as an Open Source developer. My work during the GSoC 2019 period can be found in my “temp” branch in my musicbrainz-server clone. The changes there will slowly get merged into the “cyna-gsoc” branch in the main musicbrainz-server repository on GitHub as they’re reviewed.

About the Project

Continue reading “GSOC 2019: Add Edit Previews to Non‐Release Entities in MusicBrainz”

GSoC 2019: JSON Web API for BookBrainz

The time has come to wrap up the very productive and learning summer of the last 3 months as a GSoC student with MetaBrainz.

Hello Everyone!!

I am Akhilesh Kumar, a recent graduate from the National Institute of Technology, Hamirpur, India. I have been working on BookBrainz for MetaBrainz Foundation Inc. as a participant in the Google Summer of Code ’19. It has been an amazing experience and I’ve learned a lot over the summer. I was mentored by Nicolas Pelletier (Mr_Monkey on IRC) during this period. This post summarizes my contributions to the project and the experiences that I had throughout the summer.

Continue reading “GSoC 2019: JSON Web API for BookBrainz”

GSoC 2019: Support for Reviewing and Rating More Entities on CritiqueBrainz

Hello everybody! My name is Shamroy Pellew, and I am a rising sophomore at SUNY Buffalo.

This summer, as part of Google Summer of Code, I collaborated with the MetaBrainz Foundation on CritiqueBrainz, the foundation’s archive of user‐written music reviews. I have accomplished much in these past four months, and it has been a great experience working under the guidance of my mentor, Suyash Garg. Even though there is still some work to be done, most of the code I wrote has either been merged or is in code review, and I believe it is safe to say I achieved the goal of my original proposal.

Proposal

I initially planned to use the mbdata package to query the MusicBrainz database for information regarding artists, labels, recordings, and works, so I can achieve my goal of supporting reviews for these entities on CritiqueBrainz. However, I soon discovered that there exists BrainzUtils, a Python package with “common utilities used throughout MetaBrainz projects.” So it was decided that it would be best to use those utilities, instead of writing my own. Of course, a few changes had to be made. CritiqueBrainz had features that BrainzUtils was missing, so those had to be moved over and merged. The inclusion of BrainzUtils was the only real divergence between my original proposal and my actual course of action. Otherwise, everything went according to plan.

Phase 1

Adapting CritiqueBrainz code to be used in BrainzUtils was a bit of a learning curve, and took up a good majority of the first phase. I had to gain familiarity with both code bases and the difference between Python 2 and 3. I also had to write some new unit tests, to ensure everything was functioning as it should, which I’ve never done in Python before. The existing BrainzUtils code and feedback from my mentor were a great help though.

Here are the merged pull requests for this phase:

Phase 2

After I finished moving features to BrainzUtils, but before I could add support for reviewing new entities, I had to convert the existing CritiqueBrainz functionality to use BrainzUtils for data retrieval. This was a simple change, as the same code was being used, but from a different source. Once that was done, I moved on and began to work on the reviewal of new entities.

Here are the merged pull requests for this phase:

Phase 3

Adding support for reviewing of new entity types required the same simple steps for each new type. First, the new types were each added to the existing SQL script which declares entity types, and for each new type, an ALTER script was made. Then, I retrieved information about each entity through BrainzUtils, including any necessary supplementary data. The searching for the new entity types also had to be implemented, using musicbrainzngs, a Python binding for the MusicBrainz web API. So, I wrapped the musicbrainzngs searching API call in a function and created new HTML templates, using Jinja, for finding the new entities. Finally, I had to enable reviews for the new entity types. I edited the list of reviewable entity types and the existing review templates to include data about the new types.

Naturally, by this point in the project, a few bugs had popped up. There were problems with handling deleted entities, some with data not being displayed, and even cases where data was completely missing. These were solved as they appeared, and were only minor headaches.

Here are the merged pull requests for this phase:

Overall, there was also some human error on my part that slowed things down. I could have communicated more effectively and delivered each task piece by piece, which would have resulted in better feedback from my mentor.

Conclusion

In total, I have opened a total of 17 pull requests across BrainzUtils and CritiqueBrainz. If I had more time, though I would have liked to work on my stretch goal of incorporating entity ratings from MusicBrainz into CritiqueBrainz. Although I did manage to open a BrainzUtils pull request for serializing the MusicBrainz ratings when fetching information, I did not get a chance to do anything with this data.

I’d like to thank the MetaBrainz Foundation for this amazing opportunity. Thanks to the team and thanks to Google, I was able to produce something that people everywhere will be able to use. I learned a lot about open source this summer, and I was able to polish up on my Python skills. I’m looking forward to continuing work on CritiqueBrainz and the continued support from the MetaBrainz team!

GSoC 2019: An open-source music recommendation engine

Give me music that I like.

When you start discovering yourself, just know that you are at the right place and with the right people.
MetaBrainz is the one for me!

I am Vansika Pareek (pristine__ on IRC), an undergraduate student at National Institute of Technology, Hamirpur, India. I have been working on the ListenBrainz-Labs project for MetaBrainz as a participant in Google Summer of Code ’19. The end of GSOC’19 is a beginning for me. Cheers!

How it all started?

Continue reading “GSoC 2019: An open-source music recommendation engine”

MusicBrainz Server update, 2019-08-22

Here is our summer vacation homework for the MusicBrainz Server: mainly improving the Guess Case tool, fixing a fair amount of bugs and continuing the migration of templates to React.

Thanks to ferbncode for fixing the Dockerfile that creates a test database. Thanks also to acid2, alastairp, bort27, brianfreud, CatQuest, chaban, cyberskull, florentl, fmera, foolip, hibiscuskazeneko, Jeluang, liftarn, michelv, mineo, murdos, paulakreuzer, PoQStacker, tommycrock, yindesu, zexpe, and everyone who tested the beta version, reported issues, or updated website localizations.

The git tag is v-2019-08-22.

Bug

  • [MBS-2614] – Vote on edits shows expired edits
  • [MBS-5338] – Guess Case doesn’t seem to recognize roman numerals above 10
  • [MBS-5755] – English/Katakana is incorrectly classified as “unlikely language/script pair”
  • [MBS-6087] – Relationship edits for recordings don’t show up on the release edit list
  • [MBS-9028] – Wikidata link makes fetch english blurb even though resulting page is a redirect
  • [MBS-9657] – Remove “with” from Guess Case at the end of a track title
  • [MBS-9837] – Regression: Guess Case button lowercases “Ya” in English
  • [MBS-9976] – ISE on ISWC report when works have been merged away
  • [MBS-10134] – Browse query with incorrect parameters gets submitted to the search server
  • [MBS-10137] – Guess feat button doesn’t change AC on recording pages
  • [MBS-10162] – Alias seemingly ignored for recording, release and RG direct searches
  • [MBS-10250] – User profile link on Spotify shows up as “Stream at Spotify” on the external links bar
  • [MBS-10260] – Video attributes for URL relationships can’t be removed in release editor
  • [MBS-10274] – Docker: musicbrainz-test-database container fails to start
  • [MBS-10278] – Artists with members listed in PossibleCollaborations if they also have other rels

Improvement

  • [MBS-1679] – Don’t display Merge Process in release editor
  • [MBS-2250] – Go back when cancelling merge
  • [MBS-3848] – Guess Case: Support for additional common ETI phrases
  • [MBS-3920] – Extend the “Titles with Featured Artists” reports
  • [MBS-7421] – Properly capitalize iWhatever-like when guessing case
  • [MBS-8065] – Stop Guess Case needlessly standardising “aka”
  • [MBS-8521] – Allow work-level-rels in browse recording request
  • [MBS-8865] – Lower case “rmx” just as “remix”
  • [MBS-9855] – Generalize NotFound templates to one general file
  • [MBS-9981] – Consider “conductor” and “founder” relationships when reporting Artists that may be collaborations
  • [MBS-10143] – Allow querying for tags/genres on discid WS requests
  • [MBS-10156] – Lowercase “remode” and “re‐mode” in ETIs when guessing case
  • [MBS-10161] – Lowercase mono/stereo/quadraphonic in parentheses when guessing case
  • [MBS-10262] – Indicate to user that new RG will be created if RG field is left empty
  • [MBS-10287] – Count tracks (rather than recordings) when determining top work artists
  • [MBS-10315] – Add the LyricWiki icon to links in the sidebar

New Feature

  • [MBS-2663] – Search for edits by non-subscribed entity
  • [MBS-6791] – Search for edits made by beginners

React Conversion Task

  • [MBS-9916] – Convert the event public pages to React
  • [MBS-9918] – Convert the label public pages to React
  • [MBS-10087] – Convert doc pages to React
  • [MBS-10116] – Convert the recording index page to React
  • [MBS-10201] – Convert artist works tab to React
  • [MBS-10202] – Convert artist relationships tab to React

Other Task

  • [MBS-10313] – Reenable CAA images on the homepage for Chrome-based browsers

MusicBrainz Server update, 2019-08-08

This summery release brings one main new feature: collaborative collections! As an editor, you can now share your collections with others. This is mainly intended for community projects, but it can also be a good way to, say, have a shared “Music we have at home” collection with your family, or collect artists with funny names with your friends. You decide how to use it!

To add collaborators to your collections, edit the collection and enter the editors you’d want as collaborators in the appropriate section (suggestion: ask first whether they’re interested, then add them!). Once they’ve been added as collaborators, they’ll be able to add and remove entities from the collection in the same way as you, but they won’t be able to change the title / description: that’s still only for the collection owner to change.

CDs collection shared as a cloak for everyone to see

The release also comes with a bunch of small improvements and bug fixes, including a couple about collections, and continues migrating to React.

Thanks to Ge0rg3 and sothotalker for their contributed code. Also, thanks to chaban, chiark, cyberskull, Dmitry, hibiscuskazeneko, jesus2099, Lotheric, mfmeulenbelt, psychoadept and everyone who tested the beta version, reported issues, or updated the website translations.

The git tag is v-2019-08-08.

Bug

  • [MBS-8867] – Guess Case normalizes “C’mon” as “C’Mon”
  • [MBS-9512] – Changing recording name to empty string should not be allowed
  • [MBS-10100] – ISE without “non-required” attributes for admin/attributes/Language/create
  • [MBS-10133] – Error message when sending an empty query to the WS is unclear
  • [MBS-10212] – SoundCloud URL with trailing slash is not displayed with user name in artist sidebar
  • [MBS-10218] – Regression: Cover Art tab not selected / highlit on release page
  • [MBS-10233] – Regression: ISE when trying to cancel a “add release annotation” edit

Improvement

  • [MBS-8569] – Don’t display ended legal names in the overview page for artists
  • [MBS-9381] – Show user’s own private collections in the list of collections for an entity
  • [MBS-10135] – Support WikiaParoles as its own site rather than LyricWiki
  • [MBS-10139] – Clarify why recording lengths can’t be edited when non standalone
  • [MBS-10210] – Only allow allowed frequencies in language admin form
  • [MBS-10215] – Make ISO number required for script admin form
  • [MBS-10217] – Explain what renaming artist credits does when editing artist
  • [MBS-10219] – Add Muziekweb to other DBs whitelist, with sidebar display
  • [MBS-10222] – Pull legal name alias instead of legal name artist for the relationship Artist-Artist “perform as/legal name”
  • [MBS-10224] – Don’t show the same legal name string multiple times in artist overview
  • [MBS-10246] – Don’t assume all event collections are attendance lists
  • [MBS-10272] – Convert the header / navbar to Bootstrap

New Feature

  • [MBS-8915] – Allow editors to choose delimiter in track parser
  • [MBS-9428] – Allow multiple users to share one collection

React Conversion Task

  • [MBS-9914] – Convert the area public pages to React
  • [MBS-10047] – Convert /oauth2/ pages to React

Other Task

  • [MBS-10131] – Update LyricWiki domain to lyrics.fandom.com