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


































































