Saturday, December 9, 2023

What are Various Modules in Langchain

The various modules mainly are 


Model I/O 

Retrieval 

Chains 

Memory 

Agents 

Callbacks 

Experimental 

The core element of any language model application is...the model. LangChain gives you the building blocks to interface with any language model.

Prompts: Templatize, dynamically select, and manage model inputs

Language models: Make calls to language models through common interfaces

Output parsers: Extract information from model outputs

Prompts

The new way of programming models is through prompts. A prompt refers to the input to the model. This input is often constructed from multiple components. LangChain provides several classes and functions to make constructing and working with prompts easy.

Prompt templates: Parametrize model inputs

Example selectors: Dynamically select examples to include in prompts


Language models

LangChain provides interfaces and integrations for two types of models:


LLMs: Models that take a text string as input and return a text string

Chat models: Models that are backed by a language model but take a list of Chat Messages as input and return a Chat Message

Output Parsers 

Language models output text. But many times you may want to get more structured information than just text back. This is where output parsers come in.

Output parsers are classes that help structure language model responses. There are two main methods an output parser must implement:

"Get format instructions": A method which returns a string containing instructions for how the output of a language model should be formatted.

"Parse": A method which takes in a string (assumed to be the response from a language model) and parses it into some structure.

And then one optional one:

"Parse with prompt": A method which takes in a string (assumed to be the response from a language model) and a prompt (assumed to the prompt that generated such a response) and parses it into some structure. The prompt is largely provided in the event the OutputParser wants to retry or fix the output in some way, and needs information from the prompt to do so.


References:

https://js.langchain.com/docs/modules/

No comments:

Post a Comment