{ "cells": [ { "cell_type": "markdown", "id": "60bb467d-861d-4b07-a48d-8e5aa177c969", "metadata": {}, "source": [ "# Email Extraction\n", "\n", "\n", "Let's evaluate an LLM on its ability to extract structured information from email texts." ] }, { "cell_type": "code", "execution_count": null, "id": "47de0d20-d20b-44be-9e41-d2275f0866e8", "metadata": { "tags": [] }, "outputs": [], "source": [ "%pip install -U langchain langchain_benchmarks openai rapidfuzz" ] }, { "cell_type": "code", "execution_count": null, "id": "c401de19-814e-4bd7-bb9c-7ea6e217985c", "metadata": { "tags": [] }, "outputs": [], "source": [ "import os\n", "\n", "# Get your API key from https://smith.langchain.com/settings\n", "os.environ[\"LANGCHAIN_API_KEY\"] = \"sk-...\"\n", "os.environ[\"OPENAI_API_KEY\"] = \"sk-...\"" ] }, { "cell_type": "code", "execution_count": 1, "id": "b39159d0-9ea1-414f-a9d8-4a7b22b3d2cc", "metadata": { "tags": [] }, "outputs": [], "source": [ "from langchain_benchmarks import clone_public_dataset, registry" ] }, { "cell_type": "markdown", "id": "03488ab1-31ed-41c2-8da2-46b02599b181", "metadata": {}, "source": [ "For this code to work, please configure LangSmith environment variables with your credentials." ] }, { "cell_type": "code", "execution_count": 2, "id": "60f22779-a948-4833-8e8c-ace9ef17f56f", "metadata": { "tags": [] }, "outputs": [ { "data": { "text/html": [ "
Name | Email Extraction |
Type | ExtractionTask |
Dataset ID | a1742786-bde5-4f51-a1d8-e148e5251ddb |
Description | A dataset of 42 real emails deduped from a spam folder, with semantic HTML tags removed, as well as a script for initial extraction and formatting of other emails from an arbitrary .mbox file like the one exported by Gmail.\n", "\n", "Some additional cleanup of the data was done by hand after the initial pass.\n", "\n", "See https://github.com/jacoblee93/oss-model-extraction-evals. |
\n", " | inputs.input | \n", "outputs.output | \n", "reference | \n", "feedback.json_edit_distance | \n", "feedback.score_string:accuracy | \n", "error | \n", "execution_time | \n", "inputs.input_claude | \n", "outputs.output_claude | \n", "reference_claude | \n", "feedback.json_edit_distance_claude | \n", "feedback.score_string:accuracy_claude | \n", "error_claude | \n", "execution_time_claude | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
61c40266-b994-49a2-8768-d54704cee079 | \n", "--- \\n|\\n\\nEvery business faces its set of cu... | \n", "{'sender': 'EMC Financial', 'sender_address': ... | \n", "{'output': {'tone': 'positive', 'topic': 'Busi... | \n", "0.562112 | \n", "0.7 | \n", "None | \n", "4.358837 | \n", "--- \\n|\\n\\nEvery business faces its set of cu... | \n", "{'sender': 'Sam', 'sender_phone_number': '800.... | \n", "{'output': {'tone': 'positive', 'topic': 'Busi... | \n", "0.301242 | \n", "0.7 | \n", "None | \n", "10.501042 | \n", "
2dcfadff-51dc-458c-8af0-f47a795d0c9b | \n", "Hello Jacob!\\n\\n \\n\\nHave you noticed thesurg... | \n", "{'sender': 'Sam at EMC', 'action_items': ['Fil... | \n", "{'output': {'tone': 'positive', 'topic': 'Gree... | \n", "0.505338 | \n", "0.7 | \n", "None | \n", "3.946547 | \n", "Hello Jacob!\\n\\n \\n\\nHave you noticed thesurg... | \n", "{'sender': 'Sam at EMC', 'sender_phone_number'... | \n", "{'output': {'tone': 'positive', 'topic': 'Gree... | \n", "0.113879 | \n", "0.7 | \n", "None | \n", "8.511848 | \n", "
a9c481ba-9ca5-408c-8c9c-f29127a70f7b | \n", "Hi there,\\n\\n | \\n--- \\n \\nWe've updated ou... | \n", "{'sender': 'Crunchbase Team', 'action_items': ... | \n", "{'output': {'tone': 'positive', 'topic': 'Upda... | \n", "0.245283 | \n", "0.9 | \n", "None | \n", "3.972396 | \n", "Hi there,\\n\\n | \\n--- \\n \\nWe've updated ou... | \n", "{'sender': None, 'sender_phone_number': None, ... | \n", "{'output': {'tone': 'positive', 'topic': 'Upda... | \n", "0.343434 | \n", "0.7 | \n", "None | \n", "9.739630 | \n", "
98358188-6e36-42ef-9298-83acf8d9dd12 | \n", "Consider all ways to give to \\nSave the Redwo... | \n", "{'sender': 'Tim Whalen', 'sender_address': 'Sa... | \n", "{'output': {'tone': 'positive', 'topic': 'Dona... | \n", "0.280556 | \n", "0.7 | \n", "None | \n", "3.890567 | \n", "Consider all ways to give to \\nSave the Redwo... | \n", "{'sender': None, 'sender_phone_number': None, ... | \n", "{'output': {'tone': 'positive', 'topic': 'Dona... | \n", "0.255556 | \n", "0.3 | \n", "None | \n", "9.640687 | \n", "
0f29e857-fc08-45dd-b1ea-dde1e00c4a62 | \n", "Some travelers plan ahead; others prefer a bit... | \n", "{'sender': 'Dunhill Vacations Inc.', 'sender_a... | \n", "{'output': {'tone': 'positive', 'topic': 'Trav... | \n", "0.552463 | \n", "0.7 | \n", "None | \n", "4.252478 | \n", "Some travelers plan ahead; others prefer a bit... | \n", "{'sender': 'Dunhill Vacations Inc.', 'sender_p... | \n", "{'output': {'tone': 'positive', 'topic': 'Trav... | \n", "0.584582 | \n", "0.3 | \n", "None | \n", "6.803259 | \n", "
\n", " | inputs.input | \n", "outputs.output | \n", "outputs.output_claude | \n", "
---|---|---|---|
98358188-6e36-42ef-9298-83acf8d9dd12 | \n", "Consider all ways to give to \\nSave the Redwo... | \n", "{'sender': 'Tim Whalen', 'sender_address': 'Sa... | \n", "{'sender': None, 'sender_phone_number': None, ... | \n", "
0f29e857-fc08-45dd-b1ea-dde1e00c4a62 | \n", "Some travelers plan ahead; others prefer a bit... | \n", "{'sender': 'Dunhill Vacations Inc.', 'sender_a... | \n", "{'sender': 'Dunhill Vacations Inc.', 'sender_p... | \n", "
35414bbc-4d38-41ed-876f-2a6a067e66d5 | \n", "--- \\n \\n|\\n\\nWe Passed the Stop Dangerous P... | \n", "{'sender': 'Matt Haney', 'sender_address': '10... | \n", "{'sender': 'Matt Haney', 'sender_phone_number'... | \n", "
ff1b2ed6-26a7-4501-96aa-6e3e10eadc72 | \n", "--- \\n|\\n\\n# We Provide Unique Financing Opti... | \n", "{'sender': 'info@championadvance.com', 'sender... | \n", "{'sender': None, 'sender_phone_number': None, ... | \n", "
\n", " | inputs.input | \n", "outputs.output | \n", "outputs.output_claude | \n", "
---|---|---|---|
02cfdfc4-c3dc-47e6-ad44-8e437ebf2dce | \n", "---|---|---|--- \\n \\n| \\n--- \\n **Limited ... | \n", "{'action_items': [], 'topic': 'Limited Time Up... | \n", "{'sender': 'Dunhill Vacations Inc.', 'sender_p... | \n", "
198dc232-8f98-484a-a65e-048cfb517282 | \n", "Hello Jacob,\\n\\n \\n\\nFor many small businesse... | \n", "{'sender': 'Sam at EMC', 'action_items': ['Kic... | \n", "{'sender': 'Sam at EMC', 'sender_phone_number'... | \n", "
c222957f-cc7e-46af-9cca-1270f3fa5621 | \n", "Hello Jacob,\\n\\n \\n\\nDo you know what Fortune... | \n", "{'sender': 'Sam at EMC', 'action_items': ['qua... | \n", "{'sender': 'Sam at EMC', 'sender_phone_number'... | \n", "
119ef037-8744-4eb9-93df-64458278e4f8 | \n", "--- \\n| | QUALIFY NOW \\n--- \\n \\n \\nHell... | \n", "{'sender': 'Sam at EMC', 'action_items': ['Che... | \n", "{'sender': 'Sam at EMC id:2023-09-19-20:17:53:... | \n", "