Always curious about the kind of challenges information technology companies are facing, I noticed a trend about unstructured data related topic these days. Explaining in details the differences between structured and unstructured data is beyond the scope of this blog post. Basically, examples of structured data could be dates, addresses and credit card numbers while unstructured data examples are more like natural language texts, videos and social media posts. Exploiting the value of unstructured data is a huge topic. And actually, explaining all the possibilities and limitations would take time. For the sake of brevity, let's just remind that large part of today's data is unstructured, the volume is growing quickly and companies are struggling to deal with it.
As a contributor to the Red Hat Build of Apache Camel, I decided to experiment with Quarkus LangChain4j to extract such a structured information from raw text. Let's imagine a situation where an insurance company records the transcript of the discussion between customers and hotline. With Red Hat Build of Apache Camel, we could consume the conversation transcripts as raw text data from a lot of different systems. But how could we extract information like the customer name and birth date from the conversation transcripts to later store them in let's say a relational database? Is it possible at all anyway?
So, in search of answers, I started to build a prototype as shown in the schema above. In input, we have a raw text conversation between an operator and a customer. This conversation is injected inside a large language model prompt through the use of a LangChain4j AI service as demonstrated here. Then, the large language model answers with a JSON document containing the extracted customer satisfaction, name, birthday and also a short summary of the input conversation. As a last step, LangChain4j transforms this JSON document into a Java object.
Building this prototype was a good opportunity to learn. After an initial period of infancy, I eventually realized that explicitly configuring the model to output JSON only responses was paramount. Step by step, I had success in extracting structured information from 3 conversations transcripts with a 7 billion parameter model. It takes quite some time for the model to give answers as I don't have any dedicated graphical processor units on hand to speed up computation. Still, I was able to create a Camel Quarkus community example where you can find all technical details.
Now, beyond a simple proof of concept, it would be interesting to see what it takes to implement a true business like scenario. From previous experience in a handwriting recognition company, I would say that the key is to check whether the extraction accuracy is high enough to trigger return on investment. As such, it would be interesting to see what accuracy could be achieved by changing the model, using a 30 billion parameter model or improving the prompt for instance. For such an experience to be realistic, it would need at least a set of 100 conversations with expected output, plus some graphical processing units compute power. Anyone interested?
If yes, I would propose my readers to review the unstructured data they have at disposal and imagine the value that could be derived from it. Anyone having an interest could then play with the community example. And there is a good news here for Red Hat customers entitled to use the last supported version of Red Hat Build of Apache Camel Quarkus. Indeed, you don't need to migrate to the latest upstream version and can experiment data extraction straight away with the Red Hat version.
I've tested this setup at this commit level with Openjdk 21 and Apache Maven 3.9.6. You simply need to amend the pom.xml file with the setup below:
<properties>
<quarkus.platform.version>3.8.5.SP1-redhat-00001</quarkus.platform.version>
<camel-quarkus.platform.version>3.8.5.SP1-redhat-00001</camel-quarkus.platform.version>
<quarkus.platform.group-id>com.redhat.quarkus.platform</quarkus.platform.group-id>
<camel-quarkus.platform.group-id>${quarkus.platform.group-id}</camel-quarkus.platform.group-id>
<camel-quarkus.platform.artifact-id>quarkus-camel-bom</camel-quarkus.platform.artifact-id>
</properties>
<pluginRepositories>
<pluginRepository>
<id>redhat-ga</id>
<url>https://maven.repository.redhat.com/ga</url>
</pluginRepository>
</pluginRepositories>
<repositories>
<repository>
<id>redhat-ga</id>
<url>https://maven.repository.redhat.com/ga</url>
</repository>
</repositories>
Of course, Quarkus LangChain4j is not supported yet, still it's possible to experiment and contact Red Hat in case of interest.
That's it for today. So far, I hope we have learned a bit about unstructured data and seen a prototype in action. Maybe it would give ideas for people to experiment data extraction with true business data.