find_projection: Find the 'projection matrix' to a semantic vector

View source: R/utils-embedding-matrices.R

find_projectionR Documentation

Find the 'projection matrix' to a semantic vector

Description

"Project" each word in a word embedding matrix of D dimension along a vector of D dimensions, extracted from the same embedding space. The vector can be a single word, or a concept vector obtained from get_centroid(), get_direction(), or get_regions().

Usage

find_projection(wv, vec)

Arguments

wv

Matrix of word embedding vectors (a.k.a embedding model) with rows as words.

vec

Vector extracted from the embeddings

Details

All the vectors in the matrix A are projected onto the a vector, v, to find the projection matrix, P, defined as:

P = \frac{A \cdot v}{v \cdot v} * v

Value

A new word embedding matrix, each row of which is parallel to vector.

Examples


data(ft_wv_sample)

vec <- ft_wv_sample["space", ]
proj <- find_projection(wv = ft_wv_sample, vec = vec)



text2map documentation built on Sept. 23, 2026, 5:07 p.m.