The quallmer package is an easy-to-use toolbox to quickly apply AI-assisted qualitative coding to large amounts of texts, images, pdfs, tabular data and other structured data.
Using qlm_code(), users can apply codebook-based qualitative coding
powered by large language models (LLMs) to generate structured,
interpretable outputs, after first converting audio recordings to text
with qlm_transcribe() or translating texts into the language of the
analysis with qlm_translate() where needed. The package includes
built-in codebooks for common applications and allows researchers to
create custom codebooks tailored to their specific research questions
using qlm_codebook(). To ensure quality and reliability of
AI-generated coding, quallmer provides qlm_compare() for
evaluating inter-rater reliability and qlm_validate() for assessing
accuracy against gold standards. With qlm_replicate(), researchers can
systematically compare results across different models and settings to
assess sensitivity and reproducibility. The qlm_trail() function
creates complete audit trails following Lincoln and Guba’s (1985)
concept for establishing trustworthiness in qualitative research.
The quallmer package makes AI-assisted qualitative coding accessible without requiring deep expertise in R, programming or machine learning.
qlm_transcribe() and qlm_translate() (optional)qlm_transcribe() converts audio recordings to text, through a
transcription endpoint such as OpenAI’s or a chat model that accepts
audio, such as Gemini.qlm_translate() translates texts or a quanteda corpus into another
language, using DeepL, Google’s Translation LLM, Qwen-MT or any chat
model supported by ellmer. Set the source language with from where
you know it: when a provider cannot handle a language it detects, it
can return a fluent but invented translation without reporting an
error.qlm_code() codes directly,
with per-document provenance that qlm_trail() reports. A translated
corpus keeps its document variables.qlm_codebook()
instructions and type specifications from
ellmer to
define coding instructions and output structure.data_codebook_sentiment) demonstrate
how to use built-in codebooks for common qualitative coding tasks.qlm_code()qlm_codebook.qlm_coded object containing the coded results and metadata
for reproducibility.qlm_segment() (optional)qlm_code() for more granular analysis (in the same pass or as a
separate step).qlm_replicate()qlm_compare()qlm_coded objects to assess inter-rater
reliability.qlm_validate()qlm_trail()qlm_trail(..., path = "filename") to save RDS archive and Quarto
report.qlm_backfill()qlm_failures() lists the units a run failed on and
why, and qlm_backfill() re-codes just those units and merges them
back, so a few transient failures do not mean re-running the corpus.qlm_code(backfill = 2) does this in the same call.For an interactive Shiny application to perform manual coding, review AI-generated annotations, and compute agreement metrics, see the companion package quallmer.app.
The package supports all LLMs currently available with the ellmer
package. For authentication and usage of each of these LLMs, please
refer to the respective
ellmer
documentation and see our tutorial for setting up an OpenAI API
key
or getting started with an open-source Ollama
model.
You can install the development version of quallmer from https://github.com/quallmer/quallmer with:
# install.packages("pak")
# pak::pak("quallmer/quallmer")
install.packages("quallmer", repos = c('https://quallmer.r-universe.dev', 'https://cloud.r-project.org'))
To learn more about how to use the package, please refer to our step-by-step tutorials.
Development of this package was assisted by Claude Code, an AI coding assistant by Anthropic, for code refactoring, documentation updates, and package restructuring. We also found OpenAI’s Codex good for planning solutions to issues and for reviewing pull requests.
Krippendorff, K. (2019). Content Analysis: An Introduction to Its Methodology (4th ed.). Sage. doi:10.4135/9781071878781