Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/fhdsl/AI_for_software into …
Browse files Browse the repository at this point in the history
…main
  • Loading branch information
jhudsl-robot committed Jul 17, 2023
2 parents bbf0aa5 + 608a63e commit a956c47
Show file tree
Hide file tree
Showing 26 changed files with 90 additions and 30 deletions.
2 changes: 1 addition & 1 deletion docs/01-intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ The methods used for chatbots have evolved over time. Now chatbots often utilize
Despite the fact that chatbots have been around awhile, the popularity of OpenAI's ChatGPT and DALL-E programs has sparked a recent surge of interest. These chatbots are in part particularly powerful due to the fact that large amounts of computing power were used to train their NLP models on very large datasets [@caldarini2022literature; @cahn2017chatbot]. Large language model AIs can be divided into two categories: those that can be reached using an internet browser, and those that can be reached using an integrated development environment (IDE).

::: warning
The information presented in this course is meant for use with open source code and software. It is unclear what happens to the information fed to AI chatbots as prompts, or how secure the data are. We know data are saved and may be used to further train the AI tools, but the specifics of how data are saved and how sensitive or personally identifiable information are protected.
The information presented in this course is meant for use with open source code and software. It is unclear what happens to the information fed to AI chatbots as prompts, or how secure the data are. We know data are saved and may be used to further train the AI tools, but the specifics of how data are saved, as well as how sensitive or personally identifiable information are protected, is unknown.

Err on the side of caution when interacting with them. We do **not** recommend using proprietary code or private information for prompts unless you are working with an AI that you or your company built and you know is secure.
:::
Expand Down
2 changes: 1 addition & 1 deletion docs/03-writing_code.md
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ devtools::session_info()
## collate en_US.UTF-8
## ctype en_US.UTF-8
## tz Etc/UTC
## date 2023-07-14
## date 2023-07-17
##
## ─ Packages ───────────────────────────────────────────────────────────────────
## package * version date lib source
Expand Down
12 changes: 9 additions & 3 deletions docs/04-refactoring.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ However, AI has significant potential to help with code refactoring. AI can use

AI refactoring is also faster and more accurate than manual refactoring. This is particularly useful for large-scale software projects with massive codebases, where manual code review and refactoring can be an enormous task. In the next sections, we'll take a look at some examples of using AI to refactor code.

::: warning
The information presented in this course is meant for use with open source code and software. It is unclear what happens to the information fed to AI chatbots as prompts, or how secure the data are. We know data are saved and may be used to further train the AI tools, but the specifics of how data are saved, as well as how sensitive or personally identifiable information are protected, is unknown.

Err on the side of caution when interacting with them. We do **not** recommend using proprietary code or private information for prompts unless you are working with an AI that you or your company built and you know is secure.
:::

## Example One: Correcting Syntax

Programming languages operate using their established set of rules. For example, [Python](https://www.python.org/) uses indentation to define code blocks. However, when you shift between development environments, indentation and line breaks can sometimes be affected, causing major headaches!
Expand Down Expand Up @@ -547,7 +553,7 @@ proc.time() - start_time

```
## user system elapsed
## 12.208 0.000 12.208
## 12.039 0.001 12.041
```

:::{.query}
Expand Down Expand Up @@ -575,7 +581,7 @@ proc.time() - start_time

```
## user system elapsed
## 0.575 0.327 0.598
## 0.650 0.356 0.680
```

The `outer()` function performs the same calculation as the nested loop in the original code, but more efficiently. It returns a matrix of all possible combinations of x and y values, with each element of the matrix being the product of the corresponding x and y values. The `rowSums()` function is then used to sum the elements of each row of the matrix, which is equivalent to summing the products of x and y for each index `i` in the original loop. This method avoids the need for the nested loop, resulting in a faster and more efficient computation.
Expand Down Expand Up @@ -603,7 +609,7 @@ proc.time() - start_time

```
## user system elapsed
## 0.265 0.288 0.350
## 0.334 0.284 0.396
```

One optimized way to perform the same calculation is by using the `%*%` operator to perform matrix multiplication. This can be done by converting x and y to matrices and transposing one of them so that their dimensions align for matrix multiplication. This code should be much faster than the original implementation because it takes advantage of highly optimized matrix multiplication algorithms in R.
Expand Down
8 changes: 7 additions & 1 deletion docs/05-annotation.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ There are many benefits to annotating code:
- Improves maintainability
- Improves quality

::: warning
The information presented in this course is meant for use with open source code and software. It is unclear what happens to the information fed to AI chatbots as prompts, or how secure the data are. We know data are saved and may be used to further train the AI tools, but the specifics of how data are saved, as well as how sensitive or personally identifiable information are protected, is unknown.

Err on the side of caution when interacting with them. We do **not** recommend using proprietary code or private information for prompts unless you are working with an AI that you or your company built and you know is secure.
:::

## Improves readability

<img src="05-annotation_files/figure-html//1MCNeSO4aOm1iESWDLOGTcx3aLEbnu8UttV0QGVAeafE_g22de39942ac_19_8.png" title="Dino says It’s great this code is well annotated using AI. I totally forgot what I was doing with this code when I wrote it. " alt="Dino says It’s great this code is well annotated using AI. I totally forgot what I was doing with this code when I wrote it. " width="100%" style="display: block; margin: auto;" />
Expand Down Expand Up @@ -368,7 +374,7 @@ devtools::session_info()
## collate en_US.UTF-8
## ctype en_US.UTF-8
## tz Etc/UTC
## date 2023-07-14
## date 2023-07-17
##
## ─ Packages ───────────────────────────────────────────────────────────────────
## package * version date lib source
Expand Down
6 changes: 6 additions & 0 deletions docs/06-understanding_other_ppl_code.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ Keep these ethical considerations in mind when using AI to summarize code.
**Does the code contain any sensitive or personal information?** If the code contains any sensitive or personal information, you should take special care to protect that information.
:::

::: warning
The information presented in this course is meant for use with open source code and software. It is unclear what happens to the information fed to AI chatbots as prompts, or how secure the data are. We know data are saved and may be used to further train the AI tools, but the specifics of how data are saved, as well as how sensitive or personally identifiable information are protected, is unknown.

Err on the side of caution when interacting with them. We do **not** recommend using proprietary code or private information for prompts unless you are working with an AI that you or your company built and you know is secure.
:::

## Example One: Summarizing Code You Didn't Write

Here's some simple code using the R programming language, written by an unnamed programmer. If you are familiar with R, you might be able to understand what this code does with little effort. However, if you don't know R, you're relatively new to R, or you're just having a bad day, understanding what this bit of code can take a great deal more energy and time. AI language bots can ease that burden.
Expand Down
2 changes: 1 addition & 1 deletion docs/About.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ Tools Used:
## collate en_US.UTF-8
## ctype en_US.UTF-8
## tz Etc/UTC
## date 2023-07-14
## date 2023-07-17
##
## ─ Packages ───────────────────────────────────────────────────────────────────
## package * version date lib source
Expand Down
2 changes: 1 addition & 1 deletion docs/about-the-authors.html
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ <h1>About the Authors</h1>
## collate en_US.UTF-8
## ctype en_US.UTF-8
## tz Etc/UTC
## date 2023-07-14
## date 2023-07-17
##
## ─ Packages ───────────────────────────────────────────────────────────────────
## package * version date lib source
Expand Down
6 changes: 5 additions & 1 deletion docs/annotating-your-code.html
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,10 @@ <h2><span class="header-section-number">5.2</span> Annotating Code is Good Pract
<li>Improves maintainability</li>
<li>Improves quality</li>
</ul>
<div class="warning">
<p>The information presented in this course is meant for use with open source code and software. It is unclear what happens to the information fed to AI chatbots as prompts, or how secure the data are. We know data are saved and may be used to further train the AI tools, but the specifics of how data are saved, as well as how sensitive or personally identifiable information are protected, is unknown.</p>
<p>Err on the side of caution when interacting with them. We do <strong>not</strong> recommend using proprietary code or private information for prompts unless you are working with an AI that you or your company built and you know is secure.</p>
</div>
</div>
<div id="improves-readability" class="section level2" number="5.3">
<h2><span class="header-section-number">5.3</span> Improves readability</h2>
Expand Down Expand Up @@ -644,7 +648,7 @@ <h2><span class="header-section-number">5.10</span> Summary</h2>
## collate en_US.UTF-8
## ctype en_US.UTF-8
## tz Etc/UTC
## date 2023-07-14
## date 2023-07-17
##
## ─ Packages ───────────────────────────────────────────────────────────────────
## package * version date lib source
Expand Down
2 changes: 1 addition & 1 deletion docs/introduction.html
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ <h2><span class="header-section-number">1.4</span> The AI Chatbots</h2>
<p>The methods used for chatbots have evolved over time. Now chatbots often utilize AI methods like <a href="https://en.wikipedia.org/wiki/Deep_learning">deep learning</a> (which involve multiple layers of abstractions of the input data <span class="citation">(<a href="references.html#ref-wikipedia_deep_learning_2023" role="doc-biblioref"><span>“Deep Learning”</span> 2023</a>)</span>) to extract meaning from the language data <span class="citation">(<a href="references.html#ref-wikipedia_natural_2023" role="doc-biblioref"><span>“Natural Language Processing”</span> 2023</a>)</span>. As these methods use large quantities of text, they are therefore often called large language models <span class="citation">(<a href="references.html#ref-wikipedia_large_language_2023" role="doc-biblioref"><span>“Large Language Model”</span> 2023</a>)</span>.</p>
<p>Despite the fact that chatbots have been around awhile, the popularity of OpenAI’s ChatGPT and DALL-E programs has sparked a recent surge of interest. These chatbots are in part particularly powerful due to the fact that large amounts of computing power were used to train their NLP models on very large datasets <span class="citation">(<a href="references.html#ref-caldarini2022literature" role="doc-biblioref">Caldarini, Jaf, and McGarry 2022</a>; <a href="references.html#ref-cahn2017chatbot" role="doc-biblioref">Cahn 2017</a>)</span>. Large language model AIs can be divided into two categories: those that can be reached using an internet browser, and those that can be reached using an integrated development environment (IDE).</p>
<div class="warning">
<p>The information presented in this course is meant for use with open source code and software. It is unclear what happens to the information fed to AI chatbots as prompts, or how secure the data are. We know data are saved and may be used to further train the AI tools, but the specifics of how data are saved and how sensitive or personally identifiable information are protected.</p>
<p>The information presented in this course is meant for use with open source code and software. It is unclear what happens to the information fed to AI chatbots as prompts, or how secure the data are. We know data are saved and may be used to further train the AI tools, but the specifics of how data are saved, as well as how sensitive or personally identifiable information are protected, is unknown.</p>
<p>Err on the side of caution when interacting with them. We do <strong>not</strong> recommend using proprietary code or private information for prompts unless you are working with an AI that you or your company built and you know is secure.</p>
</div>
<p><img src="resources/images/01-intro_files/figure-html/1MCNeSO4aOm1iESWDLOGTcx3aLEbnu8UttV0QGVAeafE_g23e17ee1585_223_77.png" title="The dinosaur cartoon says in a speech bubble 'Wow, there are already so many options!' as names of AI tools swirl around the dinosaur's head." alt="The dinosaur cartoon says in a speech bubble 'Wow, there are already so many options!' as names of AI tools swirl around the dinosaur's head." width="100%" style="display: block; margin: auto;" /></p>
Expand Down
2 changes: 1 addition & 1 deletion docs/no_toc/01-intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ The methods used for chatbots have evolved over time. Now chatbots often utilize
Despite the fact that chatbots have been around awhile, the popularity of OpenAI's ChatGPT and DALL-E programs has sparked a recent surge of interest. These chatbots are in part particularly powerful due to the fact that large amounts of computing power were used to train their NLP models on very large datasets [@caldarini2022literature; @cahn2017chatbot]. Large language model AIs can be divided into two categories: those that can be reached using an internet browser, and those that can be reached using an integrated development environment (IDE).

::: warning
The information presented in this course is meant for use with open source code and software. It is unclear what happens to the information fed to AI chatbots as prompts, or how secure the data are. We know data are saved and may be used to further train the AI tools, but the specifics of how data are saved and how sensitive or personally identifiable information are protected.
The information presented in this course is meant for use with open source code and software. It is unclear what happens to the information fed to AI chatbots as prompts, or how secure the data are. We know data are saved and may be used to further train the AI tools, but the specifics of how data are saved, as well as how sensitive or personally identifiable information are protected, is unknown.

Err on the side of caution when interacting with them. We do **not** recommend using proprietary code or private information for prompts unless you are working with an AI that you or your company built and you know is secure.
:::
Expand Down
2 changes: 1 addition & 1 deletion docs/no_toc/03-writing_code.md
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ devtools::session_info()
## collate en_US.UTF-8
## ctype en_US.UTF-8
## tz Etc/UTC
## date 2023-07-14
## date 2023-07-17
##
## ─ Packages ───────────────────────────────────────────────────────────────────
## package * version date lib source
Expand Down
12 changes: 9 additions & 3 deletions docs/no_toc/04-refactoring.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ However, AI has significant potential to help with code refactoring. AI can use

AI refactoring is also faster and more accurate than manual refactoring. This is particularly useful for large-scale software projects with massive codebases, where manual code review and refactoring can be an enormous task. In the next sections, we'll take a look at some examples of using AI to refactor code.

::: warning
The information presented in this course is meant for use with open source code and software. It is unclear what happens to the information fed to AI chatbots as prompts, or how secure the data are. We know data are saved and may be used to further train the AI tools, but the specifics of how data are saved, as well as how sensitive or personally identifiable information are protected, is unknown.

Err on the side of caution when interacting with them. We do **not** recommend using proprietary code or private information for prompts unless you are working with an AI that you or your company built and you know is secure.
:::

## Example One: Correcting Syntax

Programming languages operate using their established set of rules. For example, [Python](https://www.python.org/) uses indentation to define code blocks. However, when you shift between development environments, indentation and line breaks can sometimes be affected, causing major headaches!
Expand Down Expand Up @@ -547,7 +553,7 @@ proc.time() - start_time

```
## user system elapsed
## 280.405 0.068 280.464
## 210.361 0.068 210.452
```

:::{.query}
Expand Down Expand Up @@ -575,7 +581,7 @@ proc.time() - start_time

```
## user system elapsed
## 0.733 0.308 0.942
## 0.771 0.244 0.746
```

The `outer()` function performs the same calculation as the nested loop in the original code, but more efficiently. It returns a matrix of all possible combinations of x and y values, with each element of the matrix being the product of the corresponding x and y values. The `rowSums()` function is then used to sum the elements of each row of the matrix, which is equivalent to summing the products of x and y for each index `i` in the original loop. This method avoids the need for the nested loop, resulting in a faster and more efficient computation.
Expand Down Expand Up @@ -603,7 +609,7 @@ proc.time() - start_time

```
## user system elapsed
## 0.424 0.340 0.496
## 0.334 0.248 0.357
```

One optimized way to perform the same calculation is by using the `%*%` operator to perform matrix multiplication. This can be done by converting x and y to matrices and transposing one of them so that their dimensions align for matrix multiplication. This code should be much faster than the original implementation because it takes advantage of highly optimized matrix multiplication algorithms in R.
Expand Down
Loading

0 comments on commit a956c47

Please sign in to comment.