← Latest papers
🤖 machine learning

Discovering Data Structures: Nearest Neighbor Search and Beyond

This paper proposes a general end-to-end learning framework that automatically discovers optimal data structures and query algorithms from scratch without initialization, successfully replicating known solutions like binary search, k-d trees, and locality-sensitive hashing for nearest neighbor search while also adapting to frequency estimation in data streams.

Original authors: Omar Salemohamed, Laurent Charlin, Shivam Garg, Vatsal Sharan, Gregory Valiant

Published 2026-06-09
📖 5 min read🧠 Deep dive

Original authors: Omar Salemohamed, Laurent Charlin, Shivam Garg, Vatsal Sharan, Gregory Valiant

Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer

Imagine you have a massive, messy library of books. Traditionally, librarians (computer scientists) spend years designing specific rules and filing systems (data structures) to find a book quickly. They might say, "Put all books alphabetically on the shelves" or "Group them by color and size." These rules work well for everyone, but they don't know your specific habits. Maybe you always borrow mystery novels, or maybe your library has a weird pattern where 90% of the books are about cats.

This paper asks a bold question: Can we teach a computer to invent its own library filing system from scratch, just by looking at the books and practicing how to find them?

The authors say yes. They created a "learning machine" that doesn't just follow rules; it discovers the rules itself.

The Two-Part Team

The system they built is like a team of two robots working together:

  1. The Organizer (Data-Processing Network): This robot looks at the messy pile of data (the books) and figures out the best way to rearrange them. It doesn't just sort them alphabetically; it learns to sort them in a way that makes the next robot's job easier.
  2. The Searcher (Query-Execution Network): This robot is given a specific question (e.g., "Find the book about cats"). It is only allowed to peek at a very small number of shelves (a limited "budget" of looks). It has to learn a strategy to find the right book as fast as possible using those few peeks.

The magic happens because they train together. The Organizer learns to arrange the books specifically to help the Searcher, and the Searcher learns how to read the Organizer's arrangement. They practice millions of times until they invent a system that works perfectly for the specific type of books they have.

What Did They Discover?

The researchers tested this on different types of "libraries" (datasets) and found that the robots reinvented famous human inventions, often improving on them:

  • The Simple List (1D Data): When the data was just a line of numbers, the Organizer learned to sort the numbers perfectly. The Searcher then learned a strategy better than the standard "Binary Search" (which is like guessing the middle of the list). If the numbers were usually small, the Searcher learned to start looking at the beginning of the list instead of the middle, saving time.
  • The 2D Map: When the data had two dimensions (like a map with X and Y coordinates), the robots learned to build a k-d tree. This is a complex way of splitting a map into smaller and smaller squares to find a location quickly. The robots figured this out without anyone telling them what a "tree" or a "split" was.
  • The High-Dimensional Maze: When dealing with complex data like images (which have thousands of features), the robots learned something called Locality Sensitive Hashing (LSH). Imagine taking a photo of a cat and instantly knowing it belongs in the "Cat Bucket" without looking at every other photo. The robots learned to project complex images into simple buckets, just like human experts do.
  • The "Heavy Hitter" Trick: In a test involving counting how often items appear (like tracking popular IP addresses on the internet), the robots learned to reserve special "VIP slots" in their memory for the most frequent items. This prevented the common items from getting mixed up with the rare ones, beating standard counting tools.

The "Aha!" Moment

The most surprising part is that the robots didn't need a human to say, "Hey, try sorting this!" or "Use a tree structure!" They started with random noise and, through trial and error, reverse-engineered these classic computer science algorithms on their own.

In one experiment with images of numbers, the robots learned to recognize that the images were actually numbers, sorted them by value, and then searched them efficiently—all without being told what a "number" was or how to sort them. They just learned that "similar-looking images" should be grouped together to make searching faster.

The Catch (Limitations)

The paper is honest about its limits:

  • Scale: The experiments were done on relatively small libraries (around 100 to 500 items). Real-world libraries have millions. The robots might get overwhelmed with that much data right now.
  • Speed: The robots take a long time to "think" (pre-process) before they can start searching. In real life, we often need instant answers.
  • Black Box: While the robots found great solutions, we don't always have a simple mathematical proof explaining why their specific arrangement works. We just know it works because we tested it.

The Bottom Line

This paper proves that neural networks can act like algorithmic inventors. Instead of humans designing the filing system, we can let the computer discover the most efficient way to organize and search data based on the specific patterns of the data it sees. It's like giving a robot a messy room and a limited amount of time to find a specific toy, and watching it invent a new way to organize the room that is even better than what a human would have designed.

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →