Artificial intelligence has the potential to revolutionise how we design everything.
Imagine having an AI assistant to create engineering calculation workflows. The AI assistant could be a conversational chatbot like Google Gemini or ChatGPT. Unfortunately however, these chatbots are not currently safe for engineering tasks as they can produce erroneous calculation answers with high confidence, which can be misleading.
CalcTree plays a pivotal role here. CalcTree is a cloud-based platform that allows users to define engineering and calculation logic in languages they're familiar with (Python, spreadsheets, no-code). CalcTree and LLMs can be strung together using their APIs, and so the accuracy of engineering calculations from CalcTree is combined with the power of an LLM.
In this article, we discuss the technical details of connecting CalcTree's API with Google Gemini, and we demonstrate how this was used to obtain an accurate result for a bearing capacity calculation.
What are LLMs?
Why are ChatGPT and Google Gemini bad at calculations, while it is very good at other stuff?
ChatGPT and Google Gemini are language models, not computational models. This is very important as the model approaches the input problems as language problems rather than mathematical ones. When we ask a simple problem such as “10 + 10”, it will return an answer of "20" because, from all the information it’s been trained on, 20 was determined to be the most preferred response based on feedback.
We ran a few tests on ChatGPT by providing engineering-related prompts to see how well it performs. Check out the experiment here. In summary, ChatGPT does an impressive job of explaining engineering concepts to us. It can follow general calculation guidelines and understand procedures, though it is unable to make judgments when it comes to the correct usage of some input data.
Setting up Google Gemini with CalcTree's API
The below snippets are from a Google Colab Notebook. You can access the full script in the code source of this page.
Step 1: Obtain APIs
Firstly. we need to obtain:
CalcTree API key and page ID of the calculation template. This CalcTree API guide talks us through how to do this.
Step 2: Install the necessary packages and classes
Here are the necessary packages:
Here are the necessary classes:
Step 3: Create a tool
We create a tool which is a function that is decorated by a LangChain tool class. LangChain is a programming framework to help develop code using language models. The LangChain tool class uses the user prompt as the parameters to be passed onto the function.
Step 4: Create a user prompt and output
We can understand how the parameters are represented with the function name for the tool created.
Results
We compare the results of the ultimate bearing capacity,
qu
given the following inputs:
Footing width,
B=10m
Footing depth,
D=7m
Soil cohesion,
c=40kPa
Soil friction angle,
ϕ=37°
Soil unit weight,
γ=11kN/m3
Load inclination,
α=12°
The comparison below shows the result from using Google Gemini with CalcTree's API is the same as the CalcTree template itself, and the result from using Google Gemini or ChatGPT-4 alone is not accurate.
Let's do this calculation by hand to validate our results. The ultimate bearing capacity of a shallow footing is given by:
In conclusion, the integration of the CalcTree API with a conversational chatbot like Google Gemini significantly enhances the accuracy and reliability of engineering calculations. Traditional LLMs, despite their advanced capabilities in language understanding and generation, are limited in their ability to perform accurate engineering calculations.
CalcTree helps bridge this gap because it makes engineering data accessible and interpretable by systems designed for AI training, via its API.
By leveraging CalcTree's API, LLMs can communicate with these templates, thus combining the conversational ease and flexibility of LLMs with the rich knowledge of engineering computations.
Acknowledgments
This article was created in collaboration with Kamal Samaila.
CalcTree, the app you're reading this one is a calculation management platform. You can sign-up and build hosted, shareable web apps (complete with an API and a web publishing module) with tools like Python and Spreadsheets. Learn more here!