File size: 11,558 Bytes
10d6a86 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
{
"cells": [
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"The autoreload extension is already loaded. To reload it, use:\n",
" %reload_ext autoreload\n"
]
}
],
"source": [
"%load_ext autoreload\n",
"%autoreload 2\n",
"\n",
"import sys\n",
"sys.path.append('../')\n",
"\n",
"from dotenv import load_dotenv, find_dotenv\n",
"envs = load_dotenv(find_dotenv('env'), override=True)\n",
"\n",
"from warnings import filterwarnings\n",
"filterwarnings('ignore')\n",
"\n",
"from llm.llm import LLM\n",
"\n",
"from litellm import ModelResponse\n",
"\n",
"from typing import Literal\n",
"from rich import print\n",
"import os"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"#instantiate the LLM Class\n",
"turbo = 'gpt-3.5-turbo-0125'\n",
"#the LLM Class will use the OPENAI_API_KEY env var as the default api_key \n",
"llm = LLM(turbo)\n",
"\n",
"# use the gpt3.5 model that is free - recent"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [],
"source": [
"vs = [\"Lastly, during the quarter, we increased our reserves for general product and automobile self-\\ninsurance liabilities, driven by changes in our estimates about the cost of asserted and unasserted \\nclaims, resulting in additional expense of $1.3 billion. This impact is primarily recorded in cost of \\nsales on our income statement. As our business has grown quickly over the last several years, \\nparticularly as we've built out our fulfillment and transportation network, and claim amounts have \\nseen industry-wide inflation, we've continued to evaluate and adjust this reserve for both asserted \\nclaims, as well as our estimate for unasserted claims.\\nWe reported overall net income of $278 million in the fourth quarter. While we primarily focus our \\ncomments on operating income, I'd point out that this net income includes a pre-tax valuation loss \\nof $2.3 billion included in non-operating income from our common stock investment in Rivian \\nAutomotive. As we've noted in recent quarters, this activity is not related to Amazon's ongoing \\noperations, but rather the quarter-to-quarter fluctuations in Rivian's stock price. As we head into \\nthe New Year, we remain heads down focused on driving a better customer experience.\",\"tenet of we want to find a way to meaningfully streamline our costs in all of our businesses, not \\njust their existing large businesses, but also in some of the investments we're making, we want to \\nactually do a pretty good thorough look about what we're investing and how much we think we \\nneed to. But doing so, without having to give up our ability to invest in the key long-term strategic \\ninvestments that we think could change broad customer experiences, and change Amazon over \\ntime.\\nAnd you saw that process led to us choosing to pause on incremental headcount, as we tried to \\nassess what was happening in the economy, and we eliminated some programs, Fabric.com, and \\nAmazon Care, and Amazon Glow, and Amazon Explore, and we decided to go slower on some -- \\non the physical store expansion and the grocery space until we had a format that we really \\nbelieved in rolling out, and we went a little bit slower on some devices. Until we made the very \\nhard decision that Brian talked about earlier, which was the hardest decision I think we've all been \\na part of, which was to reduce or eliminate 18,000 roles.\",\"operating income. This operating income was negatively impacted by three large items, which \\nadded approximately $2.7 billion of costs in the quarter. This is related to employee severance, \\nimpairments of property and equipment and operating leases, and changes in estimates related to \\nself-insurance liabilities. These costs primarily impacted our North America segment. If we had not \\nincurred these charges in Q4, our operating income would have been approximately $5.4 billion. \\nWe are encouraged with the progress we continue to make in streamlining the costs in our \\nAmazon Stores business. We entered the quarter with labor more appropriately matched to \\ndemand across our operations network, compared to Q4 of last year, allowing us to have the right \\nlabor, in the right place, at the right time, and drive productivity gains. We also saw continued \\nefficiencies across our transportation network, where process and tech improvements resulted in \\nhigher Amazon Logistics productivity and improved line haul fill rates. While transportation \\noverperformed expectations in the quarter, we also saw productivity improvements across our \\nfulfillment centers, in line with our plan. We also saw good leverage driven by strong holiday \\nvolumes.\"]"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'Search result 0: The 2022 decline reflects the separation of U.S. videoand lower personnel costs associated with ongoingtransformation initiatives, partially offset by higher baddebt expense, the elimination of Connect America FundPhase II (CAF II) government credits and increasedwholesale network access charges. Wireless equipmentcosts were up slightly, with higher sales volumes and thesale of higher-priced smartphones largely offset by lower3G shutdown costs in 2022. In the first quarter of 2022, weupdated the expected economic lives of customerrelationships, which extended the amortization period ofdeferred acquisition and fulfillment costs and reducedexpenses approximately $395, with $150 recorded toMobility, $115 to Business Wireline and $130 to ConsumerWireline.\\nThe 2021 decline reflects our 2021 business divestitures,\\nlower bad debt expense and lower personnel costsassociated with our transformation initiatives. Declineswere mostly offset by increased domestic wirelessequipment expense from higher volumes.\\nAsset impairments and abandonments and\\nrestructuring increased in 2022 and decreased in 2021.\\nSearch result 1: The 2022 decline reflects the separation of U.S. videoand lower personnel costs associated with ongoingtransformation initiatives, partially offset by higher baddebt expense, the elimination of Connect America FundPhase II (CAF II) government credits and increasedwholesale network access charges. Wireless equipmentcosts were up slightly, with higher sales volumes and thesale of higher-priced smartphones largely offset by lower3G shutdown costs in 2022. In the first quarter of 2022, weupdated the expected economic lives of customerrelationships, which extended the amortization period ofdeferred acquisition and fulfillment costs and reducedexpenses approximately $395, with $150 recorded toMobility, $115 to Business Wireline and $130 to ConsumerWireline.\\nThe 2021 decline reflects our 2021 business divestitures,\\nlower bad debt expense and lower personnel costsassociated with our transformation initiatives. Declineswere mostly offset by increased domestic wirelessequipment expense from higher volumes.\\nAsset impairments and abandonments and\\nrestructuring increased in 2022 and decreased in 2021.\\nSearch result 2: Credit Losses As of January 1, 2020, we adopted,\\nthrough modified retrospective application, ASU No.2016-13, “Financial Instruments—Credit Losses (Topic 326):Measurement of Credit Losses on Financial Instruments,”or Accounting Standards Codification (ASC) 326 (ASC 326),which replaces the incurred loss impairment methodologyunder prior GAAP with an expected credit loss model. ASC326 affects trade receivables, loans, contract assets,certain beneficial interests, off-balance-sheet creditexposures not accounted for as insurance and otherfinancial assets that are not subject to fair value throughnet income, as defined by the standard. Under theexpected credit loss model, we are required to considerfuture economic trends to estimate expected creditlosses over the lifetime of the asset. Upon adoption onJanuary 1, 2020, we recorded a $293 reduction to“Retained earnings,” $395 increase to “Allowances forcredit losses” applicable to our trade and loan receivables,$10 reduction of contract assets, $105 reduction of netdeferred income tax liability and $7 reduction of“Noncontrolling interest.” Our adoption of ASC 326 did nothave a material impact on our financial statements.'"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"searches"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"\"Amazon's loss includes a pre-tax valuation loss of $2.3 billion included in non-operating income from their common stock investment in Rivian Automotive. This loss is not related to Amazon's ongoing operations but rather reflects quarter-to-quarter fluctuations in Rivian's stock price.\""
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"system_message = \"\"\"\n",
"You are a financial analyst, with a deep expertise in financial reports.\n",
"You are able to quickly understand a series of paragraphs, or quips even, extracted from financial reports by a vector search system. \n",
"\"\"\" \n",
"searches = \"\\n\".join([f\"Search result {i}: {v}\" for i,v in enumerate(vs,1)])\n",
"\n",
"question = \"What is Amazon's loss?\"\n",
"\n",
"user_prompt = f\"\"\"\n",
"Use the below context enclosed in triple back ticks to answer the question. \\n\n",
"The context is given by a vector search into a vector database of financial reports, so you can assume the context is accurate.\n",
"They search results are given in order of relevance (most relevant first). \\n\n",
"```\n",
"Context:\n",
"```\n",
"{searches}\n",
"```\n",
"Question:\\n\n",
"{question}\\n\n",
"------------------------\n",
"1. If the context does not provide enough information to answer the question, then\n",
"state that you cannot answer the question with the provided context.\n",
"2. Do not use any external knowledge or resources to answer the question.\n",
"3. Answer the question directly and with as much detail as possible, within the limits of the context.\n",
"------------------------\n",
"Answer:\\n\n",
"\"\"\".format(searches=searches, question=question)\n",
"\n",
"\n",
"response = llm.chat_completion(system_message=system_message,\n",
" user_message=user_prompt,\n",
" temperature=0.01,\n",
" stream=False,\n",
" raw_response=False)\n",
"response\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "venv",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.14"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
|