Sadly Not, Havoc Dinosaur

Add Email Asks to My To-Do List

Find the "asks" in an email; produce a bulleted list of same; add these to a to-do list; save to a file

Headshot of the author, Colarusso. David Colaursso

This is the 8th post in my series 50 Days of LIT Prompts.

I'm a big fan of lists. If there's one productivity hack worth its salt, it's the list. Create a list of discrete tasks, and check them off as you go. It's simple and it works, and although people joke about their inboxes serving as to-do lists, let's face the fact that a lot of email authors don't always put their asks front and center. Given LLMs' facility with words, I think there's something we can do about that.

Last week we introduced a template to help answer emails. Today, we'll ask our LLM to figure out what an email is asking of us, produce a set of action items, and add these to a to-do list. We'll also show you how save your scratch pad to a file.

As we've noted before, our ability to answer such questions is improved if we understand how the tools we're using actually work. Which is to say, here's where we pause to share a micro-lesson. You can skim over or skip this if you like. However, if you make it through these micro-lessons, the payoff will be big. Like, "understand what this AI thing actually is" big.

Micro-Lesson: Document Classification

Yesterday, we discussed how word2vec's ability to encode words as numbers allowed us to do math with words. Today, we'll look at how those numbers can also be used to help us classify documents based on their subject matter. You'll remember that we said each word gets assigned some point in 300-diminsional space. At the time, I said not to think about that too hard, and now I want to introduce a tool we can use to avoid trying to visualize that which we cannot. It's called a projection. Imagine you have three groupings of points in two-dimensional space.

Consider the first image above. You can cast shadows from these points on the y-axis. Alternatively, as shown in the second image you could cast shadows on the x-axis. However, in both of these cases you're missing something. In both of these cases we only see two groupings of shadows. It turns out that there is some special angle at which we could place a line upon which to cast our shadows such that we don't lose sight of the three groups. For example, our third image above. Alas, the method for figuring out exactly where to hold our shadow catcher is beyond the scope of this post. In this way we can take the information contained in our two-dimensional space and capture some sense of its structure in 1 dimension (the line of shadows).

Likewise, we can take words in our 300-dimensional space and produce a 2-D projection. That is, if we want to "visualize" what's going on with something like 300-diminsions, we can make use of a projection to get a sense of what's going on. The trick is finding the right surface upon which to cast our shadows. Imagine that we take all the words in a document and find their average using the numeric values we got from word2vec. In this way we can produce a point in our 300-diminsional space corresponding to each document. And using a projection, we can see the shadows cast by these points. The following image shows such a projection for a collection of news articles. The difference being that instead of word2vec a different method (tf-idf) was used to produce the numbers associated with each document. The observations we're about to make, however, hold across the two.

You'll see that the category of an article is specified by color and that articles from the same category are grouped together. This is a consequence of similar articles existing close to each other in the space of numbers used by their encoding methods. But the point I want to get across today is simply this. You can see that there is structure to the grouping of articles. There are borders between the different categories. This means that if a new article is added to the plot, we can make a guess about its category based only on where it falls. We call such a classification, document classification.

Hold on to that for a while. Next week we'll tie everything together. Enough talking, let's build something!

We'll do our building in the LIT Prompts extension. If you aren't familiar with the LIT Prompts extension, don't worry. We'll walk you through setting things up before we start building. If you have used the LIT Prompts extension before, skip to The Prompt Pattern (Template).

Up Next

Questions or comments? I'm on Mastodon @Colarusso@mastodon.social


Setup LIT Prompts

7 min intro video

LIT Prompts is a browser extension built at Suffolk University Law School's Legal Innovation and Technology Lab to help folks explore the use of Large Language Models (LLMs) and prompt engineering. LLMs are sentence completion machines, and prompts are the text upon which they build. Feed an LLM a prompt, and it will return a plausible-sounding follow-up (e.g., "Four score and seven..." might return "years ago our fathers brought forth..."). LIT Prompts lets users create and save prompt templates based on data from an active browser window (e.g., selected text or the whole text of a webpage) along with text from a user. Below we'll walk through a specific example.

To get started, follow the first four minutes of the intro video or the steps outlined below. Note: The video only shows Firefox, but once you've installed the extension, the steps are the same.

Install the extension

Follow the links for your browser.

  • Firefox: (1) visit the extension's add-ons page; (2) click "Add to Firefox;" and (3) grant permissions.
  • Chrome: (1) visit the extension's web store page; (2) click "Add to Chrome;" and (3) review permissions / "Add extension."

If you don't have Firefox, you can download it here. Would you rather use Chrome? Download it here.

Point it at an API

Here we'll walk through how to use an LLM provided by OpenAI, but you don't have to use their offering. If you're interested in alternatives, you can find them here. You can even run your LLM locally, avoiding the need to share your prompts with a third-party. If you need an OpenAI account, you can create one here. Note: when you create a new OpenAI account you are given a limited amount of free API credits. If you created an account some time ago, however, these may have expired. If your credits have expired, you will need to enter a billing method before you can use the API. You can check the state of any credits here.

Login to OpenAI, and navigate to the API documentation.

Once you are looking at the API docs, follow the steps outlined in the image above. That is:

  1. Select "API keys" from the left menu
  2. Click "+ Create new secret key"

On LIT Prompt's Templates & Settings screen, set your API Base to https://api.openai.com/v1/chat/completions and your API Key equal to the value you got above after clicking "+ Create new secret key". You get there by clicking the Templates & Settings button in the extension's popup:

  1. open the extension
  2. click on Templates & Settings
  3. enter the API Base and Key (under the section OpenAI-Compatible API Integration)

Once those two bits of information (the API Base and Key) are in place, you're good to go. Now you can edit, create, and run prompt templates. Just open the LIT Prompts extension, and click one of the options. I suggest, however, that you read through the Templates and Settings screen to get oriented. You might even try out a few of the preloaded prompt templates. This will let you jump right in and get your hands dirty in the next section.

If you receive an error when trying to run a template after entering your Base and Key, and you are using OpenAI, make sure to check the state of any credits here. If you don't have any credits, you will need a billing method on file.

If you found this hard to follow, consider following along with the first four minutes of the video above. It covers the same content. It focuses on Firefox, but once you've installed the extension, the steps are the same.


The Prompt Pattern (Template)

When crafting a LIT Prompts template, we use a mix of plain language and variable placeholders. Specifically, you can use double curly brackets to encase predefined variables. If the text between the brackets matches one of our predefined variable names, that section of text will be replaced with the variable's value. Today we'll be using the {{highlighted}} and {{scratch}} variables. See the extension's documentation.

The {{highlighted}} variable contains any text you have highlighted/selected in the active browser tab when you open the extension, and the {{scratch}} variable contains the text in your Scratch Pad. Remember, the scratch pad is accessible from the extension's popup window. The button is to the right of the Settings & Templates button that you have used before. That being said, we're actually introducing two templates today. The first will produce a list of action items and append them to your Scratch Pad, and the second will save the content of your Scratch Pad to a file.

To run the first template, highlight the text of an email, and run. The LLM will generate a draft to do list and place it at the end of your Sctrach Pad. To accomplish this last part be sure to set output to "Screen + append to scratch pad."

Remember, you are potentially highlighting sensitive or otherwise private data. So, you need to think carefully about the particulars of your situation. For example, if you're running LM Studio locally then there isn't much to consider as the information won't leave your computer. However, if you're using some other API provider, you will be sending them the contents of anything you select. One thing you have going in your favor is that as an API user you may be subject to special terms that better protect your privacy. For example, as of this writing, users of OpenAI's API were subject to a different set of terms than users of ChatGPT. Namely, they are subject to the Business Terms which importantly preclude the use of your data for training purposes. This is important because if your data is being used to train an LLM it may one day come out the other end.

Here's the first template's title.

Get email asks

Here's the template's text.

Your name is David. Here's an email or email thread you just received. 

---

{{highlighted}}

---

For the above email or email thread, draft a bulleted list of action items either explicitly or implicitly suggested by the email(s). Add a parenthetical to each stating who should be doing it.

Action Items:

And here are the first template's parameters:

To be entirely honest, this next part is mostly just to introduce the "SAVE TO FILE" post-run behavior. That being said, I can think of a lot of situations when it might be nice to save the scratch pad contents to a file. So, this is a handy template to have in your library.

Here's the second template's title.

Save scratch pad to file

Here's the template's text.

{{scratch}}

Pretty simple, eh? And here are the second template's parameters:

Working with the above templates

To work with the above templates, you could copy it and its parameters into LIT Prompts one by one, or you could download a single prompts file and upload it from the extension's Templates & Settings screen. This will replace your existing prompts.

You can download a prompts file (the above template and its parameters) suitable for upload by clicking this button:


Kick the Tires

It's one thing to read about something and another to put what you've learned into practice. Let's see how this template performs.


TL;DR References

ICYMI, here are blubs for a selection of works I linked to in this post. If you didn't click through above, you might want to give them a look now.