One-Hot Encoding
Given an ordered vocabulary V, the one-hot encoding of a word is the vector in {0,1}^|V| that is 1 at the word's index and 0 everywhere else.
Properties#
- Pairwise orthogonal: for , hence (Cosine Similarity).
- Documents and queries are sums: a document column of the term-document matrix in the Vector Space Model (VSM) is the sum of the one-hot encodings of its words, with multiplicity: (with tf entries). A query vector is the same sum; since a query typically contains few keywords, each at most once, it has a few 1s and 0s otherwise.
- Dimension : very large for real vocabularies, and the vectors are maximally sparse (one nonzero entry).
- No semantics: “internet” and “web” are exactly as (dis)similar as “internet” and “beach” (cos-sim in both cases). This motivates word embeddings: dense, low-dimensional vectors in which related words have high cos-sim.
Example#
Sources#
- Slides 11, p. 17 (vocabulary), Slides 11, p. 18 (definition), Slides 11, p. 19 (documents as sums), Slides 11, p. 20 (orthogonality, no semantics)
- DBIS_VL11 > Vocabulary, DBIS_VL11 > One-hot encoding