[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"doc-seo-492047-105":3,"detail-sidebar-cat-0-en-105":81,"doc-detail-492047-en":130},{"code":4,"msg":5,"data":6},0,"ok",{"site_id":7,"language":8,"slug":9,"title":10,"keywords":11,"description":12,"schema_data":13,"social_meta":74,"head_meta":76,"extra_data":78,"updated_unix":80},105,"en","using-large-language-models-for-text-annotation-in-social-science-and-humanities-a-hands-on-pythonr-tutorial","Using Large Language Models for Text Annotation in Social Science and Humanities - A Hands-On Python/R Tutorial","","Large language models (LLMs) are increasingly used by social science and humanities researchers working with textual data, especially to automate time-consuming text annotation for empirical analysis. The tutorial addresses two common barriers: starting with LLMs and evaluating, correcting, and mitigating annotation limitations that can bias downstream results such as regression estimates and p-values. It offers step-by-step guidance for Python and R users, covering API access, task design, quality evaluation, uncertainty-aware integration, and practical cost, efficiency, and reproducibility considerations.",{"@graph":14,"@context":73},[15,34,56],{"@type":16,"itemListElement":17},"BreadcrumbList",[18,23,27,31],{"item":19,"name":20,"@type":21,"position":22},"https://docshare.wps.com","Home","ListItem",1,{"item":24,"name":25,"@type":21,"position":26},"https://docshare.wps.com/document/","Document",2,{"item":28,"name":29,"@type":21,"position":30},"https://docshare.wps.com/document/research-report/","Research & Report",3,{"item":32,"name":10,"@type":21,"position":33},"https://docshare.wps.com/document/using-large-language-models-for-text-annotation-in-social-science-and-humanities-a-hands-on-pythonr-tutorial/492047/",4,{"url":32,"name":10,"@type":35,"image":36,"author":41,"headline":10,"publisher":44,"fileFormat":47,"inLanguage":8,"description":12,"dateModified":48,"datePublished":49,"encodingFormat":47,"isAccessibleForFree":50,"interactionStatistic":51},"DigitalDocument",{"url":37,"@type":38,"width":39,"height":40},"https://docshare.wps.com/thumbnails/using-large-language-models-for-text-annotation-in-social-science-and-humanities-a-hands-on-pythonr-tutorial/492047.png","ImageObject",300,407,{"name":42,"@type":43},"Blue Pony","Person",{"url":19,"name":45,"@type":46},"DocShare","Organization","application/pdf","2026-11-16","2026-10-01",true,{"@type":52,"interactionType":53,"userInteractionCount":55},"InteractionCounter",{"@type":54},"ViewAction",9,{"@type":57,"mainEntity":58},"FAQPage",[59,65,69],{"name":60,"@type":61,"acceptedAnswer":62},"What problems does the tutorial address for social science and humanities researchers using LLMs for annotation?","Question",{"text":63,"@type":64},"It targets getting started with LLMs and understanding how to evaluate and correct annotation limitations, which can introduce bias in downstream analyses such as regression results and p-values.","Answer",{"name":66,"@type":61,"acceptedAnswer":67},"Which programming environments does the tutorial support for hands-on annotation workflows?",{"text":68,"@type":64},"It provides step-by-step guidance for both Python and R users, including concrete examples and code snippets.",{"name":70,"@type":61,"acceptedAnswer":71},"How does the tutorial help users evaluate and improve annotation quality?",{"text":72,"@type":64},"It explains how to compute agreement between LLM and gold labels, identify problematic items, examine issues, and iteratively fix data problems and improve prompts.","https://schema.org",{"og:url":32,"og:type":75,"og:title":10,"og:site_name":45,"og:description":12},"article",{"robots":77,"canonical":32},"index,follow",{"doc_id":79,"site_id":7},492047,1791395344,{"code":4,"msg":82,"data":83},"success",[84,88,92,96,101,106,111,115,119,122,126],{"id":22,"doc_module":4,"doc_module_name":25,"category_name":85,"show_sort_weight":86,"slug":87},"Story & Novel",90,"story-novel",{"id":26,"doc_module":4,"doc_module_name":25,"category_name":89,"show_sort_weight":90,"slug":91},"Literature",80,"literature",{"id":33,"doc_module":4,"doc_module_name":25,"category_name":93,"show_sort_weight":94,"slug":95},"Exam",70,"exam",{"id":97,"doc_module":4,"doc_module_name":25,"category_name":98,"show_sort_weight":99,"slug":100},5,"Comic",60,"comic",{"id":102,"doc_module":4,"doc_module_name":25,"category_name":103,"show_sort_weight":104,"slug":105},6,"Technology",50,"technology",{"id":107,"doc_module":4,"doc_module_name":25,"category_name":108,"show_sort_weight":109,"slug":110},7,"Healthcare",40,"healthcare",{"id":112,"doc_module":4,"doc_module_name":25,"category_name":29,"show_sort_weight":113,"slug":114},8,30,"research-report",{"id":55,"doc_module":4,"doc_module_name":25,"category_name":116,"show_sort_weight":117,"slug":118},"Religion & Spirituality",20,"religion-spirituality",{"id":117,"doc_module":4,"doc_module_name":25,"category_name":120,"show_sort_weight":117,"slug":121},"World Cup","world-cup",{"id":123,"doc_module":4,"doc_module_name":25,"category_name":124,"show_sort_weight":123,"slug":125},10,"Lifestyle","lifestyle",{"id":127,"doc_module":4,"doc_module_name":25,"category_name":128,"show_sort_weight":97,"slug":129},19,"General","general",{"code":4,"msg":82,"data":131},{"doc_id":79,"user_id":132,"nickname":42,"user_avatar":133,"doc_module":4,"category_id":112,"category_name":29,"doc_title":10,"doc_description":12,"doc_content":134,"file_id":135,"file_url":136,"file_type":137,"file_size":138,"view_count":55,"is_deleted":4,"is_public":22,"is_downloadable":22,"audit_status":22,"page_count":139,"language":140,"language_code":8,"site_id":7,"html_lang":8,"table_of_contents":141,"faqs":142,"seo_title":143,"seo_description":12,"update_tm":144,"read_time":145,"preview_page_count":97,"preview_urls":146},962090760266,"https://ap-avatar.wpscdn.com/davatar_276721f389ce27ea32af1340a28f341c","Utrecht University Repository  \n\n| Title | Using Large Language Models for Text Annotation in Social Science and Humanities: A Hands-On Python/R Tutorial |\n| --- | --- |\n| Authors | Fang , Qixiang; Garcia-Bernardo , Javier; van Kesteren , Erik-Jan |\n| Publication Date | 2025-11-13 |\n| Link | [https://dspace.library. uu. nl/handle/1874/463464](https://dspace.library. uu. nl/handle/1874/463464) |\n| Citation | Fang , Q , Garcia-Bernardo , J & van Kesteren , E-J 2025 ' Using Large Language Models for Text Annotation in Social Science and Humanities: A Hands-On Python/R Tutorial' OSF. [https://doi.org/10.31235/osf.io/v4eq6_v1](https://doi.org/10.31235/osf.io/v4eq6_v1) |\n| Versions / License | Preprint |\n| Rights | [https://www. uu. nl/en/university-library/license-and-reuse-conditions](https://www. uu. nl/en/university-library/license-and-reuse-conditions) |\n\nUsing Large Language Models for Text Annotation in Social Science and Humanities: A Hands-On  \nPython/R Tutorial  \nQixiang Fang, Javier Garcia Bernardo, Erik-Jan van Kesteren  \nSoDa Science Team, Utrecht University, Netherlands  \nNovember 12, 2025  \nAbstract  \nLarge language models (LLMs) have become an essential tool for social scientists and humanities (SSH) researchers who work with textual data. One particularly valuable use case is automating text annotation, traditionally a time-consuming step in preparing data for empirical analysis. Yet, many SSH researchers face two challenges: getting started with LLMs, and understanding how to evaluate and correct for their limitations. The rapid pace of model development can make LLMs appear inaccessible or intimidating, while even experienced users may overlook how annotation errors can bias results from downstream analyses (e.g. , regression estimates, p-values), even when accuracy appears high. This tutorial provides a step-by-step, hands-on guide to using LLMs for text annotation in SSH research for both Python and R users. We cover (1) how to choose and access LLM APIs, (2) how to design and run annotation tasks programmatically, (3) how to evaluate annotation quality and iterate on prompts, (4) how to integrate annotations into statistical workflows while accounting for uncertainty, and (5) how to manage cost, efficiency, and reproducibility. Throughout, we provide concrete examples, code snippets, and best-practice checklists to help researchers confidently and transparently incorporate LLM-based annotation into their workflows.  \nContents  \n1 Introduction 4  \n2 Understand LLMs for Text Annotation 6  \n2.1 From Logistic Regression to Language Modelling ............... 7  \n2.2 A Segue to Prompting and Annotation .................... 7  \n2.3 Summary .................................... 8  \n3 Research Project Set-up 8  \n3.1 Know Your Research Question and Data ................... 9  \n3.2 Secure a Gold-Labelled Subset ......................... 9  \n3.3 Summary .................................... 12  \n4 Design Good Prompts 12  \n4.1 Taxonomy and Anatomy of Prompts ..................... 12  \n4.2 Prompt Engineering Techniques (Quick Wins) ................. 13  \n5 Set Up the Computational Environment 17  \n5.1 A Quick Start with Cloud Notebooks ..................... 17  \n5.2 LLM APIs vs. Local LLMs ........................... 17  \n5.3 Obtain and Secure API Keys ......................... 18  \n5.4 Minimal Dependencies ............................. 18  \n5.5 Model Choice .................................. 19  \n5.6 Hyperparameters and Minimal Stability Settings ............... 19  \n5.7 Summary .................................... 20  \n6 Run Your First Prompt Requests 20  \n6.1 Data Preparation ................................ 20  \n6.2 System Prompt and Model Initialisation ................... 21  \n6.3 A Single Prompt Demo ............................. 22  \n6.4 Multiple Prompts Demo ............................ 22  \n7 Structuring LLM Annotations 23  \n7.1 Structured Output ............................... 23  \n7.2 A Single Prompt Demo .........","cbCaiv1UZYB9qaOg","https://ap.wps.com/l/cbCaiv1UZYB9qaOg","pdf",613706,42,"English","# Introduction\n# Understand LLMs for Text Annotation\n## From Logistic Regression to Language Modelling\n## A Segue to Prompting and Annotation\n## Summary\n# Research Project Set-up\n## Know Your Research Question and Data\n## Secure a Gold-Labelled Subset\n## Summary\n# Design Good Prompts\n## Taxonomy and Anatomy of Prompts\n## Prompt Engineering Techniques (Quick Wins)\n# Set Up the Computational Environment\n## A Quick Start with Cloud Notebooks\n## LLM APIs vs. Local LLMs\n## Obtain and Secure API Keys\n## Minimal Dependencies\n## Model Choice\n## Hyperparameters and Minimal Stability Settings\n# Run Your First Prompt Requests\n# Structuring LLM Annotations\n# Evaluate Annotation Quality\n# Consider Annotation Error in Downstream Analyses\n# Taking Your Annotations to the Next Level\n# Conclusion and Outlook","[{\"question\":\"What problems does the tutorial address for social science and humanities researchers using LLMs for annotation?\",\"answer\":\"It targets getting started with LLMs and understanding how to evaluate and correct annotation limitations, which can introduce bias in downstream analyses such as regression results and p-values.\"},{\"question\":\"Which programming environments does the tutorial support for hands-on annotation workflows?\",\"answer\":\"It provides step-by-step guidance for both Python and R users, including concrete examples and code snippets.\"},{\"question\":\"How does the tutorial help users evaluate and improve annotation quality?\",\"answer\":\"It explains how to compute agreement between LLM and gold labels, identify problematic items, examine issues, and iteratively fix data problems and improve prompts.\"}]","Using Large Language Models for Text Annotation in Social Science and Humanities - A Hands-On Python/R Tutorial | PDF",1790856877,106,[147,151,155,159,163],{"page_no":22,"url":148,"width":149,"height":150},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-17/7c6967e8a220a654a06de8d9428b2d9e.webp",983,1390,{"page_no":26,"url":152,"width":153,"height":154},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-17/28f637b0369ccac29b2fce67bb267c1b.webp",982,1388,{"page_no":30,"url":156,"width":157,"height":158},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-17/64864495168338b4d74eceb3445bbcd5.webp",981,1387,{"page_no":33,"url":160,"width":161,"height":162},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-17/4c5ca5526f3e309b0de851f60cd73439.webp",980,1385,{"page_no":97,"url":164,"width":165,"height":166},"https://res-academy.cache.wpscdn.com/upload/kdocshare/2026-11-17/a913782349aea2a55eb636b9abc06f93.webp",979,1384]