QA Generation | ğŸ¦œï¸�ğŸ”— Langchain





Skip to main contentğŸ¦œï¸�ğŸ”— LangChainDocsUse casesIntegrationsAPILangSmithJS/TS DocsCTRLKGet startedIntroductionInstallationQuickstartModulesModel I/â€‹OData connectionChainsMemoryAgentsCallbacksModulesGuidesEvaluationString EvaluatorsComparison EvaluatorsTrajectory EvaluatorsExamplesAgent VectorDB Question Answering BenchmarkingComparing Chain OutputsData Augmented Question AnsweringEvaluating an OpenAPI ChainQuestion Answering Benchmarking: Paul Graham EssayQuestion Answering Benchmarking: State of the Union AddressQA GenerationQuestion AnsweringSQL Question Answering Benchmarking: ChinookDebuggingDeploymentLangSmithModel ComparisonEcosystemAdditional resourcesGuidesEvaluationExamplesQA GenerationQA GenerationThis notebook shows how to use the QAGenerationChain to come up with question-answer pairs over a specific document.
This is important because often times you may not have data to evaluate your question-answer system over, so this is a cheap and lightweight way to generate it!from langchain.document_loaders import TextLoaderloader = TextLoader("../../modules/state_of_the_union.txt")doc = loader.load()[0]from langchain.chat_models import ChatOpenAIfrom langchain.chains import QAGenerationChainchain = QAGenerationChain.from_llm(ChatOpenAI(temperature=0))qa = chain.run(doc.page_content)qa[1]    {'question': 'What is the U.S. Department of Justice doing to combat the crimes of Russian oligarchs?',     'answer': 'The U.S. Department of Justice is assembling a dedicated task force to go after the crimes of Russian oligarchs.'}PreviousQuestion Answering Benchmarking: State of the Union AddressNextQuestion AnsweringCommunityDiscordTwitterGitHubPythonJS/TSMoreHomepageBlogCopyright Â© 2023 LangChain, Inc.