Unified embeddings for translation
A method of training word embeddings is provided. The method includes determining anchors, each comprising a first word in a first domain and a second word in a second domain, training word embeddings for the first and second domains, and training a transform for transforming word embedding vectors in the first domain to word embedding vectors in the second domain, wherein the training minimizes a loss function that includes an anchor loss for each anchor, such that for each anchor, the anchor loss is based on a distance between the anchor's second word's embedding vector and the transform of the anchor's first word's embedding vector, and for each anchor, the anchor loss for the respective anchor is zero when the distance between the respective anchor's second word's embedding vector and the transform of the respective anchor's first word's embedding vector is less than a specific tolerance.
1. A method of training word embeddings, the method comprising:
determining a plurality of anchors, each anchor comprising a first word in a first domain and a second word in a second domain;
training (1) a word embedding for the first domain;
training (2) a word embedding for the second domain; and
training (3) a transform for transforming word embedding vectors in the first domain to word embedding vectors in the second domain, wherein:
the training minimizes a loss function that includes an anchor loss for each anchor;
for each respective anchor of the plurality of anchors, the anchor loss for the respective anchor is based on a distance between the respective anchor's second word's embedding vector and the transform of the respective anchor's first word's embedding vector; and
for each respective anchor of the plurality of anchors, the anchor loss for the respective anchor is zero when the distance between the respective anchor's second word's embedding vector and the transform of the respective anchor's first word's embedding vector is less than a specific tolerance.
2. The method of claim 1 , wherein the first domain comprises words in a first language and the second domain comprises words in a second language.
3. The method of claim 1 , further comprising translating a word in the first domain to a word in the second domain by:
projecting, using the word embedding for the first domain, the first word in the first domain to a first word embedding vector in the first domain;
transforming, using the trained transform, the first word embedding vector in the first domain to a second word embedding vector in the second domain; and
identifying a word in the second domain having a projection, using the word embedding for the second domain, that is closest to the second word embedding vector in the second domain.
4. The method of claim 1 , wherein at least one anchor of the plurality of anchors represents a named entity.
5. The method of claim 1 , further comprising:
determining a further plurality of anchors, each anchor of the further plurality of anchors, comprising a first word in the first domain and a second word in a third domain,
wherein for each respective anchor of the further plurality of anchors, the anchor loss for the respective anchor is zero when the distance between the respective anchor's second word's embedding vector and the transform of the respective anchor's first word's embedding vectors is less than the specific tolerance.
6. The method of claim 1 , wherein the loss function gives a first weight to a first anchor of the plurality of anchors and a second weight to a second anchor of the plurality of anchors.
7. A non-transitory computer-readable recording medium having a computer program recorded thereon, the computer program, when executed by one or more processors of a computer system, causes the computer system to perform a method comprising:
determining a plurality of anchors, each anchor comprising a first word in a first domain and a second word in a second domain;
training (1) a word embedding for the first domain;
training (2) a word embedding for the second domain; and
training (3) a transform for transforming word embedding vectors in the first domain to word embedding vectors in the second domain, wherein:
the training minimizes a loss function that includes an anchor loss for each anchor;
for each respective anchor of the plurality of anchors, the anchor loss for the respective anchor is based on a distance between the respective anchor's second word's embedding vector and the transform of the respective anchor's first word's embedding vector; and
for each respective anchor of the plurality of anchors, the anchor loss for the respective anchor is zero when the distance between the respective anchor's second word's embedding vector and the transform of the respective anchor's first word's embedding vector is less than a specific tolerance.
8. The non-transitory computer-readable recording medium of claim 7 , wherein the first domain comprises words in a first language and the second domain comprises words in a second language.
9. The non-transitory computer-readable recording medium of claim 7 , wherein the method further comprises translating a word in the first domain to a word in the second domain by:
projecting, using the word embedding for the first domain, the first word in the first domain to a first word embedding vector in the first domain;
transforming, using the trained transform, the first word embedding vector in the first domain to a second word embedding vector in the second domain; and
identifying a word in the second domain having a projection, using the word embedding for the second domain, that is closest to the second word embedding vector in the second domain.
10. The non-transitory computer-readable recording medium of claim 7 , wherein at least one anchor of the plurality of anchors represents a named entity.
11. The non-transitory computer-readable recording medium of claim 7 , wherein the method further comprises:
determining a further plurality of anchors, each anchor of the further plurality of anchors, comprising a first word in the first domain and a second word in a third domain,
wherein for each respective anchor of the further plurality of anchors, the anchor loss for the respective anchor is zero when the distance between the respective anchor's second word's embedding vector and the transform of the respective anchor's first word's embedding vectors is less than the specific tolerance.
12. The non-transitory computer-readable recording medium of claim 7 , wherein the loss function gives a first weight to a first anchor of the plurality of anchors and a second weight to a second anchor of the plurality of anchors.
13. A method of translating a word in a first domain to a word in a second domain using a trained transform, the method comprising:
projecting, using a word embedding for a first domain, the word in the first domain to a word embedding vector in the first domain;
transforming, using the trained transform, the word embedding vector in the first domain to a word embedding vector in the second domain; and
identifying a word in the second domain having a projection, using a word embedding for the second domain, that is closest to the word embedding vector in the second domain,
wherein the trained transform is trained by:
determining a plurality of anchors, each anchor comprising a first word in the first domain and a second word in the second domain;
training (1) the word embedding for the first domain;
training (2) the word embedding for the second domain; and
training (3) a transform for transforming word embedding vectors in the first domain to word embedding vectors in the second domain, wherein:
the training minimizes a loss function that includes an anchor loss for each anchor;
for each respective anchor of the plurality of anchors, the anchor loss for the respective anchor is based on a distance between the respective anchor's second word's embedding vector and the transform of the respective anchor's first word's embedding vector; and
for each respective anchor of the plurality of anchors, the anchor loss for the respective anchor is zero when the distance between the respective anchor's second word's embedding vector and the transform of the respective anchor's first word's embedding vector is less than a specific tolerance.