← Resource library

Method note

How to use LLMs for text analysis (Törnberg)

Step-by-step Python guide for social scientists with little programming experience, from API setup and prompt design to validating LLM labels, using populism detection as the running example.

What is reported

The guide provides a step-by-step teaching workflow for LLM text analysis; this site has not rerun its examples.

Before you use it

Written in 2023; model names and prices have changed, but the validation workflow still applies.

Sources and review

Original source ↗

Source checked · Not tested by this site

Checked the 2023 preprint abstract and scope. Package and model details need updating when running the tutorial.

Evidence / source record ↗

License and reuse

No license has been recorded. Check the source’s license before reusing code, models or data.

A license note is not a license audit. Open source does not guarantee free hosting, model access or commercial reuse.

Related resources