<?xml version="1.0" encoding="UTF-8"?>
<TEI xml:space="preserve" xmlns="http://www.tei-c.org/ns/1.0" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://www.tei-c.org/ns/1.0 https://raw.githubusercontent.com/kermitt2/grobid/master/grobid-home/schemas/xsd/Grobid.xsd"
 xmlns:xlink="http://www.w3.org/1999/xlink">
	<teiHeader xml:lang="en">
		<fileDesc>
			<titleStmt>
				<title level="a" type="main">A Reliable Common-Sense Reasoning Socialbot Built Using LLMs and Goal-Directed ASP</title>
			</titleStmt>
			<publicationStmt>
				<publisher/>
				<availability status="unknown"><licence/></availability>
				<date type="published" when="2024-10-12">October 12, 2024</date>
			</publicationStmt>
			<sourceDesc>
				<biblStruct>
					<analytic>
						<author>
							<persName><forename type="first">Yankai</forename><surname>Zeng</surname></persName>
							<affiliation key="aff0">
								<orgName type="institution">The University of Texas at Dallas</orgName>
								<address>
									<settlement>Richardson</settlement>
									<country key="US">USA</country>
								</address>
							</affiliation>
						</author>
						<author>
							<persName><forename type="first">Abhiramon</forename><surname>Rajashekharan</surname></persName>
							<affiliation key="aff0">
								<orgName type="institution">The University of Texas at Dallas</orgName>
								<address>
									<settlement>Richardson</settlement>
									<country key="US">USA</country>
								</address>
							</affiliation>
						</author>
						<author>
							<persName><forename type="first">Kinjal</forename><surname>Basu</surname></persName>
							<affiliation key="aff1">
								<orgName type="department">IBM Research 3 CETINIA</orgName>
								<orgName type="institution">Universidad Ray Juan Carlos</orgName>
								<address>
									<settlement>Madrid</settlement>
									<country key="ES">Spain</country>
								</address>
							</affiliation>
						</author>
						<author>
							<persName><forename type="first">Huaduo</forename><surname>Wang</surname></persName>
							<affiliation key="aff0">
								<orgName type="institution">The University of Texas at Dallas</orgName>
								<address>
									<settlement>Richardson</settlement>
									<country key="US">USA</country>
								</address>
							</affiliation>
						</author>
						<author>
							<persName><forename type="first">Joaquín</forename><surname>Arias</surname></persName>
						</author>
						<author>
							<persName><forename type="first">Gopal</forename><surname>Gupta</surname></persName>
							<affiliation key="aff0">
								<orgName type="institution">The University of Texas at Dallas</orgName>
								<address>
									<settlement>Richardson</settlement>
									<country key="US">USA</country>
								</address>
							</affiliation>
						</author>
						<title level="a" type="main">A Reliable Common-Sense Reasoning Socialbot Built Using LLMs and Goal-Directed ASP</title>
					</analytic>
					<monogr>
						<idno type="ISSN">1613-0073</idno>
						<imprint>
							<date type="published" when="2024-10-12">October 12, 2024</date>
						</imprint>
					</monogr>
					<idno type="MD5">3D83285634D72EFDF2ECCF438A0F75B3</idno>
				</biblStruct>
			</sourceDesc>
		</fileDesc>
		<encodingDesc>
			<appInfo>
				<application version="0.7.2" ident="GROBID" when="2025-04-23T19:51+0000">
					<desc>GROBID - A machine learning software for extracting information from scholarly documents</desc>
					<ref target="https://github.com/kermitt2/grobid"/>
				</application>
			</appInfo>
		</encodingDesc>
		<profileDesc>
			<textClass>
				<keywords>
					<term>Answer Set Programming</term>
					<term>s(CASP)</term>
					<term>Large Language Model</term>
					<term>Socialbot</term>
				</keywords>
			</textClass>
			<abstract/>
		</profileDesc>
	</teiHeader>
	<text xml:lang="en">
		<body>
<div xmlns="http://www.tei-c.org/ns/1.0"><p>Conversational agents are designed to understand dialogues and generate meaningful responses to communicate with humans. After the popularity of ChatGPT, with its surprising performance and powerful conversational ability, commercial Large Language Models (LLMs) for general NLP tasks such as GPT-4 <ref type="bibr" target="#b1">[2]</ref>, sprung up and brought the generative AI as a solution to the public view. These LLMs work quite well in content generation tasks, but their deficiency in knowledge-and-reasoning-oriented tasks is well-established by now <ref type="bibr" target="#b2">[3]</ref>. These models themselves cannot tell whether the text they generate is based on facts or made-up stories, and they cannot always follow the given data and rules strictly and sometimes even modify the data at will, also called hallucination. The reasoning that these LLMs appear to perform is also at a very shallow level. These are serious flaws that make the LLMs unsuitable for fact-based conversations such as providing correct information to a user. The reason for this flaw is that LLMs generate text that is purely based on a pattern-matching mechanism, and consequently have no understanding of the meaning of sentences thus a safe and sound way of reasoning is not guaranteed <ref type="bibr" target="#b2">[3]</ref>. In contrast, humans understand the meaning of sentences and then use their reasoning capabilities to check for consistency and take further action. Thus, to make the machine-generated response reliable and consistent, our socialbot needs to follow a similar approach.</p><p>Following the above insights, in this work, we report on developing an elaborate conversational socialbot that can understand human dialog and respond properly according to human expectations. The goal of this socialbot is to be able to engage in multiple rounds of social conversations with users about their interests, understand the context of what the user is saying like a human, and be able to initiate new topics or make relevant recommendations at the right time to control the pace of the chat. We currently focus our topics of interest on discussions of movies, books, and related people, and use the STAR framework <ref type="bibr" target="#b3">[4]</ref> to build a social conversational bot called AutoCompanion. AutoCompanion uses an LLM to interact with the user and translate between natural language dialogues and knowledge represented in predicates. It further uses s(CASP) <ref type="bibr" target="#b4">[5]</ref>, an ASP system to reason over this knowledge. After the user's input is parsed into predicates by the LLM, s(CASP) uses reasoning (and a bit of randomness) to decide whether to continue with the current topic of conversation, move on to a related topic, or recommend books or movies that are currently on sale based on the user's preferences. Questions asked by the user are also answered. Subsequently, the instructions for the next step from the reasoner are passed on to another LLM in the form of an open-ended free-for-all on that topic, and the generated sentence is provided to the user as a reply.</p><p>We believe that the misuse of LLM in fact-based domains should be controlled to avoid and that the best way to utilize LLM is to use it only as an interface for parsing and presenting knowledge. Our AutoCompanion outperforms LLM-only socialbots in reliability, scalability, controllability, creativity, and many other aspects.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>Vocabulary (Ontology) Design</head><p>AutoCompanion leverages LLMs such as the GPT series to parse the natural language sentences to knowledge. The prompts are given to LLMs including the knowledge ontology, which is represented in the predicates used in the reasoning part, and several examples covering the use cases. The LLM-produced predicates are formed in themes, where a theme is a set of predicates centralized on one property of a topic instance. It typically contains one talk predicate: "talk(Topic, Instance_name, Property). ", one attitude predicate: "attitude(positive/negative/ask/argue). ", and one content predicate: "content(Property, Detailed_content).". Here the topic is defined either to be a movie, a book, or related people, and the property indicates an aspect of the topic instance to be potentially discussed, such as the plots, scenes, lines of a movie, etc. If the user asks a question, the predicate question: "question(What_is_asked)" is also captured. For instance, when the user compliments the scene of the movie Titanic where the giant ship is sinking, the predicates extracted from the user would be: 1 talk(movie, 'Titanic', scene). content(scene, sinking). attitude(positive).</p><p>The user preference is also extracted to be used later for recommendation. The preference is presented by the prefer predicate: "prefer(Topic, Property, Preference). ".</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>Topic Control</head><p>We leverage the s(CASP) ASP reasoner to guide and switch between the topics using CKT <ref type="bibr" target="#b5">[6]</ref> and RCC <ref type="bibr" target="#b6">[7]</ref>. Once a theme is selected, the ASP reasoner chooses whether to remain in the same topic instance or switch to a relevant one. When the ASP reasoner continues the current topic instance, CKT is used. It maintains a state with a list of properties that can be discussed for each topic instance. Once the reasoner chooses to go deeper into one instance using other properties, the CKT will be triggered to pick up one property that has not been discussed yet for this topic instance. The CKT also chooses whether to remain on the current property and the attitude towards the current property. The CKT component chooses what property to discuss under a topic. The code for CKT is shown below:    The first rule indicates to continue the current property if continue_attr, which is evoked by a random function, is true. The second and third rule forms an even loop, making it possible to choose any available property. The fourth rule defines that the discussed property should not be selected.</p><p>The RCC selector will be invoked if the ASP reasoner switches to a relevant topic instance. In AutoCompanion, an RCC is a new topic instance that shares some common properties (e.g., genre, actor) with the current instance. These relations are formatted and listed for the reasoner to search the RCCs automatically. The topic switching is implemented by the codes below.   Response Generation AutoCompanion leaves the generation of these specifics to LLM, controlling only the topic and property for each round. We assume that the LLMs are experts in common topics such as famous movies and books, which makes it possible for us to leverage this advantage of LLMs in constructing AutoCompanion. The knowledge-required answer is generated with the prompt template as below:</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>What are the most interesting [property] for [topic] [instance]? [attitude] -&gt;</head><p>And LLM would generate an answer for that. For example, If we ask about the positive value expressed in Batman Begin:</p><p>What are the most interesting value expressed for Batman Begins? positive -&gt;</p><p>The LLM would generate: If the RCC mechanism is invoked, the response generator will also create cohesive sentences that naturally mention the next topic instance to discuss. The template for a cohesive sentence is: Similarly, if the reasoner answers the questions from the user, one of the following templates will be used according to the condition: The reply sentences generated by the above templates are then concatenated and processed by an LLM language modifier to make the replies more coherent, gentler, and more informal.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>Knowledge Base Construction</head><p>The movie data is from the IMDb dataset, 1 where we collected the information of release year, runtime, rating, countries involved, languages, genres, top 10 casts with their characters, directors, writers, editors, composers, producers, cinematographers, and the plot summary. The book data is collected from the Users-Books-Dataset, 2 including 528 books with information about their series, author, rating, language, genres, awards, setting places, characters, and plot descriptions. These are also recorded as properties along with their writing style, symbolism, emotional impact, and social background. We also collect the information of the people involved in these movies and books from the IMDb dataset.</p></div>
<div xmlns="http://www.tei-c.org/ns/1.0"><head>Conclusion</head><p>This work presents an approach to building a socialbot that utilizes LLM to translate between natural language and predicates while employing an ASP reasoner as the backend. We used this framework to develop the AutoCompanion socialbot to chat about movies and book-related topics. AutoCompanion parses the sentences to different themes regarding books and movies using an LLM and controls the next theme to respond by s(CASP), the ASP reasoner. We believe this organic combination of LLM and ASP is one of the most effective ways to realize the control of LLM-based socialbots.</p></div><figure xmlns="http://www.tei-c.org/ns/1.0" xml:id="fig_0"><head>1 next_attr(</head><label>1</label><figDesc>Topic, Name, Attr) :-continue_attr, talk(Topic, Name, Attr), 2 response_attr(Topic, Attr).</figDesc></figure>
<figure xmlns="http://www.tei-c.org/ns/1.0" xml:id="fig_1"><head>3 next_attr(</head><label>3</label><figDesc>Topic, Name, Attr) :-response_attr(Topic, Attr), 4 not neg_next_attr(Topic, Name, Attr).</figDesc></figure>
<figure xmlns="http://www.tei-c.org/ns/1.0" xml:id="fig_2"><head>5 neg_next_attr(</head><label>5</label><figDesc>Topic, Name, Attr) :-not next_attr(Topic, Name, Attr).</figDesc></figure>
<figure xmlns="http://www.tei-c.org/ns/1.0" xml:id="fig_3"><head>6 neg_next_attr(</head><label>6</label><figDesc>Topic, Name, Attr) :-hist(I, Topic, Name, Attr, Attitude, From).</figDesc></figure>
<figure xmlns="http://www.tei-c.org/ns/1.0" xml:id="fig_4"><head>1 next_topic(</head><label>1</label><figDesc>Topic, Name, Attr, 'None', 'None') :-2 round(I), hist(I, Topic, Name, Attr, Attitude, 'user'), 3 not discussed_before(Topic, Name, Attr).</figDesc></figure>
<figure xmlns="http://www.tei-c.org/ns/1.0" xml:id="fig_5"><head>4 next_topic(</head><label>4</label><figDesc>Topic, Name, Attr, 'None', 'None') :-5 continue_topic, talk(Topic, Name, Attr1), 6 next_attr(Topic, Name, Attr).</figDesc></figure>
<figure xmlns="http://www.tei-c.org/ns/1.0" xml:id="fig_6"><head>7 next_topic(</head><label>7</label><figDesc>Topic, Name, Attr, Source, Relation) :-8 len_rcc(I), random(1, I, N), rcc(N, Topic, Name, Source, Relation), 9 next_attr(Topic, Name, Attr).</figDesc></figure>
<figure xmlns="http://www.tei-c.org/ns/1.0" xml:id="fig_7"><head>I</head><label></label><figDesc>feel like Batman Begins nails it with the whole inner battle vibe. It's not just about taking down bad guys; it's Bruce Wayne wrestling with his own demons, and that's what makes it hit home. Do you have the same feeling as me?</figDesc></figure>
<figure xmlns="http://www.tei-c.org/ns/1.0" xml:id="fig_8"><head></head><label></label><figDesc>Because you mentioned [source_topic_instance], it makes me think of the [next_topic][next_topic_instance], since[relation_of_them].</figDesc></figure>
<figure xmlns="http://www.tei-c.org/ns/1.0" xml:id="fig_9"><head>I</head><label></label><figDesc>remembered that the [property] of the [topic] [topic_instance] is [answer]. Sorry I could not remember the [property] of the [topic] [topic_instance].</figDesc></figure>
		</body>
		<back>
			<div type="references">

				<listBibl>

<biblStruct xml:id="b0">
	<monogr>
		<author>
			<persName><forename type="first">Y</forename><surname>Zeng</surname></persName>
		</author>
		<author>
			<persName><forename type="first">A</forename><surname>Rajashekharan</surname></persName>
		</author>
		<author>
			<persName><forename type="first">K</forename><surname>Basu</surname></persName>
		</author>
		<author>
			<persName><forename type="first">H</forename><surname>Wang</surname></persName>
		</author>
		<author>
			<persName><forename type="first">J</forename><surname>Arias</surname></persName>
		</author>
		<author>
			<persName><forename type="first">G</forename><surname>Gupta</surname></persName>
		</author>
		<idno type="arXiv">arXiv:2407.18498</idno>
		<title level="m">A reliable common-sense reasoning socialbot built using llms and goal-directed asp</title>
				<imprint>
			<date type="published" when="2024">2024</date>
		</imprint>
	</monogr>
	<note type="report_type">arXiv preprint</note>
</biblStruct>

<biblStruct xml:id="b1">
	<monogr>
		<title/>
		<author>
			<persName><forename type="first">J</forename><surname>Achiam</surname></persName>
		</author>
		<author>
			<persName><forename type="first">S</forename><surname>Adler</surname></persName>
		</author>
		<author>
			<persName><forename type="first">S</forename><surname>Agarwal</surname></persName>
		</author>
		<author>
			<persName><forename type="first">L</forename><surname>Ahmad</surname></persName>
		</author>
		<author>
			<persName><forename type="first">I</forename><surname>Akkaya</surname></persName>
		</author>
		<author>
			<persName><forename type="first">F</forename><forename type="middle">L</forename><surname>Aleman</surname></persName>
		</author>
		<author>
			<persName><forename type="first">D</forename><surname>Almeida</surname></persName>
		</author>
		<author>
			<persName><forename type="first">J</forename><surname>Altenschmidt</surname></persName>
		</author>
		<author>
			<persName><forename type="first">S</forename><surname>Altman</surname></persName>
		</author>
		<author>
			<persName><forename type="first">S</forename><surname>Anadkat</surname></persName>
		</author>
		<imprint>
			<date type="published" when="2023">2023</date>
		</imprint>
	</monogr>
	<note type="report_type">Gpt-4 technical report</note>
</biblStruct>

<biblStruct xml:id="b2">
	<monogr>
		<author>
			<persName><forename type="first">M</forename><surname>Nezhurina</surname></persName>
		</author>
		<author>
			<persName><forename type="first">L</forename><surname>Cipolina-Kun</surname></persName>
		</author>
		<author>
			<persName><forename type="first">M</forename><surname>Cherti</surname></persName>
		</author>
		<author>
			<persName><forename type="first">J</forename><surname>Jitsev</surname></persName>
		</author>
		<ptr target="https://arxiv.org/abs/2302.03494" />
		<title level="m">Alice in wonderland: Simple tasks showing complete reasoning breakdown in state-of-the-art large language models</title>
				<imprint>
			<date type="published" when="2024">2024</date>
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b3">
	<monogr>
		<title level="m" type="main">Reliable natural language understanding with large language models and answer set programming</title>
		<author>
			<persName><forename type="first">A</forename><surname>Rajasekharan</surname></persName>
		</author>
		<author>
			<persName><forename type="first">Y</forename><surname>Zeng</surname></persName>
		</author>
		<author>
			<persName><forename type="first">P</forename><surname>Padalkar</surname></persName>
		</author>
		<author>
			<persName><forename type="first">G</forename><surname>Gupta</surname></persName>
		</author>
		<imprint>
			<date type="published" when="2023">2023</date>
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b4">
	<monogr>
		<title level="m" type="main">Constraint answer set programming without grounding</title>
		<author>
			<persName><forename type="first">J</forename><surname>Arias</surname></persName>
		</author>
		<author>
			<persName><forename type="first">M</forename><surname>Carro</surname></persName>
		</author>
		<author>
			<persName><forename type="first">E</forename><surname>Salazar</surname></persName>
		</author>
		<author>
			<persName><forename type="first">K</forename><surname>Marple</surname></persName>
		</author>
		<author>
			<persName><forename type="first">G</forename><surname>Gupta</surname></persName>
		</author>
		<idno type="DOI">10.48550/ARXIV.1804.11162</idno>
		<ptr target="https://arxiv.org/abs/1804.11162.doi:10.48550/ARXIV.1804.11162" />
		<imprint>
			<date type="published" when="2018">2018</date>
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b5">
	<monogr>
		<author>
			<persName><forename type="first">K</forename><surname>Basu</surname></persName>
		</author>
		<author>
			<persName><forename type="first">H</forename><surname>Wang</surname></persName>
		</author>
		<author>
			<persName><forename type="first">N</forename><surname>Dominguez</surname></persName>
		</author>
		<author>
			<persName><forename type="first">X</forename><surname>Li</surname></persName>
		</author>
		<author>
			<persName><forename type="first">F</forename><surname>Li</surname></persName>
		</author>
		<author>
			<persName><forename type="first">S</forename><forename type="middle">C</forename><surname>Varanasi</surname></persName>
		</author>
		<author>
			<persName><forename type="first">G</forename><surname>Gupta</surname></persName>
		</author>
		<title level="m">CASPR: a commonsense reasoning-based conversational socialbot</title>
				<imprint>
			<date type="published" when="2021">2021</date>
		</imprint>
	</monogr>
</biblStruct>

<biblStruct xml:id="b6">
	<analytic>
		<title level="a" type="main">Discasp: A graph-based ASP system for finding relevant consistent concepts with applications to conversational socialbots</title>
		<author>
			<persName><forename type="first">F</forename><surname>Li</surname></persName>
		</author>
		<author>
			<persName><forename type="first">H</forename><surname>Wang</surname></persName>
		</author>
		<author>
			<persName><forename type="first">K</forename><surname>Basu</surname></persName>
		</author>
		<author>
			<persName><forename type="first">E</forename><surname>Salazar</surname></persName>
		</author>
		<author>
			<persName><forename type="first">G</forename><surname>Gupta</surname></persName>
		</author>
	</analytic>
	<monogr>
		<title level="m">Proc 37th ICLP (Tech. Comm)</title>
				<meeting>37th ICLP (Tech. Comm)</meeting>
		<imprint>
			<publisher>EPTCS</publisher>
			<date type="published" when="2021">2021</date>
			<biblScope unit="volume">345</biblScope>
			<biblScope unit="page" from="205" to="218" />
		</imprint>
	</monogr>
</biblStruct>

				</listBibl>
			</div>
		</back>
	</text>
</TEI>
