Can the AI chatbot ChatGPT do Geotechnical Engineering?

Philip Chin Fung Tsang

by Philip Chin Fung Tsang

Recently, there is a storm on the internet. ChatGPT was released. It has crossed one million users in only 5 days while it took Netflix 3.5 years. Someone said it will change the way we search. So, what is it, and what is its capability for geotechnical engineering and Python scripting?
Download the white paper and get INSPIRED

Learn how collaborative parametric design models allow you to work together for better solutions.


What is ChatGPT?

This is an AI chatbot developed by OpenAI that specialise in language model, more specifically GPT. It is designed for conversational languages, like a Google search engine but with more human-like features. We can ask any questions (e.g. search on Google) or ask for more complex tasks such as writing code.

How does it work?

ChatGPT had been trained with massive amounts of data from various sources through 2021 using Reinforcement Learning from Human Feedback (RLHF). In RLHF, humans rate multiple questions and answer pairs, and rank them on quality. This generates a reward function that is used to optimise the GPT model with a reinforcement learning algorithm. **Since the data was collected up to 2021, ChatGPT has limitation of providing information about current events as the knowledge is compiled from historical data.


As a Python geek, I definitely love to try this new AI tool and see how far it can go. I have been playing with ChatGPT over the past few days. Below are the engineering tasks I gave ChatGPT ordered by difficulties:

  • Find design standard of pile foundations in Australia and display the formula involved
  • Plot a linear regression
  • Extract PDF content

Task 1: Ask about geotechnical design

I was curious about how good ChatGPT is in terms of searching for information. Therefore, I asked about how AI would design reinforced soil walls. Here are the two questions I asked:

1what standard we use for reinforced soil wall in Australia

rss wall from Philip on Vimeo.

1how to design reinforced soil wall

rss wall2 from Philip on Vimeo.

ChatGPT provides the correct standards required for designing reinforced soil walls. More impressively, it outlines a thorough procedure for reinforced soil design. It may not provide all formula for the design but it can provide junior engineers with a general design guideline so what design parameters need to be considered.

That was an easy one, let's try something more complicated.

Task 2: Plot a linear regression

If you want to plot a linear regression using Python and not sure how the script should be structured, you can simply ask ChatGPT:

1plot a linear regression with Python using matplotlib

linear_regression2 from Philip on Vimeo.

Here is the code created by ChatGPT:

1import matplotlib.pyplot as plt 2import numpy as np 3 4# Generate some random data to fit a linear regression to 5np.random.seed(0) 6x = np.random.uniform(-1, 1, size=100) 7y = 2 * x + 0.1 * np.random.normal(size=100) 8 9# Fit a linear regression to the data 10slope, intercept = np.polyfit(x, y, deg=1) 11 12# Plot the data and the fitted line 13plt.scatter(x, y) 14plt.plot(x, intercept + slope * x, 'r')

Run the script in VS Code and you will get:

Linear regression chatgpt.png

This is impressive! First, the code it created includes comments which tell us what each line of code does. Second, it generates sample data and precisely produces a linear regression line as we requested.

Task 3: Extract PDF content

As geotechnical engineers, we often deal with a massive amount of PDFs. I want to try ChatGPT's capability in creating Python script to extract information from PDFs.

I used a publicly available borehole log as an example, you can find it in the following link:

The BH log contains 90 pages and I want to extract all borehole IDs from the log. Ask ChatGPT to write a Python script for us:

1extract string using pdfplumber and regex search for string after keyword 'BOREHOLE LOG'

pdf_extract from Philip on Vimeo.

Below is the script created by ChatGPT:

1import re 2import pdfplumber 3 4 5# Open the PDF file using pdfplumber 6with"document.pdf") as pdf: 7 # Loop through each page of the PDF 8 for page in pdf.pages: 9 # Extract the text from the page 10 text = page.extract_text() 11 # Use the regex search function to find the string after the keyword "BOREHOLE LOG" 12 result ="BOREHOLE LOG(.*)", text) 13 # If the search was successful, print the extracted string 14 if result: 15 print(

We need to download the PDF to our local directory, if we run the script, you will see the following results:

pdf chatgpt code.png

The script has helped to extract all the borehole IDs from the log which is exactly what I want!


Although ChatGPT is a really powerful tool, I still recommend beginners to write code themselves because of the following three reasons: Writing code can allow you to come up with your own logic. There is no correct answer for a coding task and it's important to train the mindset of script development.

  1. ChatGPT is not perfect in which sometimes I found it requires very specific question to conduct a task. There are a massive amount of external modules in Python and I notice that ChatGPT has default modules which may not lead to the results we want. It's always necessary to learn reading documentations of different modules and understanding the limitation of each module.
  2. After few trials, I also found that ChatGPT does not always give the same answers/script to the users. This is because it is an AI model which will constantly change over time. This may cause confusion for people with zero programming experience.

Nevertheless, ChatGPT is still powerful as it provides users with a detailed explanation of how it creates Python scripts which is a perfect way to learn programming.

How I will use ChatGPT:

  1. Ask quick questions. ChatGPT can provide you with a broad or even detailed direction to look into which saves you time doing research on Google.
  2. Use as your programming consultant, ask if you have doubts about certain tasks. In other words, use it as a Stack Overflow alternative.

Now it's your time to play with ChatGPT!

illustration of platform

Build any application you can imagine

Explore the platform

Related Blog Posts

Avoid Piping with Open-Source Web App

Read more

Easily Turn Grasshopper Models into Sharable Web Apps with VIKTOR

Read more

Precipitation tool shows 2023 is another extremely dry year

Read more
Get our best content in your inbox

Subscribe to our newsletter and get the latest industry insights

Customer Cases

Blog Posts

White Papers & Guides