Building an AI Technical Assistant: Leveraging ChatGPT and Embeddings
Without saying, there has been a great deal of activity and buzz surrounding OpenAI and more specifically ChatGPT. This has generated (no pun intended ??) a great deal of excitement and discussion across social media and the boundless potential that generative AI can bring across various industry verticals.
Recently I dipped my toes into the water and tested the summation capabilities that is possible with ChatGPT. In short, it does a great job at taking the information we have in 'technician speak' and converting the technical jargon and often incomplete sentences into 'customer speak' with the aim of making it easier for customers to understand. The below is an example of the outcome and although this example of ChatGPT is impressive, I don't think it fully demonstrates the capabilities and potential of generative AI.
So what's next? What if were able to add a conversational layer over our own expansive data sources which would then enable employees like technicians to conduct semantic search and draw insights from the data. Imagine being able to go beyond lexical searches e.g. searching for an error code and to be able to ask start asking complex questions of the data and receive comprehensive detailed responses from the data.
The possibilities and benefits here are endless as we pretty much can create an AI technical assistant with the knowledge that our technicians have acquired over the years. So with this said and as a part of my own learning, I have been working with one of our engineer to create and deploy a prototype for "TechGPT", a chatbot that can aid with technicians whilst they are out in the field using our own data.
As you may already know, ChatGPT was trained on a large corpus of text spanning a diverse range of texts including books, articles, websites, and other forms of written text which were collected up until 2021. What it wasn't trained on was 'our' data and as such, asking questions about our own data won't really work, at least for now.
Fortunately, there are a few options here. One of them is involves using embeddings. Through embeddings, we can create numerical representations (vectors) of our text ranging from words to entire paragraphs. By using vectors, we can then apply mathematical concepts to the proximity or how similar two vectors or two pieces of text are.
As an example, here I am using the text-embedding-ada-002 model to create vectors for the names of fruit. A common way to compare vectors is cosine similarity which is way beyond my mere comprehension, but it basically measures the angle of two vectors within a range of 0 and 1.
For this example, I extracted a portion of a dataset from Azure Cognitive Search into a .CSV file. The dataset is from our troubleshooting data which includes a detailed record of all faults and the corresponding corrective actions taken worldwide. Because the data comes from all around the world, the data contained is made up of many different languages.
领英推荐
To prepare the data, features corresponding the machine and issue such as the model, serial number, findings and any corrective actions were concatenated into a single column. Next, the column was fed into the text-embedding-ada-002 model tog generate embeddings. For this scenario, these embeddings were then saved as a pickle file.
In a production workflow, the embeddings could be stored in various platforms and services, such as Azure Cognitive Search, Cosmos DB, SQL database, or blob storage.
With our embeddings now available, the next step is to use a chatbot that can offer a user interface to collect input from the user, match the input with the generated embeddings, and generate a response to return to the user. Here Gradio was to create the UI elements to mimic chatbot functionality. In a nutshell, the chatbot will:
For deployment, we containerised our Python script and pushed the image to an Azure Container Registry. From there, it was relatively straightforward to create an Linux Azure App Service from the docker image. Again, you could interchangeably use Azure Container Instances or Azure Kubernetes Services depending on your requirements.
Overall, generative AI is an effective way to create virtual assistants and experts that can provide personalized, scalable, consistent, and accurate responses to user queries, based on historical data. Every organisation around the world has vast amounts of data and generative AI can leverage this data to create insights and create value in various domains, such as customer service, healthcare, and finance.