SYSTEM NOTICE

Auto translation by AI. Be sure, accuracy, nuances and authorial intent may not be fully reflected.
見出し画像

I tried out ChatGPT's Code Interpreter

The Code Interpreter feature has been implemented in ChatGPT, so I tried it out immediately.

Currently, it is available on a limited basis only for the paid ChatGPT Plus plan.
By the way, along with this release, the gpt-4 API has also been opened to Plus users, so those who can use it should give it a try.

This is a feature that people who have nothing to do with programming should be using!

It means that ChatGPT, which could only read and write text, can now even execute programs!
...It's like the image of Kannon with a thousand hands, isn't it...
The feeling of invincibility is amazing...

What is Code Interpreter?

In the first place, 'Interpreter' means a translator. Since 'Code' is attached to it, it means a translator between natural language and code.

What is an interpreter?
It means 'translator'. It is one of the ways to execute programs on a computer. It refers to a program that interprets and executes source code one instruction at a time. It processes and executes source code written in a programming language while interpreting and converting it into machine language programs (object programs). Representative programming languages include BASIC, Lisp, JavaScript, Python, Ruby, etc.

Otsuka Corporation
https://mypage.otsuka-shokai.co.jp/cmp/contents/business-oyakudachi/words/interpreter.html


It's a term that seems to have nothing to do with anyone other than engineers, but I will say it again. ChatGPT Code Interpreter isa feature that people who have nothing to do with programming should be using!

How to use

First of all, since it is released on a limited basis, you need to subscribe to the paid ChatGPT Plus.
Even so, it is not available by default, so you need to change the settings.
With the left menu displayed after logging in, click your login name at the bottom left to open Settings.
From there, open Beta features and enable the check for Code Interpreter.

It's on now

Start a new chat, select gpt-4 from the tab at the top, and select Code Interpreter from within it.
With this, you can execute programs within ChatGPT.

It's OK if there is a check mark ✅ on Code Interpreter

Execute python code on ChatGPT

First, let's start with something quick. It's a graph drawing of a quadratic function that even a junior high school student can understand.

Please execute a sample of a quadratic function with the code interpreter.

user

Certainly. A quadratic function is generally expressed in the form \(f(x) = ax^2 + bx + c\). Here, \(a\), \(b\), and \(c\) are constants.

Here, as an example, let's plot the quadratic function \(f(x) = x^2 - 3x + 2\) using the values \(a=1\), \(b=-3\), and \(c=2\). To draw the graph of this function, we first define the range of \(x\) and calculate the value of \(f(x)\) for that range.

Let's draw a graph using Python's matplotlib and numpy libraries.

The graph below represents the quadratic function \(f(x) = x^2 - 3x + 2\). This function becomes \(0\) at \(x = 1\) and \(x = 2\), and takes positive or negative values for other values. These points are called the roots or zeros of the quadratic function.

Also, this function forms an upward-opening parabola (because \(a > 0\)), and the vertex is found at \(x = -\frac{b}{2a}\).

Please let me know if there is any other quadratic function you would like to plot, or if you have any other questions.

ChatGPT Model: Code Interpreter

Graph plotting is also possible

It can even draw a graph from such a rough instruction...

Code Interpreter creates and executes Python code

You can see the executed code

Moreover, if you click Show Work, you can even see the code that was executed.

Naturally, there is no need to show it to people who don't understand programming, so it doesn't appear unless you click it, but conversely, this means that even those who don't understand programming can now write executable programs.

The barrier to entry is lower than Excel functions...

Data is lost when the session is disconnected

I will share the executed interaction via the URL below.

However, some kind of error appears.

This code interpreter (beta) chat has timed out.
You may continue the conversation, but previous files, links, and code blocks below may not work as expected.
This code interpreter (beta) chat has timed out.
You may continue the conversation, but previous files, links, and code blocks below may not work as expected.

I also confirmed other errors, so I will share them.
It seems you cannot share images of the execution results.
It is recommended to save screenshots or output images.

This chat contains files or images produced by Code
Interpreter which are not yet visible in Shared Chats.
This chat contains files or images produced by Code
Interpreter which are not yet visible in Shared Chats.
Image output is not supported in a shared chat
Image output is not supported in a shared chat

What Code Interpreter can do

I found a post like this.
So you can see which libraries are available along with their versions!
This is helpful.

It seems like it can do a lot, but naturally there are limitations too.
By the way, when I tried executing the same command, it was no longer possible. It's only been two days since the release, so they are quick to respond...

I guess it would be pretty dangerous if you could use the pip command...

I asked again what it can do.

Code Interpreter can execute Python code and return the results to the user. Using this feature, you can perform various mathematical calculations, data analysis, data visualization, and machine learning model training and evaluation.

Below are some of the main features provided by Code Interpreter:

1. **Mathematical calculations:** You can solve problems in arithmetic, algebra, statistics, probability theory, etc. For example, you can find solutions to equations or perform statistical analysis.

2. **Data analysis:** You can manipulate and analyze datasets using Python data analysis libraries (pandas, numpy, etc.).

3. **Data visualization:** You can visually represent data using libraries such as matplotlib, seaborn, and plotly.

4. **Machine learning:** You can train and evaluate machine learning models using libraries such as scikit-learn, TensorFlow, and PyTorch.

5. **Text manipulation:** You can process text data using Python's string manipulation functions or perform pattern matching using regular expressions.

However, there are the following limitations:

- Code Interpreter only supports Python. It cannot execute code in other programming languages.
- Internet access is disabled. Therefore, you cannot make requests to external APIs or perform web scraping.
- Some libraries and features are unavailable. For example, GUI libraries (such as Tkinter) and multiprocessing cannot be used.

Please utilize these features to help with your problem-solving and learning.

ChatGPT Model: Code Interpreter

There are so many things it can do now that I can't even write them all down...

Limitations

Since there are naturally security concerns, it seems there are also many limitations. I checked what it cannot do.

This Code Interpreter (or Code Execution Environment) is designed to execute Python code in a Jupyter notebook environment, and some limitations have been set. The main limitations are listed below:

1. **Internet Access**: Access to the internet is disabled. This means that requests to external APIs, web scraping, connecting to external databases, and downloading external resources are not possible.

2. **System Commands**: System-level commands (e.g., `os.system()`, `subprocess.run()`, etc.) are restricted. This limits the execution of shell commands and the reading/writing of system files.

3. **Long Execution Times**: The execution time for a single code cell is limited to a maximum of 120 seconds (2 minutes). If this time is exceeded, execution is automatically stopped.

4. **High Memory Usage**: Processes that consume large amounts of memory are restricted. If memory usage is too high, code execution may be stopped.

5. **Specific Python Libraries**: Some Python libraries are unavailable. This includes certain system-dependent libraries and libraries that use network functionality.

6. **Data Persistence**: Data persistence is not guaranteed. When a session ends, all data generated during that session is deleted.

The above limitations are in place to protect user and system security and to ensure fair resource usage. With these limitations, many common data analysis and machine learning tasks can be performed, and code can be executed safely.

ChatGPT Model: Code Interpreter

It is very clear that safety is being prioritized.
Considering the speed at which these limitations were implemented, one could predict that security is being defined using natural language.

How to create graphs from CSV files

I have summarized this in a separate article, so please refer to that as well!

Future expectations

With the OpenAI API functions feature updated last month and plugin development, many things can be implemented using natural language as an interface.

However, it was aimed at programmers and the barrier to entry was quite high for the general public. After all, the low barrier to entry of the ChatGPT GUI is wonderful.
If the features necessary for Functions and plugin development can be implemented with the arrival of the Code Interpreter, it will become possible for non-developers to develop systems using natural language.
The barrier between those who order and those who fulfill orders will become increasingly smooth.

It's moving!
Let's share the joy!!


いいなと思ったら応援しよう!