liveBook · Manning

Language model

As explained in Hugging Face in Action

A large language model is a high-capacity neural model trained on large text corpora to process and generate language.

A large language model (LLM) is a high-capacity AI model that learns patterns and structures from massive training datasets to understand and generate humanlike text. Pretraining builds general knowledge of grammar, syntax, and semantics; fine-tuning adapts the model to tasks such as classification, translation, sentiment analysis, and summarization. section 7.1

Key characteristics include:

  • Large training scale exposes models to books, articles, websites, videos, and images. section 7.1
  • Trainable parameters include weights and biases; increasing their number raises training time, memory requirements, computing needs, and cost. section 7.1
  • Tokens are chunks of text processed as individual units, including subword units such as the pieces of “unhappiness.” section 7.1 section 7.4

Calling an LLM through LangChain

A practical application connects a prompt, an LLM, and an output parser: `llm_chain = prompt | openai_model | StrOutputParser()`. Invoking the chain with “Who is Steve Jobs?” returns a generated answer. The same workflow can use an OpenAI model such as `gpt-4o-mini` or Hugging Face’s `tiiuae/falcon-7b-instruct`. section 7.2.8

Listing 7.5 Creating a chain using OpenAI LLM
from langchain import PromptTemplate
from langchain_core.output_parsers import StrOutputParser

template = '''
Question: {question}
Answer: '''

prompt = PromptTemplate(
    template = template,
    input_variables = ['question']
)

llm_chain = prompt | openai_model | StrOutputParser()

Shows the runnable LangChain composition of a prompt template, OpenAI chat model, and string output parser. section 7.2.8

LLMs can run locally or through cloud services. Local execution keeps processing on the user’s computer but may be slower and require substantial memory and processing power. Cloud models can respond faster and may provide higher-quality results, but queries and document contents sent through hosted services are processed on provider servers and may incur usage charges. section 7.3.9 section 7.4

Applications extend LLMs with LangChain for chained components, LlamaIndex for ingesting and querying private or domain-specific data, retrieval-augmented generation for external retrieval, agents for multistep tool use, and Gradio for web frontends. section 7.4 section 9.0

How Hugging Face in Action covers it

How deep it goes
Defines training, parameters, and tokens, then demonstrates API-based use; it stops short of neural-network mathematics and model construction.
Examples
Demonstrates question answering, translation, invoice and receipt queries, private-document retrieval, and tabular-data analysis.
What it assumes
Assumes Python and prior exposure to pretrained models, while introducing LLMs, tokens, prompting, model providers, and application frameworks.
What you can do after
Build it from scratch with LangChain or LlamaIndex, then operate local or hosted models in question-answering and private-data workflows.
How it connects
Connects LLMs with tokens, fine-tuning, LangChain, LlamaIndex, retrieval-augmented generation, agents, Hugging Face, and OpenAI.

Also explained in

Compare how 67 books explain language model →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Hugging Face in Action. The section links point to the parts of the book it draws on.