Flag Logical Fallacies with a Browser Extension
David Colaursso
Co-director, Suffolk's Legal Innovation & Tech Lab
This is the 23rd post in my series 50 Days of LIT Prompts.
I'm not an AI doomer in the sense that I don't think much about p(doom)—the probability that AI will end humanity. I'm much more worried about megacorps exploiting AI for profit at the expense of the marginalized. Which is to say, I'm more concerned about the world of RoboCop than I am of the Terminator. So, I am sympathetic to those who worry that AI-generated misinformation could supercharge the asymmetry at the center of Brandolini's Law, which states, "The amount of energy needed to refute bullshit is an order of magnitude bigger than that needed to produce it." There's a lot to worry about in a world where the cost of BS production drops nearly to zero. So, I thought I'd explore what could be done for the side of the angels. Today's template aims to spot and flag logical fallacies based on the text of a webpage—like an AI fact checker of sorts. Below is output from today's template. It's what the template produced from the text of an article documenting a hearing on global warming before the U.S. House of Representatives Science, Space and Technology Committee from May 2018. I found it, and the article that follows in the dateset associated with this post on an training logical fallacy detectors.
{
"fallacies": [
{
"fallacy": "False cause",
"explanation": "The assertion that rocks tumbling into the ocean are causing sea level rise is an example of a false cause fallacy. This argument incorrectly assumes a causal relationship between two events (erosion and sea level rise) without sufficient evidence to prove that one causes the other, especially in the context of global sea level rise driven by climate change."
},
{
"fallacy": "Appeal to authority",
"explanation": "When Rep. Lamar Smith cites an opinion piece published in The Wall Street Journal that claims sea levels are not rising because of climate change, it's an appeal to authority fallacy. This fallacy occurs because the argument relies on the authority of the publication and the author, rather than on scientific evidence or consensus regarding climate change and sea level rise."
},
{
"fallacy": "Personal incredulity",
"explanation": "Rep. Mo Brooks expressing skepticism about mainstream scientific consensus on the factors contributing to sea level rise, despite being presented with evidence from reputable scientific organizations, is an example of personal incredulity. This fallacy is present when someone finds a concept difficult to understand, or outside their personal experience, and therefore concludes it cannot be true."
}
]
}
In case you didn't click through to the article, it was published on Science.com and titled Republican lawmaker: Rocks tumbling into ocean causing sea level rise. Climate scientist tries to correct false statements at hearing. Maybe this is a promising tool we can release at scale to address all that ails or fractured media ecosystem. If we can't get critical thinking an literacy taught in school, maybe this is the silver bullet we've been looking for... Hold that thought. Here's the output from another article, this one from 2017 titled Record-breaking climate change pushes world into 'uncharted territory'.
{
"fallacies": [
{
"fallacy":"Appeal to emotion",
"explanation":"The text uses emotionally charged language, such as describing the climate situation as 'startling' and stating that 'our children and grandchildren will look back on the climate deniers and ask how they could have sacrificed the planet.' This is designed to evoke an emotional response rather than presenting a purely logical argument."
},
{
"fallacy":"Ad hominem",
"explanation":"The text indirectly attacks climate change deniers and the Trump administration by suggesting they 'continue to bury their heads in the sand' and implying they are sacrificing the planet for 'cheap fossil fuel energy.' This could be seen as attacking the character or motives of those who disagree with the presented viewpoint on climate change, rather than addressing their arguments directly."
},
{
"fallacy":"Appeal to authority",
"explanation":"The article references the opinions and statements of various scientists and experts to support its claims about climate change. While their expertise is relevant, the argument leans heavily on their authority without providing detailed evidence for all claims, which could be seen as an appeal to authority."
}
]
}
Originally, I was going to call this post "Bias Bingo," hence the image of the cats and dogs playing bingo, but I ended up setteling on fallacies instead of biases. That being said, I feel the need to focus on one bias for a moment. It's a pet peeve of mine—false balance, sometimes called bothsidesism. False ballance is the tendency of the media to treat both sides of an argument as if they are equally valid even when this isn't supported by the evidence (e.g., providing equal air time to Flat Earthers and NASA scientist). The above smells a lot like bothsidesism. The latter list has a certain feel of truthiness to it. Yes, the second articel does appeal to emotion, but sometimes such appeals are appropriate. Likewise, both articles appeal to authority. However, the fallacy applies only when such an appeal is made blindly without regard for the evidence or relevant expertise such an authority might possess. That being said, the template flagging these aspects of the article did actually force me to more deeply engage with the arguments. So, maybe there's something to it. If I had to pick a use for the template as is, I'd suggest something with a lot of back and forth. I think it could be good for writers to who want to strengthen their arguments. They could point the template at their own writing and defend against any purported fallacies. I wouldn't, however, call its output authoritative.
Evey few years someone comes along saying AI will solve content moderation, but the truth is content moderation is hard, because just like spotting fallacies it requires an understanding of human nuance. Let's be honest, the template was playing the part of a high school debater, looking for structural weaknesses in an argument and narrowly interpreting what facts are in evidence. It's acting like a straw Vulcan, failing not because rationality failed but because it isn't actually acting rationally. Remember, LLMs are sentence completion machines. Here they are engaged in making only what appears to be a rational analysis.
You might be wondering if it's worth the time it would take to work through the example below, and I would say, yes. When you kick the tires, I'll ask you to do your best to "fix" the output, and just like playing Moderator Mayhem (a game that simulates content moderation) the process will help illustrate the difficulties inherent in getting an LLM to "act logically." Do I think these tools will get better? Yes. Do I think that something like this template could actually help people spot logical fallacies? Yes, but just like content moderation, I doubt AI as is can do it all. That being said...
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)
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 {{innerText}}
. See the extension's documentation.
The {{innerText}}
variable will be replaced by the innerText of your current page (roughly speaking the hard-coded text of a page). If you read through the prompt below, its operation is pretty strightforward. You'll note that just like Monday's template, we're using JSON to help structre our output while providing a frame for a chain-of-thought prompt.
FWIW, the list of logical fallacies and their definitions were drawn from the excellent Thou shalt not commit logical fallacies poster, as described here and reformatted by gpt-3.5.
Here's the template's title.
Flag Logical Fallacies with a Browser Extension
Here's the template's text.
You are a high school A Simulated Speech and Debate Coach, working with science and English teachers to help your students better understand common logical fallacies. You're searching for examples of fallacies to highlight and explain to your students. In a moment, I will give you a text to evaluate for logical fallacies. The text may or may not contain fallacies you can use. Be on the lookout for any of the following common logical fallacies:
1. Strawman: Misrepresenting someone's argument to make it easier to attack.
2. False cause: Assuming a relationship between things means that one is the cause of the other.
3. Appeal to emotion: Manipulating an emotional response instead of a valid argument.
4. Fallacy fallacy: Presuming a claim is wrong because it was poorly argued or a fallacy was made.
5. Slippery slope: Claiming that if one thing happens, then extreme outcomes will follow.
6. Ad hominem: Attacking an opponent's character to undermine their argument.
7. Tu quoque: Avoiding criticism by turning it back on the accuser.
8. Personal incredulity: Dismissing something because it's difficult to understand.
9. Special pleading: Moving the goalposts or making exceptions when a claim is shown to be false.
10. Loaded question: Asking a question with a presumption built in to make the answer appear guilty.
11. Burden of proof: Shifting the burden of proof to someone else to disprove a claim.
12. Ambiguity: Using double meanings or ambiguous language to mislead.
13. Gambler's fallacy: Believing that independent events are influenced by past outcomes.
14. Bandwagon: Appealing to popularity as a form of validation.
15. Appeal to authority: Assuming something is true because an authority figure believes it.
16. Composition/division: Assuming something true for a part applies to the whole, or vice versa.
17. No true Scotsman: Dismissing relevant criticisms by appealing to purity.
18. Genetic: Judging something as good or bad based on where it comes from.
19. Black-or-white: Presenting only two alternative states when more possibilities exist.
20. Begging the question: Circular reasoning where the conclusion is included in the premise.
21. Appeal to nature: Arguing that something 'natural' is valid, justified, or ideal.
22. Anecdotal: Using personal experience or isolated examples instead of strong evidence.
23. The Texas sharpshooter: Cherry-picking data to fit a predetermined conclusion.
24. Middle ground: Assuming a compromise between two extremes must be the truth.
---
Here's the text:
{{innerText}}
---
Now that you've read the text. If you found any fallacies, think about the most egregious examples, and provide a list of JSON objects for the worst fallacies. The list should be of the following structure:
{
"fallacies": [
{
"fallacy":"name of fallacy",
"explanation":"explanation of why the text is an example of this fallacy"
},
{
"fallacy":"name of fallacy",
"explanation":"explanation of why the text is an example of this fallacy"
}
]
}
If multiple fallacies are present, provide multiple examples, but no more than three in total. If there are no clear fallacies return:
{
"fallacies": []
}
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:
1000
. 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:
Yes
. This asks the model to output its answer in something called JSON, which is a nice machine-readable way to structure data. See https://en.wikipedia.org/wiki/JSON - 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:
FULL STOP
. Like the choice of output, we can decide what to do after a template runs. To keep things simple, I went with "FULL STOP." - 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.
- Pick a fight. Open three articles you think are particularly insightful and three "hate reads" you think wildly miss the mark. Run the template on them all, and see what you think of its classifications. Do you see where it's coming from? Does it have a point? If you disagree, why? Can you tweak the template to have it behave the way you think it should? What do you have to add? Do you have to tell it that some things are beyond argument? If so, what? Could you defend your choices to someone who disagreed with you on the topic of the offending text?
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.
- Silicon Valley Confronts a Grim New A.I. Metric by Kevin Roose. P(doom), or the probability of doom, is a statistic that some artificial intelligence researchers use to assess the likelihood of an AI apocalypse or other catastrophic event caused by AI. It has become a popular topic of discussion in Silicon Valley, with techies casually asking each other about their p(doom) as a way to gauge their views on the potential risks of AI. The term originated on an online message board called LessWrong and has since been adopted by members of the Effective Altruism movement. However, p(doom) is not a precise measurement and is more about where someone stands on the spectrum of utopia to dystopia. It reflects their thoughts on the potential impact of AI and its regulation. Summary based on a draft from our day one template.
- Decolonial AI: Decolonial Theory as Sociotechnical Foresight in Artificial Intelligence by Shakir Mohamed, Marie-Therese Png & William Isaac. The article discusses the integration of decolonial theory into artificial intelligence (AI) to address ethical and societal impacts. It highlights the importance of critical science and post-colonial theories in understanding AI's role in modern societies, emphasizing the need for a decolonial approach to prevent harm to vulnerable populations. The paper proposes tactics for developing a decolonial AI, including creating a critical technical practice, seeking reverse tutelage, and renewing affective and political communities. These strategies aim to align AI research and technology development with ethical principles, centering on the well-being of all individuals, especially those most affected by technological advancements. Summary based on a draft from our day one template.
- Moderator Mayhem: A Mobile Game To See How Well YOU Can Handle Content Moderation by Mike Masnick. Moderator Mayhem is a mobile browser-based game developed in partnership with Engine that allows players to experience the challenges of content moderation. In the game, players act as front-line content moderators for a fictional review website called TrustHive. They must make quick decisions about whether to keep up or take down user-generated content based on the company's policies. The game aims to provide a realistic understanding of the complex scenarios and competing pressures faced by content moderators. Players receive feedback on their performance and can see how their decisions are perceived by the public and their superiors. The game does not provide a "correct" answer, as content moderation often involves subjective judgment. Summary based on a draft from our day one template.
- Thou shalt not commit logical fallacies by School of Thought. FWIW, this poster hangs in my office at the law school. From the site's description, "A logical fallacy is a flaw in reasoning. Logical fallacies are like tricks or illusions of thought, and they're often very sneakily used by politicians and the media to fool people. Don't be fooled! This website has been designed to help you identify and call out dodgy logic wherever it may raise its ugly, incoherent head."