Semantic Textual Similarity
Semantic Textual Similarity
Similarity in Replika
Denis Fedorenko
Research Engineer, Luka Inc.
Plan
• Task definition
• Baseline model
• Model improvements
• Find a model
M: (text1, text2) → ℝ
Toy STS model
• How many common words are in two texts?
• Example:
• Such that:
M: (E(text1), E(text2)) → ℝ
where M is a similarity function (e.g. cosine)
or some trainable model (e.g. logistic regression, neural network)
STS in Replika
• The task is to determine whether two utterances are
semantically equivalent
• Find a model
Result:
Matched phrase
Example: Replika-QA
User phrase constraint:
User phrase templates:
Result:
Matched phrase
STS evaluation
• On holdout testsets:
• In the wild:
• Baseline model
• Model improvements
∈ (0, 1)
sigmoid(W * |v1 – v2|)
rule: 1 if f(x) > 0.5 else 0
v1=DM.Encoder(utter1) v2=DM.Encoder(utter2)
• Baseline model
• Model improvements
Trainset
Preprocessed
Preprocess Mark & Split
utterance pairs
Amazon Testset
Mechanical Turk
(crowdsourcing)
Matches extraction
• Extract matches of the baseline model from the
logs. Obtained false positives will help to improve
precision
• Testsets
Extract Result:
Feature vector Classify
features 0|1
Trainset
Classification pipeline
Text pair Vectorize Vector pair
Extract Result:
Feature vector Classify
features 0|1
less is better
more is better
• Best configuration:
• Linear SVM
Model selection discussion
• Quality gain is not as high as it could be
Context Response
encoder encoder
Cosine
Loss:
Cosine Cosine
Loss:
Sigmoid
Loss:
Update weights
Transfer learning results
• Model: