· Xiaojing Yang · NLP and LLMs · 2 min read

中文

Word Embeddings and Sentence Embeddings

How discrete language becomes vector space, and why sentence embeddings matter for retrieval and evaluation.

Core idea

Embeddings turn symbolic text into geometric objects that models can compare, transform, and retrieve.

1. From words to vectors

Words are discrete symbols. Neural models need numbers. Embeddings map tokens, words, sentences, or documents into dense vectors where similarity can be computed.

Embedding levels
Token embedding
one model token
Word embedding
lexical meaning
Sentence embedding
sentence-level semantics
Document embedding
longer context
Retrieval
nearest neighbors

2. Why sentence embeddings are different

A word embedding represents a lexical item. A sentence embedding tries to compress context, syntax, topic, and meaning into one vector. That compression is useful but lossy.

Use caseEmbedding level
Similar wordsword embeddings
Semantic searchsentence/document embeddings
RAG retrievalpassage embeddings
MT evaluationmultilingual sentence representations

3. Hugging Face practice

from transformers import AutoTokenizer, AutoModel

name = "sentence-transformers/all-MiniLM-L6-v2"
tokenizer = AutoTokenizer.from_pretrained(name)
model = AutoModel.from_pretrained(name)

4. My research connection

Embeddings connect directly to RAG, COMET-style MT evaluation, multilingual similarity, and error analysis. In petroleum-domain MT, sentence representations can reveal whether technical meaning is preserved even when surface wording changes.

Similarity view

Vectors close together are treated as semantically related.

Caution

Embedding similarity can miss factual grounding, domain terminology, and negation.

Takeaway

Embeddings are powerful because they make language measurable, but the measurement is never the whole meaning.

Interview pattern

My interview answer would usually be:

  1. define the concept in one sentence;
  2. explain the data flow;
  3. name the main failure mode;
  4. connect it to evaluation, multilinguality, or fine-tuning.

References

Share:
Back to Blog

Related Posts

View All Posts »
FoundationsNLP and LLMsEN

Attention Mechanism

Attention as a learned way to decide what context matters for each token.

FoundationsNLP and LLMsEN

Fine-Tuning Transformers

How pretrained language models are adapted to a task or domain with supervised data.

FoundationsNLP and LLMsEN

LLM Evaluation and Failure Modes

A practical map of LLM evaluation risks: hallucination, prompt sensitivity, bias, contamination, and brittle benchmarks.

FoundationsNLP and LLMsEN

NLP Evaluation

Why NLP evaluation needs metrics, uncertainty, human judgment, and task-specific error analysis.