Skip to content
Subin Thapa

Subin Thapa

  • Home
  • About
  • Service
  • Portfolio
  • Blog
  • Contact
Schedule Meeting

NLP Essentials: Understanding Vectors, Embeddings, and Tokenization

subinthapaApril 7, 2026April 7, 2026 No Comments

Introduction to Natural Language Processing (NLP)

Natural Language Processing (NLP) is a field of Artificial Intelligence (AI) that focuses on the interaction between computers and human language. Its primary goal is to enable machines to understand, interpret, and generate human language in a meaningful way. NLP is widely used in applications like chatbots, search engines, sentiment analysis, translation systems, and more.

To build effective NLP models, several foundational concepts and techniques are essential, ranging from text preprocessing to vector representations and semantic understanding.


1. Text Preprocessing

Text preprocessing is the first and most important step in NLP. It involves cleaning and preparing raw text so that it can be effectively used by machine learning models.

Key techniques include:

  • Tokenization: Splitting text into smaller units called tokens.
    Example:
    Text: “I love Nepal” → [“I”, “love”, “Nepal”]
  • Lowercasing: Converting all text to lowercase to maintain uniformity.
    Example: “Hello” → “hello”
  • Stopword Removal: Removing common words that do not carry significant meaning (e.g., is, the, a).
  • Stemming: Reducing words to their base or root form by cutting endings.
    Example: “playing” → “play”
  • Lemmatization: Reducing words to their proper root form based on vocabulary and meaning.
    Example: “better” → “good”
  • Punctuation Removal: Removing unnecessary symbols to clean text.

2. Text Representation

Computers cannot understand raw text; text must be converted into numbers. This is done through various text representation techniques.

2.1 Sparse Representations

  • Bag of Words (BoW): Counts the frequency of each word in a document.
    Example:
    Vocabulary: [“I”, “love”, “data”, “AI”]
    “I love data” → [1, 1, 1, 0]
    “I love AI” → [1, 1, 0, 1]
  • TF-IDF (Term Frequency – Inverse Document Frequency): Assigns higher importance to words that are rare and meaningful across the dataset.
  • N-Grams: Considers sequences of words to capture some context.
    Example: “I love AI” → unigrams: [“I”, “love”, “AI”], bigrams: [“I love”, “love AI”]

2.2 Dense Representations

Dense representations, also called embeddings, are vectors where most values are non-zero and capture semantic meaning.

  • Word2Vec and GloVe: Transform words into vectors that capture semantic relationships.
    Example: king − man + woman ≈ queen
  • FastText: Breaks words into subwords to better handle rare words.
  • Contextual Embeddings (BERT, GPT): Vectors depend on the surrounding context in a sentence, allowing for understanding of polysemy (words with multiple meanings).

3. Understanding Vectors

A vector is a list of numbers that represents information about an object, word, or sentence. In NLP, embeddings are dense vectors representing words or tokens.

  • Vectors are understood by comparison: two vectors that are close to each other in space have similar meanings.
  • Relationships between words can also be captured mathematically: king − man + woman ≈ queen.

Vectors are visualized in vector spaces, where each vector is a point in a high-dimensional space. Words with similar meanings are clustered together, and unrelated words are far apart.


4. Vector Space

A vector space is a mathematical space where vectors exist and can be combined. Vector spaces allow:

  • Addition of vectors
  • Multiplication of vectors by scalars

In NLP, each word or token is represented as a vector in a high-dimensional vector space. The proximity of vectors represents semantic similarity.

  • Sparse vector spaces: Large dimensions, mostly zeros (BoW, TF-IDF).
  • Dense vector spaces: Compact, meaningful, and used in embeddings (Word2Vec, BERT).

5. Semantic Similarity

Semantic similarity measures how similar two words, phrases, or sentences are in meaning, regardless of the exact words used.

Examples:

  • “I am happy” and “I feel joyful” → semantically similar
  • “He is very smart” and “He is intelligent” → semantically similar

In NLP, semantic similarity is computed using vector operations, such as:

  • Cosine Similarity: Measures the angle between vectors
  • Euclidean Distance: Measures the straight-line distance between vectors

6. Tokenization and Subword Tokenization

Tokenization is splitting text into smaller units called tokens. Modern NLP uses subword tokenization to handle rare words and reduce vocabulary size.

Example Sentence: “This is an apple”

  • Word-level tokenization: [“This”, “is”, “an”, “apple”]
  • Character-level tokenization: [“T”, “h”, “i”, “s”, ” “, “i”, “s”, …]
  • Subword tokenization (Byte Pair Encoding or BERT-style): [“This”, “is”, “an”, “app”, “le”]

Subword tokenization ensures that even unseen or rare words can be represented effectively.


7. NLP Workflow Summary

  1. Text Preprocessing → Clean text (tokenize, lowercase, remove stopwords)
  2. Text Representation → Convert text into vectors (BoW, TF-IDF, embeddings)
  3. Vector Space Modeling → Map words or tokens into high-dimensional vector space
  4. Similarity / Relationships → Compare vectors to measure semantic similarity
  5. Modeling / Applications → Use these vectors in ML/DL models for NLP tasks

8. Applications of NLP

  • Sentiment Analysis
  • Chatbots and Virtual Assistants
  • Search Engines
  • Machine Translation
  • Text Summarization
  • Named Entity Recognition (NER)
  • Text Classification

References for Further Reading

  1. Jurafsky, D., & Martin, J. H. (2023). Speech and Language Processing.
  2. Goldberg, Y. (2017). Neural Network Methods for Natural Language Processing.
  3. Mikolov, T., et al. (2013). Efficient Estimation of Word Representations in Vector Space.
  4. Devlin, J., et al. (2018). BERT: Pre-training of Deep Bidirectional Transformers for Language Understanding.

Post navigation

Previous: Most People Chase Returns, Smart People Chase Capital | Financial Literacy in Nepal

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Copyright © 2026 Subin Thapa
No Form Selected This form is powered by: Sticky Floating Forms Lite