Stanford CS229 Machine Learning | Spring 2026 | Lecture 13: LLMs, Next-Word Prediction Loss
Stanford Online · 1:00:42 · 4 days ago
Representation learning enables machines to organize information by mapping data into geometric space, while retrieval techniques improve accuracy by providing external context instead of retraining models.
- Data mapping — Neural networks translate raw inputs like images or text into numerical coordinates called vectors .
- Similarity goal — Systems arrange data so related items cluster together in geometric space, while unrelated items remain far apart .
- Contrastive learning — This method creates training groups by applying random variations like crops or noise to an image, forcing the model to recognize them as the same item .
- Balancing pairs — Objectives encourage the network to minimize distance for matching items while maximizing distance for random, unrelated samples .
- Hard negative mining — Including difficult, near-similar items as negative examples makes the model more precise at distinguishing subtle differences .
- Semantic search — Tools find relevant content by calculating the dot product between a query vector and a database of pre-calculated document vectors .
- Retrieval-Augmented Generation — Feeding relevant retrieved documents into an LLM provides external information without needing to retrain or update the model parameters .
- Information governance — Separating the retrieval process from the language model allows for strict access control and easier deletion of sensitive data .
How does hard negative mining impact training objectives? What are the advantages of retrieval-augmented generation over fine-tuning?