Hands-On Learning: Teaching Students about Large Language Models with Python Coding

Wednesday 05 March 2025


Scientists have been working on a new way to teach students about large language models, and it’s all thanks to an innovative approach that combines Python coding with interactive activities.


Large language models are complex artificial intelligence systems that can generate human-like text based on what they’ve learned from vast amounts of data. They’re not just limited to simple tasks like answering questions or translating languages; these models can create entire paragraphs, even stories and dialogues. But how do they work?


To help students understand the basics of large language models, researchers have developed a series of interactive Python activities that allow students to experiment with different parameters and see firsthand how the models process and generate text.


One of the key concepts explored in these activities is word embeddings, which are a way for computers to represent words as numerical vectors. This allows them to understand the relationships between words and make predictions about what comes next in a sentence or paragraph.


The researchers used two types of large language models in their experiments: Word2Vec and GPT-2. Word2Vec is a neural network-based model that creates word embeddings by analyzing large amounts of text data, while GPT-2 is a generative model that can generate human-like text based on what it’s learned from the data.


In one activity, students used Python code to train a Word2Vec model on a small corpus of sentences and then tested its ability to predict the next word in a sentence. They found that the model was able to make accurate predictions when given similar contexts, but struggled with more abstract or ambiguous language.


In another activity, students explored GPT-2’s ability to generate text based on a prompt. By adjusting different parameters such as temperature and model size, they saw how these factors affected the coherence and creativity of the generated text.


One of the key insights from this study is that large language models are not just simple machines that can be used for specific tasks; they’re complex systems that require careful tuning and understanding to achieve their full potential. By giving students hands-on experience with these models, researchers hope to inspire a new generation of scientists and engineers who will push the boundaries of what’s possible with AI.


The study also highlights the importance of critical thinking in evaluating the outputs of large language models. While these systems can generate impressive text, they’re not perfect and can sometimes produce inaccurate or misleading information.


Cite this article: “Hands-On Learning: Teaching Students about Large Language Models with Python Coding”, The Science Archive, 2025.


Large Language Models, Python Coding, Interactive Activities, Artificial Intelligence, Word Embeddings, Neural Network-Based Model, Generative Model, Gpt-2, Word2Vec, Critical Thinking.


Reference: Eugenio Tufino, “Exploring Large Language Models (LLMs) through interactive Python activities” (2025).


Leave a Reply