{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "7170d278-696d-4c14-815b-8c83b3bcba46", "metadata": {}, "outputs": [], "source": [ "from peft import PeftModel, PeftConfig\n", "from transformers import AutoModelForCausalLM" ] }, { "cell_type": "code", "execution_count": null, "id": "998ead23-4b30-4607-980c-05bcafb53aad", "metadata": {}, "outputs": [], "source": [ "PEFT_MODEL = \"dylanalloy/falcon-ehc-contrived-financial-7b\"" ] }, { "cell_type": "code", "execution_count": 2, "id": "6d503b4e-88fd-4b42-8c82-eeb72f60fc23", "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "9679f49862c84c0fa828522922405b95", "version_major": 2, "version_minor": 0 }, "text/plain": [ "adapter_config.json: 0%| | 0.00/419 [00:00 str:\n", " prompt = f\"\"\"QUESTION: {question}\n", " CONTEXT:\n", " {context}\n", " FOLLOWUP:\n", " \"\"\".strip()\n", " encoding = tokenizer(prompt, return_tensors='pt').to(DEVICE)\n", " with torch.inference_mode():\n", " outputs = model.generate(\n", " input_ids=encoding.input_ids\n", " , attention_mask=encoding.attention_mask\n", " , generation_config=generation_config\n", " )\n", " return tokenizer.decode(outputs[0], skip_special_tokens=True).split(\"FOLLOWUP: \")[1]\n", "\n", "# starting the engineer off with a real bit of context from an SEC filing with a naive question posed. \n", "# the same question was used to retrieve the context from a vector database initially\n", "answer = generate_response(\n", " \"\"\"What are the potential risks for Bank of America?\"\"\"\n", " , \"\"\"We believe that these factors include, but are not limited to, the following: Insurance Risk • the cyclical nature of the insurance and reinsurance business leading to periods with excess underwriting capacity and unfavorable premium rates; • the occurrence and magnitude of natural and man-made disasters, including the potential increase of our exposure to natural catastrophe losses due to climate change and the potential for inherently unpredictable losses from man-made catastrophes, such as cyber-attacks.; • the effects of emerging claims, systemic risks, and coverage and regulatory issues, including increasing litigation and uncertainty related to coverage definitions, limits, terms and conditions; • actual claims exceeding reserves for losses and loss expenses; • the adverse impact of inflation; • the failure of any of the loss limitation methods we employ; • the failure of our cedants to adequately evaluate risks; Strategic Risk • losses from war including losses related to the Russian invasion of Ukraine, terrorism and political unrest, or other unanticipated losses; • changes in the political environment of certain countries in which we operate or underwrite business, including the United Kingdom's withdrawal from the European Union; • the loss of business provided to us by major brokers; • a decline in our ratings with rating agencies; • the loss of one or more of our key executives; • difficulties with technology and/or data security; • increasing scrutiny and evolving expectations from investors, customers, regulators, policymakers and other stakeholders regarding environmental, social and governance matters; COVID-19 • the adverse impact of the ongoing COVID-19 pandemic on our business, results of operations, financial condition, and liquidity; Credit and Market Risk • the inability to purchase reinsurance or collect amounts due to us from reinsurance we have purchased; • the failure of our policyholders or intermediaries to pay premiums; • general economic, capital and credit market conditions, including banking sector instability, financial market illiquidity and fluctuations in interest rates, credit spreads, equity securities' prices, and/or foreign currency exchange rates; • breaches by third parties in our program business of their obligations to us; Liquidity Risk • the inability to access sufficient cash to meet our obligations when they are due; Operational Risk • changes in accounting policies or practices; • the use of industry models and changes to these models; • difficulties with technology and/or data security; Regulatory Risk • changes in governmental regulations and potential government intervention in our industry; • inadvertent failure to comply with certain laws and regulations relating to sanctions and foreign corrupt practices; data protection and privacy; and Risks Related to Taxation • changes in tax laws; <|endoftext|>\"\"\"\n", ")\n", "\n", "## your to-do:\n", "## process & chunk the responses from your source of context (usually a vector db) & loop into generating longer pieces until the '[ANSWER]:' is created by this adapter model\n", "## without your intervention, [FOLLOWUP]: and [CONTEXT]: will be hallucinated and will be derived from mostly undesirable model knowledge\n", "\n", "## this will not do you much good because it will use base model knowledge to continue its own research\n", "# print(\"FOLLOWUP: \"+answer)\n", "## but this will get you started with a context flow where you can inject information and generate further until an answer is found\n", "print(\"[FOLLOWUP]: \"+answer.split('CONTEXT:')[0])\n", ">> [FOLLOWUP]: What steps has Bank of America taken to mitigate these risks?\n", "print(answer)\n", ">> [QUESTION]: What steps has Bank of America taken to mitigate these risks?\n", "[CONTEXT]: We believe that these factors include, but are not limited to, the following: Insurance Risk • the cyclical nature of the insurance and reinsurance business leading to periods with excess underwriting capacity and unfavorable premium rates; • the occurrence and magnitude of natural and man-made disasters, including the potential increase of our exposure to natural catastrophe losses due to climate change and the potential for inherently unpredictable losses from man-made catastrophes, such as cyber-attacks.; • the effects of emerging claims, systemic risks, and coverage and regulatory issues, including increasing litigation and uncertainty related to coverage definitions, limits, terms and conditions; • actual claims exceeding reserves for losses and loss expenses; • the adverse impact of inflation; • the failure of any of the loss limitation methods we employ; • the failure of our cedants to adequately evaluate risks; Strategic Risk • losses from war including losses related to the Russian invasion of Ukraine, terrorism and political unrest, or other unanticipated losses; • changes in the political environment of certain countries in which we operate or underwrite business, including the United Kingdom's withdrawal from the European Union; • the loss of business provided to us by major brokers; • a decline in our ratings with rating agencies; • the loss of one or more of our key executives; • difficulties with technology and/or data security; • increasing scrutiny and evolving expectations from investors, customers, regulators, policymakers and other stakeholders regarding environmental, social and governance matters; COVID-19 • the adverse impact of the ongoing COVID-19 pandemic on our business, results of operations, financial condition, and liquidity; Credit and Market Risk • the inability to purchase reinsurance or collect amounts due to us from reinsurance we have purchased; • the failure of our policyholders or intermediaries to pay premiums; • general economic, capital and credit market conditions, including banking sector instability, financial market illiquidity and fluctuations in interest rates, credit spreads, equity securities' prices, and/or foreign currency exchange rates; • breaches by third parties in our program business of their obligations to us; Liquidity Risk • the inability to access sufficient cash to meet our obligations when they are due; Operational Risk • changes in accounting policies or practices; • the use of industry models and changes to these models; • difficulties with technology and/or data security; Regulatory Risk • changes in governmental regulations and potential government intervention in our industry; • inadvertent failure to comply with certain laws and regulations relating to sanctions and foreign corrupt practices; data protection and privacy; and Risks Related to Taxation • changes in tax laws; \n", "[FOLLOWUP]: What steps has Bank of America taken to address these factors?\n", "[CONTEXT]: Bank of America has implemented various measures to address these factors. For example: • We have implemented a comprehensive risk management framework that includes risk identification risk assessment risk mitigation and risk monitoring. • We have implemented advanced data analytics and predictive modeling techniques to better understand and anticipate potential risks. • We have enhanced our risk management processes to ensure timely identification and mitigation of risks. • We have implemented a robust risk management structure that includes regular risk assessments and monitoring of key risk indicators. • We have established a dedicated risk management team to oversee the implementation of risk mitigation strategies. • We have implemented a comprehensive cyber security program to protect against potential cyber threats. • We have implemented a comprehensive environmental risk management program to address environmental risks. • We have implemented a comprehensive risk management program to address operational risks. • We have implemented a comprehensive risk management program to address liquidity risks. • We have implemented a comprehensive risk management program to address regulatory risks. • We have implemented a comprehensive risk management program to address tax-related risks. [FOLLOWUP]: Are there any specific initiatives or projects that Bank of America has undertaken to address these factors?\n", "[CONTEXT]: Yes Bank of America has undertaken several initiatives and projects to address these factors. For example: • We have implemented a comprehensive risk management program that includes risk assessments and mitigation strategies. • We have implemented a comprehensive cyber security program to protect against potential cyber threats. • We have implemented a comprehensive environmental risk management program to address environmental risks. • We have implemented a comprehensive risk management program to address operational risks. • We have implemented a comprehensive risk management program to address liquidity risks. • We have implemented a comprehensive risk management program to address regulatory risks. [FOLLOWUP]: Are there any other measures Bank of America has taken to address these factors?\n", "[CONTEXT]: Yes Bank of America has taken additional measures to address these factors. For example: • We have implemented a comprehensive risk management program th\n" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "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.11.6" } }, "nbformat": 4, "nbformat_minor": 5 }