id
stringlengths
14
16
text
stringlengths
36
2.73k
source
stringlengths
49
117
33e03640b3c8-0
.md .pdf Zilliz Contents Installation and Setup Wrappers VectorStore Zilliz# This page covers how to use the Zilliz Cloud ecosystem within LangChain. Zilliz uses the Milvus integration. It is broken into two parts: installation and setup, and then references to specific Milvus wrappers. Installation and Setup# Instal...
https://python.langchain.com/en/latest/integrations/zilliz.html
7c46e2e48d10-0
.md .pdf OpenAI Contents Installation and Setup Wrappers LLM Embeddings Tokenizer Moderation OpenAI# This page covers how to use the OpenAI ecosystem within LangChain. It is broken into two parts: installation and setup, and then references to specific OpenAI wrappers. Installation and Setup# Install the Python SDK w...
https://python.langchain.com/en/latest/integrations/openai.html
7c46e2e48d10-1
Contents Installation and Setup Wrappers LLM Embeddings Tokenizer Moderation By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 28, 2023.
https://python.langchain.com/en/latest/integrations/openai.html
d65ccc97fe22-0
.md .pdf Hazy Research Contents Installation and Setup Wrappers LLM Hazy Research# This page covers how to use the Hazy Research ecosystem within LangChain. It is broken into two parts: installation and setup, and then references to specific Hazy Research wrappers. Installation and Setup# To use the manifest, install...
https://python.langchain.com/en/latest/integrations/hazy_research.html
45b831890d87-0
.md .pdf LanceDB Contents Installation and Setup Wrappers VectorStore LanceDB# This page covers how to use LanceDB within LangChain. It is broken into two parts: installation and setup, and then references to specific LanceDB wrappers. Installation and Setup# Install the Python SDK with pip install lancedb Wrappers# ...
https://python.langchain.com/en/latest/integrations/lancedb.html
5442e6c99598-0
.md .pdf Wolfram Alpha Wrapper Contents Installation and Setup Wrappers Utility Tool Wolfram Alpha Wrapper# This page covers how to use the Wolfram Alpha API within LangChain. It is broken into two parts: installation and setup, and then references to specific Wolfram Alpha wrappers. Installation and Setup# Install r...
https://python.langchain.com/en/latest/integrations/wolfram_alpha.html
43bbca2be173-0
.md .pdf Runhouse Contents Installation and Setup Self-hosted LLMs Self-hosted Embeddings Runhouse# This page covers how to use the Runhouse ecosystem within LangChain. It is broken into three parts: installation and setup, LLMs, and Embeddings. Installation and Setup# Install the Python SDK with pip install runhouse...
https://python.langchain.com/en/latest/integrations/runhouse.html
c63dd8895c27-0
.ipynb .pdf Vectara Text Generation Contents Prepare Data Set Up Vector DB Set Up LLM Chain with Custom Prompt Generate Text Vectara Text Generation# This notebook is based on chat_vector_db and adapted to Vectara. Prepare Data# First, we prepare the data. For this example, we fetch a documentation site that consists...
https://python.langchain.com/en/latest/integrations/vectara/vectara_text_generation.html
c63dd8895c27-1
source_chunks = [] splitter = CharacterTextSplitter(separator=" ", chunk_size=1024, chunk_overlap=0) for source in sources: for chunk in splitter.split_text(source.page_content): source_chunks.append(chunk) Cloning into '.'... Set Up Vector DB# Now that we have the documentation content in chunks, let’s put...
https://python.langchain.com/en/latest/integrations/vectara/vectara_text_generation.html
c63dd8895c27-2
print(chain.apply(inputs)) generate_blog_post("environment variables")
https://python.langchain.com/en/latest/integrations/vectara/vectara_text_generation.html
c63dd8895c27-3
[{'text': '\n\nEnvironment variables are an essential part of any development workflow. They provide a way to store and access information that is specific to the environment in which the code is running. This can be especially useful when working with different versions of a language or framework, or when running code...
https://python.langchain.com/en/latest/integrations/vectara/vectara_text_generation.html
c63dd8895c27-4
and any environment variables.\n\nUsing environment variables with the Deno CLI tasks extension is a great way to ensure that your code is running in the correct environment. For example, if you are running a test suite,'}, {'text': '\n\nEnvironment variables are an important part of any programming language, and they ...
https://python.langchain.com/en/latest/integrations/vectara/vectara_text_generation.html
c63dd8895c27-5
&& echo $VAR && deno eval "console.log(\'Deno: \' + Deno.env.get(\'VAR\'))"\n```\n\nThis would output the following:\n\n```\nhello\nDeno: undefined\n```\n\nAs you can see, the value stored in the shell variable is not available in the spawned process.\n\n'}, {'text': '\n\nWhen it comes to developing applications, envir...
https://python.langchain.com/en/latest/integrations/vectara/vectara_text_generation.html
c63dd8895c27-6
is `DENO_DIR`. This environment variable is used to store the directory where Deno will store its files. This includes the Deno executable, the Deno cache, and the Deno configuration files. By setting this environment variable, you can ensure that Deno will always be able to find the files it needs.\n\nFinally, there i...
https://python.langchain.com/en/latest/integrations/vectara/vectara_text_generation.html
c63dd8895c27-7
`Deno.env` has getter and setter methods. Here is example usage:\n\n```ts\nDeno.env.set("FIREBASE_API_KEY", "examplekey123");\nDeno.env.set("FIREBASE_AUTH_DOMAIN", "firebasedomain.com");\n\nconsole.log(Deno.env.get("FIREBASE_API_KEY")); // examplekey123\nconsole.log(Deno.env.get("FIREBASE_AUTH_'}]
https://python.langchain.com/en/latest/integrations/vectara/vectara_text_generation.html
c63dd8895c27-8
Contents Prepare Data Set Up Vector DB Set Up LLM Chain with Custom Prompt Generate Text By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 28, 2023.
https://python.langchain.com/en/latest/integrations/vectara/vectara_text_generation.html
335bff698c62-0
.ipynb .pdf Chat Over Documents with Vectara Contents Pass in chat history Return Source Documents ConversationalRetrievalChain with search_distance ConversationalRetrievalChain with map_reduce ConversationalRetrievalChain with Question Answering with sources ConversationalRetrievalChain with streaming to stdout get_...
https://python.langchain.com/en/latest/integrations/vectara/vectara_chat.html
335bff698c62-1
qa = ConversationalRetrievalChain.from_llm(llm, retriever, memory=memory) <class 'langchain.vectorstores.vectara.Vectara'> query = "What did the president say about Ketanji Brown Jackson" result = qa({"question": query}) result["answer"] " The president said that Ketanji Brown Jackson is one of the nation's top legal m...
https://python.langchain.com/en/latest/integrations/vectara/vectara_chat.html
335bff698c62-2
result['answer'] ' Justice Stephen Breyer.' Return Source Documents# You can also easily return source documents from the ConversationalRetrievalChain. This is useful for when you want to inspect what documents were returned. qa = ConversationalRetrievalChain.from_llm(llm, vectorstore.as_retriever(), return_source_docu...
https://python.langchain.com/en/latest/integrations/vectara/vectara_chat.html
335bff698c62-3
ConversationalRetrievalChain with map_reduce# We can also use different types of combine document chains with the ConversationalRetrievalChain chain. from langchain.chains import LLMChain from langchain.chains.question_answering import load_qa_chain from langchain.chains.conversational_retrieval.prompts import CONDENSE...
https://python.langchain.com/en/latest/integrations/vectara/vectara_chat.html
335bff698c62-4
result = chain({"question": query, "chat_history": chat_history}) result['answer'] ' The president did not mention Ketanji Brown Jackson.\nSOURCES: ../../modules/state_of_the_union.txt' ConversationalRetrievalChain with streaming to stdout# Output from the chain will be streamed to stdout token by token in this example...
https://python.langchain.com/en/latest/integrations/vectara/vectara_chat.html
335bff698c62-5
chat_history = [(query, result["answer"])] query = "Did he mention who she suceeded" result = qa({"question": query, "chat_history": chat_history}) Justice Stephen Breyer. get_chat_history Function# You can also specify a get_chat_history function, which can be used to format the chat_history string. def get_chat_hist...
https://python.langchain.com/en/latest/integrations/vectara/vectara_chat.html
f84f68acf491-0
.md .pdf Autonomous Agents Contents Baby AGI (Original Repo) AutoGPT (Original Repo) MetaPrompt (Original Repo) Autonomous Agents# Autonomous Agents are agents that designed to be more long running. You give them one or multiple long term goals, and they independently execute towards those goals. The applications com...
https://python.langchain.com/en/latest/use_cases/autonomous_agents.html
b83029917cc3-0
.md .pdf Agent Simulations Contents Simulations with One Agent Simulations with Two Agents Simulations with Multiple Agents Agent Simulations# Agent simulations involve interacting one of more agents with each other. Agent simulations generally involve two main components: Long Term Memory Simulation Environment Spec...
https://python.langchain.com/en/latest/use_cases/agent_simulations.html
b83029917cc3-1
Simulated Environment: PettingZoo: an example of how to create a agent-environment interaction loop for multiple agents with PettingZoo (a multi-agent version of Gymnasium). Generative Agents: This notebook implements a generative agent based on the paper Generative Agents: Interactive Simulacra of Human Behavior by Pa...
https://python.langchain.com/en/latest/use_cases/agent_simulations.html
8b290173e485-0
.md .pdf Querying Tabular Data Contents Document Loading Querying Chains Agents Querying Tabular Data# Conceptual Guide Lots of data and information is stored in tabular data, whether it be csvs, excel sheets, or SQL tables. This page covers all resources available in LangChain for working with data in this format. D...
https://python.langchain.com/en/latest/use_cases/tabular.html
2cc17e198310-0
.md .pdf Summarization Summarization# Conceptual Guide Summarization involves creating a smaller summary of multiple longer documents. This can be useful for distilling long documents into the core pieces of information. The recommended way to get started using a summarization chain is: from langchain.chains.summarize ...
https://python.langchain.com/en/latest/use_cases/summarization.html
44fb51464dca-0
.md .pdf Agents Contents Create Your Own Agent Step 1: Create Tools (Optional) Step 2: Modify Agent (Optional) Step 3: Modify Agent Executor Examples Agents# Conceptual Guide Agents can be used for a variety of tasks. Agents combine the decision making ability of a language model with tools in order to create a syste...
https://python.langchain.com/en/latest/use_cases/personal_assistants.html
44fb51464dca-1
Modify the output parser. This is necessary if the agent is having trouble parsing the language model output. (Optional) Step 3: Modify Agent Executor# This step is usually not necessary, as this is pretty general logic. Possible reasons you would want to modify this include adding different stopping conditions, or han...
https://python.langchain.com/en/latest/use_cases/personal_assistants.html
50659a06d5cf-0
.md .pdf Extraction Extraction# Conceptual Guide Most APIs and databases still deal with structured information. Therefore, in order to better work with those, it can be useful to extract structured information from text. Examples of this include: Extracting a structured row to insert into a database from a sentence Ex...
https://python.langchain.com/en/latest/use_cases/extraction.html
d0ad1271b6c2-0
.md .pdf Code Understanding Contents Conversational Retriever Chain Code Understanding# Overview LangChain 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 generat...
https://python.langchain.com/en/latest/use_cases/code.html
d0ad1271b6c2-1
The full tutorial is available below. Twitter the-algorithm codebase analysis with Deep Lake: A notebook walking through how to parse github source code and run queries conversation. LangChain codebase analysis with Deep Lake: A notebook walking through how to analyze and do question answering over THIS code base. prev...
https://python.langchain.com/en/latest/use_cases/code.html
d097cb622d2b-0
.md .pdf Question Answering over Docs Contents Document Question Answering Adding in sources Additional Related Resources End-to-end examples Question Answering over Docs# Conceptual Guide Question answering in this context refers to question answering over your document data. For question answering over other types ...
https://python.langchain.com/en/latest/use_cases/question_answering.html
d097cb622d2b-1
The LLM response will contain the answer to your question, based on the content of the documents. The recommended way to get started using a question answering chain is: from langchain.chains.question_answering import load_qa_chain chain = load_qa_chain(llm, chain_type="stuff") chain.run(input_documents=docs, question=...
https://python.langchain.com/en/latest/use_cases/question_answering.html
d097cb622d2b-2
Additional Related Resources# Additional related resources include: Utilities for working with Documents: Guides on how to use several of the utilities which will prove helpful for this task, including Text Splitters (for splitting up long documents) and Embeddings & Vectorstores (useful for the above Vector DB example...
https://python.langchain.com/en/latest/use_cases/question_answering.html
d7754bdbb4f2-0
.md .pdf Interacting with APIs Contents Chains Agents Interacting with APIs# Conceptual Guide Lots of data and information is stored behind APIs. This page covers all resources available in LangChain for working with APIs. Chains# If you are just getting started, and you have relatively simple apis, you should get st...
https://python.langchain.com/en/latest/use_cases/apis.html
643b378402bb-0
.rst .pdf Evaluation Contents The Problem The Solution The Examples Other Examples Evaluation# Note Conceptual Guide This section of documentation covers how we approach and think about evaluation in LangChain. Both evaluation of internal chains/agents, but also how we would recommend people building on top of LangCh...
https://python.langchain.com/en/latest/use_cases/evaluation.html
643b378402bb-1
We intend this to be a collection of open source datasets for evaluating common chains and agents. We have contributed five datasets of our own to start, but we highly intend this to be a community effort. In order to contribute a dataset, you simply need to join the community and then you will be able to upload datase...
https://python.langchain.com/en/latest/use_cases/evaluation.html
643b378402bb-2
SQL Question Answering (Chinook): A notebook showing evaluation of a question-answering task over a SQL database (the Chinook database). Agent Vectorstore: A notebook showing evaluation of an agent doing question answering while routing between two different vector databases. Agent Search + Calculator: A notebook showi...
https://python.langchain.com/en/latest/use_cases/evaluation.html
916e9c0ad6d9-0
.md .pdf Chatbots Chatbots# Conceptual Guide Since language models are good at producing text, that makes them ideal for creating chatbots. Aside from the base prompts/LLMs, an important concept to know for Chatbots is memory. Most chat based applications rely on remembering what happened in previous interactions, whic...
https://python.langchain.com/en/latest/use_cases/chatbots.html
faaa358683f4-0
.ipynb .pdf Voice Assistant Voice Assistant# This chain creates a clone of ChatGPT with a few modifications to make it a voice assistant. It uses the pyttsx3 and speech_recognition libraries to convert text to speech and speech to text respectively. The prompt template is also changed to make it more suitable for voice...
https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
faaa358683f4-1
{history} Human: {human_input} Assistant:""" prompt = PromptTemplate( input_variables=["history", "human_input"], template=template ) chatgpt_chain = LLMChain( llm=OpenAI(temperature=0), prompt=prompt, verbose=True, memory=ConversationBufferWindowMemory(k=2), ) import speech_recognition as s...
https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
faaa358683f4-2
engine.runAndWait() listen(None) Calibrating... Okay, go! listening now... Recognizing... C:\Users\jaden\AppData\Roaming\Python\Python310\site-packages\tqdm\auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html from .auton...
https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
faaa358683f4-3
Assistant is aware that human input is being transcribed from audio and as such there may be some errors in the transcription. It will attempt to account for some words being swapped with similar-sounding words or phrases. Assistant will also keep responses concise, because human attention spans are more limited over t...
https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
faaa358683f4-4
Assistant is aware that human input is being transcribed from audio and as such there may be some errors in the transcription. It will attempt to account for some words being swapped with similar-sounding words or phrases. Assistant will also keep responses concise, because human attention spans are more limited over t...
https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
faaa358683f4-5
Overall, Assistant is a powerful tool that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether you need help with a specific question or just want to have a conversation about a particular topic, Assistant is here to assist. Assistant is aware that human ...
https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
faaa358683f4-6
Assistant is constantly learning and improving, and its capabilities are constantly evolving. It is able to process and understand large amounts of text, and can use this knowledge to provide accurate and informative responses to a wide range of questions. Additionally, Assistant is able to generate its own text based ...
https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
faaa358683f4-7
Prompt after formatting: Assistant is a large language model trained by OpenAI. Assistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a language model, Assistant is able to generate human-li...
https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
faaa358683f4-8
Human: I'd like to learn more about neural networks. AI: Sure! Neural networks are a type of artificial intelligence that use a network of interconnected nodes to process data and make decisions. They are used in a variety of applications, from image recognition to natural language processing. Neural networks are oft...
https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
faaa358683f4-9
Overall, Assistant is a powerful tool that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether you need help with a specific question or just want to have a conversation about a particular topic, Assistant is here to assist. Assistant is aware that human ...
https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
faaa358683f4-10
> Entering new LLMChain chain... Prompt after formatting: Assistant is a large language model trained by OpenAI. Assistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a language model, Assis...
https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
faaa358683f4-11
Human: Tell me about a brand new discovered bird species. AI: A new species of bird was recently discovered in the Amazon rainforest. The species, called the Spix's Macaw, is a small, blue parrot that is believed to be extinct in the wild. It is the first new species of bird to be discovered in the Amazon in over 100...
https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
faaa358683f4-12
Assistant is constantly learning and improving, and its capabilities are constantly evolving. It is able to process and understand large amounts of text, and can use this knowledge to provide accurate and informative responses to a wide range of questions. Additionally, Assistant is able to generate its own text based ...
https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
faaa358683f4-13
Human: Tell me a children's story about the importance of honesty and trust. AI: Once upon a time, there was a young boy named Jack who lived in a small village. Jack was always honest and trustworthy, and his friends and family knew they could always count on him. One day, Jack was walking through the forest when he...
https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
faaa358683f4-14
Overall, Assistant is a powerful tool that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether you need help with a specific question or just want to have a conversation about a particular topic, Assistant is here to assist. Assistant is aware that human ...
https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
faaa358683f4-15
Assistant: > Finished chain. You're welcome! listening now... Recognizing... Do you know of online brands like Photoshop and Freq that you don't have to download in some sort of way? Do you know of online brands like Photoshop and Freq that you don't have to download in some sort of way? > Entering new LLMChain chain...
https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
faaa358683f4-16
Human: Wow, Assistant, that was a really good story. Congratulations! AI: Thank you! I'm glad you enjoyed it. Human: Thank you. AI: You're welcome! Human: Do you know of online brands like Photoshop and Freq that you don't have to download in some sort of way? Do you know of online brands like Photoshop and Freq t...
https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
faaa358683f4-17
Overall, Assistant is a powerful tool that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether you need help with a specific question or just want to have a conversation about a particular topic, Assistant is here to assist. Assistant is aware that human ...
https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
faaa358683f4-18
Prompt after formatting: Assistant is a large language model trained by OpenAI. Assistant is designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a language model, Assistant is able to generate human-li...
https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
faaa358683f4-19
AI: Yes, there are several online brands that offer photo editing and other creative tools without the need to download any software. Adobe Photoshop Express, Pixlr, and Fotor are some of the most popular online photo editing tools. Freq is an online music production platform that allows users to create and share musi...
https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
faaa358683f4-20
521 break --> 523 buffer = source.stream.read(source.CHUNK) 524 if len(buffer) == 0: break # reached end of the stream 525 frames.append(buffer) File c:\ProgramData\miniconda3\envs\lang\lib\site-packages\speech_recognition\__init__.py:199, in Microphone.MicrophoneStream.read(self, size) 198 def read(se...
https://python.langchain.com/en/latest/use_cases/chatbots/voice_assistant.html
a60ea5df2579-0
.ipynb .pdf SQL Question Answering Benchmarking: Chinook Contents Loading the data Setting up a chain Make a prediction Make many predictions Evaluate performance SQL Question Answering Benchmarking: Chinook# Here we go over how to benchmark performance on a question answering task over a SQL database. It is highly r...
https://python.langchain.com/en/latest/use_cases/evaluation/sql_qa_benchmarking_chinook.html
a60ea5df2579-1
{'question': 'How many employees are there?', 'answer': '8'} Setting up a chain# This uses the example Chinook database. To set it up follow the instructions on https://database.guide/2-sample-databases-sqlite/, placing the .db file in a notebooks folder at the root of this repository. Note that here we load a simple c...
https://python.langchain.com/en/latest/use_cases/evaluation/sql_qa_benchmarking_chinook.html
a60ea5df2579-2
llm = OpenAI(temperature=0) eval_chain = QAEvalChain.from_llm(llm) graded_outputs = eval_chain.evaluate(predicted_dataset, predictions, question_key="question", prediction_key="result") We can add in the graded output to the predictions dict and then get a count of the grades. for i, prediction in enumerate(predictions...
https://python.langchain.com/en/latest/use_cases/evaluation/sql_qa_benchmarking_chinook.html
804cbbb51c60-0
.ipynb .pdf LLM Math Contents Setting up a chain LLM Math# Evaluating chains that know how to do math. # Comment this out if you are NOT using tracing import os os.environ["LANGCHAIN_HANDLER"] = "langchain" from langchain.evaluation.loading import load_dataset dataset = load_dataset("llm-math") Downloading and prepar...
https://python.langchain.com/en/latest/use_cases/evaluation/llm_math.html
804cbbb51c60-1
sum(correct) / len(correct) 1.0 for i, example in enumerate(dataset): print("input: ", example["question"]) print("expected output :", example["answer"]) print("prediction: ", numeric_output[i]) input: 5 expected output : 5.0 prediction: 5.0 input: 5 + 3 expected output : 8.0 prediction: 8.0 input: 2^3...
https://python.langchain.com/en/latest/use_cases/evaluation/llm_math.html
804cbbb51c60-2
next Evaluating an OpenAPI Chain Contents Setting up a chain By Harrison Chase © Copyright 2023, Harrison Chase. Last updated on May 28, 2023.
https://python.langchain.com/en/latest/use_cases/evaluation/llm_math.html
6abc97556a70-0
.ipynb .pdf Agent Benchmarking: Search + Calculator Contents Loading the data Setting up a chain Make a prediction Make many predictions Evaluate performance Agent Benchmarking: Search + Calculator# Here we go over how to benchmark performance of an agent on tasks where it has access to a calculator and a search tool...
https://python.langchain.com/en/latest/use_cases/evaluation/agent_benchmarking.html
6abc97556a70-1
predictions = [] predicted_dataset = [] error_dataset = [] for data in dataset: new_data = {"input": data["question"], "answer": data["answer"]} try: predictions.append(agent(new_data)) predicted_dataset.append(new_data) except Exception as e: predictions.append({"output": str(e), **...
https://python.langchain.com/en/latest/use_cases/evaluation/agent_benchmarking.html
7ac2a04424b7-0
.ipynb .pdf Data Augmented Question Answering Contents Setup Examples Evaluate Evaluate with Other Metrics Data Augmented Question Answering# This notebook uses some generic prompts/language models to evaluate an question answering system that uses other sources of data besides what is in the model. For example, this...
https://python.langchain.com/en/latest/use_cases/evaluation/data_augmented_question_answering.html
7ac2a04424b7-1
"answer": "Nothing" } ] # Generated examples from langchain.evaluation.qa import QAGenerateChain example_gen_chain = QAGenerateChain.from_llm(OpenAI()) new_examples = example_gen_chain.apply_and_parse([{"doc": t} for t in texts[:5]]) new_examples [{'query': 'According to the document, what did Vladimir Putin miscal...
https://python.langchain.com/en/latest/use_cases/evaluation/data_augmented_question_answering.html
7ac2a04424b7-2
eval_chain = QAEvalChain.from_llm(llm) graded_outputs = eval_chain.evaluate(examples, predictions) for i, eg in enumerate(examples): print(f"Example {i}:") print("Question: " + predictions[i]['query']) print("Real Answer: " + predictions[i]['answer']) print("Predicted Answer: " + predictions[i]['result'...
https://python.langchain.com/en/latest/use_cases/evaluation/data_augmented_question_answering.html
7ac2a04424b7-3
Predicted Answer: I don't know. Predicted Grade: INCORRECT Example 4: Question: How many countries were part of the coalition formed to confront Putin? Real Answer: 27 members of the European Union, France, Germany, Italy, the United Kingdom, Canada, Japan, Korea, Australia, New Zealand, and many others, even Switzer...
https://python.langchain.com/en/latest/use_cases/evaluation/data_augmented_question_answering.html
7ac2a04424b7-4
Predicted Grade: CORRECT Evaluate with Other Metrics# In addition to predicting whether the answer is correct or incorrect using a language model, we can also use other metrics to get a more nuanced view on the quality of the answers. To do so, we can use the Critique library, which allows for simple calculation of va...
https://python.langchain.com/en/latest/use_cases/evaluation/data_augmented_question_answering.html
7ac2a04424b7-5
for k, v in metrics.items() } Finally, we can print out the results. We can see that overall the scores are higher when the output is semantically correct, and also when the output closely matches with the gold-standard answer. for i, eg in enumerate(examples): score_string = ", ".join([f"{k}={v['examples'][i]['val...
https://python.langchain.com/en/latest/use_cases/evaluation/data_augmented_question_answering.html
7ac2a04424b7-6
Example 2: Question: According to the document, what did Vladimir Putin miscalculate? Real Answer: He miscalculated that he could roll into Ukraine and the world would roll over. Predicted Answer: Putin miscalculated that the world would roll over when he rolled into Ukraine. Predicted Scores: rouge=0.5185, chrf=0.695...
https://python.langchain.com/en/latest/use_cases/evaluation/data_augmented_question_answering.html
7ac2a04424b7-7
Question: What action is the U.S. Department of Justice taking to target Russian oligarchs? Real Answer: The U.S. Department of Justice is assembling a dedicated task force to go after the crimes of Russian oligarchs and joining with European allies to find and seize their yachts, luxury apartments, and private jets. P...
https://python.langchain.com/en/latest/use_cases/evaluation/data_augmented_question_answering.html
16983697d113-0
.ipynb .pdf Evaluating an OpenAPI Chain Contents Load the API Chain Optional: Generate Input Questions and Request Ground Truth Queries Run the API Chain Evaluate the requests chain Evaluate the Response Chain Generating Test Datasets Evaluating an OpenAPI Chain# This notebook goes over ways to semantically evaluate ...
https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
16983697d113-1
See Generating Test Datasets at the end of this notebook for more details. # import re # from langchain.prompts import PromptTemplate # template = """Below is a service description: # {spec} # Imagine you're a new user trying to use {operation} through a search bar. What are 10 different things you want to request? # W...
https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
16983697d113-2
dataset [{'question': 'What iPhone models are available?', 'expected_query': {'max_price': None, 'q': 'iPhone'}}, {'question': 'Are there any budget laptops?', 'expected_query': {'max_price': 300, 'q': 'laptop'}}, {'question': 'Show me the cheapest gaming PC.', 'expected_query': {'max_price': 500, 'q': 'gaming ...
https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
16983697d113-3
chain_outputs = [] failed_examples = [] for question in questions: try: chain_outputs.append(api_chain(question)) scores["completed"].append(1.0) except Exception as e: if raise_error: raise e failed_examples.append({'q': question, 'error': e}) scores["complet...
https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
16983697d113-4
'Yes, there are several tablets under $400. These include the Apple iPad 10.2" 32GB (2019), Samsung Galaxy Tab A8 10.5 SM-X200 32GB, Samsung Galaxy Tab A7 Lite 8.7 SM-T220 32GB, Amazon Fire HD 8" 32GB (10th Generation), and Amazon Fire HD 10 32GB.', 'It looks like you are looking for the best headphones. Based on the ...
https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
16983697d113-5
"I found several Nike and Adidas shoes in the API response. Here are the links to the products: Nike Dunk Low M - Black/White: https://www.klarna.com/us/shopping/pl/cl337/3200177969/Shoes/Nike-Dunk-Low-M-Black-White/?utm_source=openai&ref-site=openai_plugin, Nike Air Jordan 4 Retro M - Midnight Navy: https://www.klarna...
https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
16983697d113-6
Jordan 1 Retro High OG M - True Blue/Cement Grey/White: https://www.klarna.com/us/shopping/pl/cl337/3204655673/Shoes/Nike-Air-Jordan-1-Retro-High-OG-M-True-Blue-Cement-Grey-White/?utm_source=openai&ref-site=openai_plugin, Nike Air Jordan 11 Retro Cherry - White/Varsity Red/Black: https://www.klarna.com/us/shopping/pl/c...
https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
16983697d113-7
"I found several skirts that may interest you. Please take a look at the following products: Avenue Plus Size Denim Stretch Skirt, LoveShackFancy Ruffled Mini Skirt - Antique White, Nike Dri-Fit Club Golf Skirt - Active Pink, Skims Soft Lounge Ruched Long Skirt, French Toast Girl's Front Pleated Skirt with Tabs, Alexia...
https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
16983697d113-8
template = """You are trying to answer the following question by querying an API: > Question: {question} The query you know you should be executing against the API is: > Query: {truth_query} Is the following predicted query semantically the same (eg likely to produce the same answer)? > Predicted Query: {predict_query}...
https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
16983697d113-9
' The original query is asking for laptops with a maximum price of 300. The predicted query is asking for laptops with a minimum price of 0 and a maximum price of 500. This means that the predicted query is likely to return more results than the original query, as it is asking for a wider range of prices. Therefore, th...
https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
16983697d113-10
" The original query is asking for the top rated laptops, so the 'size' parameter should be set to 10 to get the top 10 results. The 'min_price' parameter should be set to 0 to get results from all price ranges. The 'max_price' parameter should be set to null to get results from all price ranges. The 'q' parameter shou...
https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
16983697d113-11
' The first part of the query is asking for a Desktop PC, which is the same as the original query. The second part of the query is asking for a size of 10, which is not relevant to the original query. The third part of the query is asking for a minimum price of 0, which is not relevant to the original query. The fourth...
https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
16983697d113-12
Evaluate this against the user’s original question. from langchain.prompts import PromptTemplate template = """You are trying to answer the following question by querying an API: > Question: {question} The API returned a response of: > API result: {api_response} Your response to the user: {answer} Please evaluate the a...
https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
16983697d113-13
request_eval_results [' The original query is asking for all iPhone models, so the "q" parameter is correct. The "max_price" parameter is also correct, as it is set to null, meaning that no maximum price is set. The predicted query adds two additional parameters, "size" and "min_price". The "size" parameter is not nece...
https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
16983697d113-14
' The original query is asking for tablets under $400, so the first two parameters are correct. The predicted query also includes the parameters "size" and "min_price", which are not necessary for the original query. The "size" parameter is not relevant to the question, and the "min_price" parameter is redundant since ...
https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
16983697d113-15
' The original query is asking for a skirt, so the predicted query is asking for the same thing. The predicted query also adds additional parameters such as size and price range, which could help narrow down the results. However, the size parameter is not necessary for the query to be successful, and the price range is...
https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
16983697d113-16
" The API response provided a list of laptops with their prices and attributes. The user asked if there were any budget laptops, and the response provided a list of laptops that are all priced under $500. Therefore, the response was accurate and useful in answering the user's question. Final Grade: A", " The API respo...
https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
16983697d113-17
' The API response provided a list of shoes from both Adidas and Nike, which is exactly what the user asked for. The response also included the product name, price, and attributes for each shoe, which is useful information for the user to make an informed decision. The response also included links to the products, whic...
https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
16983697d113-18
parsed_response_results = parse_eval_results(request_eval_results) # Collect the scores for a final evaluation table scores['result_synthesizer'].extend(parsed_response_results) # Print out Score statistics for the evaluation session header = "{:<20}\t{:<10}\t{:<10}\t{:<10}".format("Metric", "Min", "Mean", "Max") print...
https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
16983697d113-19
Attempting to load an OpenAPI 3.0.1 spec. This may result in degraded performance. Convert your OpenAPI spec to 3.1.* spec for better support. # List the paths in the OpenAPI Spec paths = sorted(spec.paths.keys()) paths ['/v1/public/openai/explain-phrase', '/v1/public/openai/explain-task', '/v1/public/openai/transla...
https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
16983697d113-20
additional_context?: string, /* Full text of the user's question. */ full_query?: string, }) => any; # Compress the service definition to avoid leaking too much input structure to the sample data template = """In 20 words or less, what does this service accomplish? {spec} Function: It's designed to """ prompt = Promp...
https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
16983697d113-21
"I'm looking for the Dutch word for 'no'.", "Can you explain the meaning of 'hello' in Japanese?", "I need help understanding the Russian word for 'thank you'.", "Can you tell me how to say 'goodbye' in Chinese?", "I'm trying to learn the Arabic word for 'please'."] # Define the generation chain to get hypotheses a...
https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html
16983697d113-22
'{"task_description": "Help with pronunciation of \'yes\' in Portuguese", "learning_language": "Portuguese", "native_language": "English", "full_query": "Can you help me with the pronunciation of \'yes\' in Portuguese?"}', '{"task_description": "Find the Dutch word for \'no\'", "learning_language": "Dutch", "native_la...
https://python.langchain.com/en/latest/use_cases/evaluation/openapi_eval.html