Personalized snippet suggestions without storing user text (Grammarly)

Vlad Nykytiuk18 Jan 2023

Problem

Grammarly Business offers snippets: saved phrases a user inserts into a chat or email. For customer-facing teams they cut repetitive typing and typos. The feature helps only once the library holds a few useful snippets, so many users never see its value: a cold-start problem. The obvious fix, suggesting snippets from what the user often types, collides with a privacy rule: user text is not stored with the account.

Example from the article: a user typed "Please let me know how it goes" and "Let me know how it went". When they type "Let me know how it goes", the product should offer to save it as a snippet, without having kept any of the earlier texts.

Solution in brief

Hash every checked sentence with SimHash, so similar sentences get similar hashes, and store only the hashes per user. A daily Spark job counts, by Hamming distance, which hashes of the past week have many similar ones. These go to Redis and are matched against new text in real time.

Questions this case answers
  • How to detect a user's habitual phrases, including slightly reworded ones, without keeping the raw text
  • How to bootstrap a personal content library for new users from their own behavior when generic or hand-built content scales poorly
  • How to find the sentences a user types again and again without storing their text?
  • How to solve the cold start of a saved-text (snippet) library without prebuilt collections?

Tools and methods

  • SimHash (locality-sensitive hashing) — similar sentences get close hashes
  • Hamming distance — compares two hashes; similar means below a threshold
  • Apache Kafka — carries hashed events to storage
  • Apache Spark — daily job finding frequent hashes per user
  • Redis — in-memory store of each user's top candidate hashes
  • A/B test — checks that suggestions raise snippet creation
Continue reading — it's free

Google or a one-time email code. No password.