Learn how collaborative parametric design models allow you to work together for better solutions.
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.
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:
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.
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') 15plt.show()
Run the script in VS Code and you will get:
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.
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 pdfplumber.open("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 = re.search(r"BOREHOLE LOG(.*)", text) 13 # If the search was successful, print the extracted string 14 if result: 15 print(result.group(1))
We need to download the PDF to our local directory, if we run the script, you will see the following results:
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.
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:
Now it's your time to play with ChatGPT!
Subscribe to our newsletter and get the latest industry insights