Corresponding lecture
There is no corresponding lecture.
Description
When OpenAI debuted its now famous ChatGPT on November 30th, 2022, it took the world by storm. In the short time since, OpenAI has led the rapid development of large language models (LLM) and generative AI for a range of applications. One clear place where AI and LLMs excel is in coding. The Codex LLM created by OpenAI is trained on Github code and a production version of this tool is available as Github Copilot. In this lab, I’ll demonstrate how you can use Copilot as a ‘pair programmer’, allowing you much more rapidly and seemlessly start new coding projects.
In the first 1/2 of lab, we’ll review the solution for last week’s lab. Then we’ll transition to doing a test drive of Copilot using the LEMIS dataset from the LearnR portion of the course. Then, for the second 1/2 of the class, we’ll discuss and begin the lab for next week.
What you’ll need to get started
-
Copilot is free for students and teachers, but getting access to it can be a little confusing. At the start of the course, I asked everyone to follow these step-by-step instructions.
-
Download this stripped down version of the solutions script from the capstone project that’s part of the LearnR portion of the course. Note, this ‘script’ has only comments…no code. With Copilot turned on in RStudio, I’ll demo how we can analyze the LEMIS dataset and answer the questions from last week’s lab using Copilot.
Tips and tricks for using Copilot
- Probably the single most important thing to understand from this lab is that, with Copiot turned on, your comments in your scripts now become powerful prompts for generative AI. In other words, your comments are no longer just for you or someone else that might look at your script…they are also helping Copilot understand what you hope to achieve at each point in your script.
- Copilot has ‘cross-tab’ awareness. This means that if you have open multiple scripts in RStudio, Copilot will be aware of the code in these other tabs and will use this information to provide better responses to your prompts. So, in this class for example, if you were to open all the step scripts, this would be immensely helpful as you begin a new RNA-seq analysis project with a new analysis script.
- Copilot (like all LLMs) will be wrong many times. It is your responsibility to check the code provided by these AI tools for accuracy. Code suggested by Copilot should be considered as a rough draft, not a polished final product.
- ChatGPT is great at explaining code that you don’t understand! You can take advantage of this when you are presented with a script that has little or not comments/annotations.
- One of my favorite uses of ChatGPT in coding is when I need to make a regular expression for matching text