Skip to content

Commit

Permalink
Adds explanation to insurance and legal rag
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanhliu21 committed Aug 8, 2024
1 parent fb04d77 commit 20ca45d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 38 deletions.
53 changes: 16 additions & 37 deletions examples/multimodal/insurance_rag.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Building a Multimodal RAG Pipeline over Auto Insurance Claims"
"# Building a Multimodal RAG Pipeline over an Auto Insurance Claim"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"This cookbook shows how to use LlamaParse and OpenAI's multimodal GPT-4o model to parse auto insurance claim documents that contain complex tabular data.\n",
"This cookbook shows how to use LlamaParse and OpenAI's multimodal GPT-4o model to parse auto insurance claim documents that contain complex tabular data. In this example, we will use an auto insurance claim template form, which contains complex tabular inputs regarding information about the location of the accident, accident description, information about vehicles of both parties, and injury information. The template is shown below.\n",
"\n",
"![Auto Insurance Template](https://github.com/user-attachments/assets/aadbaa5b-16d2-490f-be35-f8ee06571633)\n",
"\n",
"This example demonstrates how LlamaParse can be used on insurance documents, which often contains complex tabular data. We parse these tabluar PDF files into markdown-formatted tables, which can be indexed and queried over with a `VectorStoreIndex`. This can help insurance companies accelerate the process of gathering information about car accidents from insurance claim documents."
]
Expand All @@ -31,7 +33,7 @@
"metadata": {},
"outputs": [],
"source": [
"%pip install llama-index llama-parse"
"%pip install llama-index"
]
},
{
Expand All @@ -40,7 +42,7 @@
"metadata": {},
"outputs": [],
"source": [
"!wget https://github.com/user-attachments/files/16445439/claims.zip -O claims.zip\n",
"!wget https://github.com/user-attachments/files/16536240/claims.zip -O claims.zip\n",
"!unzip -o claims.zip\n",
"!rm claims.zip"
]
Expand Down Expand Up @@ -72,7 +74,7 @@
"import os\n",
"\n",
"os.environ[\"OPENAI_API_KEY\"] = \"<Your OpenAI API Key>\"\n",
"os.environ[\"LLAMA_CLOUD_API_KEY\"] = \"<Your LlamaCloud API Key>\""
"os.environ[\"LLAMA_CLOUD_API_KEY\"] = \"<Your Llamacloud API Key>\""
]
},
{
Expand Down Expand Up @@ -240,7 +242,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"## Example Queries"
"Example queries are shown below."
]
},
{
Expand All @@ -251,7 +253,7 @@
{
"data": {
"text/markdown": [
"Michael De Santa filed the insurance claim for the accident that happened on Eclipse Blvd."
"Michael Johnson filed the insurance claim for the accident that happened on Sunset Blvd."
],
"text/plain": [
"<IPython.core.display.Markdown object>"
Expand All @@ -265,7 +267,7 @@
"from IPython.display import display, Markdown\n",
"\n",
"response = query_engine.query(\n",
" \"Who filed the insurance claim for the accident that happened on Eclipse Blvd?\"\n",
" \"Who filed the insurance claim for the accident that happened on Sunset Blvd?\"\n",
")\n",
"display(Markdown(str(response)))"
]
Expand All @@ -278,7 +280,7 @@
{
"data": {
"text/markdown": [
"Ms. Patel's accident occurred on March 10, 2023, at approximately 9:15 AM in the Boise Towne Square Mall parking lot. She was heading west at a parking space and, after checking her mirrors and blind spots, did not see any approaching vehicles. However, Michael Chen, the driver of the other vehicle, was driving too fast through the parking lot and failed to stop in time, resulting in a collision with Ms. Patel's vehicle. The impact caused significant damage to the rear bumper and trunk of her car."
"Ms. Patel's accident occurred on March 10, 2023, at approximately 9:15 AM in the Boise Towne Square Mall parking lot. She was heading west at a parking space and, after checking her mirrors and blind spots, did not see any approaching vehicles. However, Michael Chen, the driver of another vehicle, was driving too fast through the parking lot and failed to stop in time, resulting in a collision with Ms. Patel's vehicle. This caused significant damage to the rear bumper and trunk of her car."
],
"text/plain": [
"<IPython.core.display.Markdown object>"
Expand All @@ -301,7 +303,7 @@
{
"data": {
"text/markdown": [
"Mr. De Santa's red sedan sustained significant damage in a car accident. The initial collision with a blue pickup truck at an intersection caused substantial front-end damage, including crumpled components like the hood, fenders, and bumper. The force of the impact caused the sedan to spin and strike a nearby traffic pole, further damaging the side and rear of the vehicle. The combination of these collisions resulted in severe structural damage, likely compromising the frame, suspension, and other critical systems, rendering the vehicle inoperable."
"Mr. Johnson's red sedan, a 2020 Honda Accord, was damaged on the front passenger side, including a dented fender and a broken headlight. The estimated repair cost is $3,500."
],
"text/plain": [
"<IPython.core.display.Markdown object>"
Expand All @@ -312,7 +314,7 @@
}
],
"source": [
"response = query_engine.query(\"How was Mr. De Santa's red sedan damaged?\")\n",
"response = query_engine.query(\"How was Mr. Johnson's red sedan damaged?\")\n",
"display(Markdown(str(response)))"
]
},
Expand Down Expand Up @@ -347,30 +349,7 @@
{
"data": {
"text/markdown": [
"The blue pickup is owned by Walter White."
],
"text/plain": [
"<IPython.core.display.Markdown object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"response = query_engine.query(\"Who owns the blue pickup?\")\n",
"display(Markdown(str(response)))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [
{
"data": {
"text/markdown": [
"One witness for Ms. Patel's accident is Sophia Rodriguez. She can be contacted at 5554567890."
"The witness for Ms. Patel's accident is Sophia Rodriguez. She can be contacted at 5554567890."
],
"text/plain": [
"<IPython.core.display.Markdown object>"
Expand All @@ -395,7 +374,7 @@
{
"data": {
"text/markdown": [
"Yes, Ms. Johnson sustained minor injuries, including a bruised knee and some whiplash."
"Yes, Ms. Johnson sustained injuries. She experienced minor injuries, including a bruised knee and some whiplash."
],
"text/plain": [
"<IPython.core.display.Markdown object>"
Expand All @@ -420,7 +399,7 @@
{
"data": {
"text/markdown": [
"Mark Johnson is liable for the damages because he collided with the rear of Emily Rodriguez's vehicle while she was braking gently to maintain a safe distance from the vehicle in front of her."
"Mark Johnson is liable for the damages from the accident on Lombard Street. He was driving a delivery van that collided with the rear of Emily Rodriguez's vehicle. In rear-end collisions, the driver who hits the vehicle in front is typically at fault because they are expected to maintain a safe distance and be able to stop in time to avoid a collision."
],
"text/plain": [
"<IPython.core.display.Markdown object>"
Expand Down
14 changes: 13 additions & 1 deletion examples/multimodal/legal.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,19 @@
"source": [
"# Building a RAG Pipeline over Legal Documents\n",
"\n",
"This example shows how LlamaParse and LlamaIndex can be used to parse various types of legal documents, which may contain complex tabular data. The advantage of this is being able to quickly retrieve a specific answer to a legal question with comprehensive context — knowledge of precedents, statutes, and cases presented in the given documents. A user can quickly find the answer to or find out more details about a specific legal question without having to read through the often long documents by using LLMs."
"This example shows how LlamaParse and LlamaIndex can be used to parse various types of legal documents, which may contain complex tabular data. The advantage of this is being able to quickly retrieve a specific answer to a legal question with comprehensive context — knowledge of precedents, statutes, and cases presented in the given documents. A user can quickly find the answer to or find out more details about a specific legal question without having to read through the often long documents by using LLMs.\n",
"\n",
"In this example, we will be using legal documents from the archive of the Library of Congress ([link to dataset](https://www.loc.gov/item/2020445568/)). These documents vary by format, with some containing pure text and others containing headings, sections, and large tables. This shows how LlamaParse can parse a wide variety of documents and still retrieve accurate results.\n",
"\n",
"The documents in this example include:\n",
"- [APA Program Report](https://www.irs.gov/pub/irs-apa/a_2003-19.pdf)\n",
"- [2004 Report on the CRA performance of Barre Savings Bank in Barre, MA](https://github.com/user-attachments/files/16536412/barre_savings_bank_evaluation.pdf)\n",
"- [2016 Energy Supply/Demand Forecast](https://github.com/user-attachments/files/16536415/energy_supply_demand.pdf)\n",
"- [Transcript of Senate Committee Hearing about Foreign Markets](https://github.com/user-attachments/files/16536422/foreign_markets.pdf)\n",
"- [A Motion To Stay for an Indiana Court Case](https://github.com/user-attachments/files/16536427/motion_to_stay.pdf)\n",
"- [Article About an OC Representative's Bill to Introduce Offshore Drilling to CA](https://github.com/user-attachments/files/16536437/oc_bill_offshore_drilling.pdf)\n",
"- [Charter of the Subcommittee on Ocean Science and Technology](https://github.com/user-attachments/files/16536445/ost_subcommittee_charter.pdf)\n",
"- [US Immigration Case](https://github.com/user-attachments/files/16536446/us_immigration_case.pdf)"
]
},
{
Expand Down

0 comments on commit 20ca45d

Please sign in to comment.