Build Neural Symbolic Software using LLMs

Sean Wu
5 min readFeb 12, 2024

--

What is prompt engineering?

Ever since the discovery that instruction-tuned large language models (LLMs) can be “programmed” using natural language instead of programming languages, the so-called prompt engineering approach has been used to solve many different problems. The integration of LLMs into software development, leveraging the common-sense knowledge embedded in them, has offered developers unprecedented opportunities to create innovative and intelligent software solutions. In this blog post, we’ll explore three different ways that LLMs can be used in software to solve problems, based on whether there are predefined structures in both the input and output domains.

The ‘input domain’ and ‘output domain’ of a problem refer to the set of possible inputs and outputs, respectively, for that problem. Understanding and analyzing these domains is crucial for accurately defining the problem and evaluating the effectiveness of the solutions. A domain can have a ‘predefined structure’; by this, we mean that every instance in the domain can be described by a clearly defined set of slots, governed by some rules or constraints regarding what instance is considered legitimate and what is not. For example, the input domain for movie ticketing services includes slots for movie title, showtime, format, and quantity, while the output domain includes theater, seats, and cost, each with well-defined semantics.

When a domain is endowed with a predefined structure, every instance within it can easily have a canonical representation, making it trivial to determine whether two instances in that domain are the same. Throughout the rest of this writing, when we refer to a structured or unstructured domain or problem, it is always in respect to some predefined structure.

For problems without structure

All businesses depend on their employees to provide value to their users. In order to educate their employees and ensure a consistent experience, businesses have accumulated a lot of valuable unstructured text in the form of documentation, emails, etc. Is it possible to directly make use of this unstructured text to answer the questions their users might have?

Until very recently, there actually was no good way for that. Often, businesses had to painstakingly organize useful information into query-answer pairs for users to access conversationally. However, this has changed with the introduction of LLMs. In particular, a popular form of LLM application called retrieval-augmented generation has proven to be effective in bringing the value buried in unstructured text directly to end users through conversational user interfaces.

Instead of making LLM generate responses based solely on the static weights learned during pretraining, the RAG system introduces a retrieval component that can extract relevant text from a set of internal documents based on query. This allows the LLM to generate responses based on both the user query and the retrieved content according some prompt, thus provide business specific answer to user query.

Instead of trying to extract structure for every question or problem a user might have which can take significant effort, businesses can simply throw related documents to a RAG system and call it a day. While there are still some technical challenges like hallucination, RAG-based LLM systems can be effective tools for unstructured questions, particularly when these questions are not deemed mission-critical.

For problem with structure

It might be counterintuitive, but LLMs, as pure neural-based solutions, can also be very useful in solving complex problems with well-defined structures. For example, in a recent Nature paper titled ‘Solving Olympiad Geometry without Human Demonstrations,’ DeepMind has proposed AlphaGeometry, a theorem prover for Euclidean plane geometry that approaches the performance of an average International Mathematical Olympiad (IMO) gold medallist.

Auxiliary construction is geometry’s instance of exogenous term generation, representing the infinite branching factor of theorem proving, and is widely recognized in other mathematical domains as the key challenge in proving many difficult theorems. By pretraining and fine-tuning a language model on synthetic data for auxiliary construction, the resulting LLM can generate useful auxiliary constructions with high probability. Thus, it can be more effective in guiding a symbolic deduction engine through all possible auxiliary constructions compared to a brute force approach.

In reality, many tasks do not permit analytical solutions. Like auxiliary construction, sometimes, even imperatively constructing heuristics for them can be challenging, requiring an understanding of the solution space. Problems can simply be difficult; for example, even the smartest minds require many years of rigorous training to achieve International Mathematical Olympiad (IMO) gold medallist performance. With careful training, LLMs can also be effective in solving these well-structured component problems that require some genius, thus making it hard to come up with step-by-step solutions, as demonstrated by AlphaGeometry.

Conversion between structured and unstructured

amazon data to text

Aside from solving actual problems, LLM is specially useful for converting from unstructured text to structured data and back. Such translation is very useful to build application with conversational user interface. Since the input from user and output to user are in natural text, we need to first convert natural text (function calling or dialog understanding) into predefined structure representation for existing APIs to take over, and then we need to render the structured output from the software back to user.

Parting words

Most software is traditionally built in the symbolic space, typically by specifying step-by-step instructions for solving problems. Neural networks have begun to dominate many perception-related tasks, such as object recognition and speech recognition. Recently, transformer-based Large Language Models (LLMs) have proven to be useful at the symbolic level as well. Examples include using LLMs to solve geometry proof problems at the level of an International Mathematical Olympiad (IMO) gold medallist and playing chess at the grandmaster level. This hints at what’s next: we will likely see a lot of integration of LLMs into software development. Are you ready?

Reference:

https://www.nature.com/articles/s41586-023-06747-5
https://arxiv.org/pdf/2402.04494.pdf

--

--