1 of 55

Computational models for

Lexical Semantic Change

Francesco Periti, francesco.periti@unimi.it

LOT Winter School 2024

2 of 55

CIAO!

Francesco Periti

3rd year - PhD Student

Natural Language Processing, Distributional Semantic Models, Lexical Semantic Change

francesco.periti@unimi.it

2

LOT Winter School 2024

3 of 55

Contextualized

embedding

models

3

LOT Winter School 2024

4 of 55

Problem definition

4

manufacture

From to make by hand

To to make by machine

gay

From cheerful

To homosexual

Lexical Semantic Change

LOT Winter School 2024

5 of 55

Static vs. Contextualized embeddings

Quantifying lexical semantic change

5

plane

trained / pre-trained��Word2Vec

FastText

GloVe

pre-trained / fine-tuned��BERT - mBERT

RoBERTa - XLM-R

XL-LEXEME

[...] plane [...]

[...] plane [...]

[...] plane [...]

[...] plane [...]

[...] plane [...]

word-level approaches word usage-level approaches

LOT Winter School 2024

6 of 55

Word-usage selection

6

target word

- If a particle of mass m is placed on a smooth inclined plane and re- leased, it will slide down the slope.

- [...]

Word usages

- Euclidean planes are Euclidean spaces of dimension two

- [...]

- The plane flew above the clouds.

- [...]

LOT Winter School 2024

7 of 55

Word-usage selection

7

def word_usage_selection(corpus: list, target: str):

indexes_target_token = list() # position of word in sentence

word_usages = list() # sentences

for sentence in corpus:

sentence_lemma = lemmatize(sentence) # spacy (See spacy.io/api/token)

for token in sentence_lemma:

if token.lemma_ == target:

start = token.idx

end = start + len(token.text)

indexes_target_token.append(f'{start}:{end}')

word_usages.append(sentence)

# break

df = pd.DataFrame() # pandas

df['indexes_target_token'] = indexes_target_token

df['context'] = word_usages

return df

target word

LOT Winter School 2024

either or

8 of 55

Embedding extraction

8

target word

bert

[ "[CLS]", "the", "plane", "flew", "above", "the", "clouds", ".", "[SEP]" ]

The plane flew above the clouds.

word usage

LOT Winter School 2024

[,, 🔵,,,, ,, ]

9 of 55

Embedding extraction

9

def embedding_extraction(df: pd.DataFrame):

embeddings = list()

for _, row in df.iterrows():

start, end = row["indexes_target_token"].split(':')

start, end = int(start), int(end)

left_context = row['context'][:start]� word = row['context'][start:end]

right_context = row['context'][end:]�

left_tokens = ['[CLS]'] + tokenize(left_context)

word_tokens = tokenize(word)

right_tokens = tokenize(right_context) + ['[SEP]']

# start and end in terms of tokens

start, end = len(left_tokens), len(left_tokens) + len(word_tokens)

# tokenization and embeddings

encoded_input = tokenizer(row['context']) # transformers

output = model(**encoded_input)

embedding = output.last_hidden_state[0, start:end, :].mean(axis=0)

embeddings.append(embedding)

return np.array(embeddings)

target word

bert

word usage

LOT Winter School 2024

The plane flew above the clouds.

index: 4:9

[CLS], the, plane, flew, above, the, clouds, ., [SEP]

index: 2:3

10 of 55

Embedding aggregation by averaging

10

target word

bert

word usages

word prototype

word prototype

plane

aircraft

airplane

slope

ramp

incline

facet

surface

sheet

LOT Winter School 2024

11 of 55

Embedding aggregation by clustering + averaging

11

target word

bert

plane

landing

boarding

aviation

plane

infinity

parallel lines

surface

plane

inclined

inclined by 60°

word usages

LOT Winter School 2024

inclined by 20°

sense prototypes

sense prototypes

12 of 55

Shift assessment

12

LOT Winter School 2024

target word

bert

word usages

A survey

13 of 55

Overall pipeline

13

- If a particle of mass m is placed on a smooth inclined plane and re- leased, it will slide down the slope.

- [...]

Word usage

selection

Embedding extraction

Embedding

aggregation

[, , 🔵,,,]

prototypes

Shift

assessment

LOT Winter School 2024

14 of 55

A classification of LSC approaches

14

LOT Winter School 2024

Meaning representation

Time-awareness

Learning modality

How the meaning(s) of a

word is represented

How the time of the text is considered

How external knowledge is exploited

form-based

sense-based

time-oblivious

time-aware

supervised

unsupervised

A survey

15 of 55

Meaning representation

form-based approaches

15

LOT Winter School 2024

form-based

sense-based

multiple word senses

[...]

Average Pairwise Distance (APD)

Inverted similarity over word prototype (PRT)

APD

PRT

degree of polysemy

dominant sense

16 of 55

Meaning representation

form-based approaches

16

LOT Winter School 2024

def apd(embeddings_t1: np.array, embeddings_t2: np.array, metric: str='cosine'):

pairwise_distances = cdist(embeddings_t1, embeddings_t2, metric=metric) # scipy

return np.mean(pairwise_distances) # numpy

def prt(embeddings_t1: np.array, embeddings_t2: np.array):

word_prototype_t1 = embeddings_t1.mean(axis=0)

word_prototype_t2 = embeddings_t2.mean(axis=0)

return cosine(word_prototype_t1, word_prototype_t2)

17 of 55

Meaning representation

sense-based approaches via clustering

17

LOT Winter School 2024

form-based

sense-based

degree of polysemy

dominant sense

multiple word senses

K-Mean

Affinity Propagation

18 of 55

Meaning representation

sense-based approaches via clustering

18

LOT Winter School 2024

form-based

sense-based

degree of polysemy

dominant sense

multiple word senses

Average Pairwise Distance between sense Prototypes (APDP)

Jensen Shannon Divergence (JSD)

[ 3 , 2 , 0 ]�

[ 0 , 2 , 3 ]

APDP

JSD

19 of 55

Meaning representation

sense-based approaches via clustering

19

LOT Winter School 2024

def clustering_jsd(embeddings_t1: np.array, embeddings_t2: np.array):

embeddings = np.concatenate([embeddings_t1, embeddings_t2], axis=0)

# cluster labels

L = clustering(embeddings) # clustering embeddings as a whole - sklearn

L1, L2 = L[:embeddings_t1.shape[0]], L[embeddings_t1.shape[0]:]

# time-specific distributions

L1_dist, L2_dist = time_specific_distributions(L1, L2)�

return jensenshannon(L1_dist, L2_dist) # scipy

def clustering_apdp(embeddings_t1: np.array, embeddings_t2: np.array, metric: str='cosine'):

embeddings = np.concatenate([embeddings_t1, embeddings_t2], axis=0)

# cluster labels

L = clustering(embeddings) # clustering embeddings as a whole

L1, L2 = L[:embeddings_t1.shape[0]], L[embeddings_t1.shape[0]:]� unique_L1, unique_L2 = np.unique(L1), np.unique(L2)

sense_prototype_t1 = np.array([embeddings_t1[L1 == label].mean(axis=0) for label in unique_L1])

sense_prototype_t2 = np.array([embeddings_t2[L2 == label].mean(axis=0) for label in unique_L2])

return apd(sense_prototype_t1 , sense_prototype_t2, metric)

20 of 55

Time awareness

time-oblivious approaches

20

LOT Winter School 2024

time-oblivious

time-aware

contextualization

diachronic data

time embedding

you are a cheerful and lively person.

Thou art a gay and jovial fellow.

1. The context is always time-specific.

2. The model is trained on diachronic data.

1890

1990

Modern

Historical

21 of 55

Time awareness

time-aware approaches

21

LOT Winter School 2024

time-oblivious

time-aware

contextualization

diachronic data

time embedding

you are a cheerful and lively person.

Thou art a gay and jovial fellow.

The model cannot generalize across time

1890

1990

Þu eart glæd and wynsum gefera

1000

22 of 55

Time awareness

time-aware approaches

22

LOT Winter School 2024

time-oblivious

time-aware

contextualization

stability

time embedding

Temporal Referencing Time Masking

Thou art a gay_[1890] and jovial fellow.�

Gay_[2020] pride radiates love and acceptance.

Temporal Attention

Dynamic Contextualized Word Embeddings

23 of 55

Time awareness

time-aware approaches

23

LOT Winter School 2024

Time-referencing�corpus1 = temporal_referencing(corpus1, target, tag)

corpus2 = temporal_referencing(corpus2, target, tag)

new_tokens_with_tag = extract_new_tokens(corpus1) + extract_new_tokens(corpus2)

add_token_to_vocab(model, new_tokens_with_tag )

fine_tuned(model)��embeddings = embedding_extraction(model)�semantic_change_approach(embeddings)

Time-maskingcorpus1 = temporal_referencing(corpus1, tag)

corpus2 = temporal_referencing(corpus2, tag)

new_tokens_with_tag = [1, 2]

add_token_to_vocab(model, new_tokens_with_tag )

fine_tuned(model)��embeddings = embedding_extraction(model)�semantic_change_approach(embeddings)

24 of 55

Learning modality

supervised

24

LOT Winter School 2024

supervised

unsupervised

lexicographic supervision

manual supervision

only text

Gloss Reader

WordNet

Oxford Dictionary

Diachronic Senses

XL-LEXEME

WiC benchmarks

Deep Mistake

Inclined planes simplify lifting on slopes.

The plane is inclined at a slight angle.

The plane is inclined at a slight angle.

Passengers quickly boarded the plane

[...] plane [...]

[...] plane [...]

[...] plane [...]

Word-in-Context (WiC)

25 of 55

Learning modality

supervised

25

LOT Winter School 2024

Inclined <t> planes </t> simplify lifting on slopes.

The <t> planes </t> is inclined at a slight angle.

The <t> plane </t> is inclined at a slight angle.

Passengers quickly boarded the <t> plane </t>

[...] plane [...]

[...] plane [...]

[...] plane [...]

Word-in-Context (WiC)

26 of 55

Learning modality

unsupervised

26

LOT Winter School 2024

supervised

unsupervised

lexicographic supervision

manual supervision

only text

APD

PRT

Clustering + APDP

Clustering + JSD

XL-LEXEME

BERT

mBERT

XLM-R

pre-trained model + LSC approach

27 of 55

Scalability and interpretability

issues

27

LOT Winter School 2024

28 of 55

Scalability

Memory consumption

28

The plane flew above the clouds.

[ "[CLS]", "the", "plane", "flew", "above", "the", "clouds", ".", "[SEP]" ]

[,, 🔵,,,, ,, ]

An embedding contains 768 floats

A survey

Solution:

  • Process one target word at a time
  • Dimensionality reduction of the embeddings
  • Random sampling the occurrences

LOT Winter School 2024

A floating-point in Python requires 8 B

A word appearing 500.000 times

requires 3Gb + overhead

29 of 55

Scalability

Computation time

29

A vocabulary may contain more than 500.000 words�Clustering and dimensionality reduction take time

A survey

Solution:

  • We need a GPU
  • Select a small set of target words
  • Random sampling the occurrences

LOT Winter School 2024

30 of 55

Interpretability

form-based approaches

30

A survey

form-based approaches are not interpretable

Solution:

  • Quantify semantic change across the entire vocabulary.
  • Use to select a small set of targets

LOT Winter School 2024

31 of 55

Interpretability

word meaning representation

31

A survey

Changes in contextual variance

Clusters of word meanings are clusters of “sense nodules” - i.e., lumps of meaning with greater stability under contextual changes (Cruse, 2000)

A word may change its context without changing its meaning

Solution:�

  • ? ? ?

LOT Winter School 2024

32 of 55

Interpretability

word meaning description

32

A survey

list of keywords

close reading

random sampling

Solution:�

  • generating natural language definitions of contextualised word usage

Definitions

LOT Winter School 2024

33 of 55

Lexical Semantic Change over multiple time periods

33

LOT Winter School 2024

34 of 55

Word meaning evolution

APD

34

A survey

. . .

1750

1800

1900

1950

2024

. . .

1850

LOT Winter School 2024

LSC

LSC

LSC

LSC

LSC

LSC

35 of 55

Word meaning evolution

APD

35

36 of 55

Word meaning evolution

PRT

36

A survey

. . .

1750

1800

1900

1950

2024

. . .

1850

LOT Winter School 2024

LSC

LSC

LSC

LSC

LSC

LSC

Evolving

Average

37 of 55

Word meaning evolution

Clustering

37

A survey

. . .

1750

LSC

1800

LSC

LSC

1900

1950

2024

. . .

LSC

LSC

. . .

1850

LSC

LOT Winter School 2024

38 of 55

Word meaning evolution

Clustering alignment

38

LOT Winter School 2024

1750

1800

1800

1850

39 of 55

Word meaning evolution

Clustering alignment

39

LOT Winter School 2024

1750

1800

40 of 55

Word meaning evolution

Massive clustering

40

. . .

1750

1800

1900

1950

2024

. . .

1850

Semantic change in interaction

LOT Winter School 2024

41 of 55

Word meaning evolution

Evolutionary clustering

41

WiDiD

introduction

In review 🤞

Incremental Affinity Propagation based on Cluster Consolidation and Stratification

1750

1800

What is Done is Done (WiDiD)

and cannot be changed

LOT Winter School 2024

clustering

evaluation

WiDiD

evaluation

42 of 55

Word meaning evolution

WiDiD drawbacks

42

Drawbacks

From evolutionary clustering to online evolutionary clustering

A sense prototype is considered as a singular word usage instance.

Word can lose meanings

Change is gradual

Assign higher importance to sense prototypes.

Solutions

Eliminate aging clusters that are no longer integrated

LOT Winter School 2024

In review 🤞

Incremental Affinity Propagation based on Cluster Consolidation and Stratification

clustering

evaluation

WiDiD

evaluation

WiDiD

introduction

43 of 55

Word meaning evolution

Cluster Monitoring

43

LOT Winter School 2024

Time-series

Degree of

Semantic Change

Time periods

44 of 55

CIAO!

Francesco Periti

3rd year - PhD Student

Natural Language Processing, Distributional Semantic Models, Lexical Semantic Change

francesco.periti@unimi.it

44

LOT Winter School 2024

45 of 55

Problem definition

45

gay

From cheerful

To homosexual

Lexical Semantic Change

LOT Winter School 2024

monitoring

46 of 55

46

LOT Winter School 2024

Graded Change Detection

over time

47 of 55

47

LOT Winter School 2024

Monitoring

Graded Change Detection

over time

Change Point

Detection

48 of 55

48

LOT Winter School 2024

monitoring

Change Point Detection

49 of 55

49

LOT Winter School 2024

Change Point Detection

Word Sense Induction

gay

From cheerful

To homosexual

Interpretation

50 of 55

50

alignment

alignment

alignment

(C)

alignment

alignment

. . .

. . .

. . .

embeddings

clustering

clustering

(A)

(B)

Clustering over consecutive time intervals

51 of 55

51

alignment

clustering

clustering

alignment

alignment

(A)

(D)

(E)

alignment

alignment

alignment

clustering

(B)

(C)

Clustering over consecutive time periods

52 of 55

52

clustering

(A)

Clustering over all time periods

. . .

. . .

. . .

embeddings

53 of 55

53

change point detection

(A)

clustering

(B)

Clustering over specific time intervals/periods

54 of 55

54

update

update

clustering

incremental

clustering

update

(A)

(C)

(C)

update

update

incremental

clustering

(B)

(B)

Incremental clustering over consecutive time periods

55 of 55

55

(A)