Geometric methods in vector spaces
Distributional Semantic Models Stefan Evert1 & Alessandro Lenci2
1University of Osnabr¨
uck, Germany
2University of Pisa, Italy Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 1 / 48
Geometric methods in vector spaces Distributional Semantic Models - - PowerPoint PPT Presentation
Geometric methods in vector spaces Distributional Semantic Models Stefan Evert 1 & Alessandro Lenci 2 1 University of Osnabr uck, Germany 2 University of Pisa, Italy Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 1 / 48
1University of Osnabr¨
2University of Pisa, Italy Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 1 / 48
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 2 / 48
Length & distance Introduction
◮ nearest neighbours ◮ clustering ◮ semantic maps ◮ representation for connectionist models
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 3 / 48
Length & distance Metric spaces
◮ u = (u1, . . . , un) ◮ v = (v1, . . . , vn) x1 v x2
1 2 3 4 5 1 2 3 4 5 6 6
u
d2 ( u, v) = 3.6 d1 ( u, v) = 5
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 4 / 48
Length & distance Metric spaces
◮ u = (u1, . . . , un) ◮ v = (v1, . . . , vn)
x1 v x2
1 2 3 4 5 1 2 3 4 5 6 6
u
d2 ( u, v) = 3.6 d1 ( u, v) = 5
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 4 / 48
Length & distance Metric spaces
◮ u = (u1, . . . , un) ◮ v = (v1, . . . , vn)
x1 v x2
1 2 3 4 5 1 2 3 4 5 6 6
u
d2 ( u, v) = 3.6 d1 ( u, v) = 5
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 4 / 48
Length & distance Metric spaces
◮ u = (u1, . . . , un) ◮ v = (v1, . . . , vn)
x1 v x2
1 2 3 4 5 1 2 3 4 5 6 6
u
d2 ( u, v) = 3.6 d1 ( u, v) = 5
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 4 / 48
Length & distance Metric spaces
◮ u = (u1, . . . , un) ◮ v = (v1, . . . , vn)
x1 v x2
1 2 3 4 5 1 2 3 4 5 6 6
u
d2 ( u, v) = 3.6 d1 ( u, v) = 5
DSM: Matrix Algebra 30 July 2009 4 / 48
Length & distance Metric spaces
◮ d (u, v) = d (v, u) ◮ d (u, v) > 0 for u = v ◮ d (u, u) = 0 ◮ d (u, w) ≤ d (u, v) + d (v, w) (triangle inequality) Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 5 / 48
Length & distance Metric spaces
◮ d (u, v) = d (v, u) ◮ d (u, v) > 0 for u = v ◮ d (u, u) = 0 ◮ d (u, w) ≤ d (u, v) + d (v, w) (triangle inequality)
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 5 / 48
Length & distance Metric spaces
◮ d (u, v) = d (v, u) ◮ d (u, v) > 0 for u = v ◮ d (u, u) = 0 ◮ d (u, w) ≤ d (u, v) + d (v, w) (triangle inequality)
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 5 / 48
Length & distance Metric spaces
◮ d (u, v) = d (v, u) ◮ d (u, v) > 0 for u = v ◮ d (u, u) = 0 ◮ d (u, w) ≤ d (u, v) + d (v, w) (triangle inequality)
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 5 / 48
Length & distance Vector norms
◮ d (u, v) is a metric ◮ u − v is a norm ◮ u = d
v x2
1 2 3 4 5 1 2 3 4 5 6 6
u
u, v) = u − v
DSM: Matrix Algebra 30 July 2009 6 / 48
Length & distance Vector norms
◮ d (u, v) is a metric ◮ u − v is a norm ◮ u = d
x1
v x2
1 2 3 4 5 1 2 3 4 5 6 6
u
u, v) = u − v
DSM: Matrix Algebra 30 July 2009 6 / 48
Length & distance Vector norms
◮ d (u, v) is a metric ◮ u − v is a norm ◮ u = d
x1
v x2
1 2 3 4 5 1 2 3 4 5 6 6
u
u, v) = u − v
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 6 / 48
Length & distance Vector norms
◮ u > 0 for u = 0 ◮ λu = |λ| · u (homogeneity, not req’d for metric) ◮ u + v ≤ u + v (triangle inequality) Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 7 / 48
Length & distance Vector norms
◮ u > 0 for u = 0 ◮ λu = |λ| · u (homogeneity, not req’d for metric) ◮ u + v ≤ u + v (triangle inequality)
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 7 / 48
Length & distance Vector norms
−1.0 −0.5 0.0 0.5 1.0 −1.0 −0.5 0.0 0.5 1.0
Unit circle according to p−norm
x1 x2 p = 1 p = 2 p = 5 p = ∞
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 8 / 48
Length & distance Vector norms
−1.0 −0.5 0.0 0.5 1.0 −1.0 −0.5 0.0 0.5 1.0
Unit circle according to p−norm
x1 x2 p = 1 p = 2 p = 5 p = ∞
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 8 / 48
Length & distance Vector norms
−1.0 −0.5 0.0 0.5 1.0 −1.0 −0.5 0.0 0.5 1.0
Unit circle according to p−norm
x1 x2 p = 1 p = 2 p = 5 p = ∞
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 8 / 48
Length & distance Vector norms
◮ f depends on the norms chosen in U and V ! Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 9 / 48
Length & distance Vector norms
◮ f depends on the norms chosen in U and V !
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 9 / 48
Length & distance Vector norms
◮ f depends on the norms chosen in U and V !
◮ NB: this is not the same as a p-norm of A in Rk·n ◮ spectral norm induced by Euclidean vector norms
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 9 / 48
Length & distance Vector norms
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 10 / 48
Length & distance Vector norms
◮ intuitive Euclidean norm ·2 ◮ “city-block” Manhattan distance ·1 ◮ maximum distance ·∞ ◮ general Minkowski p-norm ·p ◮ and many other formulae . . . Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 10 / 48
Length & distance Vector norms
◮ intuitive Euclidean norm ·2 ◮ “city-block” Manhattan distance ·1 ◮ maximum distance ·∞ ◮ general Minkowski p-norm ·p ◮ and many other formulae . . .
◮ “cosine distance” ∼ u1v1 + · · · + unvn ◮ Dice coefficient (matching non-zero coordinates) ◮ and, of course, many other formulae . . .
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 10 / 48
Length & distance Vector norms
◮ intuitive Euclidean norm ·2 ◮ “city-block” Manhattan distance ·1 ◮ maximum distance ·∞ ◮ general Minkowski p-norm ·p ◮ and many other formulae . . .
◮ “cosine distance” ∼ u1v1 + · · · + unvn ◮ Dice coefficient (matching non-zero coordinates) ◮ and, of course, many other formulae . . .
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 10 / 48
Length & distance with R
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 11 / 48
Length & distance with R
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 12 / 48
Length & distance with R
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 13 / 48
Length & distance with R
40 60 80 100 120 20 40 60 80 100 120
get use
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 14 / 48
Orientation Euclidean geometry
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 15 / 48
Orientation Euclidean geometry
◮ λu, v = u, λv = λ u, v ◮ u + u′, v = u, v + u′, v ◮ u, v + v′ = u, v + u, v′ ◮ u, v = v, u (symmetric) ◮ u, u = u2 > 0 for u = 0 (positive definite) ◮ also called dot product or scalar product Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 15 / 48
Orientation Euclidean geometry
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 16 / 48
Orientation Euclidean geometry
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 16 / 48
Orientation Euclidean geometry
◮ cos φ is the “cosine similarity” measure Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 16 / 48
Orientation Euclidean geometry
◮ cos φ is the “cosine similarity” measure
◮ the shortest connection between a point u and a subspace U
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 16 / 48
Orientation Euclidean geometry
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 17 / 48
Orientation Euclidean geometry
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 18 / 48
Orientation Euclidean geometry
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 18 / 48
Orientation Euclidean geometry
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 18 / 48
Orientation Euclidean geometry
40 60 80 100 120 20 40 60 80 100 120
get use
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 19 / 48
Orientation Euclidean geometry
◮
◮
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 20 / 48
Orientation Euclidean geometry
◮
◮
◮ recall that the columns of B specify the standard coordinates
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 20 / 48
Orientation Euclidean geometry
◮ Kronecker delta: δjk = 1 for j = k and 0 for j = k Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 21 / 48
Orientation Euclidean geometry
◮ Kronecker delta: δjk = 1 for j = k and 0 for j = k
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 21 / 48
Orientation Normal vector
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 22 / 48
Orientation Normal vector
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 22 / 48
Orientation Normal vector
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 22 / 48
Orientation Isometric maps
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 23 / 48
Orientation Isometric maps
◮ it is easy to show ATA = I by matrix multiplication,
◮ since AT is also orthogonal, it follows that
◮ side remark: the transposition operator ·T is called
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 23 / 48
Orientation Isometric maps
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 24 / 48
Orientation Isometric maps
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 24 / 48
Orientation Isometric maps
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 24 / 48
Orientation Isometric maps
DSM: Matrix Algebra 30 July 2009 24 / 48
Orientation Isometric maps
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 25 / 48
Orientation Isometric maps
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 25 / 48
Orientation Isometric maps
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 25 / 48
Orientation Isometric maps
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 25 / 48
Orientation Isometric maps
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 25 / 48
Orientation General inner product
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 26 / 48
Orientation General inner product
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 26 / 48
Orientation General inner product
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 26 / 48
Orientation General inner product
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 27 / 48
Orientation General inner product
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 27 / 48
Orientation General inner product
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 27 / 48
Orientation General inner product
x1 x2
1 2
1 2 3 3
b1 b2
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 28 / 48
Orientation General inner product
x1 x2
1 2
1 2 3 3
c2 c1
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 29 / 48
Orientation General inner product
x1 x2
1 2
1 2 3 3
c2 c1
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 29 / 48
PCA Motivation and example data
◮ targets = noun lemmas ◮ features = verb lemmas
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 30 / 48
PCA Motivation and example data
1 2 3 4 1 2 3 4 buy sell
acre advertising amount arm asset bag beer bill bit bond book bottle box bread building business car card carpet cigarette clothe club coal collection company computer copy couple currency dress drink drug equipment estate farm fish flat flower food freehold fruit furniture good home horse house insurance item kind land licence liquor lot machine material meat milk mill newspaper number
pack package packet painting pair paper part per petrol picture piece place plant player pound product property pub quality quantity range record right seat security service set share shoe shop site software stake stamp stock stuff suit system television thing ticket time tin unit vehicle video wine work year
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 31 / 48
PCA Motivation and example data
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 32 / 48
PCA Motivation and example data
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 32 / 48
PCA Motivation and example data
◮ “latent” distances in V are semantically meaningful ◮ other “residual” dimensions represent chance co-occurrence
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 32 / 48
PCA Motivation and example data
1 2 3 4 1 2 3 4 buy sell
acre advertising amount arm asset bag beer bill bit bond book bottle box bread building business car card carpet cigarette clothe club coal collection company computer copy couple currency dress drink drug equipment estate farm fish flat flower food freehold fruit furniture good home horse house insurance item kind land licence liquor lot machine material meat milk mill newspaper number
pack package packet painting pair paper part per petrol picture piece place plant player pound product property pub quality quantity range record right seat security service set share shoe shop site software stake stamp stock stuff suit system television thing ticket time tin unit vehicle video wine work year
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 33 / 48
PCA Calculating variance
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 34 / 48
PCA Calculating variance
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 34 / 48
PCA Calculating variance
−2 2 4 −2 2 4 buy sell
DSM: Matrix Algebra 30 July 2009 35 / 48
PCA Calculating variance
−2 2 4 −2 2 4 buy sell
DSM: Matrix Algebra 30 July 2009 35 / 48
PCA Calculating variance
−2 −1 1 2 −2 −1 1 2 buy sell
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 35 / 48
PCA Projection
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 36 / 48
PCA Projection
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 36 / 48
PCA Projection
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 36 / 48
PCA Projection
◮ we’ll see in a moment how to compute such projections ◮ but first, let us look at a few examples Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 36 / 48
PCA Projection
−2 −1 1 2 −2 −1 1 2 buy sell
DSM: Matrix Algebra 30 July 2009 37 / 48
PCA Projection
−2 −1 1 2 −2 −1 1 2 buy sell
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 37 / 48
PCA Projection
−2 −1 1 2 −2 −1 1 2 buy sell
DSM: Matrix Algebra 30 July 2009 37 / 48
PCA Projection
−2 −1 1 2 −2 −1 1 2 buy sell
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 37 / 48
PCA Projection
−2 −1 1 2 −2 −1 1 2 buy sell
DSM: Matrix Algebra 30 July 2009 37 / 48
PCA Projection
−2 −1 1 2 −2 −1 1 2 buy sell
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 37 / 48
PCA Projection
.
ϕ
P
v
x x, v v
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 38 / 48
PCA Projection
.
ϕ
P
v
x x, v v
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 38 / 48
PCA Covariance matrix
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 39 / 48
PCA Covariance matrix
DSM: Matrix Algebra 30 July 2009 39 / 48
PCA Covariance matrix
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 39 / 48
PCA Covariance matrix
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 39 / 48
PCA Covariance matrix
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 39 / 48
PCA Covariance matrix
◮ C is a square n × n matrix (2 × 2 in our example)
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 40 / 48
PCA Covariance matrix
◮ C is a square n × n matrix (2 × 2 in our example)
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 40 / 48
PCA The PCA algorithm
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 41 / 48
PCA The PCA algorithm
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 41 / 48
PCA The PCA algorithm
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 41 / 48
PCA The PCA algorithm
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 41 / 48
PCA The PCA algorithm
◮ note that both U and D are n × n square matrices Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 42 / 48
PCA The PCA algorithm
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 43 / 48
PCA The PCA algorithm
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 43 / 48
PCA The PCA algorithm
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 43 / 48
PCA The PCA algorithm
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 44 / 48
PCA The PCA algorithm
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 44 / 48
PCA The PCA algorithm
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 44 / 48
PCA The PCA algorithm
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 44 / 48
PCA The PCA algorithm
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 45 / 48
PCA The PCA algorithm
−2 −1 1 2 −2 −1 1 2 buy sell
DSM: Matrix Algebra 30 July 2009 46 / 48
PCA The PCA algorithm
−2 −1 1 2 −2 −1 1 2 buy sell
bottle good house packet part stock system advertising arm asset car clothe collection copy dress food insurance land liquor number
pair pound product property share suit ticket time year Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 46 / 48
PCA with R
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 47 / 48
PCA with R
Evert & Lenci (ESSLLI 2009) DSM: Matrix Algebra 30 July 2009 48 / 48