2022-11-14 04:13:23 +00:00
|
|
|
# Core Concepts
|
|
|
|
|
|
|
|
This section goes over the core concepts of LangChain.
|
|
|
|
Understanding these will go a long way in helping you understand the codebase and how to construct chains.
|
|
|
|
|
2022-11-20 04:32:45 +00:00
|
|
|
## PromptTemplates
|
|
|
|
PromptTemplates generically have a `format` method that takes in variables and returns a formatted string.
|
2022-11-14 04:13:23 +00:00
|
|
|
The most simple implementation of this is to have a template string with some variables in it, and then format it with the incoming variables.
|
|
|
|
More complex iterations dynamically construct the template string from few shot examples, etc.
|
|
|
|
|
2022-11-20 15:18:43 +00:00
|
|
|
For a more detailed explanation of how LangChain approaches prompts and prompt templates, see [here](/examples/prompts/prompt_management).
|
2022-11-20 04:32:45 +00:00
|
|
|
|
2022-11-14 04:13:23 +00:00
|
|
|
## LLMs
|
2022-12-23 18:13:07 +00:00
|
|
|
Wrappers around Large Language Models (in particular, the `generate` ability of large language models) are at the core of LangChain functionality.
|
2022-11-14 04:13:23 +00:00
|
|
|
These wrappers are classes that are callable: they take in an input string, and return the generated output string.
|
|
|
|
|
|
|
|
## Embeddings
|
|
|
|
These classes are very similar to the LLM classes in that they are wrappers around models,
|
2022-12-23 18:13:07 +00:00
|
|
|
but rather than return a string they return an embedding (list of floats). These are particularly useful when
|
2022-11-14 04:13:23 +00:00
|
|
|
implementing semantic search functionality. They expose separate methods for embedding queries versus embedding documents.
|
|
|
|
|
|
|
|
## Vectorstores
|
|
|
|
These are datastores that store documents. They expose a method for passing in a string and finding similar documents.
|
|
|
|
|
|
|
|
## Chains
|
|
|
|
These are pipelines that combine multiple of the above ideas.
|
|
|
|
They vary greatly in complexity and are combination of generic, highly configurable pipelines and more narrow (but usually more complex) pipelines.
|
2022-11-22 14:16:26 +00:00
|
|
|
|
|
|
|
## Agents
|
|
|
|
As opposed to a chain, whether the steps to be taken are known ahead of time, agents
|
|
|
|
use an LLM to determine which tools to call and in what order.
|
2022-11-26 14:38:49 +00:00
|
|
|
|
|
|
|
## Memory
|
|
|
|
By default, Chains and Agents are stateless, meaning that they treat each incoming query independently.
|
|
|
|
In some applications (chatbots being a GREAT example) it is highly important to remember previous interactions,
|
|
|
|
both at a short term but also at a long term level. The concept of "Memory" exists to do exactly that.
|
|
|
|
|