Text Encoders Lack Knowledge: Leveraging Generative LLMs for
Domain-Specific Semantic Textual Similarity
Joseph Gatto, Omar Sharif, Parker Seegmiller, Philip Bohlman, Sarah M. Preum
Dartmouth College
joseph.m.gatto.gr@dartmouth.edu
Semantic Textual Similarity (STS)
2
a girl is styling her hair
a girl is brushing her hair
Text 1:
Text 2:
STS Model
Similarity Score [0-5]
STS Objective: Predict a continuous value between 0-5 that represents the semantic similarity between two texts
Sample from STS-B Test Set
Semantic Textual Similarity (STS)
3
a girl is styling her hair
a girl is brushing her hair
Text 1:
Text 2:
RoBERTa
π Existing STS models work well on simple texts
Sample from STS-B Test Set
2.36
Prediction
True Score = 2.5
Fine-Tuned on STS
Semantic Textual Similarity (STS)
4
ugh, these doctors are gaslighting me!
My dr is making me feel like im crazy!
Text 1:
Text 2:
RoBERTa
β However, they struggle to model the relationship between complex domain-specific texts
Sample from our STS-Health Dataset
1.73
Prediction
True Score = 4.65
Fine-Tuned on STS
Semantic Textual Similarity (STS)
5
ugh, these doctors are gaslighting me!
My dr is making me feel like im crazy!
Text 1:
Text 2:
ChatGPT
We show that LLMs significantly outperform text encoders when predicting STS between complex text pairs which require significant world knowledge to understand!
Sample from our STS-Health Dataset
4.0
Prediction
True Score = 4.65
0 Shot Prompt
Why Use Text Generation for a Regression Task?
6
Recent works have claimed that LLMs have βno use caseβ on regression tasks such as STS-B*
* Jingfeng Yang, Hongye Jin, Ruixiang Tang, Xiaotian Han, Qizhang Feng, Haoming Jiang, Bing Yin, and Xia Hu. 2023. Harnessing the power of llms in practice: A survey on chatgpt and beyond. arXiv preprint arXiv:2304.13712.
Why Use Text Generation for a Regression Task?
7
Intuition: 3 Reasons Why LLMs are Well-Suited for STS
Why Use Text Generation for a Regression Task?
8
π LLMs are great at pairwise textual comparisons Making them well-suited for STS
Why Use Text Generation for a Regression Task?
9
π LLMs are great at pairwise textual comparisons Making them well-suited for STS
π§ LLMs contain significant world knowledge Remove need for domain-specific STS annotation
Why Use Text Generation for a Regression Task?
10
π LLMs are great at pairwise textual comparisons Making them well-suited for STS
π§ LLMs contain significant world knowledge Remove need for domain-specific STS annotation
π’ LLMs are familiar with percentages STS is a percentage prediction task!
Research Questions
11
Eval Sets: STS12-16, STS-B, SICK-R
Domains: Health π, News π°, Sports π
Methods: Optimal STS Prompting Strategies
12
Prompt: Output a number between 0 and 5 describing the semantic similarity between the following two sentences:
Sentence 1: <text>
Sentence 2: <text>
Prompt: Output a number between 0 and 1 describing the semantic similarity between the following two sentences:
Sentence 1: <text>
Sentence 2: <text>
π‘Key Idea: Reformulate STS as a percentage prediction task
Prior works only explore LLMs for STS in the 0-5 scale
We map the labels between 0-1 so that LLMs can leverage learned knowledge of percentages
RQ1: What is the optimal prompting strategy for STS?
13
Result: π‘Prompting for percentages improves performance on 6/7 datasets!
RQ2: How do LLMs compare to Text Encoders on STS Benchmarks?
14
Result: π‘On 6/7 benchmark datasets, our LLM approach performs on-par or better than SOTA text encoders!
RQ3: How do LLMs compare to text encoders on domain-specific STS challenge sets?
15
π°STS-News Example
Text 1: Governors Kathy Hochul & Phil Murphy join 8 other governors in opposing school textbook censorship
Text 2: The New Jersey and New York governors oppose censorship of school textbooks.
Label: 0.86/1.0
Three STS Challenge Sets (n=100) collected after May 2023
Data Source: r/NBA, r/NBATalk, r/NFL
Data Source: r/covidlonghaulers, r/LongCovid
Data Source: r/politics
RQ3: How do LLMs compare to text encoders on domain-specific STS challenge sets?
16
RQ3: How do LLMs compare to text encoders on domain-specific STS challenge sets?
17
18
Limitation: The ChatGPT API is not free!π°π°π°
This method may only be well-suited to small-scale tasks requiring STS
Key Takeaways
19
Thank You!
20
Full Paper
Data