Unnamed: 0
stringlengths
1
178
link
stringlengths
31
163
text
stringlengths
18
32.8k
0
https://python.langchain.com/docs/get_started
Get startedGet startedGet started with LangChain📄️ IntroductionLangChain is a framework for developing applications powered by language models. It enables applications that:📄️ Installation📄️ QuickstartInstallationNextIntroduction
1
https://python.langchain.com/docs/get_started/introduction
Get startedIntroductionOn this pageIntroductionLangChain is a framework for developing applications powered by language models. It enables applications that:Are context-aware: connect a language model to sources of context (prompt instructions, few shot examples, content to ground its response in, etc.)Reason: rely on ...
2
https://python.langchain.com/docs/get_started/installation
Get startedInstallationInstallationOfficial release​To install LangChain run:PipCondapip install langchainconda install langchain -c conda-forgeThis will install the bare minimum requirements of LangChain. A lot of the value of LangChain comes when integrating it with various model providers, datastores, etc. By defaul...
3
https://python.langchain.com/docs/get_started/quickstart
Get startedQuickstartOn this pageQuickstartInstallation​To install LangChain run:PipCondapip install langchainconda install langchain -c conda-forgeFor more details, see our Installation guide.Environment setup​Using LangChain will usually require integrations with one or more model providers, data stores, APIs, etc. F...
4
https://python.langchain.com/docs/expression_language/
LangChain Expression LanguageOn this pageLangChain Expression Language (LCEL)LangChain Expression Language or LCEL is a declarative way to easily compose chains together. There are several benefits to writing chains in this manner (as opposed to writing normal code):Async, Batch, and Streaming Support Any chain constru...
5
https://python.langchain.com/docs/expression_language/interface
LangChain Expression LanguageInterfaceOn this pageInterfaceIn an effort to make it as easy as possible to create custom chains, we've implemented a "Runnable" protocol that most components implement. This is a standard interface with a few different methods, which makes it easy to define custom chains as well as making...
6
https://python.langchain.com/docs/expression_language/how_to/
LangChain Expression LanguageHow toHow to📄️ Bind runtime argsSometimes we want to invoke a Runnable within a Runnable sequence with constant arguments that are not part of the output of the preceding Runnable in the sequence, and which are not part of the user input. We can use Runnable.bind() to easily pass these arg...
7
https://python.langchain.com/docs/expression_language/how_to/binding
LangChain Expression LanguageHow toBind runtime argsOn this pageBind runtime argsSometimes we want to invoke a Runnable within a Runnable sequence with constant arguments that are not part of the output of the preceding Runnable in the sequence, and which are not part of the user input. We can use Runnable.bind() to ea...
8
https://python.langchain.com/docs/expression_language/how_to/fallbacks
LangChain Expression LanguageHow toAdd fallbacksOn this pageAdd fallbacksThere are many possible points of failure in an LLM application, whether that be issues with LLM API's, poor model outputs, issues with other integrations, etc. Fallbacks help you gracefully handle and isolate these issues.Crucially, fallbacks can...
9
https://python.langchain.com/docs/expression_language/how_to/functions
LangChain Expression LanguageHow toRun arbitrary functionsOn this pageRun arbitrary functionsYou can use arbitrary functions in the pipelineNote that all inputs to these functions need to be a SINGLE argument. If you have a function that accepts multiple arguments, you should write a wrapper that accepts a single input...
10
https://python.langchain.com/docs/expression_language/how_to/map
LangChain Expression LanguageHow toUse RunnableParallel/RunnableMapOn this pageUse RunnableParallel/RunnableMapRunnableParallel (aka. RunnableMap) makes it easy to execute multiple Runnables in parallel, and to return the output of these Runnables as a map.from langchain.chat_models import ChatOpenAIfrom langchain.prom...
11
https://python.langchain.com/docs/expression_language/how_to/routing
LangChain Expression LanguageHow toRoute between multiple RunnablesOn this pageRoute between multiple RunnablesThis notebook covers how to do routing in the LangChain Expression Language.Routing allows you to create non-deterministic chains where the output of a previous step defines the next step. Routing helps provid...
12
https://python.langchain.com/docs/expression_language/cookbook/
LangChain Expression LanguageCookbookCookbookExample code for accomplishing common tasks with the LangChain Expression Language (LCEL). These examples show how to compose different Runnable (the core LCEL interface) components to achieve various tasks. If you're just getting acquainted with LCEL, the Prompt + LLM page ...
13
https://python.langchain.com/docs/expression_language/cookbook/prompt_llm_parser
LangChain Expression LanguageCookbookPrompt + LLMOn this pagePrompt + LLMThe most common and valuable composition is taking:PromptTemplate / ChatPromptTemplate -> LLM / ChatModel -> OutputParserAlmost any other chains you build will use this building block.PromptTemplate + LLM​The simplest composition is just combing a...
14
https://python.langchain.com/docs/expression_language/cookbook/retrieval
LangChain Expression LanguageCookbookRAGOn this pageRAGLet's look at adding in a retrieval step to a prompt and LLM, which adds up to a "retrieval-augmented generation" chainpip install langchain openai faiss-cpu tiktokenfrom operator import itemgetterfrom langchain.prompts import ChatPromptTemplatefrom langchain.chat_...
15
https://python.langchain.com/docs/expression_language/cookbook/multiple_chains
LangChain Expression LanguageCookbookMultiple chainsOn this pageMultiple chainsRunnables can easily be used to string together multiple Chainsfrom operator import itemgetterfrom langchain.chat_models import ChatOpenAIfrom langchain.prompts import ChatPromptTemplatefrom langchain.schema import StrOutputParserprompt1 = C...
16
https://python.langchain.com/docs/expression_language/cookbook/sql_db
LangChain Expression LanguageCookbookQuerying a SQL DBQuerying a SQL DBWe can replicate our SQLDatabaseChain with Runnables.from langchain.prompts import ChatPromptTemplatetemplate = """Based on the table schema below, write a SQL query that would answer the user's question:{schema}Question: {question}SQL Query:"""prom...
17
https://python.langchain.com/docs/expression_language/cookbook/agent
LangChain Expression LanguageCookbookAgentsAgentsYou can pass a Runnable into an agent.from langchain.agents import XMLAgent, tool, AgentExecutorfrom langchain.chat_models import ChatAnthropicmodel = ChatAnthropic(model="claude-2")@tooldef search(query: str) -> str: """Search things about current events.""" retur...
18
https://python.langchain.com/docs/expression_language/cookbook/code_writing
LangChain Expression LanguageCookbookCode writingCode writingExample of how to use LCEL to write Python code.from langchain.chat_models import ChatOpenAIfrom langchain.prompts import ChatPromptTemplate, SystemMessagePromptTemplate, HumanMessagePromptTemplatefrom langchain.schema.output_parser import StrOutputParserfrom...
19
https://python.langchain.com/docs/expression_language/cookbook/memory
LangChain Expression LanguageCookbookAdding memoryAdding memoryThis shows how to add memory to an arbitrary chain. Right now, you can use the memory classes but need to hook it up manuallyfrom operator import itemgetterfrom langchain.chat_models import ChatOpenAIfrom langchain.memory import ConversationBufferMemoryfrom...
20
https://python.langchain.com/docs/expression_language/cookbook/moderation
LangChain Expression LanguageCookbookAdding moderationAdding moderationThis shows how to add in moderation (or other safeguards) around your LLM application.from langchain.chains import OpenAIModerationChainfrom langchain.llms import OpenAIfrom langchain.prompts import ChatPromptTemplatemoderate = OpenAIModerationChain...
21
https://python.langchain.com/docs/expression_language/cookbook/tools
LangChain Expression LanguageCookbookUsing toolsUsing toolsYou can use any Tools with Runnables easily.pip install duckduckgo-searchfrom langchain.chat_models import ChatOpenAIfrom langchain.prompts import ChatPromptTemplatefrom langchain.schema.output_parser import StrOutputParserfrom langchain.tools import DuckDuckGo...
22
https://python.langchain.com/docs/expression_language/
LangChain Expression LanguageOn this pageLangChain Expression Language (LCEL)LangChain Expression Language or LCEL is a declarative way to easily compose chains together. There are several benefits to writing chains in this manner (as opposed to writing normal code):Async, Batch, and Streaming Support Any chain constru...
23
https://python.langchain.com/docs/modules/
ModulesOn this pageModulesLangChain provides standard, extendable interfaces and external integrations for the following modules, listed from least to most complex:Model I/O​Interface with language modelsRetrieval​Interface with application-specific dataChains​Construct sequences of callsAgents​Let chains choose which ...
24
https://python.langchain.com/docs/modules/model_io/
ModulesModel I/​OModel I/OThe 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 inputsLanguage models: Make calls to language models through common interfacesOutput parsers...
25
https://python.langchain.com/docs/modules/model_io/prompts/
ModulesModel I/​OPromptsPromptsA prompt for a language model is a set of instructions or input provided by a user to guide the model's response, helping it understand the context and generate relevant and coherent language-based output, such as answering questions, completing sentences, or engaging in a conversation.La...
26
https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/
ModulesModel I/​OPromptsPrompt templatesPrompt templatesPrompt templates are pre-defined recipes for generating prompts for language models.A template may include instructions, few-shot examples, and specific context and questions appropriate for a given task.LangChain provides tooling to create and work with prompt te...
27
https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/connecting_to_a_feature_store
ModulesModel I/​OPromptsPrompt templatesConnecting to a Feature StoreOn this pageConnecting to a Feature StoreFeature stores are a concept from traditional machine learning that make sure data fed into models is up-to-date and relevant. For more on this, see here.This concept is extremely relevant when considering putt...
28
https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/custom_prompt_template
ModulesModel I/​OPromptsPrompt templatesCustom prompt templateOn this pageCustom prompt templateLet's suppose we want the LLM to generate English language explanations of a function given its name. To achieve this task, we will create a custom prompt template that takes in the function name as input, and formats the pr...
29
https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/few_shot_examples
ModulesModel I/​OPromptsPrompt templatesFew-shot prompt templatesFew-shot prompt templatesIn this tutorial, we'll learn how to create a prompt template that uses few-shot examples. A few-shot prompt template can be constructed from either a set of examples, or from an Example Selector object.Use Case​In this tutorial, ...
30
https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/few_shot_examples_chat
ModulesModel I/​OPromptsPrompt templatesFew-shot examples for chat modelsOn this pageFew-shot examples for chat modelsThis notebook covers how to use few-shot examples in chat models. There does not appear to be solid consensus on how best to do few-shot prompting, and the optimal prompt compilation will likely vary by...
31
https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/format_output
ModulesModel I/​OPromptsPrompt templatesFormat template outputFormat template outputThe output of the format method is available as a string, list of messages and ChatPromptValueAs string:output = chat_prompt.format(input_language="English", output_language="French", text="I love programming.")output 'System: You ar...
32
https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/formats
ModulesModel I/​OPromptsPrompt templatesTemplate formatsTemplate formatsPromptTemplate by default uses Python f-string as its template format. However, it can also use other formats like jinja2, specified through the template_format argument.To use the jinja2 template:from langchain.prompts import PromptTemplatejinja2_...
33
https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/msg_prompt_templates
ModulesModel I/​OPromptsPrompt templatesTypes of MessagePromptTemplateTypes of MessagePromptTemplateLangChain provides different types of MessagePromptTemplate. The most commonly used are AIMessagePromptTemplate, SystemMessagePromptTemplate and HumanMessagePromptTemplate, which create an AI message, system message and ...
34
https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/partial
ModulesModel I/​OPromptsPrompt templatesPartial prompt templatesPartial prompt templatesLike other methods, it can make sense to "partial" a prompt template - e.g. pass in a subset of the required values, as to create a new prompt template which expects only the remaining subset of values.LangChain supports this in two...
35
https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/prompt_composition
ModulesModel I/​OPromptsPrompt templatesCompositionCompositionThis notebook goes over how to compose multiple prompts together. This can be useful when you want to reuse parts of prompts. This can be done with a PipelinePrompt. A PipelinePrompt consists of two main parts:Final prompt: The final prompt that is returnedP...
36
https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/prompt_serialization
ModulesModel I/​OPromptsPrompt templatesSerializationOn this pageSerializationIt is often preferrable to store prompts not as python code but as files. This can make it easy to share, store, and version prompts. This notebook covers how to do that in LangChain, walking through all the different types of prompts and the...
37
https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/prompts_pipelining
ModulesModel I/​OPromptsPrompt templatesPrompt pipeliningOn this pagePrompt pipeliningThe idea behind prompt pipelining is to provide a user friendly interface for composing different parts of prompts together. You can do this with either string prompts or chat prompts. Constructing prompts this way allows for easy reu...
38
https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/validate
ModulesModel I/​OPromptsPrompt templatesValidate templateValidate templateBy default, PromptTemplate will validate the template string by checking whether the input_variables match the variables defined in template. You can disable this behavior by setting validate_template to False.template = "I am learning langchain ...
39
https://python.langchain.com/docs/modules/model_io/prompts/example_selectors/
ModulesModel I/​OPromptsExample selectorsExample selectorsIf you have a large number of examples, you may need to select which ones to include in the prompt. The Example Selector is the class responsible for doing so.The base interface is defined as below:class BaseExampleSelector(ABC): """Interface for selecting ex...
40
https://python.langchain.com/docs/modules/model_io/models/
ModulesModel I/​OLanguage modelsOn this pageLanguage modelsLangChain provides interfaces and integrations for two types of models:LLMs: Models that take a text string as input and return a text stringChat models: Models that are backed by a language model but take a list of Chat Messages as input and return a Chat Mess...
41
https://python.langchain.com/docs/modules/model_io/output_parsers/
ModulesModel I/​OOutput parsersOn this pageOutput parsersLanguage 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 par...
42
https://python.langchain.com/docs/modules/data_connection/
ModulesRetrievalRetrievalMany LLM applications require user-specific data that is not part of the model's training set. The primary way of accomplishing this is through Retrieval Augmented Generation (RAG). In this process, external data is retrieved and then passed to the LLM when doing the generation step.LangChain p...
43
https://python.langchain.com/docs/modules/data_connection/document_loaders/
ModulesRetrievalDocument loadersOn this pageDocument loadersinfoHead to Integrations for documentation on built-in document loader integrations with 3rd-party tools.Use document loaders to load data from a source as Document's. A Document is a piece of text and associated metadata. For example, there are document loade...
44
https://python.langchain.com/docs/modules/data_connection/document_loaders/csv
ModulesRetrievalDocument loadersCSVCSVA comma-separated values (CSV) file is a delimited text file that uses a comma to separate values. Each line of the file is a data record. Each record consists of one or more fields, separated by commas.Load CSV data with a single row per document.from langchain.document_loaders.cs...
45
https://python.langchain.com/docs/modules/data_connection/document_loaders/file_directory
ModulesRetrievalDocument loadersFile DirectoryFile DirectoryThis covers how to load all documents in a directory.Under the hood, by default this uses the UnstructuredLoader.from langchain.document_loaders import DirectoryLoaderWe can use the glob parameter to control which files to load. Note that here it doesn't load ...
46
https://python.langchain.com/docs/modules/data_connection/document_loaders/html
ModulesRetrievalDocument loadersHTMLHTMLThe HyperText Markup Language or HTML is the standard markup language for documents designed to be displayed in a web browser.This covers how to load HTML documents into a document format that we can use downstream.from langchain.document_loaders import UnstructuredHTMLLoaderload...
47
https://python.langchain.com/docs/modules/data_connection/document_loaders/json
ModulesRetrievalDocument loadersJSONJSONJSON (JavaScript Object Notation) is an open standard file format and data interchange format that uses human-readable text to store and transmit data objects consisting of attribute–value pairs and arrays (or other serializable values).JSON Lines is a file format where each line...
48
https://python.langchain.com/docs/modules/data_connection/document_loaders/markdown
ModulesRetrievalDocument loadersMarkdownMarkdownMarkdown is a lightweight markup language for creating formatted text using a plain-text editor.This covers how to load Markdown documents into a document format that we can use downstream.# !pip install unstructured > /dev/nullfrom langchain.document_loaders import Unstr...
49
https://python.langchain.com/docs/modules/data_connection/document_loaders/pdf
ModulesRetrievalDocument loadersPDFPDFPortable Document Format (PDF), standardized as ISO 32000, is a file format developed by Adobe in 1992 to present documents, including text formatting and images, in a manner independent of application software, hardware, and operating systems.This covers how to load PDF documents ...
t layouts). A spectrum of models\ntrained on these datasets are currently available in the LayoutParser model zoo\nto support different use cases.\n'
metadata={'heading': '2 Related Work\n'
'content_font': 9
50
https://python.langchain.com/docs/modules/data_connection/document_transformers/
ModulesRetrievalDocument transformersOn this pageDocument transformersinfoHead to Integrations for documentation on built-in document transformer integrations with 3rd-party tools.Once you've loaded documents, you'll often want to transform them to better suit your application. The simplest example is you may want to s...
51
https://python.langchain.com/docs/modules/data_connection/text_embedding/
ModulesRetrievalText embedding modelsOn this pageText embedding modelsinfoHead to Integrations for documentation on built-in integrations with text embedding model providers.The Embeddings class is a class designed for interfacing with text embedding models. There are lots of embedding model providers (OpenAI, Cohere, ...
52
https://python.langchain.com/docs/modules/data_connection/vectorstores/
ModulesRetrievalVector storesOn this pageVector storesinfoHead to Integrations for documentation on built-in integrations with 3rd-party vector stores.One of the most common ways to store and search over unstructured data is to embed it and store the resulting embedding vectors, and then at query time to embed the unst...
53
https://python.langchain.com/docs/modules/data_connection/retrievers/
ModulesRetrievalRetrieversOn this pageRetrieversinfoHead to Integrations for documentation on built-in retriever integrations with 3rd-party tools.A retriever is an interface that returns documents given an unstructured query. It is more general than a vector store. A retriever does not need to be able to store documen...
54
https://python.langchain.com/docs/modules/data_connection/indexing
ModulesRetrievalIndexingOn this pageIndexingHere, we will look at a basic indexing workflow using the LangChain indexing API. The indexing API lets you load and keep in sync documents from any source into a vector store. Specifically, it helps:Avoid writing duplicated content into the vector storeAvoid re-writing uncha...
55
https://python.langchain.com/docs/modules/chains/
ModulesChainsOn this pageChainsUsing an LLM in isolation is fine for simple applications, but more complex applications require chaining LLMs - either with each other or with other components.LangChain provides the Chain interface for such "chained" applications. We define a Chain very generically as a sequence of call...
56
https://python.langchain.com/docs/modules/memory/
ModulesMemoryOn this pageMemoryMost LLM applications have a conversational interface. An essential component of a conversation is being able to refer to information introduced earlier in the conversation. At bare minimum, a conversational system should be able to access some window of past messages directly. A more com...
57
https://python.langchain.com/docs/modules/agents/
ModulesAgentsOn this pageAgentsThe core idea of agents is to use an LLM to choose a sequence of actions to take. In chains, a sequence of actions is hardcoded (in code). In agents, a language model is used as a reasoning engine to determine which actions to take and in which order.Some important terminology (and schema...
58
https://python.langchain.com/docs/modules/callbacks/
ModulesCallbacksCallbacksinfoHead to Integrations for documentation on built-in callbacks integrations with 3rd-party tools.LangChain provides a callbacks system that allows you to hook into the various stages of your LLM application. This is useful for logging, monitoring, streaming, and other tasks.You can subscribe ...
59
https://python.langchain.com/docs/modules/
ModulesOn this pageModulesLangChain provides standard, extendable interfaces and external integrations for the following modules, listed from least to most complex:Model I/O​Interface with language modelsRetrieval​Interface with application-specific dataChains​Construct sequences of callsAgents​Let chains choose which ...
60
https://python.langchain.com/docs/guides
GuidesGuidesDesign guides for key parts of the development process🗃️ Adapters1 items📄️ DebuggingIf you're building with LLMs, at some point something will break, and you'll need to debug. A model call will fail, or the model output will be misformatted, or there will be some nested model calls and it won't be clear w...
61
https://python.langchain.com/docs/guides/adapters/openai
GuidesAdaptersOpenAI AdapterOn this pageOpenAI AdapterA lot of people get started with OpenAI but want to explore other models. LangChain's integrations with many model providers make this easy to do so. While LangChain has it's own message and model APIs, we've also made it as easy as possible to explore other models ...
62
https://python.langchain.com/docs/guides/debugging
GuidesDebuggingOn this pageDebuggingIf you're building with LLMs, at some point something will break, and you'll need to debug. A model call will fail, or the model output will be misformatted, or there will be some nested model calls and it won't be clear where along the way an incorrect output was created.Here are a ...
orldwide. The recipient of many accolades
he has been nominated for five Academy Awards
five BAFTA Awards and six Golden Globe Awards. July 30
63
https://python.langchain.com/docs/guides/deployments/
GuidesDeploymentOn this pageDeploymentIn today's fast-paced technological landscape, the use of Large Language Models (LLMs) is rapidly expanding. As a result, it's crucial for developers to understand how to effectively deploy these models in production environments. LLM interfaces typically fall into two categories:C...
64
https://python.langchain.com/docs/guides/deployments/template_repos
GuidesDeploymentTemplate reposOn this pageTemplate reposSo, you've created a really cool chain - now what? How do you deploy it and make it easily shareable with the world?This section covers several options for that. Note that these options are meant for quick deployment of prototypes and demos, not for production sys...
65
https://python.langchain.com/docs/guides/evaluation/
GuidesEvaluationOn this pageEvaluationBuilding applications with language models involves many moving parts. One of the most critical components is ensuring that the outcomes produced by your models are reliable and useful across a broad array of inputs, and that they work well with your application's other software co...
66
https://python.langchain.com/docs/guides/evaluation/string/
GuidesEvaluationString EvaluatorsString EvaluatorsA string evaluator is a component within LangChain designed to assess the performance of a language model by comparing its generated outputs (predictions) to a reference string or an input. This comparison is a crucial step in the evaluation of language models, providin...
67
https://python.langchain.com/docs/guides/evaluation/string/criteria_eval_chain
GuidesEvaluationString EvaluatorsCriteria EvaluationOn this pageCriteria EvaluationIn scenarios where you wish to assess a model's output using a specific rubric or criteria set, the criteria evaluator proves to be a handy tool. It allows you to verify if an LLM or Chain's output complies with a defined set of criteria...
68
https://python.langchain.com/docs/guides/evaluation/string/custom
GuidesEvaluationString EvaluatorsCustom String EvaluatorCustom String EvaluatorYou can make your own custom string evaluators by inheriting from the StringEvaluator class and implementing the _evaluate_strings (and _aevaluate_strings for async support) methods.In this example, you will create a perplexity evaluator usi...
69
https://python.langchain.com/docs/guides/evaluation/string/embedding_distance
GuidesEvaluationString EvaluatorsEmbedding DistanceOn this pageEmbedding DistanceTo measure semantic similarity (or dissimilarity) between a prediction and a reference label string, you could use a vector vector distance metric the two embedded representations using the embedding_distance evaluator.[1]Note: This return...
70
https://python.langchain.com/docs/guides/evaluation/string/exact_match
GuidesEvaluationString EvaluatorsExact MatchOn this pageExact MatchProbably the simplest ways to evaluate an LLM or runnable's string output against a reference label is by a simple string equivalence.This can be accessed using the exact_match evaluator.from langchain.evaluation import ExactMatchStringEvaluatorevaluato...
71
https://python.langchain.com/docs/guides/evaluation/string/regex_match
GuidesEvaluationString EvaluatorsRegex MatchOn this pageRegex MatchTo evaluate chain or runnable string predictions against a custom regex, you can use the regex_match evaluator.from langchain.evaluation import RegexMatchStringEvaluatorevaluator = RegexMatchStringEvaluator()Alternatively via the loader:from langchain.e...
72
https://python.langchain.com/docs/guides/evaluation/string/scoring_eval_chain
GuidesEvaluationString EvaluatorsScoring EvaluatorOn this pageScoring EvaluatorThe Scoring Evaluator instructs a language model to assess your model's predictions on a specified scale (default is 1-10) based on your custom criteria or rubric. This feature provides a nuanced evaluation instead of a simplistic binary sco...
73
https://python.langchain.com/docs/guides/evaluation/string/string_distance
GuidesEvaluationString EvaluatorsString DistanceOn this pageString DistanceOne of the simplest ways to compare an LLM or chain's string output against a reference label is by using string distance measurements such as Levenshtein or postfix distance. This can be used alongside approximate/fuzzy matching criteria for v...
74
https://python.langchain.com/docs/guides/evaluation/comparison/
GuidesEvaluationComparison EvaluatorsComparison EvaluatorsComparison evaluators in LangChain help measure two different chains or LLM outputs. These evaluators are helpful for comparative analyses, such as A/B testing between two language models, or comparing different versions of the same model. They can also be usefu...
75
https://python.langchain.com/docs/guides/evaluation/trajectory/
GuidesEvaluationTrajectory EvaluatorsTrajectory EvaluatorsTrajectory Evaluators in LangChain provide a more holistic approach to evaluating an agent. These evaluators assess the full sequence of actions taken by an agent and their corresponding responses, which we refer to as the "trajectory". This allows you to better...
76
https://python.langchain.com/docs/guides/evaluation/examples/
GuidesEvaluationExamplesExamples🚧 Docs under construction 🚧Below are some examples for inspecting and checking different chains.📄️ Comparing Chain OutputsOpen In CollabPreviousAgent TrajectoryNextComparing Chain Outputs
77
https://python.langchain.com/docs/guides/fallbacks
GuidesFallbacksOn this pageFallbacksWhen working with language models, you may often encounter issues from the underlying APIs, whether these be rate limiting or downtime. Therefore, as you go to move your LLM applications into production it becomes more and more important to safeguard against these. That's why we've i...
78
https://python.langchain.com/docs/guides/langsmith/
GuidesLangSmithLangSmithLangSmith helps you trace and evaluate your language model applications and intelligent agents to help you move from prototype to production.Check out the interactive walkthrough below to get started.For more information, please refer to the LangSmith documentation.For tutorials and other end-to...
79
https://python.langchain.com/docs/guides/local_llms
GuidesRun LLMs locallyOn this pageRun LLMs locallyUse case​The popularity of projects like PrivateGPT, llama.cpp, and GPT4All underscore the demand to run LLMs locally (on your own device).This has at least two important benefits:Privacy: Your data is not sent to a third party, and it is not subject to the terms of ser...
80
https://python.langchain.com/docs/guides/model_laboratory
GuidesModel comparisonModel comparisonConstructing your language model application will likely involved choosing between many different options of prompts, models, and even chains to use. When doing so, you will want to compare these different options on different inputs in an easy, flexible, and intuitive way. LangCha...
81
https://python.langchain.com/docs/guides/pydantic_compatibility
GuidesPydantic compatibilityOn this pagePydantic compatibilityPydantic v2 was released in June, 2023 (https://docs.pydantic.dev/2.0/blog/pydantic-v2-final/)v2 contains has a number of breaking changes (https://docs.pydantic.dev/2.0/migration/)Pydantic v2 and v1 are under the same package name, so both versions cannot b...
82
https://python.langchain.com/docs/guides/safety/
GuidesSafetyModerationOne of the key concerns with using LLMs is that they may generate harmful or unethical text. This is an area of active research in the field. Here we present some built-in chains inspired by this research, which are intended to make the outputs of LLMs safer.Moderation chain: Explicitly check if a...
83
https://python.langchain.com/docs/additional_resources
MoreMore📄️ DependentsDependents stats for langchain-ai/langchain📄️ TutorialsBelow are links to tutorials and courses on LangChain. For written guides on common use cases for LangChain, check out the use cases guides.📄️ YouTube videos⛓ icon marks a new addition [last update 2023-09-21]🔗 GalleryPreviousModerationNext...
84
https://python.langchain.com/docs/additional_resources/dependents
MoreDependentsDependentsDependents stats for langchain-ai/langchain [update: 2023-10-06; only dependent repositories with Stars > 100]RepositoryStarsopenai/openai-cookbook49006AntonOsika/gpt-engineer44368imartinez/privateGPT38300LAION-AI/Open-Assistant35327hpcaitech/ColossalAI34799microsoft/TaskMatrix34161streamlit/s...
85
https://python.langchain.com/docs/additional_resources/tutorials
MoreTutorialsOn this pageTutorialsBelow are links to tutorials and courses on LangChain. For written guides on common use cases for LangChain, check out the use cases guides.⛓ icon marks a new addition [last update 2023-09-21]DeepLearning.AI courses​ by Harrison Chase and Andrew NgLangChain for LLM Application Developm...
86
https://python.langchain.com/docs/additional_resources/youtube
MoreYouTube videosOn this pageYouTube videos⛓ icon marks a new addition [last update 2023-09-21]Official LangChain YouTube channel​Introduction to LangChain with Harrison Chase, creator of LangChain​Building the Future with LLMs, LangChain, & Pinecone by PineconeLangChain and Weaviate with Harrison Chase and Bob van Lu...
87
https://python.langchain.com/docs/use_cases/question_answering/
Question AnsweringOn this pageQuestion AnsweringUse case​Suppose you have some text documents (PDF, blog, Notion pages, etc.) and want to ask questions related to the contents of those documents. LLMs, given their proficiency in understanding text, are a great tool for this.In this walkthrough we'll go over how to buil...
88
https://python.langchain.com/docs/use_cases/question_answering/how_to/vector_db_qa
Question AnsweringHow toQA using a RetrieverQA using a RetrieverThis example showcases question answering over an index.from langchain.chains import RetrievalQAfrom langchain.document_loaders import TextLoaderfrom langchain.embeddings.openai import OpenAIEmbeddingsfrom langchain.llms import OpenAIfrom langchain.text_sp...
89
https://python.langchain.com/docs/use_cases/question_answering/how_to/chat_vector_db
Question AnsweringHow toStore and reference chat historyStore and reference chat historyThe ConversationalRetrievalQA chain builds on RetrievalQAChain to provide a chat history component.It first combines the chat history (either explicitly passed in or retrieved from the provided memory) and the question into a standa...
90
https://python.langchain.com/docs/use_cases/question_answering/how_to/code/
Question AnsweringHow toCode understandingOn this pageCode understandingOverviewLangChain is a useful tool designed to parse GitHub code repositories. By leveraging VectorStores, Conversational RetrieverChain, and GPT-4, it can answer questions in the context of an entire GitHub repository or generate new code. This do...
91
https://python.langchain.com/docs/use_cases/question_answering/how_to/code/code-analysis-deeplake
Question AnsweringHow toCode understandingUse LangChain, GPT and Activeloop's Deep Lake to work with code baseOn this pageUse LangChain, GPT and Activeloop's Deep Lake to work with code baseIn this tutorial, we are going to use Langchain + Activeloop's Deep Lake with GPT to analyze the code base of the LangChain itself...
beddings(client=<class 'openai.api_resources.embedding.Embedding'>
model='text-embedding-ada-002'
deployment='text-embedding-ada-002'
92
https://python.langchain.com/docs/use_cases/question_answering/how_to/code/twitter-the-algorithm-analysis-deeplake
Question AnsweringHow toCode understandingAnalysis of Twitter the-algorithm source code with LangChain, GPT4 and Activeloop's Deep LakeOn this pageAnalysis of Twitter the-algorithm source code with LangChain, GPT4 and Activeloop's Deep LakeIn this tutorial, we are going to use Langchain + Activeloop's Deep Lake with GP...
a chunk of size 1042
which is longer than the specified 1000 Created a chunk of size 1200
which is longer than the specified 1000 Created a chunk of size 1047
93
https://python.langchain.com/docs/use_cases/question_answering/how_to/analyze_document
Question AnsweringHow toAnalyze DocumentAnalyze DocumentThe AnalyzeDocumentChain can be used as an end-to-end to chain. This chain takes in a single document, splits it up, and then runs it through a CombineDocumentsChain.with open("../../state_of_the_union.txt") as f: state_of_the_union = f.read()Summarize​Let's ta...
94
https://python.langchain.com/docs/use_cases/question_answering/how_to/conversational_retrieval_agents
Question AnsweringHow toConversational Retrieval AgentOn this pageConversational Retrieval AgentThis is an agent specifically optimized for doing retrieval when necessary and also holding a conversation.To start, we will set up the retriever we want to use, and then turn it into a retriever tool. Next, we will use the ...
95
https://python.langchain.com/docs/use_cases/question_answering/how_to/document-context-aware-QA
Question AnsweringHow toPerform context-aware text splittingPerform context-aware text splittingText splitting for vector storage often uses sentences or other delimiters to keep related text together. But many documents (such as Markdown files) have structure (headers) that can be explicitly used in splitting. The Mar...