Skip to main contentü¶úÔ∏èüîó LangChainDocsUse casesIntegrationsAPICommunityChat our docsLangSmithJS/TS DocsSearchCTRLKGet startedIntroductionInstallationQuickstartLangChain Expression LanguageInterfaceHow toCookbookLangChain Expression Language (LCEL)Why use LCEL?ModulesModel I/‚ÄãORetrievalChainsHow toAsync APIDifferent call methodsCustom chainDebugging chainsLoading from LangChainHubAdding memory (state)Using OpenAI functionsSerializationFoundationalDocumentsMemoryAgentsCallbacksModulesSecurityGuidesMoreModulesChainsHow toSerializationOn this pageSerializationThis notebook covers how to serialize chains to and from disk. The serialization format we use is JSON or YAML. Currently, only some chains support this type of serialization. We will grow the number of supported chains over time.Saving a chain to disk‚ÄãFirst, let's go over how to save a chain to disk. This can be done with the .save method, and specifying a file path with a .json or .yaml extension.from langchain.prompts import PromptTemplatefrom langchain.llms import OpenAIfrom langchain.chains import LLMChaintemplate = """Question: {question}Answer: Let's think step by step."""prompt = PromptTemplate(template=template, input_variables=["question"])llm_chain = LLMChain(prompt=prompt, llm=OpenAI(temperature=0), verbose=True)llm_chain.save("llm_chain.json")Let's now take a look at what's inside this saved file:cat llm_chain.json    {        "memory": null,        "verbose": true,        "prompt": {            "input_variables": [                "question"            ],            "output_parser": null,            "template": "Question: {question}\n\nAnswer: Let's think step by step.",            "template_format": "f-string"        },        "llm": {            "model_name": "text-davinci-003",            "temperature": 0.0,            "max_tokens": 256,            "top_p": 1,            "frequency_penalty": 0,            "presence_penalty": 0,            "n": 1,            "best_of": 1,
This notebook covers how to serialize chains to and from disk. The serialization format we use is JSON or YAML. Currently, only some chains support this type of serialization. We will grow the number of supported chains over time.
This notebook covers how to serialize chains to and from disk. The serialization format we use is JSON or YAML. Currently, only some chains support this type of serialization. We will grow the number of supported chains over time. ->: Skip to main contentü¶úÔ∏èüîó LangChainDocsUse casesIntegrationsAPICommunityChat our docsLangSmithJS/TS DocsSearchCTRLKGet startedIntroductionInstallationQuickstartLangChain Expression LanguageInterfaceHow toCookbookLangChain Expression Language (LCEL)Why use LCEL?ModulesModel I/‚ÄãORetrievalChainsHow toAsync APIDifferent call methodsCustom chainDebugging chainsLoading from LangChainHubAdding memory (state)Using OpenAI functionsSerializationFoundationalDocumentsMemoryAgentsCallbacksModulesSecurityGuidesMoreModulesChainsHow toSerializationOn this pageSerializationThis notebook covers how to serialize chains to and from disk. The serialization format we use is JSON or YAML. Currently, only some chains support this type of serialization. We will grow the number of supported chains over time.Saving a chain to disk‚ÄãFirst, let's go over how to save a chain to disk. This can be done with the .save method, and specifying a file path with a .json or .yaml extension.from langchain.prompts import PromptTemplatefrom langchain.llms import OpenAIfrom langchain.chains import LLMChaintemplate = """Question: {question}Answer: Let's think step by step."""prompt = PromptTemplate(template=template, input_variables=["question"])llm_chain = LLMChain(prompt=prompt, llm=OpenAI(temperature=0), verbose=True)llm_chain.save("llm_chain.json")Let's now take a look at what's inside this saved file:cat llm_chain.json    {        "memory": null,        "verbose": true,        "prompt": {            "input_variables": [                "question"            ],            "output_parser": null,            "template": "Question: {question}\n\nAnswer: Let's think step by step.",            "template_format": "f-string"        },        "llm": {            "model_name": "text-davinci-003",            "temperature": 0.0,            "max_tokens": 256,            "top_p": 1,            "frequency_penalty": 0,            "presence_penalty": 0,            "n": 1,            "best_of": 1,