Combining a Context Aware Neural Network with a Denoising Autoencoder\n for Measuring String Similarities

Mehdi Ben Lazreg, Morten Goodwin · DOI

TL;DR

Researchers have developed a new string similarity metric that moves beyond simple character counting by combining a Denoising Autoencoder with a Context Encoder. By learning both the common patterns of human typos and the semantic environment in which words appear, this hybrid model improves the accuracy of finding correct word versions from 63.2% (using standard Levenshtein distance) to 85.4%.

What Problem Does This Paper Address?

Traditional string similarity metrics—like the Levenshtein (edit) distance—have been the gold standard since the mid-1960s. These methods generally work by counting the number of character insertions, deletions, or substitutions needed to turn one string into another.

However, the authors argue that these "edit-based" metrics are showing their age in the era of social media. Language today is highly non-standard, filled with slang, abbreviations (e.g., "lol"), truncated words ("n" for "and"), and "leetspeak" ("4ever"). Standard metrics treat these as mere character mismatches, failing to recognize that "dogg" and "dog" are functionally the same, or that "dogg" and "cat" share a semantic context. The gap addressed here is the lack of contextual and stochastic awareness in measuring how "close" two strings really are.

Methods

The authors propose a two-pronged neural network approach to map words into a real vector space where distance actually represents similarity.

  1. Denoising Autoencoder (DAE): Instead of using an autoencoder for simple compression, they use it to "clean" text. They treat a misspelled or non-standard word as a "noisy" version of a standard word. The network is trained to take the noisy input and reconstruct the "clean" original. In doing so, the hidden layer of the DAE learns the "stochastic structure" of how humans actually make mistakes or abbreviate.
  2. Context Encoder: This part of the model learns word representations based on their surroundings (similar to the logic behind Word2Vec). It assumes that words appearing in similar contexts (like "dog" and "cat" both appearing near "pet" or "fed") should be closer together in vector space.
  3. The Hybrid Metric ($D_c$): The final distance function, $D_c$, combines these two. It calculates the distance between words in a vector space that has been informed by both character-level noise patterns and high-level semantic context.

Datasets

The study utilized two primary data sources:

  • Twitter Normalization Dataset: A collection of the 1,051 most frequent words from Twitter paired with their various common misspellings. This was originally part of an IBM data normalization challenge in 2015.
  • Context Corpus: To train the context-aware portion of the model, the authors used a dataset of 97,191 sentences containing both vocabulary words and their non-standard forms.

The authors noted that the data is "imbalanced"—some words have dozens of non-standard variations, while others have only one—which presents a significant training challenge.

Key Insights and Ideas

  • Typos Aren't Random: The core "aha" moment is that misspellings follow patterns that a neural network can "digest." By using a Denoising Autoencoder, the model learns that certain character swaps are more likely than others, making it more robust than a rigid edit-distance formula.
  • Context as a Semantic Bridge: Traditional metrics would say "apple" and "orange" are very different because they share few characters. By adding a context encoder, the model learns they are "similar" because they appear in similar linguistic neighborhoods (e.g., near "eat," "juice," or "fruit").
  • Pseudometrics vs. Metrics: The authors acknowledge that their learned distance is technically a "pseudometric." Because the goal is to make a typo and a correct word nearly identical in vector space, the "identity of indiscernibles" (where distance is 0 if and only if the strings are identical) cannot be strictly guaranteed.

Key Results

The hybrid approach significantly outperformed traditional methods in finding the "correct" version of a non-standard word:

  • Accuracy: The proposed $D_c$ metric (using Cosine similarity) reached 85.37% accuracy in identifying the correct standard word as the "closest" match.
  • Comparison: For the same task, the Normalised-Levenshtein distance only achieved 63.17%, and standard N-Gram methods reached 58.23%.
  • Top-5 Performance: When looking at whether the correct word was among the top five closest matches, the hybrid model hit 89.61%.
  • Qualitative Success: The model successfully grouped words like "dogg" not just with "dog," but also with "cat," "boy," and "kid," proving that the context encoder was successfully capturing semantic relationships that character-counting metrics totally miss.

Limitations and Future Work

  • Data Imbalance: The model struggles with words that have very few non-standard examples in the training set. If the autoencoder hasn't seen a specific type of "noise" for a word, it may not learn to denoise it accurately.
  • Mathematical Properties: As a pseudometric, it doesn't satisfy all the formal requirements of a distance metric, which might limit its use in certain traditional algorithms that require strict metric properties.
  • Future Directions: The authors suggest that this work is a "first attempt" at a fully learned string metric. Future work could involve scaling the vocabulary or applying the technique to specific domains like bioinformatics (DNA sequence similarity) where "noise" (mutations) also follows specific biological patterns.

Summary updated

BibTeX
@article{lazreg2020combining,
  author = {Mehdi Ben Lazreg and Morten Goodwin},
  title = {{Combining a Context Aware Neural Network with a Denoising Autoencoder\textbackslash\{\}n for Measuring String Similarities}},
  journal = {Comput. Speech Lang},
  year = {2020},
  doi = {10.1016/j.csl.2019.101028},
}
Figure