Building templates

In the previous lesson, you saw how you can use templates to encode exact role sequences and reject anything that doesn’t match.

However, at the end, you were left with files that were rejected by every template. Here, you’ll work with an LLM to define some new templates that cover the edge cases from the previous lesson.

Run all previous cells first

Make sure you have run every other cell in the notebook before you begin this section.

Here’s how to get started:

  1. Open your notebook and this page in split screen.

  2. Run the first cell in 11. Build your own template

  3. Choose one or more emails, and paste them into the chat.

  4. Tell the LLM what you are trying to do, and paste in the templates you already have from helpers/enron_templates.py

  5. Explicitly ask it to generate a template that will capture this example.

  6. Once the LLM has provided you with a template, add it to the next cell and run.

python
Testing template
# Replace this with the template the LLM returns
MY_TEMPLATE = {
    "name": "my_template",
    "structure": [
        # (L, "from"), (V, "from"),
        # ... paste the LLM's structure here
    ],
}

Summary

  • You can use an LLM to generate template definitions for edge cases that your existing templates reject

  • The workflow is: sample a failure, show the LLM your existing templates, and ask it to generate a new one

  • Test each new template against the corpus before adding it to the pipeline

Chatbot

How can I help you today?

Data Model

Your data model will appear here.