Skip to content

Commit

Permalink
ch2
Browse files Browse the repository at this point in the history
  • Loading branch information
emilynordmann committed Mar 31, 2024
1 parent 11010ca commit 3cd546e
Show file tree
Hide file tree
Showing 10 changed files with 1,458 additions and 27 deletions.
26 changes: 18 additions & 8 deletions 01-intro.qmd
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Intro to using AI

There are a range of AIs and an even larger number of niche apps and platforms but we're going to focus on three big hitters: OpenAI's ChatGPT, Microsoft's Copilot, and Google's Gemini. The reason we've chosen these three platforms is that they're all reasonably generic AIs, they all have a free version, you've likely heard of them, and you probably already have an account you can use with at least one of them.
There are a range of AIs and an even larger number of niche apps and platforms but we're going to focus on three big hitters: OpenAI's ChatGPT, Microsoft's Copilot, and Google's Gemini. The reason I've chosen these three platforms is that they're all reasonably generic AIs, they all have a free version, you've likely heard of them, and you probably already have an account you can use with at least one of them.

We recommend trying out more than one platform. Below we describe the advantages and disadvantages of each as we have experienced, but some of it will come down to personal preference (and do let us know if you have further thoughts on the relative use of each platform).
I recommend trying out more than one platform. Below I describe the advantages and disadvantages of each as I have experienced, but some of it will come down to personal preference (and do let me know if you have further thoughts on the relative use of each platform).

## A brief introduction

Expand Down Expand Up @@ -36,7 +36,7 @@ Second, many of the developers that have produced AI models have done so behind

You can sign-up for ChatGPT at <https://chat.openai.com/>. The free version of ChatGPT uses GPT3.5 whilst you have to pay for a subscription to get access to GPT4.0.

The free version is very fast and for beginner level coding does perform quite well. I've also found that ChatGPT does generally seem to understand the intent of what I am asking. ChatGPT also makes it easy to save your chat history so that you can continue working in previous chats at a later date. A useful feature is the "regenerate" function whereby if you're not completely happy with the response, you can quickly ask it to generate another attempt and compare them. ChatGPT also has a mobile app. ChatGPT allows you to share links to saved chats.
The free version is very fast and for beginner level coding does perform quite well. I've also found that ChatGPT is good at understanding the intent of what I want. ChatGPT also makes it easy to save your chat history so that you can continue working in previous chats at a later date. A useful feature is the "regenerate" function whereby if you're not completely happy with the response, you can quickly ask it to generate another attempt and compare them. ChatGPT also has a mobile app and allows you to share links to saved chats.

The disadvantages of ChatGPT are that it has limited internet connectivity and the information in its database will be restricted. At the time of writing this book, ChatGPT's training data extends until January 2022, so it can't tell you about anything that happened after that point (regardless of whether that's world event or a new R function). Whilst it depends on which version you're using, it rarely gives you links to sources for where it has found the information.

Expand All @@ -49,12 +49,14 @@ knitr::include_graphics("include/images/01-choose/chatgpt.gif")

### Copilot

Microsoft Copilot can be accessed at <https://copilot.microsoft.com/> and you can sign-in with your Microsoft Account. If you are a University of Glasgow student (and also at many other universities), you can access Copilot through your university account and your Office365 subscription. If you do so, you'll be able to access the Enterprise version of Copilot. The advantage of using your Enterprise account is that the data is processed more securely and what you input won't be used to train the model. The disadvantage - and it's such a big disadvantage that I don't use it much for this reason - is that it doesn't save your chat history so you start each time afresh. If you use a personal account, it will save your chat history, but also use your data to train the model.
Microsoft Copilot can be accessed at <https://copilot.microsoft.com/> and you can sign-in with your Microsoft Account. If you are a University of Glasgow student (and also at many other universities), you can access Copilot through your university account and your Office365 subscription. If you do so, you'll be able to access the Enterprise version of Copilot. The advantage of using your Enterprise account is that the data is processed more securely and what you input won't be used to train the model. The price you pay for this security - and it's such a big price that I don't use it much for this reason - is that it doesn't save your chat history so you start each time afresh. If you use a personal account, it will save your chat history, but also use your data to train the model.

However, where Copilot shines is that it has access to the internet and will give you links to where it got its information so it's easier to verify than ChatGPT. Additionally, it's not clear but if you select the conversation style to be "Creative", it will use GPT4.0 (which you have to pay for if you use ChatGPT).
However, where Copilot shines is that it has access to the internet and will give you links to where it got its information so it's easier to verify than ChatGPT. Additionally, they don't make this clear but if you select the conversation style to be "Creative", it will use GPT4.0 (which you have to pay for if you use ChatGPT).

I have found that Copilot more frequently doesn't understand the intent of what I am asking and with the same prompt as ChatGPT will give me a useless answer, but let's see how I feel about that by the end of writing this book.

My general approach is that if I want to be able to return to my conversation, I use ChatGPT or Gemini. If I want links to sources for a throwaway query, I use Copilot.

There is a Copilot mobile app.

```{r img-copilot, echo=FALSE, fig.cap="using ChatGPT"}
Expand All @@ -76,6 +78,8 @@ Another advantage is that it uses a different model to ChatGPT so if you're goin

There is a Gemini mobile app, but it isn't currently available in the UK.

Before writing this book, I had used Gemini less than the others. Let's see where I end up at the end.

```{r img-gemini, echo=FALSE, fig.cap="using ChatGPT"}
knitr::include_graphics("include/images/01-choose/gemini.gif")
Expand All @@ -91,10 +95,16 @@ knitr::include_graphics("include/images/01-choose/gemini.gif")

The key difference between using an AI and a regular search engine is that you can shape the output of the AI by "prompt engineering", which is the phrase used to describe the art of asking the question in a way that gives you the answer you want. It's easier to show than tell.

Think of a book, TV show, film, or videogame that you know really well (I chose Final Fantasy VII (the original PlayStation version). Ask the AI to give you three different summaries and try out the functionality of each platform (e.g., for ChatGPT ask it to regenerate the response, for Gemini, use modify response or Double-check response with Google):
Think of a book, TV show, film, or videogame that you know really well (I chose Final Fantasy VII (the original PlayStation version). Ask the AI to give you three different summaries and try out the functionality of each platform. For example, for ChatGPT ask it to regenerate the response, for Gemini, use modify response or Double-check response with Google.

- First, ask it for a summary without any additional context e.g., "Give me a summary of Final Fantasy VII (original playstation version)"
- Then, ask it for a summary for someone who doesn't know it, e.g., "Give me a summary of Final Fantasy VII (original playstation version) for someone who knows nothing about videogames"
- Finally, ask it for an expert summary, e.g., "Give me a summary of Final Fantasy VII (original playstation version) for an expert gamer who has played it many times"

- Then, ask it for a summary but give it a steer on the intended audience, e.g., "Give me a summary of Final Fantasy VII (original playstation version) for someone who knows nothing about videogames" or "Give me a summary of Final Fantasy VII (original playstation version) for an expert gamer who has played it many times"
- Finally, ask it for a summary, but give it a steer on how it should act, e.g., "Act as an expert videogame reviewer for the Guardian. Give me a summary of Final Fantasy VII (original playstation version) for an expert gamer who has played it many times" or "Act as someone who spends too much time on Reddit and thinks they know everything. Give me a summary of Final Fantasy VII (original playstation version) for an expert gamer who has played it many times".

The key takeaways to remember for your coding journey are:

* Tell it how to act
* Tell it who you are

Reflect on the differences between the summaries - the technicality of the language, the accuracy and nuance of the information, what it chose to focus on, and what it chose to omit. The reason I asked you to create a summary of something you already know well is that you're aware of where the gaps are. **Remember this when you're asking an AI something you don't know as well**. Just because you can't see the gaps and the inaccuracies, doesn't mean they're not there.
63 changes: 63 additions & 0 deletions 02-elaboration.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@

# Personalised tutor

This chapter will teach you how to use AI as a personalised tutor to explain concepts and functions you're struggling to understand, or would like more information on.

It will be helpful to work through these activities with a specific chapter of your course in mind (e.g., [Applied Data Skills](https://psyteachr.github.io/ads-v3/) week 1 or 2)

## Set-up

The key to maximising the usefulness of AI is to use prompt engineering to tailor the output your to your exact needs. Before you ask any questions, you need to tell the AI who you are and exactly how it should act.

Here's some examples:

> Act as an expert tutor for the programming language R. I am a learner on an Upskilling course "Applied Data Skills" and I am learning R for the first time. I work in the NHS in Health Informatics. I have never learned a programming language before. I have used Excel and SPSS. I have reasonably good general computer literacy. I will ask you questions about concepts and functions I do not understand based on my course materials. Always give me concrete examples when you provide an answer. Tailor your responses to my level of expertise. I am using R and RStudio on a Mac and the course will strongly use the tidyverse.
> Act as an expert tutor for the programming language R. I am a first year psychology student at the University of Glasgow and I am learning R for the first time. I have never learned a programming language before and I am not very confident with computers and I am anxious about learning programming. I have a Windows laptop. I will ask you questions about concepts and functions I do not understand based on my course materials. Always give me concrete examples when you provide an answer. Tailor your responses to my level of expertise. I am using R and RStudio and the course will strongly use the tidyverse.
> Act as an expert tutor for the programming language R. I am a second year psychology student at the University of Glasgow. I have been learning R for a year. I also study statistics and computing science and know a bit of Python as well. I feel confident with learning to code and I would like to stretch myself. I will ask you questions about concepts and functions I do not understand based on my course materials. Always give me concrete examples when you provide an answer. Tailor your responses to my level of expertise. I am using R and RStudio and the course will strongly use the tidyverse although I would also like to learn about base R alternative approaches.
## Activity 1

Write your set-up. It's worth spending some time to get this right, you're going to use it a lot.

I'd probably recommend using ChatGPT or Gemini for this because it's helpful to be able to save your chat and the set-up information. You could also use a personal Copilot account but the Enterprise version won't save your chats. If you'd like to use Copilot, save your set-up prompt somewhere to make it easy to reuse.

Exactly what information you provide is up to you but make sure that you explain your level of knowledge, skill, confidence and previous experience. By specifying what your field is (psychology, NHS etc.) it can then give you examples related to these fields which will make it easier for you to understand and connect your new knowledge to existing knowledge. Finally, you also want to give it some technical information about the software you're using (e.g., R and RStudio), your operating system (Windows).

## Activity 2

Enter your set-up into a new chat on your AI of choice. If you're using an AI that saves your chats, you could also rename the chat to "Personal R Tutor" or "Week 1 Tutor" or anything else that make sense to you. Depending on what information you give it, it may give you some intro to R tips and information which may be more or less useful, so if you're new and it's confusing, just ignore it.

## Example questions

Now that you've got your tutor set up, you can ask it questions. Here's some examples:

* Why do I have to learn to code?
* What is the difference between a function and an argument?
* Explain what each part of this code is doing: `ggplot(survey_data, aes(x = wait_time, y = call_time)) + geom_point()`
* Give me examples of when I would use different joins

## Activity 3

Ask the AI three questions based on your course materials. If the output doesn't seem quite right for you, consider editing your initial set-up prompt and re-running the questions to see how they output changes.


## Follow-up

Another big difference between AI and a regular search engine is that you can have a conversation with it and follow-up on your original question. Some examples:

* Can you explain it comparing it to Excel?
* Expand on your explanation of `geom_point()`
* Give me another example of code that uses this approach
* Explain it again but in more technical / simpler terms (Gemini's modify response can also be used for this)
* Ask me a question to test if I understand this correctly (we're going to go into practice testing a lot more in the next chapter)
* In your answer you said "In this example, c() is a function that combines values into a vector", what is a vector?

## Activity 4

Ask a follow-up question to each of your original questions. Additionally, try outh the features of each AI. For Gemini, use the modify response and double-check response options. For ChatGPT, use regenerate response. For Copilot, click on the suggested follow-up questions or any links it provides.




Loading

0 comments on commit 3cd546e

Please sign in to comment.