{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Document Summaries with Small Language Models (SLIMs Cookbook)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### The need for document summaries\n", "\n", "Often, we face an issue with smaller models, where the context window of the model is relatively small. If we want to pass in entire documents to the model that exceed the context window, we need to find a way to summarize the contents of the documents. Let's look at an example of how to do this with LLMWare." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### For Google Colab users" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "If you are using Colab for free, we highly recommend you activate the T4 GPU hardware accelerator. Our models are designed to run with at least 16GB of RAM, activating T4 will grant the notebook 16GB of GDDR6 RAM as apposed to the ~13GB Colab gives automatically.\n", "\n", "To activate T4:\n", "1. click on the \"Runtime\" tab\n", "2. click on \"Change runtime type\"\n", "3. select T4 GPU under Hardware Accelerator\n", "\n", "NOTE: there is a weekly usage limit on using T4 for free" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Installing and importing dependencies" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Defaulting to user installation because normal site-packages is not writeable\n", "Requirement already satisfied: llmware in c:\\users\\prash\\appdata\\roaming\\python\\python311\\site-packages (0.2.14)\n", "Requirement already satisfied: boto3==1.24.53 in c:\\users\\prash\\appdata\\roaming\\python\\python311\\site-packages (from llmware) (1.24.53)\n", "Requirement already satisfied: huggingface-hub>=0.19.4 in c:\\users\\prash\\appdata\\roaming\\python\\python311\\site-packages (from llmware) (0.19.4)\n", "Requirement already satisfied: numpy>=1.23.2 in c:\\users\\prash\\appdata\\roaming\\python\\python311\\site-packages (from llmware) (1.26.0)\n", "Requirement already satisfied: openai>=1.0.0 in c:\\users\\prash\\appdata\\roaming\\python\\python311\\site-packages (from llmware) (1.13.3)\n", "Requirement already satisfied: pymongo>=4.7.0 in c:\\users\\prash\\appdata\\roaming\\python\\python311\\site-packages (from llmware) (4.7.2)\n", "Requirement already satisfied: tokenizers>=0.15.0 in c:\\users\\prash\\appdata\\roaming\\python\\python311\\site-packages (from llmware) (0.15.2)\n", "Requirement already satisfied: torch>=1.13.1 in c:\\users\\prash\\appdata\\roaming\\python\\python311\\site-packages (from llmware) (2.1.0+cu121)\n", "Requirement already satisfied: transformers>=4.36.0 in c:\\users\\prash\\appdata\\roaming\\python\\python311\\site-packages (from llmware) (4.38.2)\n", "Requirement already satisfied: Wikipedia-API==0.6.0 in c:\\users\\prash\\appdata\\roaming\\python\\python311\\site-packages (from llmware) (0.6.0)\n", "Requirement already satisfied: psycopg-binary==3.1.17 in c:\\users\\prash\\appdata\\roaming\\python\\python311\\site-packages (from llmware) (3.1.17)\n", "Requirement already satisfied: psycopg==3.1.17 in c:\\users\\prash\\appdata\\roaming\\python\\python311\\site-packages (from llmware) (3.1.17)\n", "Requirement already satisfied: pgvector==0.2.4 in c:\\users\\prash\\appdata\\roaming\\python\\python311\\site-packages (from llmware) (0.2.4)\n", "Requirement already satisfied: colorama==0.4.6 in c:\\users\\prash\\appdata\\roaming\\python\\python311\\site-packages (from llmware) (0.4.6)\n", "Requirement already satisfied: einops==0.7.0 in c:\\users\\prash\\appdata\\roaming\\python\\python311\\site-packages (from llmware) (0.7.0)\n", "Requirement already satisfied: librosa>=0.10.0 in c:\\users\\prash\\appdata\\roaming\\python\\python311\\site-packages (from llmware) (0.10.2.post1)\n", "Requirement already satisfied: botocore<1.28.0,>=1.27.53 in c:\\users\\prash\\appdata\\roaming\\python\\python311\\site-packages (from boto3==1.24.53->llmware) (1.27.96)\n", "Requirement already satisfied: jmespath<2.0.0,>=0.7.1 in c:\\users\\prash\\appdata\\roaming\\python\\python311\\site-packages (from boto3==1.24.53->llmware) (1.0.1)\n", "Requirement already satisfied: s3transfer<0.7.0,>=0.6.0 in c:\\users\\prash\\appdata\\roaming\\python\\python311\\site-packages (from boto3==1.24.53->llmware) (0.6.2)\n", "Requirement already satisfied: typing-extensions>=4.1 in c:\\users\\prash\\appdata\\roaming\\python\\python311\\site-packages (from psycopg==3.1.17->llmware) (4.8.0)\n", "Requirement already satisfied: tzdata in c:\\users\\prash\\appdata\\roaming\\python\\python311\\site-packages (from psycopg==3.1.17->llmware) (2023.3)\n", "Requirement already satisfied: requests in c:\\users\\prash\\appdata\\roaming\\python\\python311\\site-packages (from Wikipedia-API==0.6.0->llmware) (2.31.0)\n", "Requirement already satisfied: filelock in c:\\users\\prash\\appdata\\roaming\\python\\python311\\site-packages (from huggingface-hub>=0.19.4->llmware) (3.13.1)\n", "Requirement already satisfied: fsspec>=2023.5.0 in c:\\users\\prash\\appdata\\roaming\\python\\python311\\site-packages (from huggingface-hub>=0.19.4->llmware) (2023.10.0)\n", "Requirement already satisfied: tqdm>=4.42.1 in c:\\users\\prash\\appdata\\roaming\\python\\python311\\site-packages (from huggingface-hub>=0.19.4->llmware) (4.66.1)\n", "Requirement already satisfied: pyyaml>=5.1 in c:\\users\\prash\\appdata\\roaming\\python\\python311\\site-packages (from huggingface-hub>=0.19.4->llmware) (6.0.1)\n", "Requirement already satisfied: packaging>=20.9 in c:\\users\\prash\\appdata\\roaming\\python\\python311\\site-packages (from huggingface-hub>=0.19.4->llmware) (23.1)\n", "Requirement already satisfied: audioread>=2.1.9 in c:\\users\\prash\\appdata\\roaming\\python\\python311\\site-packages (from librosa>=0.10.0->llmware) (3.0.1)\n", "Requirement already satisfied: scipy>=1.2.0 in c:\\users\\prash\\appdata\\roaming\\python\\python311\\site-packages (from librosa>=0.10.0->llmware) (1.11.3)\n", "Requirement already satisfied: scikit-learn>=0.20.0 in c:\\users\\prash\\appdata\\roaming\\python\\python311\\site-packages (from librosa>=0.10.0->llmware) (1.3.1)\n", "Requirement already satisfied: joblib>=0.14 in c:\\users\\prash\\appdata\\roaming\\python\\python311\\site-packages (from librosa>=0.10.0->llmware) (1.3.2)\n", "Requirement already satisfied: decorator>=4.3.0 in c:\\users\\prash\\appdata\\roaming\\python\\python311\\site-packages (from librosa>=0.10.0->llmware) (5.1.1)\n", "Requirement already satisfied: numba>=0.51.0 in c:\\users\\prash\\appdata\\roaming\\python\\python311\\site-packages (from librosa>=0.10.0->llmware) (0.59.1)\n", "Requirement already satisfied: soundfile>=0.12.1 in c:\\users\\prash\\appdata\\roaming\\python\\python311\\site-packages (from librosa>=0.10.0->llmware) (0.12.1)\n", "Requirement already satisfied: pooch>=1.1 in c:\\users\\prash\\appdata\\roaming\\python\\python311\\site-packages (from librosa>=0.10.0->llmware) (1.8.1)\n", "Requirement already satisfied: soxr>=0.3.2 in c:\\users\\prash\\appdata\\roaming\\python\\python311\\site-packages (from librosa>=0.10.0->llmware) (0.3.7)\n", "Requirement already satisfied: lazy-loader>=0.1 in c:\\users\\prash\\appdata\\roaming\\python\\python311\\site-packages (from librosa>=0.10.0->llmware) (0.4)\n", "Requirement already satisfied: msgpack>=1.0 in c:\\users\\prash\\appdata\\roaming\\python\\python311\\site-packages (from librosa>=0.10.0->llmware) (1.0.8)\n", "Requirement already satisfied: anyio<5,>=3.5.0 in c:\\users\\prash\\appdata\\roaming\\python\\python311\\site-packages (from openai>=1.0.0->llmware) (4.0.0)\n", "Requirement already satisfied: distro<2,>=1.7.0 in c:\\users\\prash\\appdata\\roaming\\python\\python311\\site-packages (from openai>=1.0.0->llmware) (1.9.0)\n", "Requirement already satisfied: httpx<1,>=0.23.0 in c:\\users\\prash\\appdata\\roaming\\python\\python311\\site-packages (from openai>=1.0.0->llmware) (0.23.3)\n", "Requirement already satisfied: pydantic<3,>=1.9.0 in c:\\users\\prash\\appdata\\roaming\\python\\python311\\site-packages (from openai>=1.0.0->llmware) (2.6.4)\n", "Requirement already satisfied: sniffio in c:\\users\\prash\\appdata\\roaming\\python\\python311\\site-packages (from openai>=1.0.0->llmware) (1.3.0)\n", "Requirement already satisfied: dnspython<3.0.0,>=1.16.0 in c:\\users\\prash\\appdata\\roaming\\python\\python311\\site-packages (from pymongo>=4.7.0->llmware) (2.6.1)\n", "Requirement already satisfied: sympy in c:\\users\\prash\\appdata\\roaming\\python\\python311\\site-packages (from torch>=1.13.1->llmware) (1.12)\n", "Requirement already satisfied: networkx in c:\\users\\prash\\appdata\\roaming\\python\\python311\\site-packages (from torch>=1.13.1->llmware) (3.2.1)\n", "Requirement already satisfied: jinja2 in c:\\users\\prash\\appdata\\roaming\\python\\python311\\site-packages (from torch>=1.13.1->llmware) (3.1.2)\n", "Requirement already satisfied: regex!=2019.12.17 in c:\\users\\prash\\appdata\\roaming\\python\\python311\\site-packages (from transformers>=4.36.0->llmware) (2023.12.25)\n", "Requirement already satisfied: safetensors>=0.4.1 in c:\\users\\prash\\appdata\\roaming\\python\\python311\\site-packages (from transformers>=4.36.0->llmware) (0.4.2)\n", "Requirement already satisfied: idna>=2.8 in c:\\users\\prash\\appdata\\roaming\\python\\python311\\site-packages (from anyio<5,>=3.5.0->openai>=1.0.0->llmware) (2.10)\n", "Requirement already satisfied: python-dateutil<3.0.0,>=2.1 in c:\\users\\prash\\appdata\\roaming\\python\\python311\\site-packages (from botocore<1.28.0,>=1.27.53->boto3==1.24.53->llmware) (2.8.2)\n", "Requirement already satisfied: urllib3<1.27,>=1.25.4 in c:\\users\\prash\\appdata\\roaming\\python\\python311\\site-packages (from botocore<1.28.0,>=1.27.53->boto3==1.24.53->llmware) (1.26.18)\n", "Requirement already satisfied: certifi in c:\\users\\prash\\appdata\\roaming\\python\\python311\\site-packages (from httpx<1,>=0.23.0->openai>=1.0.0->llmware) (2023.7.22)\n", "Requirement already satisfied: httpcore<0.17.0,>=0.15.0 in c:\\users\\prash\\appdata\\roaming\\python\\python311\\site-packages (from httpx<1,>=0.23.0->openai>=1.0.0->llmware) (0.16.3)\n", "Requirement already satisfied: rfc3986<2,>=1.3 in c:\\users\\prash\\appdata\\roaming\\python\\python311\\site-packages (from rfc3986[idna2008]<2,>=1.3->httpx<1,>=0.23.0->openai>=1.0.0->llmware) (1.5.0)\n", "Requirement already satisfied: llvmlite<0.43,>=0.42.0dev0 in c:\\users\\prash\\appdata\\roaming\\python\\python311\\site-packages (from numba>=0.51.0->librosa>=0.10.0->llmware) (0.42.0)\n", "Requirement already satisfied: platformdirs>=2.5.0 in c:\\users\\prash\\appdata\\roaming\\python\\python311\\site-packages (from pooch>=1.1->librosa>=0.10.0->llmware) (3.10.0)\n", "Requirement already satisfied: annotated-types>=0.4.0 in c:\\users\\prash\\appdata\\roaming\\python\\python311\\site-packages (from pydantic<3,>=1.9.0->openai>=1.0.0->llmware) (0.6.0)\n", "Requirement already satisfied: pydantic-core==2.16.3 in c:\\users\\prash\\appdata\\roaming\\python\\python311\\site-packages (from pydantic<3,>=1.9.0->openai>=1.0.0->llmware) (2.16.3)\n", "Requirement already satisfied: charset-normalizer<4,>=2 in c:\\users\\prash\\appdata\\roaming\\python\\python311\\site-packages (from requests->Wikipedia-API==0.6.0->llmware) (3.2.0)\n", "Requirement already satisfied: threadpoolctl>=2.0.0 in c:\\users\\prash\\appdata\\roaming\\python\\python311\\site-packages (from scikit-learn>=0.20.0->librosa>=0.10.0->llmware) (3.2.0)\n", "Requirement already satisfied: cffi>=1.0 in c:\\users\\prash\\appdata\\roaming\\python\\python311\\site-packages (from soundfile>=0.12.1->librosa>=0.10.0->llmware) (1.15.1)\n", "Requirement already satisfied: MarkupSafe>=2.0 in c:\\users\\prash\\appdata\\roaming\\python\\python311\\site-packages (from jinja2->torch>=1.13.1->llmware) (2.1.3)\n", "Requirement already satisfied: mpmath>=0.19 in c:\\users\\prash\\appdata\\roaming\\python\\python311\\site-packages (from sympy->torch>=1.13.1->llmware) (1.3.0)\n", "Requirement already satisfied: pycparser in c:\\users\\prash\\appdata\\roaming\\python\\python311\\site-packages (from cffi>=1.0->soundfile>=0.12.1->librosa>=0.10.0->llmware) (2.21)\n", "Requirement already satisfied: h11<0.15,>=0.13 in c:\\users\\prash\\appdata\\roaming\\python\\python311\\site-packages (from httpcore<0.17.0,>=0.15.0->httpx<1,>=0.23.0->openai>=1.0.0->llmware) (0.14.0)\n", "Requirement already satisfied: six>=1.5 in c:\\users\\prash\\appdata\\roaming\\python\\python311\\site-packages (from python-dateutil<3.0.0,>=2.1->botocore<1.28.0,>=1.27.53->boto3==1.24.53->llmware) (1.16.0)\n", "Note: you may need to restart the kernel to use updated packages.\n" ] } ], "source": [ "%pip install llmware" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "import os\n", "\n", "from llmware.prompts import Prompt\n", "from llmware.setup import Setup" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Worker function" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The process for summarizing the document is as follows:\n", "- The document gets split up into batches (each batch can be a few pages long)\n", "- The SLIM Summary tool summarizes each batch into a list of points\n", "- The points from each batch are aggregated at the end and printed, and the output is also available as a Python list\n", "\n", "The LLMWare library provides several sample files for you to run this example with, but if you wanted to use your own documents, then you can pass in the following optional parameters for the summarization:\n", "- Topic: all the points in the summary will be about this topic\n", "- Query: it is used to filter which parts of the document are considered for the summarization (only text chunks matching the query will be considered)" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "def test_summarize_document(example=\"jd salinger\"):\n", "\n", " # pull a sample document (or substitute a file_path and file_name of your own)\n", " sample_files_path = Setup().load_sample_files(over_write=False)\n", "\n", " topic = None\n", " query = None\n", " fp = None\n", " fn = None\n", "\n", " if example not in [\"jd salinger\", \"employment terms\", \"just the comp\", \"un resolutions\"]:\n", " print (\"not found example\")\n", " return []\n", "\n", " if example == \"jd salinger\":\n", " fp = os.path.join(sample_files_path, \"SmallLibrary\")\n", " fn = \"Jd-Salinger-Biography.docx\"\n", " topic = \"jd salinger\"\n", " query = None\n", "\n", " if example == \"employment terms\":\n", " fp = os.path.join(sample_files_path, \"Agreements\")\n", " fn = \"Athena EXECUTIVE EMPLOYMENT AGREEMENT.pdf\"\n", " topic = \"executive compensation terms\"\n", " query = None\n", "\n", " if example == \"just the comp\":\n", " fp = os.path.join(sample_files_path, \"Agreements\")\n", " fn = \"Athena EXECUTIVE EMPLOYMENT AGREEMENT.pdf\"\n", " topic = \"executive compensation terms\"\n", " query = \"base salary\"\n", "\n", " if example == \"un resolutions\":\n", " fp = os.path.join(sample_files_path, \"SmallLibrary\")\n", " fn = \"N2126108.pdf\"\n", " # fn = \"N2137825.pdf\"\n", " topic = \"key points\"\n", " query = None\n", "\n", " # optional parameters: 'query' - will select among blocks with the query term\n", " # 'topic' - will pass a topic/issue as the parameter to the model to 'focus' the summary\n", " # 'max_batch_cap' - caps the number of batches sent to the model\n", " # 'text_only' - returns just the summary text aggregated\n", "\n", " kp = Prompt().summarize_document_fc(fp, fn, topic=topic, query=query, text_only=True, max_batch_cap=15)\n", "\n", " print(f\"\\nDocument summary completed - {len(kp)} Points\")\n", " for i, points in enumerate(kp):\n", " print(i, points)\n", "\n", " return 0" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Main function" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Here, we have our function call to the worker function above." ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "Example: Summarize Documents\n", "\n", "update: Prompt - summarize_document_fc - document - Athena EXECUTIVE EMPLOYMENT AGREEMENT.pdf\n", "update: Prompt - summarize_document_fc - number of source batches - 14\n", "update: iterating through source batches - 0 - ['Accrued Compensation - all compensation reimbursements and other amounts earned by payable to or accrued and vested for Executive through and including Executives Date of Termination including but not limited to (i) Base Salary; (ii) Executives Incentive Bonus for the fiscal year that ended immediately prior to Executives Date of Termination to the extent such Incentive Bonus was accrued and earned by but not yet paid to Executive as of Executives Date of Termination; (iii) pay for accrued but unused vacation; and (iv) reimbursable business expenses incurred by Executive on behalf of Employer']\n", "update: iterating through source batches - 1 - ['Not Found']\n", "update: iterating through source batches - 2 - ['Not to exceed 5% of base salary', 'Material Competitor', 'Sale of the Company', 'Material breach of the terms of the agreement']\n", "update: iterating through source batches - 3 - ['Base Salary: $500,000 annual rate', 'Target Bonus: 80% of base salary (\"Target Bonus\")', 'Incentive Bonus: 125% of base salary (\"Incentive Bonus\")', 'Sale Bonus: 2.5% of the equity value of the company, up to $1,000,000', 'Transition Bonus: $350,000, payable on October 1, 2013 and October 1, 2014']\n", "update: iterating through source batches - 4 - ['25 vacation days', '7 fixed holidays', '7 floating holidays', 'reimbursement of reasonable expenses', 'Initial stock options grant', 'Severance of up to 12 months salary and severance bonus if employment is terminated without Cause or resignation for Good Reason']\n", "update: iterating through source batches - 5 - ['Severance Executive will receive severance in monthly installments in accordance with Employers regular payroll practices during the Severance Period', 'Sale Bonus If the Executives employment is terminated by the Company without Cause or due to Executives resignation for Good Reason prior to the payment of the First Transition Bonus then the Company will pay the Executive a lump-sum cash amount equal to the First Transition Bonus on the First Payment Date', 'Health Care Continuation If Executive is eligible for and elects to receive continuation group health coverage mandated by Section 4980B of the Internal Revenue Code or similar state laws (', ') during the Severance Period then the Company will reimburse Executive for the amount of the COBRA premiums and the Company will reimburse Executive for the amount of the COBRA premiums']\n", "update: iterating through source batches - 6 - ['Not Found']\n", "update: iterating through source batches - 7 - ['Not Found']\n", "update: iterating through source batches - 8 - ['Not Found']\n", "update: iterating through source batches - 9 - ['Not Found']\n", "update: iterating through source batches - 10 - ['Not Found']\n", "update: iterating through source batches - 11 - ['Not Found']\n", "update: iterating through source batches - 12 - ['Notwithstanding any provision of the agreement to the contrary, if the Executive is a \"specified employee\" at the time of separation from service, then the payments or benefits otherwise payable pursuant to the agreement will be postponed to prevent any accelerated or additional tax under Section 409A of the Code', 'If any payments or benefits are postponed due to Section 409A of the Code, then the Executive will be entitled to be paid interest on such amount at an annual rate equal to the prime rate plus 2%', 'If the Executive dies during the postponement period, then the amounts withheld on account of Section 409A of the Code will be paid to the estate of the Executive within sixty days after the date of death']\n", "update: iterating through source batches - 13 - ['Not Found']\n", "\n", "Document summary completed - 23 Points\n", "0 Accrued Compensation - all compensation reimbursements and other amounts earned by payable to or accrued and vested for Executive through and including Executives Date of Termination including but not limited to (i) Base Salary; (ii) Executives Incentive Bonus for the fiscal year that ended immediately prior to Executives Date of Termination to the extent such Incentive Bonus was accrued and earned by but not yet paid to Executive as of Executives Date of Termination; (iii) pay for accrued but unused vacation; and (iv) reimbursable business expenses incurred by Executive on behalf of Employer\n", "1 Not to exceed 5% of base salary\n", "2 Material Competitor\n", "3 Sale of the Company\n", "4 Material breach of the terms of the agreement\n", "5 Base Salary: $500,000 annual rate\n", "6 Target Bonus: 80% of base salary (\"Target Bonus\")\n", "7 Incentive Bonus: 125% of base salary (\"Incentive Bonus\")\n", "8 Sale Bonus: 2.5% of the equity value of the company, up to $1,000,000\n", "9 Transition Bonus: $350,000, payable on October 1, 2013 and October 1, 2014\n", "10 25 vacation days\n", "11 7 fixed holidays\n", "12 7 floating holidays\n", "13 reimbursement of reasonable expenses\n", "14 Initial stock options grant\n", "15 Severance of up to 12 months salary and severance bonus if employment is terminated without Cause or resignation for Good Reason\n", "16 Severance Executive will receive severance in monthly installments in accordance with Employers regular payroll practices during the Severance Period\n", "17 Sale Bonus If the Executives employment is terminated by the Company without Cause or due to Executives resignation for Good Reason prior to the payment of the First Transition Bonus then the Company will pay the Executive a lump-sum cash amount equal to the First Transition Bonus on the First Payment Date\n", "18 Health Care Continuation If Executive is eligible for and elects to receive continuation group health coverage mandated by Section 4980B of the Internal Revenue Code or similar state laws (\n", "19 ) during the Severance Period then the Company will reimburse Executive for the amount of the COBRA premiums and the Company will reimburse Executive for the amount of the COBRA premiums\n", "20 Notwithstanding any provision of the agreement to the contrary, if the Executive is a \"specified employee\" at the time of separation from service, then the payments or benefits otherwise payable pursuant to the agreement will be postponed to prevent any accelerated or additional tax under Section 409A of the Code\n", "21 If any payments or benefits are postponed due to Section 409A of the Code, then the Executive will be entitled to be paid interest on such amount at an annual rate equal to the prime rate plus 2%\n", "22 If the Executive dies during the postponement period, then the amounts withheld on account of Section 409A of the Code will be paid to the estate of the Executive within sixty days after the date of death\n" ] } ], "source": [ "if __name__ == \"__main__\":\n", "\n", " print(f\"\\nExample: Summarize Documents\\n\")\n", "\n", " # 4 examples - [\"jd salinger\", \"employment terms\", \"just the comp\", \"un resolutions\"]\n", " # -- \"jd salinger\" - summarizes key points about jd salinger from short biography document\n", " # -- \"employment terms\" - summarizes the executive compensation terms across 15 page document\n", " # -- \"just the comp\" - queries to find subset of document and then summarizes the key terms\n", " # -- \"un resolutions\" - summarizes the un resolutions document\n", "\n", " summary_direct = test_summarize_document(example=\"employment terms\")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We're given an output of 23 points summarizing the `employment terms` sample document!\n", "\n", "Note that several batches gave us an output of `Not Found`, indicating that there were no relevant points related to the topic of `executive compensation terms`. This is the topic that was passed in to the `summarize_document_fc()` function call in our worker function. The model gave us the output of `Not Found` rather than unrelated points with no meaning to our topic!" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "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.0" } }, "nbformat": 4, "nbformat_minor": 2 }