python-langchain-com-docs-how_to-#llms...
python-langchain-com-docs-how_to-#llms...
Skip to
main
How-to guides content
On this page
Here you’ll find answers to “How do I….?” types of questions. These guides are goal-oriented and
concrete; they're meant to help you complete a specific task. For conceptual explanations see the
Conceptual guide. For end-to-end walkthroughs see Tutorials. For comprehensive descriptions of every
class and function see the API Reference.
Installation
How to: install LangChain packages
How to: use LangChain with different Pydantic versions
Key features
This highlights functionality that is core to using LangChain.
LCEL cheatsheet: For a quick overview of how to use the main LCEL primitives.
Components
These are the core building blocks you can use when building applications.
Prompt templates
Prompt Templates are responsible for formatting user input into a format that can be passed to a
language model.
Example selectors
Example Selectors are responsible for selecting the correct few shot examples to pass to the prompt.
Chat models
Chat Models are newer forms of language models that take messages in and output a message. See
supported integrations for details on getting started with chat models from a specific provider.
How to: do function/tool calling
How to: get models to return structured output
How to: cache model responses
How to: get log probabilities
How to: create a custom chat model class
How to: stream a response back
How to: track token usage
How to: track response metadata across providers
How to: use chat model to call tools
How to: stream tool calls
How to: handle rate limits
How to: few shot prompt tool behavior
How to: bind model-specific formatted tools
How to: force a specific tool call
How to: work with local models
How to: init any model in one line
Messages
Messages are the input and output of chat models. They have some content and a role , which
describes the source of the message.
LLMs
What LangChain calls LLMs are older forms of language models that take a string in and output a string.
Output parsers
Output Parsers are responsible for taking the output of an LLM and parsing into more structured format.
How to: parse text from message objects
How to: use output parsers to parse an LLM response into structured format
How to: parse JSON output
How to: parse XML output
How to: parse YAML output
How to: retry when output parsing errors occur
How to: try to fix errors in output parsing
How to: write a custom output parser class
Document loaders
Document Loaders are responsible for loading documents from a variety of sources.
Text splitters
Text Splitters take a document and split into chunks that can be used for retrieval.
Embedding models
Embedding Models take a piece of text and create a numerical representation of it. See supported
integrations for details on getting started with embedding models from a specific provider.
How to: embed text data
How to: cache embedding results
How to: create a custom embeddings class
Vector stores
Vector stores are databases that can efficiently store and retrieve embeddings. See supported
integrations for details on getting started with vector stores from a specific provider.
Retrievers
Retrievers are responsible for taking a query and returning relevant documents.
Indexing
Indexing is the process of keeping your vectorstore in-sync with the underlying data source.
How to: reindex data to keep your vectorstore in-sync with the underlying data source
Tools
LangChain Tools contain a description of the tool (to pass to the language model) as well as the
implementation of the function to call. Refer here for a list of pre-buit tools.
Multimodal
How to: pass multimodal data directly to models
How to: use multimodal prompts
Agents
NOTE
For in depth how-to guides for agents, please check out LangGraph documentation.
Callbacks
Callbacks allow you to hook into the various stages of your LLM application's execution.
Custom
All of LangChain components can easily be extended to support your own versions.
How to: create a custom chat model class
How to: create a custom LLM class
How to: create a custom embeddings class
How to: write a custom retriever class
How to: write a custom document loader
How to: write a custom output parser class
How to: create custom callback handlers
How to: define a custom tool
How to: dispatch custom callback events
Serialization
How to: save and load LangChain objects
Use cases
These guides cover use-case specific details.
Extraction
Extraction is when you use LLMs to extract structured information from unstructured text. For a high
level tutorial on extraction, check out this guide.
Chatbots
Chatbots involve using an LLM to have a conversation. For a high-level tutorial on building chatbots,
check out this guide.
Query analysis
Query Analysis is the task of using an LLM to generate a query to send to a retriever. For a high-level
tutorial on query analysis, check out this guide.
Summarization
LLMs can summarize and otherwise distill desired information from text, including large volumes of text.
For a high-level tutorial, check out this guide.
LangGraph
LangGraph is an extension of LangChain aimed at building robust and stateful multi-actor applications
with LLMs by modeling steps as edges and nodes in a graph.
LangGraph documentation is currently hosted on a separate site. You can peruse LangGraph how-to
guides here.
LangSmith
LangSmith allows you to closely trace, monitor and evaluate your LLM application. It seamlessly
integrates with LangChain and LangGraph, and you can use it to inspect and debug individual steps of
your chains and agents as you build.
LangSmith documentation is hosted on a separate site. You can peruse LangSmith how-to guides here,
but we'll highlight a few sections that are particularly relevant to LangChain below:
Evaluation
Evaluating performance is a vital part of building LLM-powered applications. LangSmith helps with every
step of the process from creating a dataset to defining metrics to running evaluators.
Tracing
Tracing gives you observability inside your chains and agents, and is vital in diagnosing issues.
You can see general tracing-related how-tos in this section of the LangSmith docs.
GitHub
Organization
Python
JS/TS
More
Homepage
Blog
YouTube