Core language model abstractions.
LangChain has two main classes to work with language models: chat models and "old-fashioned" LLMs (string-in, string-out).
Chat models
Language models that use a sequence of messages as inputs and return chat messages as outputs (as opposed to using plain text).
Chat models support the assignment of distinct roles to conversation messages, helping to distinguish messages from the AI, users, and instructions such as system messages.
The key abstraction for chat models is
BaseChatModel. Implementations should
inherit from this class.
See existing chat model integrations.
LLMs (legacy)
Language models that takes a string as input and returns a string.
These are traditionally older models (newer models generally are chat models).
Although the underlying models are string in, string out, the LangChain wrappers also allow these models to take messages as input. This gives them the same interface as chat models. When messages are passed in as input, they will be formatted into a string under the hood before being passed to the underlying model.