*   [](/v0.2/)
*   How-to guides

On this page

How-to guides
=============

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 [Conceptual Guides](/v0.2/docs/concepts/). For end-to-end walkthroughs see [Tutorials](/v0.2/docs/tutorials). For comprehensive descriptions of every class and function see [API Reference](https://v2.v02.api.js.langchain.com/).

Installation[​](#installation "Direct link to Installation")
------------------------------------------------------------

*   [How to: install LangChain packages](/v0.2/docs/how_to/installation/)

Key features[​](#key-features "Direct link to Key features")
------------------------------------------------------------

This highlights functionality that is core to using LangChain.

*   [How to: return structured data from an LLM](/v0.2/docs/how_to/structured_output/)
*   [How to: use a chat model to call tools](/v0.2/docs/how_to/tool_calling/)
*   [How to: stream runnables](/v0.2/docs/how_to/streaming)
*   [How to: debug your LLM apps](/v0.2/docs/how_to/debugging/)

LangChain Expression Language (LCEL)[​](#langchain-expression-language-lcel "Direct link to LangChain Expression Language (LCEL)")
----------------------------------------------------------------------------------------------------------------------------------

LangChain Expression Language is a way to create arbitrary custom chains. It is built on the [`Runnable`](https://api.js.langchain.com/classes/langchain_core_runnables.Runnable.html) protocol.

[**LCEL cheatsheet**](/v0.2/docs/how_to/lcel_cheatsheet/): For a quick overview of how to use the main LCEL primitives.

*   [How to: chain runnables](/v0.2/docs/how_to/sequence)
*   [How to: stream runnables](/v0.2/docs/how_to/streaming)
*   [How to: invoke runnables in parallel](/v0.2/docs/how_to/parallel/)
*   [How to: attach runtime arguments to a runnable](/v0.2/docs/how_to/binding/)
*   [How to: run custom functions](/v0.2/docs/how_to/functions)
*   [How to: pass through arguments from one step to the next](/v0.2/docs/how_to/passthrough)
*   [How to: add values to a chain's state](/v0.2/docs/how_to/assign)
*   [How to: add message history](/v0.2/docs/how_to/message_history)
*   [How to: route execution within a chain](/v0.2/docs/how_to/routing)
*   [How to: add fallbacks](/v0.2/docs/how_to/fallbacks)

Components[​](#components "Direct link to Components")
------------------------------------------------------

These are the core building blocks you can use when building applications.

### Prompt templates[​](#prompt-templates "Direct link to Prompt templates")

[Prompt Templates](/v0.2/docs/concepts/#prompt-templates) are responsible for formatting user input into a format that can be passed to a language model.

*   [How to: use few shot examples](/v0.2/docs/how_to/few_shot_examples)
*   [How to: use few shot examples in chat models](/v0.2/docs/how_to/few_shot_examples_chat/)
*   [How to: partially format prompt templates](/v0.2/docs/how_to/prompts_partial)
*   [How to: compose prompts together](/v0.2/docs/how_to/prompts_composition)

### Example selectors[​](#example-selectors "Direct link to Example selectors")

[Example Selectors](/v0.2/docs/concepts/#example-selectors) are responsible for selecting the correct few shot examples to pass to the prompt.

*   [How to: use example selectors](/v0.2/docs/how_to/example_selectors)
*   [How to: select examples by length](/v0.2/docs/how_to/example_selectors_length_based)
*   [How to: select examples by semantic similarity](/v0.2/docs/how_to/example_selectors_similarity)

### Chat models[​](#chat-models "Direct link to Chat models")

[Chat Models](/v0.2/docs/concepts/#chat-models) are newer forms of language models that take messages in and output a message.

*   [How to: do function/tool calling](/v0.2/docs/how_to/tool_calling)
*   [How to: get models to return structured output](/v0.2/docs/how_to/structured_output)
*   [How to: cache model responses](/v0.2/docs/how_to/chat_model_caching)
*   [How to: create a custom chat model class](/v0.2/docs/how_to/custom_chat)
*   [How to: get log probabilities](/v0.2/docs/how_to/logprobs)
*   [How to: stream a response back](/v0.2/docs/how_to/chat_streaming)
*   [How to: track token usage](/v0.2/docs/how_to/chat_token_usage_tracking)

### Messages[​](#messages "Direct link to Messages")

[Messages](/v0.2/docs/concepts/##message-types) are the input and output of chat models. They have some `content` and a `role`, which describes the source of the message.

*   [How to: trim messages](/v0.2/docs/how_to/trim_messages/)
*   [How to: filter messages](/v0.2/docs/how_to/filter_messages/)
*   [How to: merge consecutive messages of the same type](/v0.2/docs/how_to/merge_message_runs/)

### LLMs[​](#llms "Direct link to LLMs")

What LangChain calls [LLMs](/v0.2/docs/concepts/#llms) are older forms of language models that take a string in and output a string.

*   [How to: cache model responses](/v0.2/docs/how_to/llm_caching)
*   [How to: create a custom LLM class](/v0.2/docs/how_to/custom_llm)
*   [How to: stream a response back](/v0.2/docs/how_to/streaming_llm)
*   [How to: track token usage](/v0.2/docs/how_to/llm_token_usage_tracking)

### Output parsers[​](#output-parsers "Direct link to Output parsers")

[Output Parsers](/v0.2/docs/concepts/#output-parsers) are responsible for taking the output of an LLM and parsing into more structured format.

*   [How to: use output parsers to parse an LLM response into structured format](/v0.2/docs/how_to/output_parser_structured)
*   [How to: parse JSON output](/v0.2/docs/how_to/output_parser_json)
*   [How to: parse XML output](/v0.2/docs/how_to/output_parser_xml)
*   [How to: try to fix errors in output parsing](/v0.2/docs/how_to/output_parser_fixing/)

### Document loaders[​](#document-loaders "Direct link to Document loaders")

[Document Loaders](/v0.2/docs/concepts/#document-loaders) are responsible for loading documents from a variety of sources.

*   [How to: load CSV data](/v0.2/docs/how_to/document_loader_csv)
*   [How to: load data from a directory](/v0.2/docs/how_to/document_loader_directory)
*   [How to: load PDF files](/v0.2/docs/how_to/document_loader_pdf)
*   [How to: write a custom document loader](/v0.2/docs/how_to/document_loader_custom)
*   [How to: load HTML data](/v0.2/docs/how_to/document_loader_html)
*   [How to: load Markdown data](/v0.2/docs/how_to/document_loader_markdown)

### Text splitters[​](#text-splitters "Direct link to Text splitters")

[Text Splitters](/v0.2/docs/concepts/#text-splitters) take a document and split into chunks that can be used for retrieval.

*   [How to: recursively split text](/v0.2/docs/how_to/recursive_text_splitter)
*   [How to: split by character](/v0.2/docs/how_to/character_text_splitter)
*   [How to: split code](/v0.2/docs/how_to/code_splitter)
*   [How to: split by tokens](/v0.2/docs/how_to/split_by_token)

### Embedding models[​](#embedding-models "Direct link to Embedding models")

[Embedding Models](/v0.2/docs/concepts/#embedding-models) take a piece of text and create a numerical representation of it.

*   [How to: embed text data](/v0.2/docs/how_to/embed_text)
*   [How to: cache embedding results](/v0.2/docs/how_to/caching_embeddings)

### Vector stores[​](#vector-stores "Direct link to Vector stores")

[Vector stores](/v0.2/docs/concepts/#vectorstores) are databases that can efficiently store and retrieve embeddings.

*   [How to: create and query vector stores](/v0.2/docs/how_to/vectorstores)

### Retrievers[​](#retrievers "Direct link to Retrievers")

[Retrievers](/v0.2/docs/concepts/#retrievers) are responsible for taking a query and returning relevant documents.

*   [How to: use a vector store to retrieve data](/v0.2/docs/how_to/vectorstore_retriever)
*   [How to: generate multiple queries to retrieve data for](/v0.2/docs/how_to/multiple_queries)
*   [How to: use contextual compression to compress the data retrieved](/v0.2/docs/how_to/contextual_compression)
*   [How to: write a custom retriever class](/v0.2/docs/how_to/custom_retriever)
*   [How to: combine the results from multiple retrievers](/v0.2/docs/how_to/ensemble_retriever)
*   [How to: generate multiple embeddings per document](/v0.2/docs/how_to/multi_vector)
*   [How to: retrieve the whole document for a chunk](/v0.2/docs/how_to/parent_document_retriever)
*   [How to: generate metadata filters](/v0.2/docs/how_to/self_query)
*   [How to: create a time-weighted retriever](/v0.2/docs/how_to/time_weighted_vectorstore)
*   [How to: reduce retrieval latency](/v0.2/docs/how_to/reduce_retrieval_latency)

### Indexing[​](#indexing "Direct link to 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](/v0.2/docs/how_to/indexing)

### Tools[​](#tools "Direct link to Tools")

LangChain [Tools](/v0.2/docs/concepts/#tools) contain a description of the tool (to pass to the language model) as well as the implementation of the function to call.

*   [How to: create custom tools](/v0.2/docs/how_to/custom_tools)
*   [How to: use built-in tools and built-in toolkits](/v0.2/docs/how_to/tools_builtin)
*   [How to: use a chat model to call tools](/v0.2/docs/how_to/tool_calling/)
*   [How to: add ad-hoc tool calling capability to LLMs and Chat Models](/v0.2/docs/how_to/tools_prompting)

### Agents[​](#agents "Direct link to Agents")

note

For in depth how-to guides for agents, please check out [LangGraph](https://langchain-ai.github.io/langgraphjs/) documentation.

*   [How to: use legacy LangChain Agents (AgentExecutor)](/v0.2/docs/how_to/agent_executor)
*   [How to: migrate from legacy LangChain agents to LangGraph](/v0.2/docs/how_to/migrate_agent)

### Callbacks[​](#callbacks "Direct link to Callbacks")

[Callbacks](/v0.2/docs/concepts/#callbacks) allow you to hook into the various stages of your LLM application's execution.

*   [How to: pass in callbacks at runtime](/v0.2/docs/how_to/callbacks_runtime)
*   [How to: attach callbacks to a module](/v0.2/docs/how_to/callbacks_attach)
*   [How to: pass callbacks into a module constructor](/v0.2/docs/how_to/callbacks_constructor)
*   [How to: create custom callback handlers](/v0.2/docs/how_to/custom_callbacks)
*   [How to: make callbacks run in the background](/v0.2/docs/how_to/callbacks_backgrounding)

### Custom[​](#custom "Direct link to Custom")

All of LangChain components can easily be extended to support your own versions.

*   [How to: create a custom chat model class](/v0.2/docs/how_to/custom_chat)
*   [How to: create a custom LLM class](/v0.2/docs/how_to/custom_llm)
*   [How to: write a custom retriever class](/v0.2/docs/how_to/custom_retriever)
*   [How to: write a custom document loader](/v0.2/docs/how_to/document_loader_custom)
*   [How to: define a custom tool](/v0.2/docs/how_to/custom_tools)
*   [How to: create custom callback handlers](/v0.2/docs/how_to/custom_callbacks)

### Generative UI[​](#generative-ui "Direct link to Generative UI")

*   [How to: build an LLM generated UI](/v0.2/docs/how_to/generative_ui)
*   [How to: stream agentic data to the client](/v0.2/docs/how_to/stream_agent_client)
*   [How to: stream structured output to the client](/v0.2/docs/how_to/stream_tool_client)

### Multimodal[​](#multimodal "Direct link to Multimodal")

*   [How to: pass multimodal data directly to models](/v0.2/docs/how_to/multimodal_inputs/)
*   [How to: use multimodal prompts](/v0.2/docs/how_to/multimodal_prompts/)
*   [How to: call tools with multimodal data](/v0.2/docs/how_to/tool_calls_multimodal/)

Use cases[​](#use-cases "Direct link to Use cases")
---------------------------------------------------

These guides cover use-case specific details.

### Q&A with RAG[​](#qa-with-rag "Direct link to Q&A with RAG")

Retrieval Augmented Generation (RAG) is a way to connect LLMs to external sources of data. For a high-level tutorial on RAG, check out [this guide](/v0.2/docs/tutorials/rag/).

*   [How to: add chat history](/v0.2/docs/how_to/qa_chat_history_how_to/)
*   [How to: stream](/v0.2/docs/how_to/qa_streaming/)
*   [How to: return sources](/v0.2/docs/how_to/qa_sources/)
*   [How to: return citations](/v0.2/docs/how_to/qa_citations/)
*   [How to: do per-user retrieval](/v0.2/docs/how_to/qa_per_user/)

### Extraction[​](#extraction "Direct link to 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](/v0.2/docs/tutorials/extraction/).

*   [How to: use reference examples](/v0.2/docs/how_to/extraction_examples/)
*   [How to: handle long text](/v0.2/docs/how_to/extraction_long_text/)
*   [How to: do extraction without using function calling](/v0.2/docs/how_to/extraction_parse)

### Chatbots[​](#chatbots "Direct link to Chatbots")

Chatbots involve using an LLM to have a conversation. For a high-level tutorial on building chatbots, check out [this guide](/v0.2/docs/tutorials/chatbot/).

*   [How to: manage memory](/v0.2/docs/how_to/chatbots_memory)
*   [How to: do retrieval](/v0.2/docs/how_to/chatbots_retrieval)
*   [How to: use tools](/v0.2/docs/how_to/chatbots_tools)

### Query analysis[​](#query-analysis "Direct link to 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](/v0.2/docs/tutorials/query_analysis/).

*   [How to: add examples to the prompt](/v0.2/docs/how_to/query_few_shot)
*   [How to: handle cases where no queries are generated](/v0.2/docs/how_to/query_no_queries)
*   [How to: handle multiple queries](/v0.2/docs/how_to/query_multiple_queries)
*   [How to: handle multiple retrievers](/v0.2/docs/how_to/query_multiple_retrievers)
*   [How to: construct filters](/v0.2/docs/how_to/query_constructing_filters)
*   [How to: deal with high cardinality categorical variables](/v0.2/docs/how_to/query_high_cardinality)

### Q&A over SQL + CSV[​](#qa-over-sql--csv "Direct link to Q&A over SQL + CSV")

You can use LLMs to do question answering over tabular data. For a high-level tutorial, check out [this guide](/v0.2/docs/tutorials/sql_qa/).

*   [How to: use prompting to improve results](/v0.2/docs/how_to/sql_prompting)
*   [How to: do query validation](/v0.2/docs/how_to/sql_query_checking)
*   [How to: deal with large databases](/v0.2/docs/how_to/sql_large_db)

### Q&A over graph databases[​](#qa-over-graph-databases "Direct link to Q&A over graph databases")

You can use an LLM to do question answering over graph databases. For a high-level tutorial, check out [this guide](/v0.2/docs/tutorials/graph/).

*   [How to: map values to a database](/v0.2/docs/how_to/graph_mapping)
*   [How to: add a semantic layer over the database](/v0.2/docs/how_to/graph_semantic)
*   [How to: improve results with prompting](/v0.2/docs/how_to/graph_prompting)
*   [How to: construct knowledge graphs](/v0.2/docs/how_to/graph_constructing)

[LangGraph.js](https://langchain-ai.github.io/langgraphjs)[​](#langgraphjs "Direct link to langgraphjs")
--------------------------------------------------------------------------------------------------------

LangGraph.js 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.js documentation is currently hosted on a separate site. You can peruse [LangGraph.js how-to guides here](https://langchain-ai.github.io/langgraphjs/how-tos/).

[LangSmith](https://docs.smith.langchain.com/)[​](#langsmith "Direct link to langsmith")
----------------------------------------------------------------------------------------

LangSmith allows you to closely trace, monitor and evaluate your LLM application. It seamlessly integrates with LangChain and LangGraph.js, and you can use it to inspect and debug individual steps of your chains as you build.

LangSmith documentation is hosted on a separate site. You can peruse [LangSmith how-to guides here](https://docs.smith.langchain.com/how_to_guides/).

### Evaluation[​](#evaluation "Direct link to 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.

To learn more, check out the [LangSmith evaluation how-to guides](https://docs.smith.langchain.com/how_to_guides#evaluation).

* * *

#### Was this page helpful?

  

#### You can also leave detailed feedback [on GitHub](https://github.com/langchain-ai/langchainjs/issues/new?assignees=&labels=03+-+Documentation&projects=&template=documentation.yml&title=DOC%3A+%3CPlease+write+a+comprehensive+title+after+the+%27DOC%3A+%27+prefix%3E).

[

Previous

Build a Question/Answering system over SQL data

](/v0.2/docs/tutorials/sql_qa)[

Next

How-to guides

](/v0.2/docs/how_to/)

*   [Installation](#installation)
*   [Key features](#key-features)
*   [LangChain Expression Language (LCEL)](#langchain-expression-language-lcel)
*   [Components](#components)
    *   [Prompt templates](#prompt-templates)
    *   [Example selectors](#example-selectors)
    *   [Chat models](#chat-models)
    *   [Messages](#messages)
    *   [LLMs](#llms)
    *   [Output parsers](#output-parsers)
    *   [Document loaders](#document-loaders)
    *   [Text splitters](#text-splitters)
    *   [Embedding models](#embedding-models)
    *   [Vector stores](#vector-stores)
    *   [Retrievers](#retrievers)
    *   [Indexing](#indexing)
    *   [Tools](#tools)
    *   [Agents](#agents)
    *   [Callbacks](#callbacks)
    *   [Custom](#custom)
    *   [Generative UI](#generative-ui)
    *   [Multimodal](#multimodal)
*   [Use cases](#use-cases)
    *   [Q&A with RAG](#qa-with-rag)
    *   [Extraction](#extraction)
    *   [Chatbots](#chatbots)
    *   [Query analysis](#query-analysis)
    *   [Q&A over SQL + CSV](#qa-over-sql--csv)
    *   [Q&A over graph databases](#qa-over-graph-databases)
*   [LangGraph.js](#langgraphjs)
*   [LangSmith](#langsmith)
    *   [Evaluation](#evaluation)