This commit is contained in:
Simon Suo
2024-04-18 14:16:57 -07:00
parent d18949c4d7
commit ef7c73321a
2 changed files with 404 additions and 194 deletions
+26
View File
@@ -481,6 +481,32 @@
"for doc in documents:\n",
" upload_document(doc, bucket_name) "
]
},
{
"cell_type": "markdown",
"id": "43c3893e-03d2-4429-9eaf-98d1bb787e51",
"metadata": {},
"source": [
"### Next: Create Amazon Bedrock KB"
]
},
{
"cell_type": "markdown",
"id": "9c163e38-5711-4d60-b7f8-d4729d997037",
"metadata": {},
"source": [
"Now, you can create an Amazon Bedrock KB either:\n",
"1. via the AWS managment console, or\n",
"2. programmatically following this guide: https://github.com/aws-samples/amazon-bedrock-workshop/blob/main/02_KnowledgeBases_and_RAG/0_create_ingest_documents_test_kb.ipynb"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9278cf5e-057d-42ca-8d62-0ad388a0d7f2",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
+378 -194
View File
@@ -8,6 +8,20 @@
"# 2 - Agentic RAG with Bedrock KB and LlamaIndex SubQuestionQueryEngine"
]
},
{
"cell_type": "markdown",
"id": "9da233af-4204-4249-a38f-29aa3fb12e7a",
"metadata": {},
"source": [
"Naive RAG based on top-k search often fail to address complex queries that require reasoning about multiple entities.\n",
"\n",
"In this notebook, we build an agentic RAG system with Bedrock KB and LlamaIndex `SubQuestionQuery Engine`.\n",
"\n",
"Additional resources on `SubQuestionQueryEngine`:\n",
"* tutorial: https://docs.llamaindex.ai/en/stable/examples/query_engine/sub_question_query_engine/\n",
"* API docs: https://docs.llamaindex.ai/en/stable/api_reference/query_engine/sub_question/"
]
},
{
"cell_type": "markdown",
"id": "ab882819-a8a0-4748-8840-e39955c8f96f",
@@ -18,7 +32,7 @@
},
{
"cell_type": "code",
"execution_count": 32,
"execution_count": 2,
"id": "3b9d72e0-91ad-403a-aea7-d3812244678b",
"metadata": {
"scrolled": true
@@ -295,6 +309,36 @@
"%pip install llama-index-retrievers-bedrock"
]
},
{
"cell_type": "markdown",
"id": "678a6063-1d28-4cf4-88fb-01da46f6bb40",
"metadata": {},
"source": [
"### Pre-req: Created Amazon Bedrock KB"
]
},
{
"cell_type": "markdown",
"id": "25106c68-09bf-45f6-8dcb-8103ff6977f6",
"metadata": {},
"source": [
"Here, you should have a running Amazon Bedrock KB. To create one, either:\n",
"1. via the AWS managment console, or\n",
"2. programmatically following this guide: https://github.com/aws-samples/amazon-bedrock-workshop/blob/main/02_KnowledgeBases_and_RAG/0_create_ingest_documents_test_kb.ipynb\n",
"\n",
"Note down the knowledge base ID."
]
},
{
"cell_type": "code",
"execution_count": 31,
"id": "5c44a586-f843-45e6-8cf8-6ba466f03ed2",
"metadata": {},
"outputs": [],
"source": [
"knowledge_base_id = \"JQXQKUAFMZ\""
]
},
{
"cell_type": "markdown",
"id": "55c5a903-fdcb-4326-a0d4-8e44e2895e91",
@@ -305,13 +349,15 @@
},
{
"cell_type": "code",
"execution_count": 35,
"execution_count": 40,
"id": "c19fc0a8-06fc-435c-9298-5632d81902e9",
"metadata": {},
"outputs": [],
"source": [
"from llama_index.core import Settings\n",
"from llama_index.core.query_engine import RetrieverQueryEngine\n",
"from llama_index.core.tools import QueryEngineTool, ToolMetadata\n",
"from llama_index.core.response.pprint_utils import pprint_response\n",
"\n",
"from llama_index.retrievers.bedrock import AmazonKnowledgeBasesRetriever\n",
"from llama_index.llms.bedrock import Bedrock\n",
@@ -320,7 +366,7 @@
},
{
"cell_type": "code",
"execution_count": 37,
"execution_count": 5,
"id": "487a6e1d-f211-46bb-acb1-850eb31602b3",
"metadata": {},
"outputs": [],
@@ -331,159 +377,105 @@
},
{
"cell_type": "code",
"execution_count": 39,
"execution_count": 6,
"id": "2ab469e8-245d-4cf5-a385-23f2046b99fb",
"metadata": {},
"outputs": [],
"source": [
"Settings.llm = llm\n",
"Settings.embed_model = embed_model\n",
"Settings.chunk_size = 512"
"Settings.chunk_size = 1024"
]
},
{
"cell_type": "markdown",
"id": "2cee8d0c-dfe2-417f-8b24-079379822651",
"id": "37b1b2d4-1d1a-4b8a-8077-d77bdf11befb",
"metadata": {},
"source": [
"### Download data"
"### Setup agentic RAG with SubQuestionQueryEngine"
]
},
{
"cell_type": "code",
"execution_count": 40,
"id": "97e0a9c7-7217-4475-86eb-468ebdc16658",
"metadata": {
"collapsed": true,
"jupyter": {
"outputs_hidden": true
},
"scrolled": true
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"--2024-04-18 13:29:33-- https://raw.githubusercontent.com/run-llama/llama_index/main/docs/docs/examples/data/10k/lyft_2021.pdf\n",
"Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 2606:50c0:8001::154, 2606:50c0:8002::154, 2606:50c0:8003::154, ...\n",
"Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|2606:50c0:8001::154|:443... connected.\n",
"HTTP request sent, awaiting response... 200 OK\n",
"Length: 1440303 (1.4M) [application/octet-stream]\n",
"Saving to: ./data/10k/lyft_2021.pdf\n",
"\n",
"./data/10k/lyft_202 100%[===================>] 1.37M --.-KB/s in 0.1s \n",
"\n",
"2024-04-18 13:29:33 (13.8 MB/s) - ./data/10k/lyft_2021.pdf saved [1440303/1440303]\n",
"\n",
"--2024-04-18 13:29:33-- https://raw.githubusercontent.com/run-llama/llama_index/main/docs/docs/examples/data/10k/uber_2021.pdf\n",
"Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 2606:50c0:8001::154, 2606:50c0:8002::154, 2606:50c0:8003::154, ...\n",
"Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|2606:50c0:8001::154|:443... connected.\n",
"HTTP request sent, awaiting response... 200 OK\n",
"Length: 1880483 (1.8M) [application/octet-stream]\n",
"Saving to: ./data/10k/uber_2021.pdf\n",
"\n",
"./data/10k/uber_202 100%[===================>] 1.79M --.-KB/s in 0.08s \n",
"\n",
"2024-04-18 13:29:34 (22.0 MB/s) - ./data/10k/uber_2021.pdf saved [1880483/1880483]\n",
"\n"
]
}
],
"cell_type": "markdown",
"id": "0c5808d6-41ad-44f1-894e-40f017f923d1",
"metadata": {},
"source": [
"!mkdir -p './data/10k/'\n",
"!wget 'https://raw.githubusercontent.com/run-llama/llama_index/main/docs/docs/examples/data/10k/lyft_2021.pdf' -O './data/10k/lyft_2021.pdf'\n",
"!wget 'https://raw.githubusercontent.com/run-llama/llama_index/main/docs/docs/examples/data/10k/uber_2021.pdf' -O './data/10k/uber_2021.pdf'"
"We setup separate retriever & query engine for Uber and Lyft via metadata filters."
]
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 32,
"id": "d45ec59f-5e59-40ca-8016-e2d3796ff9fa",
"metadata": {},
"outputs": [],
"source": [
"knowledge_base_id = \"PO6XCEKGI1\"\n",
"top_k = 4\n",
"search_mode = \"HYBRID\""
]
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 33,
"id": "09dbcf64-181a-46a7-ab10-3c2b250c859f",
"metadata": {
"jupyter": {
"source_hidden": true
}
},
"metadata": {},
"outputs": [],
"source": [
"apple_fpath = \"data/apple_2019.pdf\"\n",
"apple_retriever = AmazonKnowledgeBasesRetriever(\n",
"lyft_fname = \"lyft_2021.pdf\"\n",
"lyft_retriever = AmazonKnowledgeBasesRetriever(\n",
" knowledge_base_id=knowledge_base_id,\n",
" retrieval_config={\n",
" \"vectorSearchConfiguration\": {\n",
" \"numberOfResults\": top_k,\n",
" \"overrideSearchType\": search_mode,\n",
" \"filter\": {\"equals\": {\"key\": \"file_path\", \"value\": apple_fpath}},\n",
" \"filter\": {\"equals\": {\"key\": \"file_name\", \"value\": lyft_fname}},\n",
" }\n",
" },\n",
")\n",
"apple_engine = RetrieverQueryEngine(retriever=apple_retriever)"
"lyft_engine = RetrieverQueryEngine(retriever=lyft_retriever)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 34,
"id": "8e5c7d0a-4760-4f06-9f36-10193c55ecfe",
"metadata": {},
"outputs": [],
"source": [
"tesla_fpath = \"data/tesla_2019.pdf\"\n",
"tesla_retriever = AmazonKnowledgeBasesRetriever(\n",
"uber_fname = \"uber_2021.pdf\"\n",
"uber_retriever = AmazonKnowledgeBasesRetriever(\n",
" knowledge_base_id=knowledge_base_id,\n",
" retrieval_config={\n",
" \"vectorSearchConfiguration\": {\n",
" \"numberOfResults\": top_k,\n",
" \"overrideSearchType\": search_mode,\n",
" \"filter\": {\"equals\": {\"key\": \"file_path\", \"value\": tesla_fpath}},\n",
" \"filter\": {\"equals\": {\"key\": \"file_name\", \"value\": uber_fname}},\n",
" }\n",
" },\n",
")\n",
"tesla_engine = RetrieverQueryEngine(retriever=tesla_retriever)"
"uber_engine = RetrieverQueryEngine(retriever=uber_retriever)"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "91c0f3bb-ceea-41c0-82ce-ea337df24dfc",
"metadata": {},
"outputs": [],
"source": [
"from llama_index.core.tools import QueryEngineTool, ToolMetadata"
]
},
{
"cell_type": "code",
"execution_count": 24,
"execution_count": 35,
"id": "3872f957-68ce-45dc-a152-62e64ac31702",
"metadata": {},
"outputs": [],
"source": [
"tools = [\n",
" QueryEngineTool(\n",
" query_engine=apple_engine,\n",
" query_engine=lyft_engine,\n",
" metadata=ToolMetadata(\n",
" name=\"apple_2019\",\n",
" description=\"10K filing for Apple 2019\",\n",
" name=\"lyft_2021\",\n",
" description=\"10K filing for Lyft 2021\",\n",
" ),\n",
" ),\n",
" QueryEngineTool(\n",
" query_engine=tesla_engine,\n",
" query_engine=uber_engine,\n",
" metadata=ToolMetadata(\n",
" name=\"tesla_2019\",\n",
" description=\"10K filing for Tesla 2019\",\n",
" name=\"uber_2021\",\n",
" description=\"10K filing for Uber 2021\",\n",
" ),\n",
" ),\n",
"]"
@@ -491,7 +483,7 @@
},
{
"cell_type": "code",
"execution_count": 25,
"execution_count": 36,
"id": "8c388cbc-24aa-40ad-9a38-3e4497b6df93",
"metadata": {},
"outputs": [],
@@ -501,7 +493,7 @@
},
{
"cell_type": "code",
"execution_count": 26,
"execution_count": 37,
"id": "9a961416-717e-4bc1-bf19-c78e9b4ee554",
"metadata": {},
"outputs": [],
@@ -511,9 +503,17 @@
")"
]
},
{
"cell_type": "markdown",
"id": "89f84afc-eba2-4d55-9b7f-71f00f51ce0a",
"metadata": {},
"source": [
"### Run queries"
]
},
{
"cell_type": "code",
"execution_count": 27,
"execution_count": 38,
"id": "8e1947b9-b218-4a9f-ab46-91b59bc7e214",
"metadata": {},
"outputs": [
@@ -522,150 +522,334 @@
"output_type": "stream",
"text": [
"Generated 2 sub questions.\n",
"\u001b[1;3;38;2;237;90;200m[apple_2019] Q: What were the key risk areas identified in the 10K filing for Apple in 2019?\n",
"\u001b[0m\u001b[1;3;38;2;90;149;237m[tesla_2019] Q: What were the key risk areas identified in the 10K filing for Tesla in 2019?\n",
"\u001b[0m\u001b[1;3;38;2;237;90;200m[apple_2019] A: Key risk areas identified in the 10K filing for Apple in 2019 included competitive markets, credit risk associated with derivative instruments, potential legal and other claims including intellectual property rights infringement, and exposure to complex and changing laws and regulations worldwide.\n",
"\u001b[0m\u001b[1;3;38;2;90;149;237m[tesla_2019] A: The key risk areas identified in the 10K filing for Tesla in 2019 included automotive revenue recognition controls for sales with resale value guarantees or buyback options, sales return reserves, management's estimation of future market values, historical experience evaluation, economic incentives for customers, warranty reserves for new and used vehicles, and interest rate risk related to borrowings with floating rates.\n",
"\u001b[1;3;38;2;237;90;200m[uber_2021] Q: What was Uber's revenue growth from 2020 to 2021?\n",
"\u001b[0m\u001b[1;3;38;2;237;90;200m[uber_2021] A: Based on the context provided, Uber's revenue grew 57% from 2020 to 2021. Specifically, the context states:\n",
"\n",
"Revenue increased $6.3 billion, or 57%, primarily attributable to an increase in Gross Bookings of 56%, or 53% on a constant currency basis.\n",
"\n",
"And later: \n",
"\n",
"Revenue was $17.5 billion, or up 57% year-over-year, reflecting the overall growth in our Delivery business and an increase in Freight revenue attributable to the acquisition of Transplace in the fourth quarter of 2021 as well as growth in the number of shippers and carriers on the network combined with an increase in volumes with our top shippers.\n",
"\n",
"So Uber's revenue grew by 57% from 2020 to 2021.\n",
"\u001b[0m\u001b[1;3;38;2;90;149;237m[lyft_2021] Q: What was Lyft's revenue growth from 2020 to 2021?\n",
"\u001b[0m\u001b[1;3;38;2;90;149;237m[lyft_2021] A: Based on the provided context, Lyft's revenue in 2021 was $3.2 billion, an increase of 36% compared to revenue of $2.4 billion in 2020. Specifically, the context states:\n",
"\n",
"\"Revenue in 2021 was $3,208 million, an increase of $836 million, or 36%, from $2,372 million in 2020. The increase in revenue was primarily due to growth in Active Riders as recovery from the COVID-19 pandemic continued and demand for our multimodal offerings increased.\"\n",
"\n",
"This indicates that Lyft's revenue grew by 36% from 2020 to 2021.\n",
"\u001b[0m"
]
}
],
"source": [
"response = await query_engine.aquery('compare risks areas for apple and tesla in 2019')"
"response = await query_engine.aquery('Compare revenue growth of Uber and Lyft from 2020 to 2021')"
]
},
{
"cell_type": "code",
"execution_count": 30,
"id": "e320d865-8101-41aa-88c2-c1752193dc7e",
"metadata": {},
"outputs": [],
"source": [
"from llama_index.core.response.pprint_utils import pprint_response"
]
},
{
"cell_type": "code",
"execution_count": 29,
"execution_count": 41,
"id": "6f37234d-9322-48f4-b03f-d034757716ab",
"metadata": {
"scrolled": true
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Final Response: Based on the provided context, Uber's revenue grew by\n",
"57% from 2020 to 2021, increasing from $11.1 billion to $17.5 billion.\n",
"Lyft's revenue grew by 36% over the same period, increasing from $2.4\n",
"billion in 2020 to $3.2 billion in 2021. In summary, Uber\n",
"experienced higher revenue growth compared to Lyft from 2020 to 2021,\n",
"with Uber's revenue growing by 57% compared to 36% growth for Lyft.\n",
"However, both companies saw strong revenue growth during this period\n",
"as demand recovered from the COVID-19 pandemic.\n",
"______________________________________________________________________\n",
"Source Node 1/10\n",
"Node ID: ae3edb68-3448-43c9-a502-4824137c3112\n",
"Similarity: None\n",
"Text: Sub question: What was Uber's revenue growth from 2020 to 2021?\n",
"Response: Based on the context provided, Uber's revenue grew 57% from\n",
"2020 to 2021. Specifically, the context states: Revenue increased\n",
"$6.3 billion, or 57%, primarily attributable to an increase in Gross\n",
"Bookings of 56%, or 53% on a constant currency basis. And later:\n",
"Revenue w...\n",
"______________________________________________________________________\n",
"Source Node 2/10\n",
"Node ID: 2911d1c5-b298-4149-99c1-cba26b2c677d\n",
"Similarity: None\n",
"Text: Sub question: What was Lyft's revenue growth from 2020 to 2021?\n",
"Response: Based on the provided context, Lyft's revenue in 2021 was\n",
"$3.2 billion, an increase of 36% compared to revenue of $2.4 billion\n",
"in 2020. Specifically, the context states: \"Revenue in 2021 was\n",
"$3,208 million, an increase of $836 million, or 36%, from $2,372\n",
"million in 2020....\n",
"______________________________________________________________________\n",
"Source Node 3/10\n",
"Node ID: 9840ec83-4447-42f3-a173-111d35e0cc1f\n",
"Similarity: 0.67621344\n",
"Text: | |—%|—%| |Net loss attributable to Uber Technologies, Inc.|\n",
"|(61)%|(3)%| (1) Totals of percentage of revenues may not foot due to\n",
"rounding. ## Comparison of the Years Ended December 31, 2020 and 2021\n",
"|Revenue|Year Ended December 31,|2020|2021|2020 to 2021 % Change|\n",
"|---|---|---|---|---| |Revenue|$11,139|$17,455|57%| | 2021 Compared\n",
"to 2020 ...\n",
"______________________________________________________________________\n",
"Source Node 4/10\n",
"Node ID: ff11ddbd-a4ae-418e-9783-7821f1e7ebc2\n",
"Similarity: 0.67621344\n",
"Text: Delivery We typically expect to experience seasonal increases\n",
"in our revenue in the first and fourth quarters compared to the second\n",
"and third quarters, although the historical growth of Delivery has\n",
"masked these seasonal fluctuations. In 2021, we experienced less\n",
"seasonality as a result of the COVID-19 pandemic and related\n",
"restrictions, which ...\n",
"______________________________________________________________________\n",
"Source Node 5/10\n",
"Node ID: 885e14a5-22ee-48fb-a44c-e8ccde54f7a0\n",
"Similarity: 0.6697111793963709\n",
"Text: Additionally, we saw an increase in Delivery revenue resulting\n",
"from an increase in certain Courier payments and incentives that are\n",
"recorded in cost of revenue, where we are primarily responsible for\n",
"delivery services and pay Couriers for services provided. Mobility\n",
"Gross Bookings grew 36%, on a constant currency basis, from 2020, due\n",
"to increas...\n",
"______________________________________________________________________\n",
"Source Node 6/10\n",
"Node ID: d79b1840-9718-4d49-bf25-23b2105fe698\n",
"Similarity: 0.6695421\n",
"Text: | |Delivery Adjusted EBITDA| |$(873)|$(348)|60%| | |Adjusted\n",
"EBITDA (1), (2)| |$(2,528)|$(774)|69%| | (1) See the section titled\n",
"“Reconciliations of Non-GAAP Financial Measures” for more information\n",
"and reconciliations to the most directly comparable GAAP financial\n",
"measure. (2) See the section titled “Certain Key Metrics and Non-GAAP\n",
"Financial...\n",
"______________________________________________________________________\n",
"Source Node 7/10\n",
"Node ID: fa07fcf1-890c-40e4-994d-0f0e46d658ec\n",
"Similarity: 0.64853275\n",
"Text: became more widely distributed and more communities reopened.\n",
"Revenue in 2021 also benefited from revenues from licensing and data\n",
"access agreements, beginning in the --- ## Cost of Revenue |Year\n",
"Ended December 31|2021|2020|2019|2020 to 2021 % Change|2019 to 2020 %\n",
"Change| |---|---|---|---|---|---| |\n",
"|$1,649,532|$1,447,516|$2,176,469|14%|(33)%|...\n",
"______________________________________________________________________\n",
"Source Node 8/10\n",
"Node ID: cb0de46d-2133-48cc-94c1-a8017d720e39\n",
"Similarity: 0.64853275\n",
"Text: Revenue per Active Rider increased in each of the three months\n",
"periods ended March 31, June 30, September 30, and December 31, 2021\n",
"as compared to the same periods in 2020, primarily reflecting the\n",
"improvement in demand on our platform compared to earlier periods\n",
"during the COVID-19 pandemic, which had materially limited people's\n",
"mobility and se...\n",
"______________________________________________________________________\n",
"Source Node 9/10\n",
"Node ID: 642dde1f-c305-46f7-a867-90b5bf940825\n",
"Similarity: 0.6256318\n",
"Text: Weve made the commitment to reach 100% electric vehicles\n",
"(“EVs”) on the Lyft network by the end of 2030. We believe many users\n",
"are loyal to Lyft because of our values, brand and commitment to\n",
"social and environmental responsibility. Our values, brand and focus\n",
"on customer experience are key differentiators for our business. We\n",
"continue to beli...\n",
"______________________________________________________________________\n",
"Source Node 10/10\n",
"Node ID: 9d723fd6-38be-491d-8fb6-c2dbba7648c5\n",
"Similarity: 0.61033964\n",
"Text: We believe our transportation network offers a viable\n",
"alternative to car ownership. We generate substantially all of our\n",
"revenue from our ridesharing marketplace that connects drivers and\n",
"riders. We collect service fees and commissions from drivers for their\n",
"use of our ridesharing marketplace. As drivers accept more rider leads\n",
"and complete mor...\n"
]
}
],
"source": [
"pprint_response(response, show_source=True)"
]
},
{
"cell_type": "code",
"execution_count": 42,
"id": "941412b8-ee09-4ac7-ae1d-d99c387d7a76",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Final Response: The key risk areas identified in the 10K filing for\n",
"Apple in 2019 included competitive markets, credit risk associated\n",
"with derivative instruments, potential legal and other claims\n",
"including intellectual property rights infringement, and exposure to\n",
"complex and changing laws and regulations worldwide. On the other\n",
"hand, the key risk areas identified in the 10K filing for Tesla in\n",
"2019 included automotive revenue recognition controls for sales with\n",
"resale value guarantees or buyback options, sales return reserves,\n",
"management's estimation of future market values, historical experience\n",
"evaluation, economic incentives for customers, warranty reserves for\n",
"new and used vehicles, and interest rate risk related to borrowings\n",
"with floating rates.\n",
"Generated 2 sub questions.\n",
"\u001b[1;3;38;2;237;90;200m[uber_2021] Q: What were the major investments made by Uber in 2021?\n",
"\u001b[0m\u001b[1;3;38;2;237;90;200m[uber_2021] A: Based on the provided context, in 2021 Uber:\n",
"\n",
"- Divested its JUMP business and contributed JUMP assets to Lime in exchange for common stock, preferred stock, and warrants in Lime. This gave Uber an approximately 10% fully diluted ownership interest in Lime.\n",
"\n",
"- Made investments in and partnerships with platforms like Carmera and Motional to advance autonomous vehicle technology. \n",
"\n",
"- Continued expanding its Delivery business globally, which grew Gross Bookings by 66% in 2021.\n",
"\n",
"- Saw increased demand for its Mobility business as Trip volumes recovered from the impacts of COVID-19, with Mobility Gross Bookings growing 36% in 2021.\n",
"\n",
"The context indicates these were some of the major investments and strategic moves for Uber in 2021 as it continued to expand its businesses globally.\n",
"\u001b[0m\u001b[1;3;38;2;90;149;237m[lyft_2021] Q: What were the major investments made by Lyft in 2021?\n",
"\u001b[0m\u001b[1;3;38;2;90;149;237m[lyft_2021] A: Based on the context, it seems Lyft made several major investments in 2021, including:\n",
"\n",
"- Investing in research and development to launch new innovations on their platform.\n",
"\n",
"- Making strategic acquisitions to complement their business. The context does not specify what companies were acquired.\n",
"\n",
"- Investing in sales and marketing to grow their community, build their brand, and increase brand awareness. \n",
"\n",
"- Continuing to invest organically and through acquisitions for the future, even with the impact of COVID-19.\n",
"\n",
"- Investing in the expansion of their network of Light Vehicles and Lyft Autonomous to deploy and scale third-party self-driving technology.\n",
"\n",
"- Investing in their LyftUp initiative to provide affordable and reliable transportation options.\n",
"\n",
"- Committing to reach 100% electric vehicles on their platform by 2030.\n",
"\n",
"So in summary, major investments were made in R&D, acquisitions, brand building, expanding transportation offerings, self-driving technology, sustainability initiatives, and continuing to invest for the future.\n",
"\u001b[0m"
]
}
],
"source": [
"response = await query_engine.aquery('Compare the investments made by Uber and Lyft')"
]
},
{
"cell_type": "code",
"execution_count": 43,
"id": "99a6afdb-ca91-4215-bdf8-17a2272fd7cf",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Final Response: Based on the provided context, here is a comparison of\n",
"the major investments made by Uber and Lyft in 2021: Uber: - Divested\n",
"its JUMP business and gained equity stake in Lime through the deal. -\n",
"Made investments in autonomous vehicle technology companies like\n",
"Carmera and Motional. - Expanded its Delivery business globally with\n",
"66% Gross Bookings growth. - Saw increased demand for Mobility\n",
"business with 36% Gross Bookings growth. Lyft: - Invested in research\n",
"and development to launch new innovations. - Made strategic\n",
"acquisitions to complement their business (unspecified companies). -\n",
"Invested in sales, marketing and brand building. - Continued investing\n",
"for future growth despite COVID-19 impacts. - Expanded network of\n",
"Light Vehicles and Lyft Autonomous for self-driving tech. - Invested\n",
"in LyftUp for affordable transportation options. - Committed to 100%\n",
"electric vehicles by 2030. In summary, both made significant\n",
"investments in 2021 - Uber in divesting assets and gaining strategic\n",
"stakes, while expanding core businesses. Lyft focused more on internal\n",
"investments in innovation, brand building, sustainability and future\n",
"growth.\n",
"______________________________________________________________________\n",
"Source Node 1/10\n",
"Node ID: aef1d97a-4824-415a-81e1-a55f62041c40\n",
"Node ID: 891041e2-ee37-4dfc-a2e3-321b51cfe98d\n",
"Similarity: None\n",
"Text: Sub question: What were the key risk areas identified in the 10K\n",
"filing for Apple in 2019? Response: Key risk areas identified in the\n",
"10K filing for Apple in 2019 included competitive markets, credit risk\n",
"associated with derivative instruments, potential legal and other\n",
"claims including intellectual property rights infringement, and\n",
"exposure to ...\n",
"Text: Sub question: What were the major investments made by Uber in\n",
"2021? Response: Based on the provided context, in 2021 Uber: -\n",
"Divested its JUMP business and contributed JUMP assets to Lime in\n",
"exchange for common stock, preferred stock, and warrants in Lime. This\n",
"gave Uber an approximately 10% fully diluted ownership interest in\n",
"Lime. - Made inv...\n",
"______________________________________________________________________\n",
"Source Node 2/10\n",
"Node ID: 400270b3-f089-4b86-b736-7bdd311d97f5\n",
"Node ID: e6284686-3e42-4140-97e5-0257ee3501dd\n",
"Similarity: None\n",
"Text: Sub question: What were the key risk areas identified in the 10K\n",
"filing for Tesla in 2019? Response: The key risk areas identified in\n",
"the 10K filing for Tesla in 2019 included automotive revenue\n",
"recognition controls for sales with resale value guarantees or buyback\n",
"options, sales return reserves, management's estimation of future\n",
"market values, ...\n",
"Text: Sub question: What were the major investments made by Lyft in\n",
"2021? Response: Based on the context, it seems Lyft made several major\n",
"investments in 2021, including: - Investing in research and\n",
"development to launch new innovations on their platform. - Making\n",
"strategic acquisitions to complement their business. The context does\n",
"not specify what...\n",
"______________________________________________________________________\n",
"Source Node 3/10\n",
"Node ID: cefcebde-22f0-4309-b735-ea63829d5c54\n",
"Similarity: 0.56899893\n",
"Text: Licensing The Company licenses the use of certain of its\n",
"intellectual property, and provides other related services. Other\n",
"Services The Company delivers a variety of other services available\n",
"in certain countries, including Apple Arcade™, a game subscription\n",
"service; Apple Card™, a co-branded credit card; Apple News+, a\n",
"subscription news and m...\n",
"Node ID: 554b84d4-0dcb-4d8c-8794-56c2be7a6185\n",
"Similarity: 0.59476256\n",
"Text: The income tax effect of the sale was not material. The\n",
"divestiture of Uber Eats India did not represent a strategic shift\n",
"that would have had a major effect on our operations and financial\n",
"results, and therefore does not qualify for reporting as a\n",
"discontinued operation for financial statement purposes. ##\n",
"Divestiture of JUMP and Investment in...\n",
"______________________________________________________________________\n",
"Source Node 4/10\n",
"Node ID: 12ceba11-656d-473f-b1a1-8fdc76e0bef8\n",
"Similarity: 0.56899893\n",
"Text: The credit risk amounts represent the Companys gross exposure\n",
"to potential accounting loss on derivative instruments that are\n",
"outstanding or unsettled if all counterparties failed to perform\n",
"according to the terms of the contract, based on then-current currency\n",
"or interest rates at each respective date. The Companys exposure to\n",
"credit loss and...\n",
"Node ID: 63dfb873-f6e6-48af-818a-a9a32aab47a4\n",
"Similarity: 0.59476256\n",
"Text: | |Delivery Adjusted EBITDA| |$(873)|$(348)|60%| | |Adjusted\n",
"EBITDA (1), (2)| |$(2,528)|$(774)|69%| | (1) See the section titled\n",
"“Reconciliations of Non-GAAP Financial Measures for more information\n",
"and reconciliations to the most directly comparable GAAP financial\n",
"measure. (2) See the section titled “Certain Key Metrics and Non-GAAP\n",
"Financial...\n",
"______________________________________________________________________\n",
"Source Node 5/10\n",
"Node ID: 1f30a6e5-2fac-444c-a562-ed1432348c2c\n",
"Similarity: 0.5647855781355375\n",
"Text: The SEC maintains an Internet site that contains reports, proxy\n",
"and information statements, and other information regarding issuers\n",
"that file electronically with the SEC at www.sec.gov. The Company\n",
"periodically provides other information for investors on its corporate\n",
"website, www.apple.com, and its investor relations website,\n",
"investor.apple.com...\n",
"Node ID: 461b3944-2cef-4e62-8267-a73cbad6c4e6\n",
"Similarity: 0.58865976\n",
"Text: Delivery We typically expect to experience seasonal increases\n",
"in our revenue in the first and fourth quarters compared to the second\n",
"and third quarters, although the historical growth of Delivery has\n",
"masked these seasonal fluctuations. In 2021, we experienced less\n",
"seasonality as a result of the COVID-19 pandemic and related\n",
"restrictions, which ...\n",
"______________________________________________________________________\n",
"Source Node 6/10\n",
"Node ID: e2fb85bc-b73e-4cf5-be8e-28c62e4c8f50\n",
"Similarity: 0.55775213\n",
"Text: Except as described in Part II, Item 8 of this Form 10-K in the\n",
"Notes to Consolidated Financial Statements in Note 10, “Commitments\n",
"and Contingencies” under the heading “Contingencies,” in the opinion\n",
"of management, there was not at least a reasonable possibility the\n",
"Company may have incurred a material loss, or a material loss greater\n",
"than a re...\n",
"Node ID: 8cc6538b-3ffd-4135-9c24-dba730e5ca9d\n",
"Similarity: 0.57530993\n",
"Text: directly comparable GAAP financial measure. (2) See the section\n",
"titled “Certain Key Metrics and Non-GAAP Financial Measures” below for\n",
"more information. (3) MAPCs presented for annual periods are MAPCs\n",
"for the fourth quarter of the year. (4) Net loss attributable to Uber\n",
"Technologies, Inc. includes stock-based compensation expense of $827\n",
"mil...\n",
"______________________________________________________________________\n",
"Source Node 7/10\n",
"Node ID: b34fa82b-56af-4ad1-b290-e0599be74894\n",
"Similarity: 0.565212\n",
"Text: These procedures included testing the effectiveness of controls\n",
"relating to automotive revenue recognition for sales to customers with\n",
"a resale value guarantee or buyback option as well as the related\n",
"sales return reserve, including controls over managements estimate of\n",
"expected future market values and historical experience. These\n",
"procedures a...\n",
"Node ID: a7b223a8-c050-4dd4-ad93-6facd603c2ae\n",
"Similarity: 0.64772755\n",
"Text: As anoper step in pe shift from personal car ownership, weve\n",
"also launched Lyft Pink, our premier membership program, which offers\n",
"discounted pricing for rideshare, bikes, and scooters, in addition to\n",
"perks for car rentals. We launched our national Resilient Streets\n",
"Initiative in September 2020 and offered a vision for how cities can\n",
"safely and...\n",
"______________________________________________________________________\n",
"Source Node 8/10\n",
"Node ID: 187534f6-30ad-4867-9834-856c507e6cd4\n",
"Similarity: 0.565212\n",
"Text: # SECURITIES AND EXCHANGE COMMISSIONUNITED STATES Washington,\n",
"D.C. 20549 ## FORM 10-K (Mark One) ☒ ANNUAL REPORT PURSUANT TO\n",
"SECTION 13 OR 15(d) OF THE SECURITIES EXCHANGE ACT OF 1934 For the\n",
"fiscal year ended OR December 31, 2019 ☐ TRANSITION REPORT PURSUANT\n",
"TO SECTION 13 OR 15(d) OF THE SECURITIES EXCHANGE ACT OF 1934 For the\n",
"transition...\n",
"Node ID: 8472f66e-7bf7-40ad-8edb-fdcf789d1a3d\n",
"Similarity: 0.64772755\n",
"Text: Together, these investments have enabled us to create a powerful\n",
"multimodal platform and scaled user network. Notwithstanding the\n",
"impact of COVID-19, we are continuing to invest in the future, both\n",
"organically and through acquisitions of complementary businesses. We\n",
"also continue to invest in the expansion of our network of Light\n",
"Vehicles and L...\n",
"______________________________________________________________________\n",
"Source Node 9/10\n",
"Node ID: aa50de0c-2047-4bd3-9752-9a1aa1589488\n",
"Similarity: 0.5628578\n",
"Text: /s/ PricewaterhouseCoopers LLP San Jose, California February\n",
"13, 2020 CERTIFICATIONS Exhibit 31.1 I, Elon Musk, certify that: I\n",
"have reviewed this Annual Report on Form 10-K of Tesla, Inc.; Based on\n",
"my knowledge, this report does not contain any untrue statement of a\n",
"material fact or omit to state a material fact necessary to make the\n",
"statem...\n",
"Node ID: 3762f669-3e9c-4a2d-85d7-4443833f1292\n",
"Similarity: 0.6312369037002221\n",
"Text: We offer drivers the flexibility to generate income on their own\n",
"schedule, so they can best prioritize what is important in their\n",
"lives. - Technology. Our predictive technology around ride volume and\n",
"demand enables us to share key information with drivers about when and\n",
"where to drive to maximize their earnings on a real-time basis. -\n",
"Insurance....\n",
"______________________________________________________________________\n",
"Source Node 10/10\n",
"Node ID: e2ad29a3-ca3a-4ef8-81df-1dee85a72cf9\n",
"Similarity: 0.5622827\n",
"Text: These changes would have resulted in an adverse impact of $362\n",
"million at December 31, 2019 and $176 million at December 31, 2018\n",
"assuming no foreign currency hedging. Interest Rate Risk We are\n",
"exposed to interest rate risk on our borrowings that bear interest at\n",
"floating rates. Pursuant to our risk management policies, in certain\n",
"cases, we ut...\n"
"Node ID: e8c29add-a03d-4158-85ad-14fca5821f62\n",
"Similarity: 0.6138469\n",
"Text: We believe our transportation network offers a viable\n",
"alternative to car ownership. We generate substantially all of our\n",
"revenue from our ridesharing marketplace that connects drivers and\n",
"riders. We collect service fees and commissions from drivers for their\n",
"use of our ridesharing marketplace. As drivers accept more rider leads\n",
"and complete mor...\n"
]
}
],
@@ -676,7 +860,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "941412b8-ee09-4ac7-ae1d-d99c387d7a76",
"id": "ece0dde8-285b-4f01-8ed4-c51666babe93",
"metadata": {},
"outputs": [],
"source": []