Estimate project
← All posts

A Sensible Business Application of Generative LLMs

This article will give you a clearer picture of what generative large language models can realistically do and what risks come with them.

10 min read
Machine LearningLLMGenAILLMsRAGconcept shift

Because AI-based generative tools such as the now well-known ChatGPT, Midjourney, etc. are so easy to use, interest in AI and its popularity have grown exponentially. Ordinary people discuss Artificial intelligence while shopping, riding in cabs, or walking down the street, while visionaries sketch out how artificial intelligence is going to transform the world and the way businesses operate. Companies gripped by FOMO are eager to adopt generative AI as soon as possible, so that they don’t fall behind in the competition for new customers.

I believe we are heading toward broad adoption of AI-assisted tools that boost productivity. Still, we should keep in mind that artificial intelligence is no magic wand capable of fixing every problem we have.To set realistic expectations, we have to understand what today’s generative AI systems can and cannot do.

Read on to learn which tasks generative large language models handle well, which they struggle with, and how they can be applied in AI-driven products. Throughout this article I concentrate on generative neural network models, and more precisely on generative language models akin to ChatGPT.

Capabilities of Generative LLMs

Generative large language models are deep learning models that were exposed during training to a large part of the Internet, countless books, scientific papers, etc. From this material they learned to understand language, draw inferences, and reproduce the patterns found in those texts. At this stage, the deep learning model memorizes particular patterns and passages, which it later readily hands back to the user when answering questions and following commands. Thanks to what they absorb during this phase, Generative large language models can respond to questions across the wide spectrum of subjects they encountered in training. It is here that foundation models gain knowledge of the world and learn facts, yet they also pick up biases. Since the training data is contaminated with toxic statements and Internet texts carrying prejudice about race, gender, etc., the model will reproduce the same behavior in the responses it generates. That is certainly not the kind of content we would want our product’s users to encounter.

Once trained on the instruction following task, these models can interpret the command supplied by the user and produce the text that, in the model’s judgment, fits it best. We can think of this stage as the one in which foundation models learn to reason about and understand commands, which they subsequently attempt to carry out.

The good, the bad, and the ugly

One of our ML engineers has analysed in detail which tasks generative large language models do brilliantly and which ones they completely fail at.

In short, his conclusion is that generative models like ChatGPT excel at producing fluff, i.e. nicely written text that does not always convey much information. This stems directly from how the models are trained and is an inherent trait of theirs. Their weak points are: properly grasping more complex commands, reasoning about the world when no contextual information is supplied, delivering verified information on a particular subject, and the risk of producing harmful content in response to a cleverly constructed user request.

The ability to produce polished, readable text is a major strength of these models, yet the hallucinations of generative models seriously restrict their usefulness in business solutions. Nobody wants a system that may give toxic and unreliable answers, because they come from knowledge encoded in the model’s weights rather than from trustworthy sources. Working with such models means verifying information against reliable knowledge sources, either to trust the model’s answers or to catch its falsehoods. If only we could take advantage of what generative large language models do best, namely writing readable texts, while also solving the hallucination problem…

Retrieval-augmented question answering

Enter, riding a white horse, an approach built on a knowledge base: retrieval-augmented question answering.

One way to tackle hallucinations is to supply the knowledge base as context, so that the language model relies solely on it when carrying out the command. This lets us bypass the messy knowledge the model absorbed in training. What we use instead is a database of approved documents combined with the AI model’s knack for generating fluff.

image3

Architecture of a Q&A system featuring a knowledge base and a request classifier.

The proposed solution is built around a knowledge base, a request classifier, and a response.

The knowledge base is split into smaller chunks. Whenever a user sends a request, the system retrieves a set of document chunks from the knowledge base that are closest to that request. This step relies on text embeddings and vector similarity to locate semantically related documents. We employ vector-based knowledge bases here to achieve high retrieval quality and faster computation. Next, the documents and the client’s request are inserted into a purpose-built prompt, where the knowledge base documents serve as the context the generative large language model uses to carry out the client’s command.

Moreover, for every generated sentence we can point to the source the response was based on. To do so, we can build a simpler text classifier neural network model that matches the generated sentence from the model’s answer against selected passages from the knowledge base. If no source for the information can be found, we can treat it as a model hallucination. We can then remove the hallucination from the response or send the large language model a request stating that it made an error and needs to fix its answer1. Given such a simpler and more precise instruction, the model is far more likely to understand the command and fix the response.

Another component, additional yet essential, will be mechanisms that neutralize malicious user requests. Instructions of this kind can make the system reply in an inappropriate, threatening, or abusive way. We want to prevent this both to keep users safe and to protect the company’s reputation. To achieve that, a text classifier neural network can decide whether a user request is malicious.

If it is, the user would receive a message saying the request does not satisfy the system’s requirements. If it is not, the request would be passed to the system to be processed and answered.

Other approaches exist for handling malicious user commands and toxic responses. Riding the wave of large language model popularity, NVIDIA has released an open-source library for neutralizing malicious prompts, NeMo-Guardrails, which can be applied to this task.

A product built on the method described above will require monitoring of the whole system, which is made up of many parts: a large language model, a text classifier, and prepared prompts. It will matter to check how far responses are grounded in documents from the knowledge base2, how much bias and toxicity they contain, and how susceptible the system is to crafted queries that provoke toxic model responses3. For the text classifier, the key is to track how well it detects hallucinations in generated responses, while for the prepared prompts the metric to watch is how accurately the system carried out the user’s instructions. All these parameters need continuous monitoring, and whenever issues appear, the system should be repaired.

Model degradation over time

Customers of enterprise-class solutions expect operation to be predictable and stable. As the authors of the article4 demonstrated, only full control over every component of the system can guarantee such qualities; they showed how the GPT4 model deteriorated between March and June 2023.

According to the article, the models hidden behind an API wall, which we may use to build NLG-based systems, undergo changes we cannot control and are not even notified about. As a result, the solution we build may degrade considerably, with no way for us to respond. In a comparable situation with our own large language model, we can always back up the current model, introduce changes, and roll back to the previous, properly functioning version if something breaks or degrades. With external APIs this may not be an option. The solution vendor will then have to find a different large language model provider or scramble to build its own model of quality matching the original solution. In my view, it is wiser to guard against this risk in advance and spare your users the trouble. Whichever path you take, you will need tooling to track model quality over time.

Business use case

Enterprise-class customers count on predictable and stable operation. The authors of the article [^5], who showed how the GPT4 model deteriorated between March and June 2023, demonstrated that only full control over all system components can deliver these qualities.

The article reveals that models behind an API wall, which can serve as the basis for NLG-based systems, change in ways we cannot control and without us even being informed. This may seriously degrade the solution we build, leaving us unable to respond. In the analogous case of having our own large language model, we can always keep a backup of the current model, apply changes, and, should anything fail or degrade, return to the earlier, properly working version. External APIs may not allow this. The solution vendor will then be forced either to seek another large language model provider or to frantically build its own model that matches the original solution in quality. In my opinion, it is better to secure yourself against this risk up front and keep your users away from problems. Whatever path you choose, tools for monitoring model quality over time will be required.

Let’s now consider which business use cases can gain from such a solution. A product built on retrieval-augmented question answering works well as an extension of current systems that rely on keyword search and vector semantic similarity methods. Unlike classical search systems, here user instructions can ask the system to carry out an operation, analysis, or aggregation. It can take the form of a chatbot, enabling interaction within a session, refining commands, and specifying the desired outcome in more detail.

For the users of such systems, the only thing that changes is the format of queries and of the search results they receive, which will be natural language. On top of that, users will learn which particular documents or document fragments the answer was generated from. With more detailed commands, we can expect searches to perform better and, consequently, system users to become more productive.

Picture a system that analyzes the financial statements of publicly traded companies. Conventional systems relying on keywords or on semantic similarity between documents and queries can merely return the relevant document sections. A chatbot system powered by a generative large language model, by contrast, can for instance compare financial results across several years. If the user is not happy with the answer format, he can request a comparison table along with a brief textual description. Such a system would act as a kind of assistant capable of handling simple tasks. Its analytical abilities depend entirely on the large language model, so they can be tailored to a particular business and application.

‍

Summary

I hope this article has given you a clearer picture of what generative large language models can realistically do and what risks they bring. Given their shortcomings, they need many safety nets to detect and neutralize harmful behaviors such as hallucinations or toxic responses. Even so, their ability to carry out commands and produce well-written responses makes it possible to harness them and boost the productivity of the people using such systems, by giving them a digital assistant that, much like a computer from Blade Runner, takes over tedious tasks and gets the job done faster.

‍


  1. Xiang Yue, Boshi Wang, Kai Zhang, Ziru Chen, Yu Su, & Huan Sun. (2023). Automatic Evaluation of Attribution by Large Language Models. ↩
  2. Nelson F. Liu, Tianyi Zhang, & Percy Liang. (2023). Evaluating Verifiability in Generative Search Engines. ↩
  3. https://haystack.deepset.ai/blog/how-to-prevent-prompt-injections ↩
  4. https://arxiv.org/abs/2307.09009 ↩