AI-assisted LIT Reviews
![A colection of books and sticky notes on a desk in a library](images/50-days/cites.png)
David Colaursso
Co-director, Suffolk's Legal Innovation & Tech Lab
This is the 39th post in my series 50 Days of LIT Prompts.
Today's template builds on Tuesday and Wednesday's use of entity extraction. We'll be using an LLM to extract the citations from scholarly articles and save them to a csv file. After that we can add columns to the file to help make finding copies easier and to track if we've read the articles. Finding and reading all the cites in a paper is often part of the larger process of conducting LIT review. Here's the workflow for this AI-assisted portion.
Extract & Clean
- Open up your scholarly paper. For this example, I used my own Unsupervised Machine Scoring of Free Response Answers—Validated Against Law School Final Exams.
- Select and copy the paper's text into your clipboard.
- Paste the paper's text into the LIT Prompts Scratch Pad (accessible from the extension's popup).
- Select the text in the Scratch Pad, and run the template. Note: You can't run the template from a PDF, it has to be text inside a proper webpage, hence the need to use the Scratch Pad.
- When the template prompts you to save the file, rename it from
output.txt
to something likecites.csv
. If your browser doesn't ask you how to save the file, change the name after it's saved. - Open your csv in your favorite spreadsheet program and add columns that use the title and author to create a web search (e.g.,
=HYPERLINK(TEXTJOIN("?q=",true,"https://scholar.google.com//scholar",TEXTJOIN(" by ",true,B2,A2)),"Google Scholar")
). - Add a column to mark off when you've read the paper.
Pro Tip: If the file you downloaded doesn't open, try opening it with a text editor. There's probably some small formating issue you can fix (e.g., two rows are on the same line or ```
has been placed around the text of the file). Sipily fix the formating and save.
Here's the sheet I produced based on my Unsupervised Machine Scoring paper.
For short papers this works pretty well, but I did try some longer law review articles and it wasn't as good at creating a comprehensive list of citations. Part of this may have been the use of footnotes, but I suspect part of it was also the volume of cites. As always, remember you need to keep LLMs on a short leash. So, my suggestion is that you double check the output. Even with this step, however, I think this still saves you time as you don't have to copy-paste everything.
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
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:
- Select "API keys" from the left menu
- 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:
- open the extension
- click on Templates & Settings
- 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)
![A slide showing the George Box quote: All models are wrong, but some models are useful.](images/boxquote.png)
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 {{highlighted}}
. 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.
For a breakdown of how to use this template, check out the workflow above: Extract & Clean.
Here's the template's title.
Get citations from selected
Here's the template's text.
I'm about to show you a selection of text from an academic paper, complete with citations to other works. Your job is to find all the citations and produce the text for a csv file containing a row for each citation. The csv should have the following headers: "author", "title", "name_of_publication", and "date". Consequently, each row should have the following data all encased in double quotes: author, title, name of publication, and date. Be sure to add a carriage return/line break to the end of each row, including the header row. If part of the information isn't available return "unknown" for that part.
TEXT FROM ACADEMIC PAPER
{{highlighted}}
---
Now provide a line for the header and each citation (row) in the csv file. Return only the text of the file. Do NOT place it in quotes or provide any extraneous text, just the header and rows.
And here are the template's parameters:
- Output Type:
LLM
. This choice means that we'll "run" the template through an LLM (i.e., this will ping an LLM and return a result). Alternatively, we could have chosen "Prompt," in which case the extension would return the text of the completed template. - Model:
gpt-4o-mini
. This input specifies what model we should use when running the prompt. Available models differ based on your API provider. See e.g., OpenAI's list of models. - Temperature:
0
. Temperature runs from 0 to 1 and specifies how "random" the answer should be. Since we're seeking fidelity to a text, I went with the least "creative" setting—0. - Max Tokens:
3000
. This number specifies how long the reply can be. Tokens are chunks of text the model uses to do its thing. They don't quite match up with words but are close. 1 token is something like 3/4 of a word. Smaller token limits run faster. - JSON:
No
. This asks the model to output its answer in something called JSON. We don't need to worry about that here, hence the selection of "No." - Output To:
Screen Only
. We can output the first reply from the LLM to a number of places, the screen, the clipboard... Here, we're content just to have it go to the screen. - Post-run Behavior:
SAVE TO FILE
. Like the choice of output, we can decide what to do after a template runs. Here we will save the output to a file. This will trigger your browser's download feature. - Hide Button:
unchecked
. This determines if a button is displayed for this template in the extension's popup window.
Working with the above template
To work with the above template, 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.
- Take it for a spin. Find some papers of your own ans see how they do.