AI chatbot ChatGPT

If you haven’t heard about the new hype ChatGPT yet, let me quickly get you up to speed. ChatGPT is an artificial intelligence chatbot developed by OpenAI.

As it’s a chatbot, you’re interacting with it in text form as a dialogue. It can remember things you’ve previously discussed and will try to keep its answers aligned with the topic of your conversation.

What can it do?

Writing blog posts

It can do many things. Maybe you have read my previous blog post Introduction to Neural Networks. This post (excluding the image of a neural network I have inserted) was completely written by ChatGPT.
It started with my prompt:

I want to write a blog post about neural networks. Can you help me with the outline? It’s for an audience with a technical background but no experience with machine learning.

It replied with a reasonable outline for such a blog post. So I asked

Let’s write the first chapter

And it gave me the first chapter! So I continued asking for the remaining chapters, sometimes requesting a simpler or more exhaustive version. After maybe 15 minutes I had an (in my opinion) understandable blog post with a nice structure and flow.

Coding

Yesterday, I needed to compare two contours for one of my customer projects to ensure the medical algorithms that we develop actually perform on the level of a human physician. So I pulled out the old Hausdorff distance as a metric.
So I asked ChatGPT for help

I need to compute the hausdorff-distance between two lists of points in c++

#include <algorithm>
#include <cmath>
#include <vector>

struct Point {
  double x;
  double y;
};

double hausdorff_distance(const std::vector& points1, const std::vector& points2) {
  double max_dist1 = 0;
  double max_dist2 = 0;

  // Compute the maximum distance between points in list 1 and points in list 2
  for (const Point& p1 : points1) {
    double min_dist = std::numeric_limits::max();
    for (const Point& p2 : points2) {
      double dx = p1.x - p2.x;
      double dy = p1.y - p2.y;
      double dist = std::sqrt(dx * dx + dy * dy);
      min_dist = std::min(min_dist, dist);
    }
    max_dist1 = std::max(max_dist1, min_dist);
  }

  // Compute the maximum distance between points in list 2 and points in list 1
  for (const Point& p1 : points2) {
    double min_dist = std::numeric_limits::max();
    for (const Point& p2 : points1) {
      double dx = p1.x - p2.x;
      double dy = p1.y - p2.y;
      double dist = std::sqrt(dx * dx + dy * dy);
      min_dist = std::min(min_dist, dist);
    }
    max_dist2 = std::max(max_dist2, min_dist);
  }

  // Return the maximum of the two maximum distances
  return std::max(max_dist1, max_dist2);
}

Well that already looks pretty good. But we actually use the Eigen library. So I asked ChatGPT

Looks good, but can you please use Eigen types?

And it changed the code to use Eigen data types and distance function.

#include <Eigen/Core>
#include <algorithm>

using Eigen::Vector2d;

double hausdorff_distance(const std::vector& points1, const std::vector& points2) {
  double max_dist1 = 0;
  double max_dist2 = 0;

  // Compute the maximum distance between points in list 1 and points in list 2
  for (const Vector2d& p1 : points1) {
    double min_dist = std::numeric_limits::max();
    for (const Vector2d& p2 : points2) {
      double dist = (p1 - p2).norm();
      min_dist = std::min(min_dist, dist);
    }
    max_dist1 = std::max(max_dist1, min_dist);
  }

  // Compute the maximum distance between points in list 2 and points in list 1
  for (const Vector2d& p1 : points2) {
    double min_dist = std::numeric_limits::max();
    for (const Vector2d& p2 : points1) {
      double dist = (p1 - p2).norm();
      min_dist = std::min(min_dist, dist);
    }
    max_dist2 = std::max(max_dist2, min_dist);
  }

  // Return the maximum of the two maximum distances
  return std::max(max_dist1, max_dist2);
}

Next, I had a lot of folders containing gzip files. And I wanted to extract them. Let’s ask ChatGPT again

I need to extract gzip files in subfolders in powershell using 7zip

And it actually was able to help me with my non-default 7Zip installation directory.

What can’t it do?

The biggest problem I see with ChatGPT is it’s unbelievable ability to bullshit. Even if it’s insanely wrong, it’s so confident and gives explanations that seem to make sense.
This is okay-ish for funny examples where it’s obvious the answers are wrong. However, what happens when it’s wrong for things you don’t know about, i.e., real-world use-cases where you’re actually looking for help.

How does it work?

It uses a large language model which is based on the GPT-3.5 architecture. The GPT-3 model, which this is based on, has 175 billion (with a b!) parameters, requiring 800 GB of storage. Details on the ChatGPT model are not (yet) released to the public.

At the moment, ChatGPT can be used for free here: https://chat.openai.com

Whether the model will ever be released to the public remains unknown at the moment. However, even if…you’ll need a lot of GPU power to run it locally.

Florian Gabsteiger
Letzte Artikel von Florian Gabsteiger (Alle anzeigen)

Ähnliche Artikel