A non-transitory computer-readable medium configured to store code comprising instructions, wherein the instructions, when executed by one or more processors, cause the one or more processors to:
- store a taxonomy of items that are connected through a hierarchy based on attributes of the items;
- receive, at an online system, a query directed at a search interface;
- apply a first neural network, by the online system, to extract an embedding for the query, the embedding for the query representing the query in a latent space of the first neural network, wherein applying the first neural network to extract the embedding for the query comprises:
- extracting a query latent vector in a first hidden layer of the first neural network;
- apply a second neural network to extract item embeddings for each of a plurality of items maintained in an item database by the online system, each item embedding corresponding to an item offered by the online system and representing the item in the latent space of the second neural network, wherein applying the second neural network to extract an item embedding for an item comprises:
- extracting an item latent vector in a second hidden layer of the second neural network;
- compare the embedding for the query to the item embeddings based on the taxonomy of items to identify a set of items;
- and
- generate, as a response to the query directed at the search interface, a query result comprising the set of items.