INF1-IP: Week 5

Lecture 8 - Introduction to Generative AI

This lecture does not introduce new programming concepts and as such is not assessed and has no related self-guided notebook or key terms. We give this lecture because we think it is important for programmers to have a basic understanding of the field of AI, and give it in this week to not provide too much new programming material in the week of the first Class Test.

 

Learning outcomes
  • Describing the field of artificial intelligence and its major subfields
  • Understanding, on a high level, how large language models generate text
  • Understanding the ethical implications of creating and using LLMs and the causes of these issues

 

Further reading

For more on embeddings and LLMs, see also the materials for Week 9 of Intro to Cognitive Science, which some of you might be taking next semester.

 


 

Lecture 9 - Code quality 1: Testing and documentation

 

Learning outcomes
  • Applying decomposition and DRY to give functions clear, reusable jobs
  • Explaining test-driven development and the red → green → refactor cycle
  • Writing assert checks to automatically verify program functionality

 

Key terms
Click to expand.

Decomposition

Breaking a problem into smaller parts with clear responsibilities.

DRY

“Don't Repeat Yourself”: keeping a shared rule in one place.

Refactoring

Improving code's structure while preserving its intended behaviour.

Assertion

A condition that is checked during execution. A false condition causes an AssertionError.

Test case

An input together with its expected result or behaviour.

Test-driven development

An approach to coding in which you write a failing test for a small requirement, implement it, and then improve structure while keeping the tests passing.

Regression test

A retained check that can catch the return of a repaired bug.

 

New syntax
Click to expand.

assert condition

Continues silently if condition evaluates to True or stops the program with AssertionError if not.

assert condition, "message"

Includes a message with the AssertionError if the assertion fails.

AssertionError

A type of error raised when an assertion fails.

 

Further reading and practice

 


 

Tutorial

Tutorial 3: The Tools of the Trade 2 walks you through installing packages from the internet and setting up virtual environments to manage more advanced Python projects.

  • Interactive notebook (right-click → Save As... then remove the .txt part so it is saved as an .ipynb)
    • Note that this notebook was created to be used in Notable; its interactive checker cells might not work in every environment.

 


 

Assessment

Class Test 1 will take place on Thursday 22nd October in AT6:06. Check your timetable to see which session you are scheduled for.

For details, see Assessment.

 


 

License
All rights reserved The University of Edinburgh