Objective
Qualitative coding means reading data such as tutoring transcripts or student comments and labeling each piece with a theme, called a code or construct. It is a core step in education research, but it takes a lot of time, especially with large datasets. Researchers have tried to automate it for decades. Large language models such as GPT-4 now make that look possible.
Earlier studies showed that GPT can code some kinds of data well, but they left open which codes it handles best and which way of asking works best. The authors also asked whether codes that are hard for people are hard for GPT.
This paper tested several ways of prompting GPT-4 (the instructions given to the model), plus one use of embeddings (numbers that represent the meaning of a text so that two texts can be compared). The ways of prompting were:
- Zero-shot: only a definition of the code, no examples.
- Few-shot: the definition plus labeled examples.
- Few-shot with context: the examples plus background and nearby lines.
The team asked which method works best for which kind of code, using three different education datasets.
Methods
This was a quantitative study that compared GPT-4 labels with human labels. It can show how well the model agrees with people on these datasets. It cannot show that the same results would hold for other data or other models.
The team ran three separate studies, each with its own dataset and codebook. In each one, two human researchers coded the data and settled disagreements by discussion. That agreed set was treated as the correct answer. GPT-4 (version gpt-4-turbo-2024-04-09, accessed through OpenAI's programming interface, with temperature set to 0 for steady output) then coded each code as a yes or no question. Each coding run was repeated three times and the results averaged. Agreement was reported with Cohen's kappa, which measures agreement beyond chance, along with precision (how many of GPT's yes answers were right) and recall (how many true cases it found).
- Study 1: transcripts of four 60-minute virtual Algebra I tutoring sessions with six 9th-grade students in the United States. The team coded the 990 tutor lines against 10 codes such as Greetings and Direct Instruction.
- Study 2: observations written by 76 learners exploring astronomy worlds in Minecraft, collected in 2022 at five locations across three states, coded against 11 codes.
- Study 3: practice code submitted by 169 students learning C# in an introductory course in Poland, 44,448 submissions in all. The team focused on tasks about conditional statements and coded 13 types of change between two consecutive submissions.
In Study 1, eleven experienced researchers also rated each code from 1 to 5 on clarity, concreteness, objectivity, granularity and specificity. The paper does not give ethics approval details.
Key Findings
Overall, GPT-4 agreed well with people on many codes, but the best prompt style changed from code to code.
Overall results
- With at least one prompt style, GPT-4 reached kappa of 0.70 or higher on 25 of the 34 codes across the three studies.
- No single method was best throughout. Zero-shot worked for clearly defined codes, such as Greetings in Study 1 (kappa 0.79) and Questioning (0.91), but it missed cases that were only implied.
Study 1: tutoring transcripts
- Human coders first agreed with each other at kappa between 0.24 and 0.87, depending on the code.
- Examples helped a lot for some codes. Direct Instruction rose from 0.11 with Zero-shot to 0.79 with Few-shot. Session Logistics rose from 0.15 to 0.85. Guided Practice rose from 0.16 to 0.55.
- Examples also caused errors. After one example included the phrase All right, fellas, GPT labeled 23 lines starting with All right as Greetings. After one example of Feedback, GPT wrongly marked 10 of 11 lines that held only the word No.
- Adding context helped codes that run across several lines: Guided Practice reached 0.86 and Connecting to Prior Knowledge 0.78. It hurt single-line codes such as Clarification.
- No method passed 0.70 for Clarification or Feedback.
Study 2: Minecraft observations
- Agreement with humans ranged from 0.72 to 0.95, higher than in Study 1.
- Zero-shot did well for codes humans also agreed on, such as Questioning and Exclamation. Few-shot was better for harder codes such as Comparison.
- For Continuing Discussion, embeddings reached 0.93, ahead of context only (0.85) and Few-shot with context (0.88).
Study 3: student code
- GPT-4 did well on codes tied to a clear spot in the code, such as If Header, Function Return, Comment, Added Lines and Operator.
- It did poorly where more surrounding code was needed, for example If Body (kappa 0.12) and Function Body (0.10).
- Zero-shot usually beat Few-shot here, probably because novices make so many unexpected changes.
Why some codes were harder
- Codes that humans found hard to agree on were usually hard for GPT-4 too.
- Zero-shot success went along with how clear a code was (correlation 0.50).
Implications
The authors argue that researchers should match the prompt style to the kind of code, rather than picking one method for everything.
For researchers using LLMs to code data
- The authors suggest writing clear, concrete definitions if you plan to use Zero-shot prompts.
- They suggest using examples for codes that are hard to define, and choosing examples that separate the code from similar ones. Adding a negative example (a case that does not fit) cut overgeneralization in some cases.
- They suggest adding nearby lines only for codes that need them, because context can add noise.
- Embeddings may suit codes that depend on how two pieces of text relate.
For teachers and school leaders
Our reading (not the authors' recommendation): this work is about research methods, not classroom tools. Teachers should not assume that GPT-4 can reliably label tutoring or student work on their own without a human check.
Our reading (not the authors' recommendation): because codes that people disagree on are also hard for GPT-4, a team can use disagreement between human coders as an early warning about which codes to check closely.
The authors also note that using the programming interface is efficient. Once a prompt is set, it can code a whole dataset and be rerun easily if the prompt changes. They add that it explains its decisions less well than the ChatGPT chat tool.
Limitations
The authors point out that the programming interface gives weaker explanations of its decisions than the ChatGPT chat tool does, which limits how much it helps refine unclear definitions.
The paper also says the Few-shot with context approach was not used for most of Study 2 or any of Study 3, so methods were not compared on equal terms across all studies. Each study used slightly different methods to suit its data.
The paper does not mention, but the datasets are small and narrow. Study 1 has only four sessions and six students, and Study 2 has 76 learners, so the results may not carry over to other classrooms or subjects.
The paper does not mention, but only one model version (GPT-4 from April 2024) was tested, and models change quickly.
The paper does not mention, but the correct answers came from human coders who sometimes disagreed (kappa as low as 0.24 at first), so the benchmark itself is imperfect.
The paper does not mention, but the ratings of code difficulty came from eleven researchers and the link between ratings and results rests on just ten codes, so those patterns are only suggestive.
Future Directions
The authors list several next steps.
- Look at each method in finer detail. For some data it may help to separate task context from the flow of discussion and use only one.
- Test coding several codes in one prompt, or letting the model choose among exclusive codes, instead of one yes or no question per code. It is unclear whether this would confuse the model.
- Find better ways to handle complex, ambiguous or subtle codes.
- Test other models, such as Claude or LLaMA, and future OpenAI versions.
- Try more fully deductive coding, where the model builds coding schemes directly from theories and frameworks.
- Check how well the findings hold when the same methods are applied to other classroom datasets, subjects and age groups, since the three datasets here were small and specific.
The bottom line: This research found that GPT-4 can code many kinds of education data with good agreement with human coders, reaching kappa of 0.70 or higher on 25 of 34 codes. The right prompt style depends on the code, and codes that people find hard to agree on are also hard for the model. The evidence comes from three small datasets and one model version, so treat it as guidance for researchers, not proof that coding can be handed over to AI. Check the model's labels against a human sample before trusting them.
Comments 0
No comments yet. Be the first to share a thought.
Get new research summaries by email
Every new summary each morning, a weekly digest, or a monthly report. You choose, and you can unsubscribe in one click.