id stringlengths 14 15 | text stringlengths 27 2.12k | source stringlengths 49 118 |
|---|---|---|
39dc43079643-3 | {}, 'model_name': 'text-davinci-003'})PreviousSerializationNextTracking token usageCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright © 2023 LangChain, Inc. | https://python.langchain.com/docs/modules/model_io/models/llms/streaming_llm |
fdd7a14f1358-0 | Caching | 🦜�🔗 Langchain | https://python.langchain.com/docs/modules/model_io/models/llms/llm_caching |
fdd7a14f1358-1 | Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OPromptsLanguage modelsLLMsAsync APICustom LLMFake LLMHuman input LLMCachingSerializationStreamingTracking token usageChat modelsOutput parsersData connectionChains... | https://python.langchain.com/docs/modules/model_io/models/llms/llm_caching |
fdd7a14f1358-2 | It can speed up your application by reducing the number of API calls you make to the LLM provider.import langchainfrom langchain.llms import OpenAI# To make the caching really obvious, lets use a slower model.llm = OpenAI(model_name="text-davinci-002", n=2, best_of=2)In Memory Cache​from langchain.cache import InMemo... | https://python.langchain.com/docs/modules/model_io/models/llms/llm_caching |
fdd7a14f1358-3 | did the chicken cross the road?\n\nTo get to the other side.'# The second time it is, so it goes fasterllm.predict("Tell me a joke") CPU times: user 2.46 ms, sys: 1.23 ms, total: 3.7 ms Wall time: 2.67 ms '\n\nWhy did the chicken cross the road?\n\nTo get to the other side.'Optional Caching in Chains​You can... | https://python.langchain.com/docs/modules/model_io/models/llms/llm_caching |
fdd7a14f1358-4 | '\n\nPresident Biden is discussing the American Rescue Plan and the Bipartisan Infrastructure Law, which will create jobs and help Americans. He also talks about his vision for America, which includes investing in education and infrastructure. In response to Russian aggression in Ukraine, the United States is joining w... | https://python.langchain.com/docs/modules/model_io/models/llms/llm_caching |
4bd05156a8fc-0 | Async API | 🦜�🔗 Langchain | https://python.langchain.com/docs/modules/model_io/models/llms/async_llm |
4bd05156a8fc-1 | Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OPromptsLanguage modelsLLMsAsync APICustom LLMFake LLMHuman input LLMCachingSerializationStreamingTracking token usageChat modelsOutput parsersData connectionChains... | https://python.langchain.com/docs/modules/model_io/models/llms/async_llm |
4bd05156a8fc-2 | asyncio.run(generate_concurrently())await generate_concurrently()elapsed = time.perf_counter() - sprint("\033[1m" + f"Concurrent executed in {elapsed:0.2f} seconds." + "\033[0m")s = time.perf_counter()generate_serially()elapsed = time.perf_counter() - sprint("\033[1m" + f"Serial executed in {elapsed:0.2f} seconds." + "... | https://python.langchain.com/docs/modules/model_io/models/llms/async_llm |
4bd05156a8fc-3 | How about you? I'm doing well, thank you. How about you? I'm doing well, thank you. How about you? I'm doing well, thank you. How about yourself? I'm doing well, thanks for asking. How about you? I'm doing well, thanks! How about you? I'm doing well, thank y... | https://python.langchain.com/docs/modules/model_io/models/llms/async_llm |
748f54307791-0 | Custom LLM | 🦜�🔗 Langchain | https://python.langchain.com/docs/modules/model_io/models/llms/custom_llm |
748f54307791-1 | Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OPromptsLanguage modelsLLMsAsync APICustom LLMFake LLMHuman input LLMCachingSerializationStreamingTracking token usageChat modelsOutput parsersData connectionChains... | https://python.langchain.com/docs/modules/model_io/models/llms/custom_llm |
748f54307791-2 | if stop is not None: raise ValueError("stop kwargs are not permitted.") return prompt[: self.n] @property def _identifying_params(self) -> Mapping[str, Any]: """Get the identifying parameters.""" return {"n": self.n}We can now use this as an any other LLM.llm = CustomLLM(n=10)llm("... | https://python.langchain.com/docs/modules/model_io/models/llms/custom_llm |
3ef201ea458b-0 | Fake LLM | 🦜�🔗 Langchain
Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OPromptsLanguage modelsLLMsAsync APICustom LLMFake LLMHuman input LLMCachingSerializationStreamingTracking token usageChat mod... | https://python.langchain.com/docs/modules/model_io/models/llms/fake_llm |
1ffd35d5b49e-0 | Tracking token usage | 🦜�🔗 Langchain | https://python.langchain.com/docs/modules/model_io/models/llms/token_usage_tracking |
1ffd35d5b49e-1 | Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OPromptsLanguage modelsLLMsAsync APICustom LLMFake LLMHuman input LLMCachingSerializationStreamingTracking token usageChat modelsOutput parsersData connectionChains... | https://python.langchain.com/docs/modules/model_io/models/llms/token_usage_tracking |
1ffd35d5b49e-2 | import initialize_agentfrom langchain.agents import AgentTypefrom langchain.llms import OpenAIllm = OpenAI(temperature=0)tools = load_tools(["serpapi", "llm-math"], llm=llm)agent = initialize_agent( tools, llm, agent=AgentType.ZERO_SHOT_REACT_DESCRIPTION, verbose=True)with get_openai_callback() as cb: response = ... | https://python.langchain.com/docs/modules/model_io/models/llms/token_usage_tracking |
1ffd35d5b49e-3 | power. Action: Calculator Action Input: 29^0.23 Observation: Answer: 2.169459462491557 Thought: I now know the final answer. Final Answer: Harry Styles, Olivia Wilde's boyfriend, is 29 years old and his age raised to the 0.23 power is 2.169459462491557. > Finished chain. Total Tokens: 1506 ... | https://python.langchain.com/docs/modules/model_io/models/llms/token_usage_tracking |
2a13942a7f10-0 | Serialization | 🦜�🔗 Langchain | https://python.langchain.com/docs/modules/model_io/models/llms/llm_serialization |
2a13942a7f10-1 | Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OPromptsLanguage modelsLLMsAsync APICustom LLMFake LLMHuman input LLMCachingSerializationStreamingTracking token usageChat modelsOutput parsersData connectionChains... | https://python.langchain.com/docs/modules/model_io/models/llms/llm_serialization |
2a13942a7f10-2 | }llm = load_llm("llm.json")cat llm.yaml _type: openai best_of: 1 frequency_penalty: 0.0 max_tokens: 256 model_name: text-davinci-003 n: 1 presence_penalty: 0.0 request_timeout: null temperature: 0.7 top_p: 1.0llm = load_llm("llm.yaml")Saving​If you want to go from an LLM in memory to a s... | https://python.langchain.com/docs/modules/model_io/models/llms/llm_serialization |
67d4c143adc6-0 | Prompts | 🦜�🔗 Langchain
Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OPromptsPrompt templatesExample selectorsLanguage modelsOutput parsersData connectionChainsMemoryAgentsCallbacksModulesGuidesEc... | https://python.langchain.com/docs/modules/model_io/prompts/ |
ed2d9b3812b9-0 | Prompt templates | 🦜�🔗 Langchain | https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/ |
ed2d9b3812b9-1 | Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OPromptsPrompt templatesConnecting to a Feature StoreCustom prompt templateFew-shot prompt templatesFew shot examples for chat modelsFormat template outputTemplate ... | https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/ |
ed2d9b3812b9-2 | LangChain provides several classes and functions to make constructing and working with prompts easy.What is a prompt template?​A prompt template refers to a reproducible way to generate a prompt. It contains a text string ("the template"), that can take in a set of parameters from the end user and generates a prompt.... | https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/ |
ed2d9b3812b9-3 | you do not wish to specify input_variables manually, you can also create a PromptTemplate using from_template class method. langchain will automatically infer the input_variables based on the template passed.template = "Tell me a {adjective} joke about {content}."prompt_template = PromptTemplate.from_template(template)... | https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/ |
ed2d9b3812b9-4 | These chat messages differ from raw string (which you would pass into a LLM model) in that every message is associated with a role.For example, in OpenAI Chat Completion API, a chat message can be associated with the AI, human or system role. The model is supposed to follow instruction from system chat message more clo... | https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/ |
ed2d9b3812b9-5 | You can use ChatPromptTemplate's format_prompt -- this returns a PromptValue, which you can convert to a string or Message object, depending on whether you want to use the formatted value as input to an llm or chat model.chat_prompt = ChatPromptTemplate.from_messages([system_message_prompt, human_message_prompt])# get ... | https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/ |
61740173cc04-0 | Connecting to a Feature Store | 🦜�🔗 Langchain | https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/connecting_to_a_feature_store |
61740173cc04-1 | Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OPromptsPrompt templatesConnecting to a Feature StoreCustom prompt templateFew-shot prompt templatesFew shot examples for chat modelsFormat template outputTemplate ... | https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/connecting_to_a_feature_store |
61740173cc04-2 | where you stored itfeast_repo_path = "../../../../../my_feature_repo/feature_repo/"store = FeatureStore(repo_path=feast_repo_path)Prompts​Here we will set up a custom FeastPromptTemplate. This prompt template will take in a driver id, look up their stats, and format those stats into a prompt.Note that the input to th... | https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/connecting_to_a_feature_store |
61740173cc04-3 | driver_id}], ).to_dict() kwargs["conv_rate"] = feature_vector["conv_rate"][0] kwargs["acc_rate"] = feature_vector["acc_rate"][0] kwargs["avg_daily_trips"] = feature_vector["avg_daily_trips"][0] return prompt.format(**kwargs)prompt_template = FeastPromptTemplate(input_variables=["drive... | https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/connecting_to_a_feature_store |
61740173cc04-4 | .5 mark! Keep up the great work! And remember, even chickens can't always cross the road, but they still give it their best shot."Tecton​Above, we showed how you could use Feast, a popular open source and self-managed feature store, with LangChain. Our examples below will show a similar integration using Tecton. Tect... | https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/connecting_to_a_feature_store |
61740173cc04-5 | write them a note based on the following rules:1. If they had a transaction in the last day, write a short congratulations message on their recent sales2. If no transaction in the last day, but they had a transaction in the last 30 days, playfully encourage them to sell more.3. Always add a silly joke about chickens at... | https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/connecting_to_a_feature_store |
61740173cc04-6 | If they had a transaction in the last day, write a short congratulations message on their recent sales 2. If no transaction in the last day, but they had a transaction in the last 30 days, playfully encourage them to sell more. 3. Always add a silly joke about chickens at the end Here are the vendor's stat... | https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/connecting_to_a_feature_store |
61740173cc04-7 | langchain.prompts import PromptTemplate, StringPromptTemplatetemplate = """Given the amount a user spends on average per transaction, let them know if they are a high roller. Otherwise, make a silly joke about chickens at the end to make them feel betterHere are the user's stats:Average Amount per Transaction: ${avg_tr... | https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/connecting_to_a_feature_store |
b0ce5bd30973-0 | Format template output | 🦜�🔗 Langchain | https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/format_output |
b0ce5bd30973-1 | Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OPromptsPrompt templatesConnecting to a Feature StoreCustom prompt templateFew-shot prompt templatesFew shot examples for chat modelsFormat template outputTemplate ... | https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/format_output |
9c918c3ebaf5-0 | Types of MessagePromptTemplate | 🦜�🔗 Langchain | https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/msg_prompt_templates |
9c918c3ebaf5-1 | Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OPromptsPrompt templatesConnecting to a Feature StoreCustom prompt templateFew-shot prompt templatesFew shot examples for chat modelsFormat template outputTemplate ... | https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/msg_prompt_templates |
9c918c3ebaf5-2 | ChatPromptTemplate.from_messages([MessagesPlaceholder(variable_name="conversation"), human_message_template])human_message = HumanMessage(content="What is the best way to learn programming?")ai_message = AIMessage(content="""\1. Choose a programming language: Decide on a programming language that you want to learn.2. S... | https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/msg_prompt_templates |
ac3f67941400-0 | Custom prompt template | 🦜�🔗 Langchain | https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/custom_prompt_template |
ac3f67941400-1 | Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OPromptsPrompt templatesConnecting to a Feature StoreCustom prompt templateFew-shot prompt templatesFew shot examples for chat modelsFormat template outputTemplate ... | https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/custom_prompt_template |
ac3f67941400-2 | template expects.It exposes a format method that takes in keyword arguments corresponding to the expected input_variables and returns the formatted prompt.We will create a custom prompt template that takes in the function name as input and formats the prompt to provide the source code of the function. To achieve this, ... | https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/custom_prompt_template |
ac3f67941400-3 | to be sent to the language model prompt = PROMPT.format( function_name=kwargs["function_name"].__name__, source_code=source_code ) return prompt def _prompt_type(self): return "function-explainer"Use the custom prompt template​Now that we have created a custom prompt template... | https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/custom_prompt_template |
f6a3b83733e5-0 | Validate template | 🦜�🔗 Langchain
Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OPromptsPrompt templatesConnecting to a Feature StoreCustom prompt templateFew-shot prompt templatesFew shot examples... | https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/validate |
6233cbd94ca2-0 | Serialization | 🦜�🔗 Langchain | https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/prompt_serialization |
6233cbd94ca2-1 | Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OPromptsPrompt templatesConnecting to a Feature StoreCustom prompt templateFew-shot prompt templatesFew shot examples for chat modelsFormat template outputTemplate ... | https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/prompt_serialization |
6233cbd94ca2-2 | PromptTemplate.Loading from YAML​This shows an example of loading a PromptTemplate from YAML.cat simple_prompt.yaml _type: prompt input_variables: ["adjective", "content"] template: Tell me a {adjective} joke about {content}.prompt = load_prompt("simple_prompt.yaml")print(prompt.format(adjecti... | https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/prompt_serialization |
6233cbd94ca2-3 | me a funny joke about chickens.FewShotPromptTemplate​This section covers examples for loading few shot prompt templates.Examples​This shows an example of what examples stored as json might look like.cat examples.json [ {"input": "happy", "output": "sad"}, {"input": "tall", "output": "short"} ]An... | https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/prompt_serialization |
6233cbd94ca2-4 | Output: short Input: funny Output:The same would work if you loaded examples from the yaml file.cat few_shot_prompt_yaml_examples.yaml _type: few_shot input_variables: ["adjective"] prefix: Write antonyms for the following words. example_prompt: _type: prompt input_var... | https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/prompt_serialization |
6233cbd94ca2-5 | "input_variables": ["input", "output"], "template": "Input: {input}\nOutput: {output}" }, "examples": "examples.json", "suffix": "Input: {adjective}\nOutput:" } prompt = load_prompt("few_shot_prompt.json")print(prompt.format(adjective="funny")) Write antonyms for the following wo... | https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/prompt_serialization |
6233cbd94ca2-6 | "tall", "output": "short"} ], "suffix": "Input: {adjective}\nOutput:" } prompt = load_prompt("few_shot_prompt_examples_in.json")print(prompt.format(adjective="funny")) Write antonyms for the following words. Input: happy Output: sad Input: tall Output: short Input: funny... | https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/prompt_serialization |
6233cbd94ca2-7 | Input: happy Output: sad Input: tall Output: short Input: funny Output:PromptTempalte with OutputParser​This shows an example of loading a prompt along with an OutputParser from a file.cat prompt_with_output_parser.json { "input_variables": [ "question", "student... | https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/prompt_serialization |
6233cbd94ca2-8 | "George Washington was born in 1732 and died in 1799.\nScore: 1/2") {'answer': 'George Washington was born in 1732 and died in 1799.', 'score': '1/2'}PreviousCompositionNextPrompt PipeliningPromptTemplateLoading from YAMLLoading from JSONLoading Template from a FileFewShotPromptTemplateExamplesLoading from YAMLL... | https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/prompt_serialization |
9d6acd037388-0 | Partial prompt templates | 🦜�🔗 Langchain | https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/partial |
9d6acd037388-1 | Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OPromptsPrompt templatesConnecting to a Feature StoreCustom prompt templateFew-shot prompt templatesFew shot examples for chat modelsFormat template outputTemplate ... | https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/partial |
9d6acd037388-2 | = prompt.partial(foo="foo");print(partial_prompt.format(bar="baz")) foobazYou can also just initialize the prompt with the partialed variables.prompt = PromptTemplate(template="{foo}{bar}", input_variables=["bar"], partial_variables={"foo": "foo"})print(prompt.format(bar="baz")) foobazPartial With Functions​The... | https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/partial |
9d6acd037388-3 | Tell me a funny joke about the day 02/27/2023, 22:15:16PreviousTypes of MessagePromptTemplateNextCompositionCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright © 2023 LangChain, Inc. | https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/partial |
284552ce45be-0 | Page Not Found | 🦜�🔗 Langchain
Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKPage Not FoundWe could not find what you were looking for.Please contact the owner of the site that linked you to the original URL and let them know their link is broken.CommunityDisc... | https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/custom_prompt_template.html |
c7cbbc38ccf7-0 | Few shot examples for chat models | 🦜�🔗 Langchain | https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/few_shot_examples_chat |
c7cbbc38ccf7-1 | Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OPromptsPrompt templatesConnecting to a Feature StoreCustom prompt templateFew-shot prompt templatesFew shot examples for chat modelsFormat template outputTemplate ... | https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/few_shot_examples_chat |
c7cbbc38ccf7-2 | = ChatPromptTemplate.from_messages( [system_message_prompt, example_human, example_ai, human_message_prompt])chain = LLMChain(llm=chat, prompt=chat_prompt)# get a chat completion from the formatted messageschain.run("I love programming.") "I be lovin' programmin', me hearty!"System Messages​OpenAI provides an o... | https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/few_shot_examples_chat |
b06e3621626c-0 | Composition | 🦜�🔗 Langchain | https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/prompt_composition |
b06e3621626c-1 | Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OPromptsPrompt templatesConnecting to a Feature StoreCustom prompt templateFew-shot prompt templatesFew shot examples for chat modelsFormat template outputTemplate ... | https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/prompt_composition |
b06e3621626c-2 | ("start", start_prompt)]pipeline_prompt = PipelinePromptTemplate(final_prompt=full_prompt, pipeline_prompts=input_prompts)pipeline_prompt.input_variables ['example_a', 'person', 'example_q', 'input']print(pipeline_prompt.format( person="Elon Musk", example_q="What's your favorite car?", example_a="Tesla", ... | https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/prompt_composition |
435e761c8d69-0 | Prompt Pipelining | 🦜�🔗 Langchain | https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/prompts_pipelining |
435e761c8d69-1 | Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OPromptsPrompt templatesConnecting to a Feature StoreCustom prompt templateFew-shot prompt templatesFew shot examples for chat modelsFormat template outputTemplate ... | https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/prompts_pipelining |
435e761c8d69-2 | output_parser=None, partial_variables={}, template='Tell me a joke about {topic}, make it funny\n\nand in {language}', template_format='f-string', validate_template=True)prompt.format(topic="sports", language="spanish") 'Tell me a joke about sports, make it funny\n\nand in spanish'You can also use it in an LLMChain,... | https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/prompts_pipelining |
435e761c8d69-3 | Use a Message when there is no variables to be formatted, use a MessageTemplate when there are variables to be formatted. You can also use just a string -> note that this will automatically get inferred as a HumanMessagePromptTemplate.new_prompt = ( prompt + HumanMessage(content="hi") + AIMessage(content="what... | https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/prompts_pipelining |
bc41991bc783-0 | Few-shot prompt templates | 🦜�🔗 Langchain | https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/few_shot_examples |
bc41991bc783-1 | Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OPromptsPrompt templatesConnecting to a Feature StoreCustom prompt templateFew-shot prompt templatesFew shot examples for chat modelsFormat template outputTemplate ... | https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/few_shot_examples |
bc41991bc783-2 | was the founder of craigslist born?", "answer": """Are follow up questions needed here: Yes.Follow up: Who was the founder of craigslist?Intermediate answer: Craigslist was founded by Craig Newmark.Follow up: When was Craig Newmark born?Intermediate answer: Craig Newmark was born on December 6, 1952.So the final ans... | https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/few_shot_examples |
bc41991bc783-3 | lived longer, Muhammad Ali or Alan Turing? Are follow up questions needed here: Yes. Follow up: How old was Muhammad Ali when he died? Intermediate answer: Muhammad Ali was 74 years old when he died. Follow up: How old was Alan Turing when he died? Intermediate answer: Alan Turing was 41 years old wh... | https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/few_shot_examples |
bc41991bc783-4 | When was Craig Newmark born? Intermediate answer: Craig Newmark was born on December 6, 1952. So the final answer is: December 6, 1952 Question: Who was the maternal grandfather of George Washington? Are follow up questions needed here: Yes. Follow up: Who was the mother of George Washington?... | https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/few_shot_examples |
bc41991bc783-5 | feed them into an ExampleSelector object.In this tutorial, we will use the SemanticSimilarityExampleSelector class. This class selects few shot examples based on their similarity to the input. It uses an embedding model to compute the similarity between the input and the few shot examples, as well as a vector store to ... | https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/few_shot_examples |
bc41991bc783-6 | Follow up: Who was the mother of George Washington? Intermediate answer: The mother of George Washington was Mary Ball Washington. Follow up: Who was the father of Mary Ball Washington? Intermediate answer: The father of Mary Ball Washington was Joseph Ball. So the final answer is: Joseph Ball Feed examp... | https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/few_shot_examples |
0893f37a1cef-0 | Template Formats | 🦜�🔗 Langchain
Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OPromptsPrompt templatesConnecting to a Feature StoreCustom prompt templateFew-shot prompt templatesFew shot examples ... | https://python.langchain.com/docs/modules/model_io/prompts/prompt_templates/formats |
eaf7a9ee61d1-0 | Example selectors | 🦜�🔗 Langchain
Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OPromptsPrompt templatesExample selectorsCustom example selectorSelect by lengthSelect by maximal marginal relevance ... | https://python.langchain.com/docs/modules/model_io/prompts/example_selectors/ |
372d6076e13c-0 | Select by length | 🦜�🔗 Langchain | https://python.langchain.com/docs/modules/model_io/prompts/example_selectors/length_based |
372d6076e13c-1 | Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OPromptsPrompt templatesExample selectorsCustom example selectorSelect by lengthSelect by maximal marginal relevance (MMR)Select by n-gram overlapSelect by similari... | https://python.langchain.com/docs/modules/model_io/prompts/example_selectors/length_based |
372d6076e13c-2 | used to format the examples. example_prompt=example_prompt, # This is the maximum length that the formatted examples should be. # Length is measured by the get_text_length function below. max_length=25, # This is the function used to get the length of a string, which is used # to determine which exam... | https://python.langchain.com/docs/modules/model_io/prompts/example_selectors/length_based |
372d6076e13c-3 | Give the antonym of every input Input: happy Output: sad Input: big and huge and massive and large and gigantic and tall and much much much much much bigger than everything else Output:# You can add an example to an example selector as well.new_example = {"input": "big", "output": "small"}dynamic_pr... | https://python.langchain.com/docs/modules/model_io/prompts/example_selectors/length_based |
a76093271449-0 | Select by maximal marginal relevance (MMR) | 🦜�🔗 Langchain | https://python.langchain.com/docs/modules/model_io/prompts/example_selectors/mmr |
a76093271449-1 | Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OPromptsPrompt templatesExample selectorsCustom example selectorSelect by lengthSelect by maximal marginal relevance (MMR)Select by n-gram overlapSelect by similari... | https://python.langchain.com/docs/modules/model_io/prompts/example_selectors/mmr |
a76093271449-2 | {"input": "windy", "output": "calm"},]example_selector = MaxMarginalRelevanceExampleSelector.from_examples( # This is the list of examples available to select from. examples, # This is the embedding class used to produce embeddings which are used to measure semantic similarity. OpenAIEmbeddings(), # This... | https://python.langchain.com/docs/modules/model_io/prompts/example_selectors/mmr |
a76093271449-3 | OpenAIEmbeddings(), # This is the VectorStore class that is used to store the embeddings and do a similarity search over. FAISS, # This is the number of examples to produce. k=2,)similar_prompt = FewShotPromptTemplate( # We provide an ExampleSelector instead of examples. example_selector=example_selec... | https://python.langchain.com/docs/modules/model_io/prompts/example_selectors/mmr |
6ca93fc6b7f1-0 | Select by similarity | 🦜�🔗 Langchain | https://python.langchain.com/docs/modules/model_io/prompts/example_selectors/similarity |
6ca93fc6b7f1-1 | Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OPromptsPrompt templatesExample selectorsCustom example selectorSelect by lengthSelect by maximal marginal relevance (MMR)Select by n-gram overlapSelect by similari... | https://python.langchain.com/docs/modules/model_io/prompts/example_selectors/similarity |
6ca93fc6b7f1-2 | similarity. OpenAIEmbeddings(), # This is the VectorStore class that is used to store the embeddings and do a similarity search over. Chroma, # This is the number of examples to produce. k=1)similar_prompt = FewShotPromptTemplate( # We provide an ExampleSelector instead of examples. example_selec... | https://python.langchain.com/docs/modules/model_io/prompts/example_selectors/similarity |
6ca93fc6b7f1-3 | Input: joyful Output:PreviousSelect by n-gram overlapNextLanguage modelsCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright © 2023 LangChain, Inc. | https://python.langchain.com/docs/modules/model_io/prompts/example_selectors/similarity |
00f140b6640f-0 | Select by n-gram overlap | 🦜�🔗 Langchain | https://python.langchain.com/docs/modules/model_io/prompts/example_selectors/ngram_overlap |
00f140b6640f-1 | Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OPromptsPrompt templatesExample selectorsCustom example selectorSelect by lengthSelect by maximal marginal relevance (MMR)Select by n-gram overlapSelect by similari... | https://python.langchain.com/docs/modules/model_io/prompts/example_selectors/ngram_overlap |
00f140b6640f-2 | "lethargic"}, {"input": "sunny", "output": "gloomy"}, {"input": "windy", "output": "calm"},]# These are examples of a fictional translation task.examples = [ {"input": "See Spot run.", "output": "Ver correr a Spot."}, {"input": "My dog barks.", "output": "Mi perro ladra."}, {"input": "Spot can run.", "ou... | https://python.langchain.com/docs/modules/model_io/prompts/example_selectors/ngram_overlap |
00f140b6640f-3 | prefix="Give the Spanish translation of every input", suffix="Input: {sentence}\nOutput:", input_variables=["sentence"],)# An example input with large ngram overlap with "Spot can run."# and no overlap with "My dog barks."print(dynamic_prompt.format(sentence="Spot can run fast.")) Give the Spanish translation ... | https://python.langchain.com/docs/modules/model_io/prompts/example_selectors/ngram_overlap |
00f140b6640f-4 | overlaps with input.# Since "My dog barks." has no ngram overlaps with "Spot can run fast."# it is excluded.example_selector.threshold = 0.0print(dynamic_prompt.format(sentence="Spot can run fast.")) Give the Spanish translation of every input Input: Spot can run. Output: Spot puede correr. Input: S... | https://python.langchain.com/docs/modules/model_io/prompts/example_selectors/ngram_overlap |
418fc2d33403-0 | Custom example selector | 🦜�🔗 Langchain | https://python.langchain.com/docs/modules/model_io/prompts/example_selectors/custom_example_selector |
418fc2d33403-1 | Skip to main content🦜�🔗 LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/​OPromptsPrompt templatesExample selectorsCustom example selectorSelect by lengthSelect by maximal marginal relevance (MMR)Select by n-gram overlapSelect by similari... | https://python.langchain.com/docs/modules/model_io/prompts/example_selectors/custom_example_selector |
418fc2d33403-2 | Take a look at the current set of example selector implementations supported in LangChain here.
:::Implement custom example selector​from langchain.prompts.example_selector.base import BaseExampleSelectorfrom typing import Dict, Listimport numpy as npclass CustomExampleSelector(BaseExampleSelector): def __init... | https://python.langchain.com/docs/modules/model_io/prompts/example_selectors/custom_example_selector |
d9c61ea199c9-0 | Callbacks | 🦜�🔗 Langchain | https://python.langchain.com/docs/modules/callbacks/ |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.