Query augmentation in fashion search with MLP and Damerau-Levenshtein distance

We recently launched and put into production our hybrid search (semantic and lexical), which works with both text searches and image searches.
The problem: imprecise searches
One of the problems search platforms normally have to handle is responding to imprecise searches. People using search don’t always type words that match the catalog’s taxonomy.
Often people use everyday words that are not categorized in the products, for example “cyclamen t-shirt”: cyclamen may not be a color in the catalog, but it can somehow be traced back to something leaning toward pink or fuchsia.
Moreover, words from foreign languages, such as “décolleté,” are often not spelled correctly: double letters are missing or added, or accents are left out.
To get around these problems, in addition to the classic entry of synonyms (a table that our clients, brands, and partners can populate by hand with the alternatives and corrections for a term), we introduced two tools that try to solve them out of the box.
The first tool: typos
We have significantly reduced the typo problem by completing unfinished words with the catalog vocabulary, that is, the words contained in the sparse vectors (BM25) of our search: we try to work out which terms are closest to what the user is searching for and, even if they are incomplete, we try to autocomplete them.
We also compute the Damerau-Levenshtein distance between users’ searches and the tags, taxonomy, and brands in our catalog. This way we handle typos with neighboring letters that may be swapped, doubled, or dropped, and with accents removed. Anything close to that search, if it has a match, we accept as good: so a typo doesn’t limit the search by returning zero results.
The Damerau-Levenshtein distance counts how many edits it takes to turn one word into another. Four edits are allowed: inserting a letter, removing one, replacing one, or swapping two adjacent letters. The classic Levenshtein distance knows only the first three; Damerau adds the swap, which is the most common typo when writing in a hurry: “camicai” is 1 away from “camicia” (shirt), not 2. The lower the distance, the closer the two words are.

The second tool: interpretation
To interpret a search, we trained a small neural network on the data in our database, which collects years of outfits and products linked together by pairings. The network simply takes the text embedding as input, the same vector that semantic search already computes, and outputs tags related to that text.
It is an MLP (multilayer perceptron), and a very fast one: it doesn’t affect the speed of the search itself and doesn’t require an external LLM.
An MLP is the simplest form of neural network: a series of layers of neurons, in which every neuron is connected to all those in the next layer. During training the network sees thousands of examples and learns which tags to associate with a given text. Ours has a single hidden layer: it receives the 1,536 numbers of the embedding, passes them to 1,024 neurons, and returns a probability for each of the 557 tags. In all it has about 2 million parameters, versus the billions of an LLM: that is why it responds in an instant.

For example, with “cyclamen t-shirt” it tries to work out whether cyclamen can be traced back to certain colors. As we said, cyclamen can be pink or fuchsia: the network interprets it as pink, includes that color in the search, and pushes pink t-shirts, the ones closest to that color, up the results.
In conclusion
Two tools, no LLM in the search path. The Damerau-Levenshtein distance and completion on the catalog vocabulary mean that a typo or an unfinished word doesn’t return zero results; the MLP maps everyday words to catalog tags. Both work on the lexical side of search and don’t add filters: a wrong correction or interpretation can at most change the order of the results, not exclude any. And they do it out of the box, without the client having to define anything by hand.
Enrico Antonini, Deep learning engineer @Bantoa
More articles dal panorama fashion-tech
Want to become the next case study?
Discover how Bantoa solutions can grow your brand.


