Introduction to Programming Assistant

Session Overview

  • What is Gen AI?
  • Code Completion
  • Options
  • Best Practices for Communicating:
    • Generation
    • Correction
    • Documentation
    • Language Translation

Gen AI

Generative AI refers to artificial intelligence systems designed to create new content such as text, images, music, or code. It learns patterns from existing data and generates novel outputs that mimic those patterns.


Key Components:

  • Deep Learning Models: Uses neural networks, such as transformers, to model and generate data.
  • Pre-training and Fine-tuning: Trained on massive datasets and refined for specific tasks.
  • Modalities: Can generate across various forms, like text (ChatGPT), images (DALL·E), music, or video (Sora).


Examples of GenAI Systems:

  • Text generation (e.g., GPT-4, ChatGPT)
  • Image generation (e.g., DALL·E, MidJourney)
  • Music and video creation (e.g., Jukedeck, Runway, Sora)

Code Completion

Options

AI IDEs


Web Interfaces

Run Locally

ChatGPT

ChatGPT

  • Large Language Model

  • IT CAN BE WRONG!

It Can Be Wrong

It Can Be Wrong

GenAI Guidelines

  • NO PERSONAL INFORMATION! EVER!!!
  • Double check the work!
  • Use it interactively
  • Iteratively refine your prompts
  • Prompt engineering matters (a lot). If you aren’t obtaining helpful results with one prompt, consider re-engineering your prompt (more on this tomorrow).

GenAI Guidelines

Documentation


def calculate_sum(number_one, number_two):
  result = number_one + number_two
  
  return result

“Please generate the docstring and comments for this python function:”

ChatGPT Guidelines

Generation

“Please develop a python function to calculate euclidean distance between two points.”

ChatGPT Guidelines

Correction

def some_function(input):
    for i in range(len(input)):
        if input[i] == 2:
            del input[i]
    return True

list_01 = [1,2,4,5,6]
some_function(list_01)

“This code does not work. Would you please fix it and explain what was wrong and how you fixed it. Thank you!”

GenAI Guidelines

Language Translation


“Please convert this code from R to Python:”

table4b %>% 
  pivot_longer(c(`1999`, `2000`), names_to = "year", values_to = "population")