# LLMs and AI for Cultural Analytics

This section introduces Large Language Models (LLMs) and AI tools for humanities and social science research. The tutorials below are drawn from [**AI for Humanists**](https://aiforhumanists.com/), a project created by Melanie Walsh, [David Mimno](https://mimno.infosci.cornell.edu/), and [Matt Wilkens](https://mattwilkens.com/) and designed to help humanities researchers and students understand, use, and critically engage with AI technologies.

## What LLM Should I Use?

See the AI for Humanists [Guide to Models](https://aiforhumanists.com/guides/models/) for help choosing the right model for your research task.

## Tutorials

The following tutorials are available as Google Colab notebooks, which means you can open and run them directly in your browser without any installation.

### Local LLMs

**Working with Local LLMs (On Your Own Computer!) --- Ollama and Llama 3**
Run LLMs locally so your data never leaves your machine. Covers setting up Ollama, creating structured data from unstructured text, chatting with a local LLM, and generating document embeddings.
🚀 [Open in Colab](https://colab.research.google.com/drive/1V09aQmReB1iMDuTLIWArWODGbHlOK-kQ?usp=sharing)

### Word and Document Embeddings

**Measuring Document Similarity with LLMs**
Use LLMs to find similar texts within a dataset, including comparing narrative versus non-narrative texts and analyzing poetry collections.
🚀 [Open in Colab](https://colab.research.google.com/drive/1-aOfk6mVFUA3PH_s6P-lCaM9xKLJ0dLz?usp=sharing)

**Measuring Word Similarity with BERT**
Use a pre-trained BERT model to measure word similarity by finding semantically comparable words from poem collections.
🚀 [Open in Colab](https://colab.research.google.com/drive/1r_eoi8CMea_a3YjWC1M4EmTqKMGVMbzQ?usp=sharing)

**Measuring Word Similarity with BERT (Spanish)**
A demo showing how the word similarity approach works with a Spanish-language BERT model, illustrating that these techniques can be applied beyond English.
🚀 [Open in Colab](https://colab.research.google.com/drive/192YOj8N9isRsEvOQwaI2WZ3pRSlUgAYb?usp=sharing)

### Text Classification

**Zero-Shot Prompting with LLMs**
Classify texts without any training examples. Covers prompting strategies for book genre and narrative classification, and how to evaluate results.
🚀 [Open in Colab](https://colab.research.google.com/drive/1QIG-3bIo1BHVWWlS22-1XItlZRrGSMNe?usp=sharing)

**Training and Fine-Tuning BERT for Classification**
Train and fine-tune a BERT model to classify Goodreads reviews by book genre.
🚀 [Open in Colab](https://colab.research.google.com/drive/19jDqa5D5XfxPU6NQef17BC07xQdRnaKU?usp=sharing)

## Workshop Slides

The AI for Humanists team has also given a number of workshops on LLMs and AI for humanities researchers. Slides from past workshops are available on the [AI for Humanists Workshops page](https://aiforhumanists.com/workshops/). A few highlights:

- [Artificial Intelligence: An Overview](https://docs.google.com/presentation/d/16HD3F4jX5i04d9U_dE39O-GNCW_Wk-YQbpOYYOtWsdc/edit?usp=sharing) (NEH, December 2023)
- [Large Language Models for Humanists: A Hands-On Introduction](https://docs.google.com/presentation/d/1ROmlmVmWzxxgTpx4VPxf15sIiJv31hYmf06RzA4d9xE/edit?usp=sharing) (Simpson Center for the Humanities, November 2023)
- [A Hands-On Introduction to Large Language Models for FAccT Researchers](https://docs.google.com/presentation/d/1ZzcygY6gwKPOhl7nQbnPBT65lgsd6texRbY7AKV2DPw/edit?usp=sharing) (FAccT Conference, June 2023)
- [BERT for Social Scientists and Humanists](https://docs.google.com/presentation/d/1PwibAk_Fvnk-sCfZ0C5-4UYvqGUEU969FAyFsdDuGyU/edit#slide=id.p1) (Bell Labs, July 2022)
