AIPM: Building Your Knowledge System for Large Language Models
website·Indexed 31 days ago
https://stanford.5loi.com/en/getting-started/An open-source educational tutorial and knowledge system focused on understanding and developing large language models (LLMs). The curriculum covers LLM behavior, capabilities, and harms; training data, security, privacy, and legal considerations; and technical implementation including modeling, training, parallelism, scaling laws, modular architectures, and adaptation.
What's inside AIPM
- Common Crawl is a nonprofit organization that provides free public snapshots of the web. Due to its accessibility and scale, it serves as a standard data source for training several large language models, including T5, GPT-3, and Gopher. While smaller than the Google search index, it provides a massive corpus of raw text necessary for models to acquire broad linguistic and world knowledge.
Implement a basic Mixture-of-Experts (MoE) architecture
A Mixture-of-Experts (MoE) architecture replaces a single dense layer with a set of $N$ expert functions and a gating mechanism. Instead of a single function $f(x, \theta)$, the MoE approach uses:
- Experts: $N$ distinct expert functions $f_1, f_2, ..., f_N$, each with its own set of parameters $\theta_1, \theta_2, ..., \theta_N$.
- Gating Function: A function $G(x)$ that produces a probability distribution over the $N$ experts, determining how much weight to assign to each expert's output for a given input $x$.
- Combined Output: The final prediction is the weighted sum of the experts' outputs based on the gating distribution.
Understand legal intersections in the LLM lifecycle
The development and deployment of Large Language Models (LLMs) intersect with law primarily in two areas: data collection and application deployment.
- Data: LLMs require massive datasets, often scraped without consent. This raises issues regarding Copyright law (whether training on protected works is a violation) and Privacy law (whether training on public or private data violates individual privacy rights).
- Applications: Downstream tasks (e.g., chatbots, QA) can be used for intentional harm (spam, phishing, disinformation) or deployed in high-stakes settings (healthcare, lending, education), which may trigger existing fraud, abuse, or industry-specific regulations.
Understand data governance and data dignity concepts
Beyond simple collection, data in industry and research is managed through broader ecosystems:
- Data Governance: The process by which an organization creates, maintains, and secures data quality (e.g., the BigScience project's framework for responsible curation vs. indiscriminate scraping).
- Data Dignity: A concept treating data as collective labor rather than individual property. It suggests that because data has collective value, 'data coalitions' should act as intermediate organizations for collective bargaining between producers and buyers.
Understand the risks of LLMs in generating disinformation and radicalization
Large Language Models (LLMs) can produce fluent, novel, and persuasive text that is often indistinguishable from human-written news, making them potent tools for disinformation. Key risks include:
- Hyper-targeting: Users find AI-generated stories more credible when tailored to their specific political beliefs.
- Online Radicalization: Models like GPT-3 possess deep knowledge of extremist communities (e.g., QAnon) and can be prompted to act as believers, creating ideologically consistent and normalizing environments that influence thoughts and feelings.
- Human-AI Collaboration: The combination of human oversight and LLM generation increases the effectiveness of disinformation campaigns, particularly for state-sponsored actors.
Risk mitigation strategies include developing detection models, promoting digital literacy, and focusing on the detection of fake accounts rather than just the content.
Understand the fundamental concept of a Language Model
A language model is a statistical tool that assigns a probability score (between 0 and 1) to sequences of tokens from a given vocabulary. This score reflects the sequence's coherence based on syntactic knowledge (grammar) and world knowledge (semantic plausibility). For example, 'the mouse ate the cheese' is assigned a higher probability than 'the cheese ate the mouse' because it is more plausible in the real world, despite both being syntactically correct.Understand the transition from Dense Transformers to Modular Architectures
Dense Transformer architectures (like GPT-3) apply the same set of parameters to every input token. As these models scale, they face bottlenecks in network bandwidth and training efficiency because they must be split across many machines using data, model, and pipeline parallelism. To continue scaling, 'selective' architectures are used so that each input activates only a small subset of the model's total parameters. Two primary selective architectures are:
- Mixture-of-Experts (MoE): A set of specialized 'experts' is created, and only a few are activated per input.
- Retrieval: A store of raw data is maintained; the model retrieves relevant documents from this store to predict the output.
Understand why language model adaptation is necessary
Language models are trained in a task-agnostic way (e.g., on the Pile), but downstream tasks often differ in ways that make simple prompting insufficient:
- Formatting: Tasks may require specific outputs (e.g., binary labels for Natural Language Inference) that differ from next-token prediction or MASK filling.
- Topic Shift: The task may focus on a specialized domain (e.g., medical records) not well-represented in pre-training data.
- Temporal Shift: The task may require knowledge created after the model's training cutoff or knowledge that is not publicly available.
Analyze the role of LLMs in content moderation
Language models have a "dual use" in the context of content moderation:
- Generation: Malicious actors can use LLMs to generate and amplify toxic content or disinformation.
- Detection: LLMs can be used to detect disinformation and aid in automated content moderation (blocking, deleting, flagging, or hiding content).
Content moderation is fundamentally political and context-dependent; norms vary significantly across different platforms or communities (e.g., different subreddits on Reddit).
Understand performance disparities and social biases in LLMs
Large Language Models (LLMs) can exhibit harms in two primary forms related to group identity:
- Performance Disparities: Occur when a model performs significantly better for some social groups and worse for others on the same task (e.g., an Automatic Speech Recognition system that has higher error rates for Black speakers than White speakers). This can create a feedback loop where marginalized groups stop using the system, leading to less data and further increasing the disparity.
- Social Biases and Stereotypes: Social biases are systematic associations between concepts and specific groups (e.g., associating 'science' with 'men'). Stereotypes are a prevalent form of bias that are widely held, oversimplified, and fixed. These are often propagated through language and can lead to performance disparities if the model fails to understand anti-stereotypical data.
Understand BERT Encoder-only model architecture and objectives
Encoder-only models like BERT are designed to produce strong bidirectional contextual embeddings rather than generating text. BERT utilizes two primary objective functions: Masked Language Modeling (MLM) and Next Sentence Prediction (NSP).
Key architectural components include:
[CLS]token: The embedding of this token is used to drive classification tasks.[SEP]token: Used to separate two sequences (e.g., a premise and a hypothesis in natural language inference).- Bidirectional context: Unlike decoder-only models, BERT considers tokens both to the left and right of a target token.
Understand the environmental impact of Large Language Models (LLMs)
The environmental cost of LLMs is primarily driven by the massive compute required for training and inference. Key impacts include:
- Greenhouse Gas Emissions: Training large models can produce hundreds of metric tons of CO2eq (e.g., DeepMind's Gopher produced ~380 net metric tons CO2eq).
- Water Footprint: Data centers require significant freshwater for cooling, and electricity generation itself is a major water consumer.
- Human Toxicity: Chip manufacturing releases chemicals into the environment that can cause cancer and other health issues.
- Resource Depletion: Manufacturing electronic devices requires minerals like lithium and cobalt, as well as fossil fuels.