# 2.1.3. Extraction

LLMs can also effectively extract information from large volumes of text. Common use cases involving extraction prompts include, but are not limited to:

* **Information Retrieval**: Extracting specific information from large datasets or complex documents, like identifying key terms, phrases, or sections in legal documents.
* **Named Entity Recognition (NER)**: Extracting named entities such as people, organizations, locations, dates, etc. from a text.
* **Event Extraction**: Identifying and extracting key events, participants, etc. from a given text.

### Example: Corporate Organizational Charts

The blockchain industry has had a string of tumultuous events shakeup the recently. Arguably, the most infamous event was the collapse of FTX, the once high-flying cryptocurrency exchange and hedge fund that filed for bankruptcy in November of 2022. To be more specific, FTX, and **over 100** of its subsidiaries filed for bankruptcy. Imagine the amount of effort required from bankruptcy lawyers to uncover the intricacies of the relationships between all these corporate entities into something that can be easily understood... Enter ChatGPT 🙂

The example prompt below demonstrates how we can perform NER extraction to compile an organizational chart.

```
Prompt:
Identify all corporate entities (businesses), along with their parent companies, 
subsidiaries, and affiliates in the text below. Output in dot language.

Text:
Plaintiff Securities and Exchange Commission (the “SEC” or the “Commission”) for 
its Complaint against Defendants Coinbase, Inc. (“Coinbase”) and Coinbase Global, Inc. 
(“CGI”) (collectively, “Defendants”). CGI—Coinbase’s parent company to which 
Coinbase’s revenues flow—is a control person of Coinbase and thus violated the same 
Exchange Act provisions as Coinbase.
```

This is a contrived example, but it shows that we can direct ChatGPT to extract specific types of information along with additional metadata. Here, we're not simply asking for an exhaustive list of all corporate entities mentioned in the text, we also want to understand the relationships between these entities. You can see our interaction with ChatGPT using this prompt [here](https://chat.openai.com/share/99790c89-a1a5-49ac-bead-48ac3d8689e7). Something that we haven't seen yet, but will be discussed at length in [chapter 4](/4.-ethical-guardrails-and-professional-responsibility.md) are "Output Parsers." In our example prompt above, we provide ChatGPT with a specific instruction – "Output in dot language." ChatGPT keeps things simple, it receives text as input, and returns text as output. One thing that many users don't realize, is that we can ask ChatGPT to return different types of text, text that has specific syntactical meaning, text that represents a computer programming language, etc. In this example, we're interested in generating some type of visual representation of an organizational chart. In this prompt, we are asking ChatGPT to provide its response in Dot language (used to generate visual diagrams–will be covered in [chapter 4](/4.-ethical-guardrails-and-professional-responsibility.md)). We can take the Dot language response provided by ChatGPT to generate an image like the one below:

<figure><img src="/files/yHBmInxPlkOzqQy8hb0O" alt=""><figcaption><p>This image was generated via ChatGPT's response:<br> <code>digraph { "Coinbase Global, Inc." -> "Coinbase, Inc." [label="Parent"] }</code></p></figcaption></figure>

Extraction prompts can be used heavily by law firms to solve a variety a different problems. In the next section, we'll present an example that uses extraction with few-example prompting to automate a common workflow dreaded by countless attorneys and paralegals.

&#x20;


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.legalpromptguide.com/2.-fundamentals-of-legal-prompt-engineering/2.1.-prompt-templates/2.1.3.-extraction.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
