Welcome back to Professor Farahany’s AI Law and Policy Class. Congratulations, you’re “enrolled” in the asynchronous version of my class. Today, we are going to talk about how AI actually works. It’s technical, but we break it down into simpler terms.
Consider this your official seat in my class, except that rather than showing up at 8:30 a.m. each day, you get to keep your job, skip the debt, and maybe, just maybe, sleep in. Every Monday and Wednesday, you get to virtually attend my AI Law & Policy class alongside my actual Duke Law students. They’re taking notes, you should be, too. And realize that our in-person class is 100 minutes. Take your time working through the material.
New here? You've missed Class 1 where we discussed “What is AI?” and discovered that nobody really knows. You should read it first, because this class builds on that foundation.
By the end of this class, you should have a much better understanding of the now classic gaffe when Steven A. Schwartz cited Varghese v. China Southern Airlines (among other made-up classes), that sounded plausible but didn’t exist.
Before we get there, a hearty congratulations to the virtual students who topped the leaderboard after class 1. The in-person students circled back to “Maybe AI” for a Calculator although their instinct, like yours, was “Definitely not AI.”
And a big congrats to Marilyn and Nikolay, who won additional points because I selected their definitions of AI to share with you at the bottom of class today. All of the submissions were great, but these give us some interesting framing for the classes ahead.
The leaderboard is pinned to my homepage, but I thought we’d start the semester off by applauding the initial people who made the board. Don’t forget to fill out your class card today! Details and the link are next to the Homework section below.
Fair warning: Today gets technical. But if my in-person law students can handle it, so can you.
Ok, ready? Let’s start by seeing why lawyers are getting sanctioned left and right for hallucinated citations in their filings (although judges are no saints in this regard, either).
I. A Really Expensive Autocomplete Fail
In May 2023, Southern District of New York, attorney Steven Schwartz filed a brief opposing a motion to dismiss. In it, he cited several cases. Varghese v. China Southern Airlines, Martinez v. Delta Airlines, and Miller v. United Airlines.
There’s a small problem. The opposing counsel couldn’t find these cases because they don’t exist. When confronted by Judge Castel, Schwartz admitted he used ChatGPT for research. When the judge asked him to verify the cases, Schwartz went back to ChatGPT and asked, “Are these cases real?” ChatGPT said yes. It then fabricated full opinions with internal citations and holdings.
Judge Castel sanctioned Schwartz and his firm $5,000, writing that the lawyer “abandoned his responsibilities” and submitted papers containing “false judicial opinions with false quotes and false internal citations.”
Schwartz was the first highly cited case where this happened. Last week, Attorneys that were representing State Farm said they discovered “nonexistent case citations” across a recent batch of motions they filed, saying that they used a legal AI tool, Irys, and did not fact-check the motions (!!). But he’s just the first of what has become a long and well-documented set of hallucinated citations across law and other fields. In Oregon, a judge sanctioned lawyers $110,204.38 for briefs contained 15 nonexistent cases, and 8 fabricated quotations. An attorney in Nebraska was suspended after filing an appellate brief with 57 out of his 63 citations fabricated.
Damien Charlotin has been tracking cases across the world of “legal decisions in cases where generative AI produced hallucinated content, which typically include fake citations, but also other types of AI-generated arguments.” Here’s a graph that shows you the extent of the problem to date:
Why does this happen? I think the better way for us to understand this is by understanding how LLMs work, and why hallucinations are to be expected by their very design.
II. Tokens, Parameters, Weights, Attention
We are going to look under the hood to better understand transformer AI models, because I think once you get what the model is doing, you won’t get caught surprised when what it generates is … wrong.
A. What is a Token?
AI takes in information differently than you or I do. And AI tokens help us understand why. AI tokens are tiny bits of data that come from breaking down larger chunks of information. Whether a transformer AI model is processing text, images, audio clips, videos some other kind of input (like brain data), it will translate the data into tokens. This process is known as tokenization.
AI models that learn the relationships between those tokens to allow it to do all the cool things that they do. And the faster a token can be processed, the faster the model learns and responds to us, where the goal is to achieve the fastest processing time and lowest cost per token.
The Next Token Game
Let’s back up for a moment to try to see this.
Here’s what I wrote on the board for the in-person students: “When my dog was ___”
I then said:
“Give me the single next word that most likely comes next,” I said. “Write it down. Seriously.”
Your Turn
What word would you write? Think about it for 5 seconds.
My students called out their answers. I’ll tell you on Monday what they said … because I want you to predict in your class card today (to join the leaderboard) what their top pick was for today.
More importantly, I want you to see that this game illustrates for us how a large language model like ChatGPT can give us fake cases and citations. In the Schwartz case, ChatGPT predicted “Varghese” as a plausible plaintiff name. Then “v.” because that always comes next in case names. Then “China (and then) Southern (and then) Airlines” because airline cases were contextually relevant. Then a plausible citation format. One token at a time, creating something that looks perfectly real but is completely fictional.
(A “token” is a chunk of text—usually a word or part of a word. “ChatGPT” might be one token, while “attorney-client” might be split into "attorney" and "-client" as two tokens. The model processes everything as tokens, not as complete words or sentences. Go back to this video from class 1, at 5m44s for a quick refresher)
Models predict the next token in a sequence iteratively. These systems can draft sophisticated legal arguments with perfect IRAC structure while having no concept of what law, justice, or argumentation actually means. It’s pure pattern matching. So while Schwartz may have mistakenly believed that ChatGPT was searching a legal database, it was just predicting the next most statistically likely token based on patterns it had seen. But, as we’ll see, it’s not as simple as that. Because attention matters, too.
B. Understanding Parameters and Weights
How is this pattern matching actually happening?
Before we can understand how LLMs generate output, we need understand a little but about their architecture. A large language model consists of billions of parameters.
But what is a parameter?
Think of each parameter as a tiny dial that can be turned up or down. GPT-4 was estimate to have over 1.8 trillion+ parameters. Each dial controls how strongly one piece of information influences another.
The “weight” is where the dial is actually set—turned up high, turned down low, or somewhere in between (think of it as the exact number the dial is turned to). During training, the model learns the right setting for every single dial.
To visualize this, imagine that you are a judge and you’ve been asked to determine the sentence for a criminal defendant. You have dials to adjust for different factors that you are weighing like:
Prior convictions (dial turned HIGH—strong influence)
Defendant’s age (dial turned MEDIUM—moderate influence)
Day of the week of the crime (dial turned ZERO—no influence)
The model has billions of these dials for language patterns. During training, these dials get self-adjusted by the model over and over again it compares output to input until the model gets good at predicting text.
Once training is done, all 1.8 trillion+ dial settings are set. When you use ChatGPT, it's not learning or adjusting these weights, it’s using its dial settings (its weights) to predict what comes next. So, when the model sees something like “The defendant breached the,” certain pre-set dials determine what happens:
Dials connecting “defendant” to legal terms: HIGH
Dials connecting “breached” to contract words: HIGH
Dials connecting “the” to everything: LOW (articles aren’t informative)
These weights predict that “contract” is a likely next word, while “banana” is unlikely.
Creating Your Own Embedding Meaning Space
Those parameters also connect to something called vector embeddings, a concept that often confuses people.
Every word gets converted into a list of numbers—. These numbers represent the word’s location in “meaning space.” (“Embedding dimensions typically range from 100 to 300 for simple applications but can be much higher to more than 30,000 for LLMs and specialized models,” while “LLMs that integrate multiple expert modules with dynamic embedding architectures have reached comprehensive dimensions of 5000 to 30,000.”) Those 1.8 trillion parameters? They’re controlling how words move through this space, how they relate to each other, which ones get pulled together.
For me, it’s easier to have a way visualize something this to really get it. So you can simulate what we did in class like this. First grab five objects from your desk—paperclips, sticky notes, pens, whatever. Write these words or decided to assign meaning to each of them (one word per object):
JUDGE
COURT
PLAINTIFF
BANANA
FRUIT
Now arrange them on your desk based on how related they are to each other. Words with similar meanings should be closer together. Unrelated words should be farther apart from each other.
Done? You’ve just created a physical meaning-based embedding space.
In my live classroom, we acted this out. I had five students from the class become these words. The student representing “Judge” went first, and decided to stand near the upper right side of the classroom. “Court” then positioned themselves down a little ways to the right to him. “Plaintiff” found a spot nearby but was distinct from both and tried to figure out how close to court versus judge to get. “Banana” walked away to the far corner, with “Fruit” following. (And then we had a conversation about how “fruit” could take different meanings in different contexts that weren’t law).
In an actual meaning space embeddings model, instead of that space being on your desk or my classroom and using limited dimensions, it uses thousands of dimensions. Words that appear in similar contexts end up with similar number patterns of their assignment in that space. And the parameters—(what we are thinking of as trillions of dials)—determine exactly how close or far apart these words end up.
Let’s take a look at some actual embeddings numbers, which have way more dimensions than the three dimensions we’re used to, because we need hundreds of dimensions to map the universe of meaning:
judge: [0.21, -0.53, 0.84, 0.12, ...]
court: [0.23, -0.51, 0.81, 0.15, ...]
banana: [0.89, 0.34, -0.22, -0.91, ...]
Notice how “judge” and “court” have similar numbers? The parameters, through millions of examples, learned that these words belong together. They’re like neighbors in mathematical space. “Banana” has completely different numbers—the parameters pushed it far away because it rarely appears near legal terms.
If you really start to think about what this means, embeddings can get really dangerous for you as a budding (or practicing) lawyer. Take these terms:
motion to dismiss
motion for summary judgment
motion in limine
motion to compel
Because these all appear in similar contexts (they’re “filed,” “granted,” “denied,” involve “plaintiffs” and “defendants”), the parameters may have them positioned as neighbors in embedding space. So the AI model treats them as nearly identical.
But legally, they’re completely different:
Motion to dismiss: Even if everything plaintiff says is true, they still lose
Motion for summary judgment: The evidence shows we win
Totally different legal standards, totally different timing in a case. But at that point, the AI literally cannot tell the difference—they’re too close together in its mathematical universe.
A Quick Aside on “Reasoning” Models
Maybe you, like some of my students, are wondering about the “newer” reasoning models. Are they different? Reasoning models still use the same transformer architecture, meaning they have attention mechanisms, parameters, and token prediction, but they’ve been trained to generate internal “reasoning” tokens before answering, essentially showing their work like a good math student should do.
Instead of jumping straight from “When my dog was” to “sick,” a reasoning model might internally generate tokens like “I need to predict a plausible word that could follow ‘was’ in the context of a dog, common options include emotional states, ages, or conditions” before outputting “sick.”
But, and I really can’t emphasize this point to you enough, they are still just predicting tokens based on patterns. They’ve simply learned to generate tokens in a pattern that looks like reasoning before generating tokens that look like answers. In other words, reasoning models will sometimes “lie” about their reasoning in their “chain of thought” reasoning, and even that reasoning may not be a permanent feature of these models.
Which is why reasoning models can and DO still hallucinate legal cases, just with more sophisticated-sounding explanations. Instead of just citing Varghese v. China Southern Airlines, you might get something from the reasoning model that says: “After considering the relevant precedents in aviation liability, particularly Varghese v. China Southern Airlines, which established the doctrine of carrier strict liability...”
Fancier and more convincing explanation, making you more likely to fall for it, but STILL MADE UP.
C. The Transformer Architecture: Understanding Attention
It’s now time for us to dig into how these models decide what word comes next (you’ve heard that they are just “predicting the next token” but what does that actually mean?). The breakthrough that made ChatGPT possible is called the transformer architecture, and just like I hope you are paying attention, “attention” is what these models special.
To illustrate what “attention” means in this context, I wrote the following sentence on the board in class today:
“The witness, who was clearly nervous and had contradicted herself twice, stated that she saw the defendant.”
“Now,” I said to my class (and am now saying to you), “when the model is deciding what comes after ‘defendant,’ it needs to figure out which previous words matter most. Let’s assign weights together.”
Now you try it! Look at each word and decide: HIGH, MEDIUM, LOW, or NEAR ZERO importance for predicting what comes after “defendant”:
We could do the same thing for each and every word in the sentence. And we did in the in-person class! Here’s what the crazy board looked like today (and the sentence is there in red with the ratings above it).

These attention weights tell the model that “saw the defendant” is the key phrase. So what comes next? Try it. Predict the next word. It’s probably an action verb like “leaving,” “running,” “committing,” “shooting” or something else like that.
The attention mechanism just narrowed the universe of 50,000+ possible next words down to maybe 100 action verbs. The power of attention is that it focuses the model on what matters to predict the next word.
(These attention weights are different from the model’s parameters. The 1.8 trillion+ parameters are fixed after training. But attention weights? They’re calculated fresh for every single piece of text, using those fixed parameters. Think of parameters as the permanent rules for HOW to pay attention, while attention weights are the temporary result of applying those rules to THIS specific sentence.)
Becoming a Transformer
We then turned my entire class into a live transformer model, and I really want you to try this too, because “meaning space” is hard to really visualize without helping your brain along to do so. Grab four friends (or better still, form a study group with other virtual students in this AI Law and Policy group (seriously, meet up and try this together!) (Paid subscribers have a group chat you can use to find each other).
Here’s how we set it up:
Group 1 (Input): Say a starting phrase
Group 2 (Attention): Identify which words matter most in that phrase
Group 3 (Prediction): Based on attention’s focus, suggest possible next words
Group 4 (Selection): Pick the final word
Round 1: Here’s what it might look like in your group, and how it panned out in person.
Input said: “The cat ate a sandwich”
Attention identified: “Cat, ate and sandwich are the key words!”
Prediction offered: “then, next, maybe...”
Selection chose: “then”
Round 2: We went for another round (you should, too)
Now we had: “The cat ate a sandwich and then”
Attention shifted: “‘Then crucial now—it’s setting up what comes next”
Predictions: “got, I, we, she...”
Selection: “got”
Round 3: You can keep going!
Input: “The cat ate a sandwich and then I”
Attention: “got” is something that happened to the animal
Predictions: “sleepy, sick”
Selection: “sick”
We built “The cate ate a sandwich and then got sick, afterwards I fed her medication that night. The next day, the cat felt better and played” without anyone planning the full sentence. Each round, the context shifted, attention refocused, and new possibilities emerged.
And there you have what those models that we talked about last class (that some people think are conscious) are doing. The transformer model: sophisticated pattern matching, predicting one token at a time, with no understanding of what it’s saying, but seeming to thanks to the power of attention weights. It isn’t holding the entire sentence “in its head” at once. It’s building it as it goes.
The One-Word Story Game
Speaking of building text one word at a time, my children (they’re 6 and 11 and light up my life) claim they invented the “one-word story” game (they definitely didn’t, but don’t tell them that, it makes them feel good that they did). We play it on car rides and at dinner, and everyone adds one word to build a story together until we end up in stitches laughing about it all.
Try it with your friends or family tonight, to help people better understand how modern AI LLMs work. Your p-doom might go down a little.
And one thing that you should notice, is that if you build text one word at a time, with different people (or different attention weights) controlling each word, you can lose coherent meaning pretty quickly (it’s like the modern version of the telephone game).
Which is why ChatGPT can cite a case for one principle on page 2, then cite the same fake case for the opposite principle on page 5. No central intelligence is tracking consistency (although there are ways to address this if that’s what you’re going for). Rather than a human trying to make a coherent argument across pages, it’s just token after token, each one locally plausible, and can amount to something globally nonsensical.
And that’s where we had to stop today—saved by the bell, as it were.
Our key words from today:
Token prediction: AI doesn’t “know” law, it predicts the next most likely word
Parameters: 1.8 trillion+ dials position words in meaning space, making legal concepts mathematically indistinguishable
Weights: the numbers inside AI, where the “dials” are set to (a concept we will revisit in much greater depth).
Embeddings: it’s like the coordinates in meaning-space, the numerical representations of data points that allow a machine to map the data into meaning space by its relationship to everything else in meaning space
Attention mechanisms: Focus on certain words to narrow possibilities, but can’t ensure coherence
Next week we will keep building on this to talk about more of the architecture.
By now, you understand why hallucinations keep happening in legal cases. More importantly, you understand why it will happen and again across all of the output that we rely upon from LLMs if we don’t rigorously cite and source check them.
Your Homework
Fill out your class card for class #2!
You’re a judge. A lawyer cites an AI-hallucinated case. Write one sentence explaining to the lawyer why this happened, using the technical vocabulary from today.
And tonight? Play the one-word story game with your family. Watch the contradictions emerge. That’s AI in action.
How to Joint the Leaderboard, and/or Achieve a Certificate of Completion for the Course
(1) Leaderboard (for everyone): Last year, many of the students in the virtual cohort asked if there was a way to track their progress. So I am trying out something new this year, which is to give a way to track your progress toward completion of this course. Each class, I will have a class attendance card for you to fill out, which connects to a ledger I am keeping for the class. Completing the card earns you 10 points, filling in the homework earns you 10 points more, making an accurate prediction earns you 10 more points, and taking consecutive classes builds a streak for 5 points for each consecutive class. Plus, if I select your homework answer to feature, you get an additional 50 points! You choose your display name and I will be featuring a leaderboard on my Substack homepage.
Fill out your class card for class #2 ! (Make sure to use the same Google account all semester, since I link your student ID to your email address).
(2) Certification of Completion: At the end of the semester, there is also an option for paid subscribers who have completed 80 percent of the class cards, to take (and pass) a midterm exam and final exam to receive a certificate of completion. You do not need to be a paid subscriber to have full access to the leaderboard and lectures (option 1).
If you choose to work toward a certificate (option 2), you will receive a certificate issued personally by me, as having completed AI Law and Policy with Professor Nita Farahany on Thinking Freely. It is not a Duke Law program, it carries no academic credit nor any endorsement from Duke Law school. It does, however, mean you will have completed the material of a full semester of a law school class, and you get a certificate memorializing that. Auditing remains free for everyone.
Bonus Points Awarded for Homework on Monday:
Marilyn’s Definition of AI: “Artificial intelligence system” means a machine-based system that, for an express or implied objective, generates content, predictions, classifications, scores, rankings, recommendations, decisions, or actions from the inputs it receives, where the system’s capacity to produce those outputs derives primarily from patterns, parameters, or behaviors obtained through an automated process applied to data, examples, or interaction with an environment, rather than primarily from rules authored by a person from which the system’s input-to-output behavior is reconstructable, even if the full range of possible inputs was never individually enumerated, and whether or not the system continues to change after deployment.
Nikolay’s Definition of AI: I would consider not defining “artificial intelligence” at all as it is more of a marketing term, trying to do legal work. I wold try to define the regulated function and let the label go.
My AI Policy: I use AI to help me transform my in-class notes and lectures to deliver them to you here. I pore over every detail and citation for accuracy, and am answerable for every word. For more details on how I use AI, you can read about it here, and in detail in my forthcoming book, Cognitive Extinction: Saving Human Thought While We Still Can (St. Martin’s Press 2027).
The entire class lecture is above, but for those of you who want to support my work (thank you!), go deeper in the class, have access to the class readings, access to the video assignments, achieve a certificate of completion, or reach me via virtual chat-based office-hours, the details are below.







