This paper presents two self-contained tutorials on stance detection in Twitter data using BERT fine-tuning and prompting large language models (LLMs). The first tutorial explains BERT architecture and tokenization, guiding users through training, tuning, and evaluating standard and domain-specific BERT models with HuggingFace transformers. The second focuses on constructing prompts and few-shot examples to elicit stances from ChatGPT and open-source FLAN-T5 without fine-tuning. Various prompting strategies are implemented and evaluated using confusion matrices and macro F1 scores. The tutorials provide code, visualizations, and insights revealing the strengths of few-shot ChatGPT and FLAN-T5 which outperform fine-tuned BERTs. By covering both model fine-tuning and prompting-based techniques in an accessible, hands-on manner, these tutorials enable learners to gain applied experience with cutting-edge methods for stance detection.
翻译:本文提供了两个自成体系的教程,分别介绍如何在Twitter数据上通过BERT微调与大语言模型提示学习进行立场检测。首个教程详细阐述BERT架构与分词机制,指导用户利用HuggingFace框架对标准BERT和领域专用BERT模型进行训练、调优与评估。第二个教程聚焦于构建提示模板与少量样本示例,无需微调即可从ChatGPT和开源FLAN-T5模型中获取立场判断。研究采用混淆矩阵与宏F1分数对多种提示策略进行实施与评估。教程提供的代码、可视化结果及洞察表明,基于少量样本学习的ChatGPT与FLAN-T5在性能上超越了微调后的BERT模型。通过以可操作、低门槛的方式同时覆盖模型微调和提示驱动技术,本教程使学习者能够掌握用于立场检测的前沿方法并获得实践应用经验。