Book a free call

How NLP Powers Large Language Models

Large language models are built from natural language processing techniques: tokenization, embeddings, attention and fine-tuning. Here is what each one adds.

Hertiv engineering teamReviewed by a senior engineer
7 min read
How NLP Powers Large Language Models
On this page

Short answer

Natural language processing gives large language models the tools they are built from: tokenization splits text into pieces a model can process, embeddings turn those pieces into numbers that capture meaning, and attention lets the model weigh the relationships between words. Training, fine-tuning and alignment then shape those building blocks into a system that can answer questions, summarise documents and write code.

What does NLP contribute to a large language model?

Natural language processing (NLP) is the field of AI that gives machines the tools to read, analyse and produce human language, and large language models are built almost entirely from those tools. A large language model is not a separate invention that replaced NLP; it is NLP techniques combined at a very large scale.

The core contributions are easy to name. Tokenization turns raw text into units a model can process. Embeddings turn those units into numbers that capture meaning. Attention lets the model weigh how words relate to each other across a sentence or a document. And the training objective itself, predicting the next piece of text, is a classic language modelling task from NLP research.

What changed with scale is how well these pieces work together. The same ideas existed in smaller models for years, but training them on far more text with far more parameters made the results useful for open-ended tasks. Understanding the NLP building blocks is therefore the fastest way to understand what a language model can and cannot do.

How does tokenization shape what a model sees?

Tokenization shapes what a model sees because a model never reads words directly; it reads tokens, which are pieces of words, whole words or single characters. The tokenizer decides where those boundaries fall, and that decision affects cost, context and accuracy.

MethodHow it splits textStrength
Word-basedOn spaces and punctuationSimple, but huge vocabulary
Character-basedOne character at a timeHandles any text, very long sequences
Subword (BPE)Frequent chunks, rare words splitBalance of size and coverage

Most modern models use subword tokenization. Common words become single tokens, while rare words split into pieces, so the model can handle new words without an endless vocabulary.

Token counts also drive cost: a model is usually priced per token, and its context window is measured in tokens, not words. A long document that looks short in words can be expensive in tokens, which is why tokenization is a practical concern as well as a technical one. See what tokenization in NLP is for more detail.

What do embeddings add?

Embeddings add meaning to tokens by turning each one into a list of numbers, a vector, where tokens with similar meanings sit close together. The word for a feline and the word for a pet end up near each other in that space, while unrelated words sit far apart.

Early embeddings gave each word one fixed vector, which meant a word with two meanings had to share one representation. Modern models use contextual embeddings, where the vector for a word changes with the words around it, so the same word can mean a financial institution in one sentence and a river edge in another.

Embeddings also power the features built around language models. Search and retrieval systems compare the embedding of a question with the embeddings of stored documents to find the closest matches. Classification, clustering and duplicate detection all start from the same idea: if two texts have similar vectors, they probably mean similar things.

How does attention turn words into meaning?

Attention turns words into meaning by letting each token weigh the other tokens in the sentence and decide which ones matter for understanding it. When a model reads a pronoun, attention is the mechanism that connects it back to the noun it refers to.

In the transformer architecture, self-attention computes a score for every pair of tokens, then blends their information according to those scores. A token representing a verb gathers information from its subject and object; a token in a long document gathers context from the paragraphs that define its terms. Stacking many attention layers lets the model build increasingly abstract representations, from word shapes to sentence structure to topic.

Attention is also why longer context helps. A model with a larger context window can attend to more of the document at once, which improves summarisation and question answering. The cost is that attention grows with the square of the sequence length, which is why very long inputs are expensive and why retrieval, fetching only the relevant passages, is often used instead.

Where do training, fine-tuning and alignment fit?

Training, fine-tuning and alignment fit together as three stages that turn NLP building blocks into a usable model. Each stage has a different job, and skipping one leaves a gap the others cannot fill.

  1. Pretraining. The model learns from a large collection of text by predicting the next token, which teaches it grammar, facts and patterns of reasoning.
  2. Fine-tuning. The model is trained further on task-specific data, such as support conversations or legal documents, so it performs well in one domain. See how to fine-tune an LLM for the practical steps.
  3. Alignment. Human feedback teaches the model to follow instructions, refuse harmful requests and match the tone a product needs.
  4. Evaluation. The model is tested on held-out data and real user prompts, measuring accuracy, safety and latency.
  5. Deployment with guardrails. Input filters, output checks and retrieval keep the model inside its intended behaviour.

Fine-tuning and alignment matter because a pretrained model is a general text predictor, not an assistant. The same base model can become a careful support agent or a reckless one depending on how these stages are done. For the service side of this work, see our LLM development services.

Example (hypothetical): a document search tool

Example (hypothetical): a law firm wants a search tool over 50,000 internal documents, each averaging 400 tokens, so the collection totals 20,000,000 tokens. The team embeds every document once and stores the vectors for retrieval.

The embedding service processes 2,000 tokens per second, so indexing the whole collection takes 20,000,000 divided by 2,000, which is 10,000 seconds, or about 2.8 hours. That is a one-off cost, and new documents are embedded as they arrive.

At query time the tool embeds the question, finds the 5 closest document chunks and passes about 2,000 tokens of context to the language model, which writes the answer. The retrieval step keeps the context small and grounded in the firm's own documents, which reduces invented answers and keeps each query cheap. Without embeddings, the same question would need the whole collection in context, which would not fit and would cost far more per query.

What are the common mistakes?

The most common mistakes with NLP-powered language models come from treating the model as if it understands language the way a person does, and from skipping the unglamorous data work.

  • Assuming understanding. A model predicts likely text; it does not know facts unless they are in its training data or retrieved at query time.
  • Ignoring tokenization costs. Long inputs and verbose prompts cost more and fill the context window faster than teams expect.
  • Feeding raw documents without cleaning. Headers, footers and duplicated pages pollute embeddings and retrieval results.
  • No evaluation set. Without held-out examples and a scoring method, nobody can tell whether a change helped or hurt.
  • Prompting when fine-tuning fits. If you have thousands of labelled examples, fine-tuning usually beats a long prompt.
  • Trusting factual answers without checks. Outputs that sound confident can still be invented, so high-stakes answers need verification.

When should you use classic NLP instead of an LLM?

You should use classic NLP instead of a language model when the task is narrow, high-volume and well defined, because a smaller tool is cheaper, faster and easier to control. Language models earn their place on open-ended work.

TaskBetter toolWhy
Extracting fixed fields from formsClassic NLPPredictable output, low cost
Keyword search over documentsClassic NLPFast and exact
Sentiment on known labelsClassic NLPSmall classifier is enough
Open-ended draftingLLMNeeds generation
Reasoning over a long documentLLMNeeds context and inference
Few-shot new taskLLMNo training data needed

Many real systems combine the two: classic NLP handles extraction and routing, and the language model handles the cases that need judgement or generation. That hybrid is often cheaper and more reliable than using a language model for everything.

For a direct comparison of the two approaches, see NLP vs LLM.

For the foundations, see what natural language processing is.

Key takeaways

  • Large language models are built from NLP techniques, not a replacement for them
  • Tokenization decides what the model sees and drives both cost and context limits
  • Embeddings turn tokens into numbers that capture meaning and power search and retrieval
  • Attention lets each token weigh the rest of the text, which is how context becomes meaning
  • Classic NLP still wins for narrow, high-volume tasks; LLMs earn their place on open-ended work

Frequently asked questions

Is NLP the same as a large language model?

No. NLP is the wider field covering all techniques for processing human language, while a large language model is one kind of system built from those techniques. Classic NLP includes rule-based parsing, small classifiers and keyword methods that are still useful, whereas an LLM is a large neural model trained to predict text.

What is tokenization in simple terms?

Tokenization is splitting text into pieces a model can process, called tokens. Most models use subword tokenization, where common words stay whole and rare words split into chunks. The token count of a text decides how much it costs to process and how much of it fits in the model's context window.

Why do embeddings matter for language models?

Embeddings give the model a way to represent meaning as numbers, so words with similar meanings sit close together in vector space. They also power the features around a model: search, retrieval, classification and duplicate detection all compare embeddings to find similar texts.

Can a language model work without attention?

In practice, no modern large model does. Attention is the mechanism that lets each token consider the rest of the text, which is how the model resolves pronouns, tracks topics and uses long context. Earlier models without attention could only handle short sequences well.

Do I need to fine-tune a model for my business?

Not always. If your task is well served by good prompts and retrieval from your own documents, that is cheaper and easier to update. Fine-tuning fits when you have thousands of labelled examples and need consistent behaviour, tone or domain knowledge that prompting cannot deliver.

Will classic NLP disappear now that LLMs exist?

No. Classic NLP is cheaper, faster and more predictable for narrow tasks such as fixed-field extraction, keyword search and high-volume classification. Most production systems combine both, using classic methods where they are enough and language models where generation or reasoning is needed.

Found this useful? Share it.
Hertiv engineering team

Written from projects we build for clients: AI and agent systems in production. Every post is reviewed by a senior engineer before publishing and updated when practice changes.

About HertivHow we work

Building a product on language models or NLP? Talk to Hertiv.

A senior engineer replies within one business day. Or see our NLP Development service.

Book a free call

Keep reading

All posts

Tell us what you want to build

A senior engineer reads every request and replies within one business day with questions, a rough range, or a call link.

  • NDA on request before any details
  • You own all code, models and IP
  • US, UK and EU time-zone overlap

Your email app should open with your message ready to send. If it does not, write to contact@hertiv.com.

Prefer email? Write to contact@hertiv.com
Estimate costBook a call