Skip to main contentü¶úÔ∏èüîó LangChainDocsUse casesIntegrationsAPICommunityChat our docsLangSmithJS/TS DocsSearchCTRLKGet startedIntroductionInstallationQuickstartLangChain Expression LanguageInterfaceHow toCookbookLangChain Expression Language (LCEL)Why use LCEL?ModulesModel I/‚ÄãORetrievalChainsHow toFoundationalLLMRouterSequentialTransformationDocumentsMemoryAgentsCallbacksModulesSecurityGuidesMoreModulesChainsFoundationalLLMOn this pageLLMAn LLMChain is a simple chain that adds some functionality around language models. It is used widely throughout LangChain, including in other chains and agents.An LLMChain consists of a PromptTemplate and a language model (either an LLM or chat model). It formats the prompt template using the input key values provided (and also memory key values, if available), passes the formatted string to LLM and returns the LLM output.Get started‚Äãfrom langchain.prompts import PromptTemplatefrom langchain.llms import OpenAIfrom langchain.chains import LLMChainprompt_template = "What is a good name for a company that makes {product}?"llm = OpenAI(temperature=0)llm_chain = LLMChain(    llm=llm,    prompt=PromptTemplate.from_template(prompt_template))llm_chain("colorful socks")    {'product': 'colorful socks', 'text': '\n\nSocktastic!'}Additional ways of running LLMChain‚ÄãAside from __call__ and run methods shared by all Chain object, LLMChain offers a few more ways of calling the chain logic:apply allows you run the chain against a list of inputs:input_list = [    {"product": "socks"},    {"product": "computer"},    {"product": "shoes"}]llm_chain.apply(input_list)    [{'text': '\n\nSocktastic!'},     {'text': '\n\nTechCore Solutions.'},     {'text': '\n\nFootwear Factory.'}]generate is similar to apply, except it return an LLMResult instead of string. LLMResult often contains useful generation such as token usages and finish reason.llm_chain.generate(input_list)    LLMResult(generations=[[Generation(text='\n\nSocktastic!',
An LLMChain is a simple chain that adds some functionality around language models. It is used widely throughout LangChain, including in other chains and agents.
An LLMChain is a simple chain that adds some functionality around language models. It is used widely throughout LangChain, including in other chains and agents. ->: Skip to main contentü¶úÔ∏èüîó LangChainDocsUse casesIntegrationsAPICommunityChat our docsLangSmithJS/TS DocsSearchCTRLKGet startedIntroductionInstallationQuickstartLangChain Expression LanguageInterfaceHow toCookbookLangChain Expression Language (LCEL)Why use LCEL?ModulesModel I/‚ÄãORetrievalChainsHow toFoundationalLLMRouterSequentialTransformationDocumentsMemoryAgentsCallbacksModulesSecurityGuidesMoreModulesChainsFoundationalLLMOn this pageLLMAn LLMChain is a simple chain that adds some functionality around language models. It is used widely throughout LangChain, including in other chains and agents.An LLMChain consists of a PromptTemplate and a language model (either an LLM or chat model). It formats the prompt template using the input key values provided (and also memory key values, if available), passes the formatted string to LLM and returns the LLM output.Get started‚Äãfrom langchain.prompts import PromptTemplatefrom langchain.llms import OpenAIfrom langchain.chains import LLMChainprompt_template = "What is a good name for a company that makes {product}?"llm = OpenAI(temperature=0)llm_chain = LLMChain(    llm=llm,    prompt=PromptTemplate.from_template(prompt_template))llm_chain("colorful socks")    {'product': 'colorful socks', 'text': '\n\nSocktastic!'}Additional ways of running LLMChain‚ÄãAside from __call__ and run methods shared by all Chain object, LLMChain offers a few more ways of calling the chain logic:apply allows you run the chain against a list of inputs:input_list = [    {"product": "socks"},    {"product": "computer"},    {"product": "shoes"}]llm_chain.apply(input_list)    [{'text': '\n\nSocktastic!'},     {'text': '\n\nTechCore Solutions.'},     {'text': '\n\nFootwear Factory.'}]generate is similar to apply, except it return an LLMResult instead of string. LLMResult often contains useful generation such as token usages and finish reason.llm_chain.generate(input_list)    LLMResult(generations=[[Generation(text='\n\nSocktastic!',