Improving Diversity of Commonsense Generation by Large Language Models via In-Context Learning (2024)

Abstract: Generative Commonsense Reasoning (GCR) requires a model to reason about a situation using commonsense knowledge, while generating coherent sentences. Although the quality of the generated sentences is crucial, the diversity of the generation is equally important because it reflects the model’s ability to use a range of commonsense knowledge facts. Large Language Models (LLMs) have shown proficiency in enhancing the generation quality across various tasks through in-context learning (ICL) using given examples without the need for any fine-tuning. However, the diversity aspect in LLM outputs has not been systematically studied before. To address this, we propose a simple method that diversifies the LLM generations, while preserving their quality. Experimental results on three benchmark GCR datasets show that our method achieves an ideal balance between the quality and diversity. Moreover, the sentences generated by our proposed method can be used as training data to improve diversity in existing commonsense generators.

## introduction commonsense reasoning is the ability to make logical deductions about concepts encountered in daily life, and is considered as a critical property of intelligent agents @xcite . concepts are mental representations of classes and are expressed using words in a language @xcite . given the inputs, the gcr task requires a model to generate a coherent sentence that is grammatical and adheres to commonsense, evaluated by its similarity to a set of human-written reference sentences covering the same set of concepts @xcite . often there exists multiple relationships between a given set of concepts, leading to alternative reasoning paths that take diverse view points. for ex- dog; catch; frisbee; throw figure 1 : an example of diverse generated sentence sets in @xcite dataset. the generation shown at the bottom (in green ) is considered by human annotators to be more diverse than those at the top (in red ). we propose in-context diversification (icd), a computationally-efficient and accurate method to improve the diversity in gcr, where the sentences are generated from a pre-trained llm, and strikes a fine-balance between the output diversity and quality. icd uses an icl approach to increase the diversity of the sentences generated by an llm, while maintaining the quality of the generation. icd is a two-step process where it first lets an llm to generate sentences that are grammatical, commonsense bearing and cover the tasks' requirements. if the diversity is low, icd provides feedback to the llm, instructing it to generate more diverse sentences considering the already generated sentences. next, icd uses a diversity-based sampling method to make a trade-off between quality and diversity with a user-specific diversity metric. given that icd is using llms to generate diverse sentences via icl and without updating the parameters of the llms, an interesting and open question is whether an llm can accurately judge the diversity of a given set of sentences. to answer this question, we conduct an experiment where we instruct gpt3.5-turbo to judge the diversity of the set of input sentences according to a fivescale grading system, and convert the predicted grades into binary judgements (i.e. diverse vs. nondiverse). we compare the llm-assigned grades against those by a group of human annotators, and find a moderate-level (cohen's kappa of 0.409) agreement between human vs. llm judgements, demonstrating that llms can indeed be instructed to obtain diversity judgements for gcr tasks. we evaluate icd on three gcr tasks/datasets: commongen (lin et al., 2020), comve @xcite , and dimongen @xcite . we find that our proposed icd balances diversity and quality appropriately, improving their harmonic mean by at least 6% over that of a default baseline. moreover, the sentences generated by icd can be used as training data to improve diversity in a seq2seq model @xcite , producing results that are comparable to the models that are trained on knowledge graphs or human-written text corpora @xcite @xcite . in-context learning. recent studies demonstrate that llms can exhibit robust few-shot performance on a variety of downstream tasks through icl @xcite . icl is a technique for instructing an llm using one or more examples for a particular text generation task. the generated text is conditioned on both the input as well as the instruction prompt. @xcite show that in icl, label words in the demonstration examples function as anchors, which aggregate semantic information to their word representations in the shallow (closer to the input) layers, while providing that information to the final predictions performed by the deeper (closer to the output) layers. in contrast to fine-tuning-based methods, icl is computationally lightweight because it does not update the parameters of the llm. therefore, icl is an attractive method when integrating task-specific knowledge to an llm by simply changing the prompt and the few-shot examples @xcite . ## in-context diversification we consider the problem of generating a set of diverse sentences that express commonsense reasoning, either by covering a set of given concepts (in commongen and dimongen) or by providing an explanation for a given counterfactual statement default examples: given several key words: [src], generate one coherent sentence using background commonsense knowledge: [tgt] test instruction: given several key words: [input], generate one coherent sentence using background commonsense knowledge: [output] diversified examples: given several key words: [src], generate one coherent sentence using background commonsense knowledge: [tgt] test instruction: step1: given several key words: [input], generate [n] different and coherent sentences using background commonsense knowledge: [prv] (if the diversity of [prv] is low) step2: you have generated the following sentences: [prv], try to provide other reasonable sentences: [output] few-shot examples are included in each prompt where [src] denotes the set of input concepts and [tgt] the corresponding sentences in commongen. for a given set of [input] concepts, the llm is then required to generate sentences at the slot [output]. as shown in figure 2b, icd uses the diversified prompt, which operates in two steps. step 1 generates a set of [n] sentences, [prv]. we check for the diversity among the sentences in [prv], and if it is low, we use the prompt in step 2 to generate the final set of sentences. ## conclusion we proposed, icd, an icl-based method for achieving the optimal balance between diversity and quality in text generation via llms. our experiments, conducted on three gcr tasks, demonstrate that icd significantly improves the diversity without substantially compromising the quality. furthermore, we found that by training on the sentences generated by icd, we can improve diversity in previously proposed gcr methods.