Sentence generation device and sentence generation method

The text generation device and method address the character limit issue in LLMs by generating additional sentences within the limit, creating effective prompts for LLMs to produce accurate answers, thereby enhancing answer quality.

WO2024232155A1PCT designated stage expired Publication Date: 2024-11-14SPIRAL AI INC
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
PCT/JP2024/009229
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-05-11
Filing Date
2024-03-11
Publication Date
2024-11-14

AI Technical Summary

Technical Problem

Large-scale language models (LLMs) face limitations in generating accurate answers due to their character input constraints, making it difficult to add sufficient reference information to question prompts without exceeding the character limit.

Method used

A text generation device and method that generates additional sentences related to the question text within the character limit, using various candidate sentence acquisition and adjustment methods to create a prompt with valid reference information for input to the LLM, ensuring the total character count does not exceed the input limit.

Benefits of technology

Enables the generation of prompts with effective reference information within the predetermined character limit, improving the accuracy and suitability of answer sentences generated by the LLM.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure JP2024009229_14112024_PF_FP_ABST
    Figure JP2024009229_14112024_PF_FP_ABST
Patent Text Reader

Abstract

This invention comprises: an additional sentence generation unit 11 that, on the basis of a question sentence input by a user, generates an additional sentence, related to the question sentence, within a number of characters such that, when combined with the number of characters of the question sentence, the total number of characters does not exceed a limit on the number of characters that can be input to an answer generation unit 20 of a large-scale language mode (LLM) 1; and a prompt generation unit 12 that generates a prompt by adding, as reference information, the additional sentence generated by the additional sentence generation unit 11 to the input question sentence. By generating an additional sentence in such number of characters that the limit of the number of characters that can be input to the LLM 1 as a prompt won't be exceeded, the invention makes it possible to generate, within the range of a determined limit on the number of characters, a prompt in which a valid sentence is added as reference information to an input question sentence.
Need to check novelty before this filing date? Find Prior Art

Description

Text generation device and text generation method

[0001] The present invention relates to a sentence generation device and a sentence generation method, and more particularly to a technique for generating sentences to be input as prompts into a large-scale language model.

[0002] Conventionally, systems have been provided that perform natural language processing such as question-and-answering using large language models (LLMs). LLMs are natural language processing models trained using large amounts of text data, and take sentences as input and output sentences. When LLMs are applied to a question-and-answering system, when a question is input to the LLM, an answer is output from the LLM. In an LLM, the input sentence is called a "prompt."

[0003] While the use of LLMs has progressed in recent years, there are significant issues regarding the accuracy of answers. Specifically, the behavior of LLMs, such as confidently outputting incorrect answers, has been viewed as problematic. One solution to this problem is to generate prompts by adding information to the question. When additional information is available, the LLM uses the additional information as a reference when generating an answer to the question. For example, as shown in Figure 13, by adding reference information to the question to create a prompt, the LLM is more likely to generate an appropriate answer that takes the reference information into consideration.

[0004] Previously, a technique combining a Completion model and an Embedding model has been proposed as a technology for generating prompts using additional information. The Completion model is a model that inputs a prompt containing a question or reference sentence and outputs an answer sentence generated based on that. The Embedding model is a model that converts the input sentence into a numerical vector based on its semantics. When two sentences have similar meanings, the model parameters are adjusted so that the vectors generated from them are similar. The method that combines these models uses the vectors from the Embedding model to search for information closely related to the question sentence, reflects the search results in the prompt, and then executes the Completion model.

[0005] A technology for generating a prompt by adding reference information to an input question sentence, and then inputting the generated prompt into a language model to generate an answer sentence is also disclosed in Patent Document 1. Patent Document 1 discloses, with regard to adding information to a prompt, adding an instruction sentence including an explanation about a chatbot character to the prompt, adding a character dialogue sample to the prompt, adding a dialogue scene acquired from a dialogue storage database in relation to the dialogue topic to the prompt, and replacing words included in the question sentence with synonyms or the like and adding them to the prompt.

[0006] Furthermore, Patent Documents 2 and 3 disclose generating another question from an input question and adding it to a prompt. Patent Document 2 discloses generating another question based on a past answer history. Patent Document 3 discloses generating another question by replacing words included in a question with contracted terms or the like.

[0007] Japanese Patent Application Laid-Open No. 2022-180282 Special Publication No. 2001-519559 Special Publication No. 2002-508863

[0008] As mentioned above, inputting a prompt generated by adding reference information to a question into an LLM is effective in that it makes it easier to obtain a suitable answer than if no reference information is added. However, because the Completion model LLM has a limit on the number of characters that can be input, there is a problem in that it is not possible to add an unlimited number of sentences generated based on the input question as reference information.

[0009] The present invention has been made to solve such problems, and aims to make it possible to generate prompts that add useful sentences as reference information to the input question text, within a set character limit.

[0010] In order to solve the above-mentioned problems, the present invention generates additional sentences related to the question based on the input question, with the total number of characters, including the number of characters in the question, not exceeding the limit on the number of characters that can be input into a large-scale language model, and adds the generated additional sentences to the question as reference information to generate a prompt to be input into the large-scale language model.

[0011] According to the present invention configured as described above, when generating a prompt by adding a sentence related to an input question, the additional sentence is generated so that the number of characters does not exceed the limit on the number of characters that can be input into a large-scale language model as a prompt.Therefore, a prompt can be generated that adds valid sentences for the input question as reference information within the set character limit.

[0012] 1 is a diagram illustrating an example of the configuration of a language model system including a sentence generation device of this embodiment. FIG. 2 is a block diagram illustrating an example of the functional configuration of a sentence generation unit (sentence generation device) according to this embodiment. FIG. 3 is a block diagram illustrating an example of the functional configuration of a candidate sentence acquisition unit that implements a first candidate sentence acquisition method. FIG. 4 is a block diagram illustrating an example of the functional configuration of a candidate sentence acquisition unit that implements a second candidate sentence acquisition method. FIG. 5 is a block diagram illustrating an example of the functional configuration of a candidate sentence acquisition unit that implements a third candidate sentence acquisition method. FIG. 6 is a diagram illustrating an example of a prompt and another question generated by applying the third candidate sentence acquisition method. FIG. 7 is a diagram illustrating another example of a prompt and another question generated by applying the third candidate sentence acquisition method. FIG. 8 is a block diagram illustrating an example of the functional configuration of a candidate sentence acquisition unit that implements a fourth candidate sentence acquisition method. FIG. 9 is a diagram illustrating an example of a prompt for generating question-answer pairs for supervised learning. FIG. 10 is a diagram illustrating two examples of candidate sentences adjusted by the first candidate sentence adjustment method. FIG. 11 is a flowchart illustrating an example of the operation of a sentence generation unit (sentence generation device) according to this embodiment. FIG. 12 is a diagram illustrating an example of the content of obtaining an answer sentence by inputting a prompt generated by adding reference information to a question sentence into an LLM.

[0013] An embodiment of the present invention will be described below with reference to the drawings. Fig. 1 is a diagram showing an example of the configuration of a language model system 100 equipped with a sentence generation device according to the present embodiment. The language model system 100 according to the present embodiment is configured with a large-scale language model (LLM) 1 and a sentence database (DB) 2.

[0014] The LLM1 is connected to a user terminal 200 via a communication network 300 such as the Internet or a mobile phone network, receives a question from the user terminal 200, generates an answer to the question, and outputs the answer to the user terminal 200. When generating the answer, the LLM1 generates an additional sentence related to the question, and generates a prompt including the question and the additional sentence.

[0015] The text DB2 is a database that the LLM1 uses when generating additional information based on a question entered from the user terminal 200. While FIG. 1 shows a configuration in which the text DB2 is connected to the LLM1, this is not limiting. For example, a configuration in which part or all of the text DB2 is connected to the communication network 300 may also be used. In this case, the LLM1 accesses the text DB2 via the communication network 300 and obtains the necessary information.

[0016] LLM1 is software that performs natural language processing according to a model trained using a large amount of text data, and includes a sentence generation unit 10 and an answer generation unit 20 as functional components realized by the software. The sentence generation unit 10 corresponds to the sentence generation device of this embodiment, and its functions are realized by a program stored in a storage medium such as a computer's RAM, ROM, hard disk, or semiconductor memory operating under the control of the CPU. The functions of the answer generation unit 20 are similarly realized.

[0017] The sentence generation unit 10 of this embodiment generates a prompt for input to the LLM1 by adding reference information to a question sentence input from the user terminal 200. The prompt for input to the LLM1 is specifically a prompt for input to the answer generation unit 20. In other words, the sentence generation unit 10 generates additional sentences based on the question sentence input from the user terminal 200, and further generates sentences by adding this additional sentences as reference information for the question sentence, and inputs this to the answer generation unit 20 as a prompt.

[0018] The answer generation unit 20 receives the prompt generated by the sentence generation unit 10 and generates an answer sentence to the question sentence included in the prompt by using the additional sentence included in the prompt as reference information. In other words, the answer generation unit 20 generates an answer sentence that is more suitable for the reference information.

[0019] Fig. 2 is a block diagram showing an example of the functional configuration of the sentence generation unit 10. As shown in Fig. 2, the sentence generation unit 10 of this embodiment includes, as its functional configuration, an additional sentence generation unit 11 and a prompt generation unit 12. The additional sentence generation unit 11 includes, as its more specific functional configuration, a candidate sentence acquisition unit 111 and a sentence adjustment unit 112.

[0020] Based on a question sentence input from the user terminal 200, the additional sentence generation unit 11 generates additional sentences related to the input question sentence, with the total number of characters, including the number of characters in the question sentence, not exceeding the limit on the number of characters that can be input to the answer generation unit 20 of the LLM 1. The prompt generation unit 12 generates a prompt by adding the additional sentences generated by the additional sentence generation unit 11 to the question sentence input from the user terminal 200 as reference information.

[0021] For example, as shown in FIG. 13 , when a question such as "Is Hiroshima a good place to hang out laundry tomorrow?" is input from the user terminal 200, the additional sentence generation unit 11 generates three additional sentences indicated by #ReferenceFacts, and the prompt generation unit 12 adds these additional sentences to the question to generate a prompt. In the example of FIG. 13 , a sentence such as "Please answer the following #Question. When answering, please refer to the contents written in #ReferenceFacts and answer based on that" is also added to the beginning of the prompt. In this case, the additional sentence generation unit 11 generates the additional sentences so that the total number of characters in the prompt, which is composed of the input question and additional sentences, does not exceed the limit on the number of characters that can be input to the LLM1.

[0022] Here, the candidate sentence acquisition unit 111 of the additional sentence generation unit 11 acquires candidate sentences related to the question sentence based on the question sentence input from the user terminal 200. In order for the answer generation unit 20 to generate a more appropriate answer sentence for the question sentence, it is important to generate appropriate additional sentences for the question sentence. In order to generate appropriate additional sentences, it is important to acquire appropriate candidate sentences from the sentence DB 2. To this end, the candidate sentence acquisition unit 111 acquires candidate sentences using one or more of the methods described below.

[0023] The sentence adjustment unit 112 generates additional sentences by adjusting the candidate sentences acquired by the candidate sentence acquisition unit 111. If the candidate sentences acquired by the candidate sentence acquisition unit 111 have a large number of characters, adding the candidate sentences directly to the question sentence to generate a prompt may result in the total number of characters exceeding the limit on the number of characters that can be input to the LLM 1. In such cases, the sentence adjustment unit 112 adjusts the candidate sentences using one or more of the methods described below so that the total number of characters falls within the character limit.

[0024] The following describes in detail how the candidate sentence acquisition unit 111 acquires candidate sentences. The candidate sentence acquisition unit 111 can acquire candidate sentences by applying one or more of the following methods.

[0025] <First Candidate Sentence Acquisition Method> Fig. 3 is a block diagram showing an example of the functional configuration of the candidate sentence acquisition unit 111 that implements the first candidate sentence acquisition method. In the example shown in Fig. 3, the candidate sentence acquisition unit 111 includes a keyword extraction unit 111a and a keyword search unit 111b.

[0026] The keyword extraction unit 111a extracts search keywords from a question sentence input from the user terminal 200. For example, the keyword extraction unit 111a extracts words as search keywords from the input question sentence through morphological analysis. Here, the extracted words may be limited to specific parts of speech (e.g., nouns, verbs, adjectives, adjectival verbs, etc.), or may be extracted excluding specific parts of speech (e.g., particles, auxiliary verbs, adverbs, conjunctions, conjunctions, interjections, etc.). One or more words may be extracted; however, if multiple words are extracted and used as search keywords, it is possible to search for and acquire sentences that are more closely related to the question sentence.

[0027] The keyword search unit 111b uses the search keywords extracted by the keyword extraction unit 111a to search a sentence DB2 in which multiple sentences are recorded, and acquires sentences that include the search keywords as candidate sentences from the sentence DB2. When multiple search keywords are extracted by the keyword extraction unit 111a, the keyword search unit 111b acquires sentences that include all of the multiple search keywords as candidate sentences from the sentence DB2. If no matching sentences are found, the search may be re-executed by omitting one of the search keywords.

[0028] If there are multiple sentences that match the search keyword, the keyword search unit 111b may acquire all of these sentences. However, if all of the sentences that match the search keyword are acquired, there is a high possibility that the total number of characters will exceed the limit on the number of characters that can be input into the LLM1. Therefore, a predetermined number of sentences that match the search keyword most closely may be acquired as candidate sentences.

[0029] Here, there may be multiple types of sentence DB2 to be searched, as shown in Figure 3. Figure 3 shows three DBs: a fact information DB 2a, a persona information DB 2b, and a correct answer example information DB 2c (hereinafter, these three may be collectively referred to as sentence DBs 2a-2c). The keyword search unit 111b searches for sentences in one or more of these three sentence DBs 2a-2c, using the words extracted by the keyword extraction unit 111a as search keywords. To improve the accuracy of the answer sentences generated by the answer generation unit 20, it is preferable to search multiple databases.

[0030] The fact information DB2a is a database that stores, in a referable state, for example, a specific company's web page, Wikipedia (registered trademark), or files such as txt, csv, word, excel, and pdf uploaded by users of the user terminal 200. The persona information DB2b is a database that stores a specific user's past dialogue history with LLM1, or information extracted therefrom that can be used to estimate the user's literacy, etc. (e.g., the level of prior knowledge in a specific technical field, past travel history, demographic attributes such as age, gender, and family composition, etc.). The correct answer example information DB2c is a database that stores information in which a person manually corrects a user's past dialogue history with LLM1, such as "LLM1 should have originally responded like this."

[0031] 4 is a diagram showing an example of a prompt constructed using candidate sentences acquired from each of the three sentence DBs 2a to 2c. In FIG. 4, "#referenceable information" is a candidate sentence acquired from the factual information DB 2a, "#questioner's persona" is a candidate sentence acquired from the persona information DB 2b, and "#helpful answer example" is a candidate sentence acquired from the correct answer example information DB 2c. In the example shown in FIG. 4, since the total number of characters in all the sentences included in the prompt does not exceed the limit on the number of characters that can be input to the LLM 1, it is not necessary to execute the processing of the sentence adjustment unit 112, and the prompt shown in FIG. 4 is input to the answer generation unit 20.

[0032] <Second Candidate Sentence Acquisition Method> Fig. 5 is a block diagram showing an example of the functional configuration of the candidate sentence acquisition unit 111 that implements the second candidate sentence acquisition method. In the example shown in Fig. 5, the candidate sentence acquisition unit 111 includes a vector calculation unit 111c and a vector search unit 111d.

[0033] The vector calculation unit 111c calculates a feature vector of a sentence from a question sentence input from the user terminal 200. For example, the vector calculation unit 111c includes a small-scale language model of an Embedding model, and converts the input question sentence into a numerical vector using the Embedding model. The small-scale language model is a natural language processing model trained based on less data than LLM1. Note that the method for calculating the feature vector is not limited to this, and other known techniques may also be applied. For example, words may be extracted from the input question sentence using morphological analysis, and the meanings of the words and the relationships between the words may be vectorized.

[0034] In order to apply the second candidate sentence acquisition method, feature vectors are calculated in advance for a plurality of sentences recorded in the sentence DBs 2 a to 2 c, and the plurality of sentences are recorded in advance in association with their respective feature vectors. The vector search unit 111 d searches the sentence DBs 2 a to 2 c using the feature vector calculated by the vector calculation unit 111 c for the input question sentence, and acquires, as candidate sentences, sentences associated with the feature vector calculated by the vector calculation unit 111 c from the sentence DBs 2 a to 2 c, which satisfy a predetermined condition for similarity with the feature vector calculated by the vector calculation unit 111 c.

[0035] The predetermined conditions for acquiring sentences can be set arbitrarily. For example, a predetermined number of sentences can be acquired starting from those with the highest similarity in feature vectors. Alternatively, sentences with feature vector similarity greater than a predetermined threshold can be acquired. In this case, all sentences with feature vector similarity greater than the predetermined threshold can be acquired, or if the number of sentences with feature vector similarity greater than the predetermined threshold exceeds a predetermined number, a predetermined number of sentences with the highest similarity can be acquired.

[0036] <Third Candidate Sentence Acquisition Method> Fig. 6 is a block diagram showing an example of the functional configuration of the candidate sentence acquisition unit 111 that implements the third candidate sentence acquisition method. In the example shown in Fig. 6, the candidate sentence acquisition unit 111 further includes a question sentence generation unit 111e in addition to the vector calculation unit 111c and vector search unit 111d shown in Fig. 5. Furthermore, the sentence DB2 further includes an example question sentence DB2d that stores a plurality of example question sentences.

[0037] The question generation unit 111e generates another question from the question input from the user terminal 200. The vector calculation unit 111c calculates the feature vector of the question input from the user terminal 200 as well as the feature vector of the other question generated by the question generation unit 111e. The vector search unit 111d searches the sentence DBs 2a to 2c using the feature vector calculated from the question input from the user terminal 200 and the feature vector calculated from the other question generated by the question generation unit 111e, and acquires candidate sentences.

[0038] Here, the question generation unit 111e includes a small-scale language model generated by applying few-shot learning, for example, and generates a prompt by adding an example question to the input question, inputting the generated prompt to the small-scale language model, and outputting another question from the small-scale language model. The example question is acquired from the example question DB 2d. FIG. 7 is a diagram showing an example of the prompt and another question generated by the candidate sentence acquisition unit 111 in this case. In the example of FIG. 7, a prompt is generated by adding an example question extracted from the example question DB 2d using "Okinawa trip" contained in the input question as a keyword, and another question is generated as indicated by the example question.

[0039] Furthermore, the question generation unit 111e may construct a prompt by dynamically generating a reference question generation example in accordance with a question input from the user terminal 200. For example, the question generation unit 111e can extract, from the example question DB 2d, an example question that matches the question input from the user terminal 200, and generate a reference question generation example from the extracted example question to construct a prompt. In this example, the example question that matches the input question can be, for example, an example question that is associated with a feature vector whose similarity with the feature vector calculated from the input question is equal to or greater than a threshold.

[0040] FIG. 8 is a diagram showing an example of a prompt and another question generated by the candidate sentence acquisition unit 111 in this case. In the example of FIG. 8, a plurality of example questions matching the input question are extracted from the example question DB 2d, and a reference question generation example is generated from these to form the prompt. The small-scale language model dynamically generates another question using the plurality of question generation examples included in the prompt. In this example, the small-scale language model is generated by training using past conversation history, and instead of generating another question according to the question generation example, the small-scale language model inputs the question generation example and the conversation history to generate another question.

[0041] <Fourth Candidate Sentence Acquisition Method> Figure 9 is a block diagram showing an example of the functional configuration of the candidate sentence acquisition unit 111 that implements the fourth candidate sentence acquisition method. In the example shown in Figure 9(a), the candidate sentence acquisition unit 111 includes a question example generation unit 111f and a question and answer generation unit 111g. Furthermore, the sentence DB 2 does not include sentence DBs 2a to 2c, but includes an example question sentence DB 2d.

[0042] The question example generation unit 111f generates a reference question example from a question sentence input from the user terminal 200. The method for generating a reference question example by the question example generation unit 111f may be the same as the generation method by the question sentence generation unit 111e illustrated in FIGS. 6 and 8. That is, the question example generation unit 111f extracts an example question sentence that matches the question sentence input from the user terminal 200 from the example question sentence DB 2d and generates a reference question example from the extracted example question sentence. Alternatively, because the question and answer generation unit 111g is a small-scale language model with flexible reading comprehension capabilities, the question input from the user terminal 200 may be directly input to the question and answer generation unit 111g without bothering to generate a question example. In this case, the question example generation unit 111f and the example question sentence DB 2d may be deleted from the configuration.

[0043] The question and answer generation unit 111g inputs reference question generation examples generated by the question generation example generation unit 111f into the small-scale language model, and thereby obtains combinations of question sentences and answer sentences as candidate sentences from the small-scale language model.

[0044] The small-scale language model provided in the question and answer generation unit 111g can be, for example, a model obtained by fine-tuning LLM1 to suit a specific task. Note that although the small-scale language model is a small-scale model, it is practically difficult to fine-tune it for each user and to always store multiple small-scale language models generated thereby in the server's memory. To solve this problem, a well-known incremental learning method called LoRA may be used.

[0045] LoRA adds an ultra-small language model called an Adapter to an original small-scale language model for training, enabling efficient fine-tuning with low memory requirements. While the original small-scale language model typically has tens of gigabytes of memory, the Adapter typically only has tens of megabytes. Therefore, even if the small-scale language model resides in memory and only the Adapter is loaded on-demand in response to a user request, the load time is negligible. Alternatively, it is possible to allocate a large number of Adapters in limited memory. This method can be used not only in the question and answer generation unit 111g but also in general situations where language models are used.

[0046] When fine-tuning the small-scale language model of the question and answer generation unit 111g, either self-supervised learning or supervised learning may be used. When using self-supervised learning, for example, learning can be performed by extracting input and output pairs from a back-and-forth dialogue history. On the other hand, when using supervised learning, questions and answers can be generated by another LLM that references the dialogue history through prompts, and these question and answer pairs can be learned. An example of a prompt for obtaining question and answer pairs is shown in FIG. 10.

[0047] In the example shown in FIG. 9( b), the candidate sentence acquisition unit 111 includes a question sentence generation unit 111h and an answer sentence acquisition unit 111j. The question sentence generation unit 111h generates another question sentence from a question sentence input from the user terminal 200. The method for generating another question sentence by the question sentence generation unit 111h may be the same as the method for generating another question sentence by the question sentence generation unit 111e illustrated in FIGS. 6 to 8. Alternatively, because the answer sentence acquisition unit 111j is a small-scale language model with flexible reading comprehension capabilities, the question input from the user terminal 200 may be input directly to the answer sentence acquisition unit 111j without generating a question sentence. In this case, the question sentence generation unit 111h and the example question sentence DB 2d may be deleted from the configuration.

[0048] The answer sentence acquisition unit 111j inputs another question sentence generated by the question sentence generation unit 111h into the small-scale language model, and thereby acquires an answer sentence to the other question sentence as a candidate sentence from the small-scale language model. In the example shown in Figure 9(b), a combination of the question sentence generated by the question sentence generation unit 111h and the answer sentence acquired by the answer sentence acquisition unit 111j is output as a candidate sentence from the candidate sentence acquisition unit 111. In this case, the question sentence generation unit 111h and the answer sentence acquisition unit 111j constitute a question and answer generation unit in the claims.

[0049] When the candidate sentence acquisition unit 111 acquires candidate sentences using the method described above, the number of acquired candidate sentences is often multiple, and the acquired candidate sentences may be redundant. Therefore, if the candidate sentences acquired by the candidate sentence acquisition unit 111 are directly added to a question sentence to generate a prompt, the total number of characters in the prompt may exceed the limit on the number of characters that can be input to the LLM1. In such cases, processing by the sentence adjustment unit 112 is required.

[0050] The following describes in detail the method for adjusting candidate sentences by the sentence adjuster 112. The sentence adjuster 112 can adjust candidate sentences by applying one or more of the following techniques.

[0051] <First candidate sentence adjustment method> The sentence adjustment unit 112 generates additional sentences with a reduced number of characters by using sentence portions of the candidate sentences related to the question sentence by inputting the question sentence input from the user terminal 200 and the candidate sentences acquired by the candidate sentence acquisition unit 111 into a small-scale language model. The small-scale language model provided in the sentence adjustment unit 112 may be, for example, the LLM1 of this embodiment that has been individually fine-tuned for the above task, or it may be a small-scale language model generated for the above task.

[0052] 11 is a diagram showing two examples of candidate sentence adjustment using the first candidate sentence adjustment method. In the example shown in Fig. 11, the candidate sentence acquired by the candidate sentence acquisition unit 111 is "When you think of a trip to Okinawa, you think of the beach in the summer and the aquarium in the winter!". To adjust this to reduce the number of characters, this candidate sentence and the question sentence input from the user terminal 200 are input to a small-scale language model.

[0053] 11(a) shows an example of candidate sentence adjustment when the input question is "I want to go on a trip to Okinawa in winter. What is a recommended plan for three nights and four days?" Since the question is about a winter trip to Okinawa, the small-scale language model evaluates the relevance of the part of the candidate sentence, "In summer, the sea," to the question as low, and generates the additional sentence, "I recommend an aquarium for a trip to Okinawa," using the part of the candidate sentence, "In winter, the aquarium," which is related to the question.

[0054] In contrast, Figure 11(b) shows an example of candidate sentence adjustment when the input question is "I want to go on a trip to Okinawa in the summer. What's a recommended plan for three nights and four days?" Because the question is about a summer trip to Okinawa, the small-scale language model evaluates the relevance of the part of the candidate sentence, "Aquarium in winter," to the question as low, and generates the additional sentence, "I recommend the sea for a trip to Okinawa in summer," using the part of the candidate sentence, "The sea in summer," which is related to the question.

[0055] For the sake of explanation, an example of adjusting one candidate sentence is shown here, but adding this one candidate sentence to the question does not exceed the character limit that can be entered into LLM1. In reality, if there are multiple candidate sentences and adding all of them to the question would cause the total number of characters to exceed the character limit, the adjustment process described above is performed on each candidate sentence. This also applies to the second candidate sentence adjustment method described below.

[0056] <Second Candidate Sentence Adjustment Method> The sentence adjuster 112 may generate additional sentences with a reduced number of characters by summarizing the candidate sentences acquired by the candidate sentence acquirer 111. The candidate sentences may be summarized using a small-scale language model generated for the task, or may be summarized using a known algorithm.

[0057] Furthermore, the sentence adjustment unit 112 may generate additional sentences with a reduced number of characters by summarizing key points related to the question sentence input from the user terminal 200 for the candidate sentences acquired by the candidate sentence acquisition unit 111. In this case, the sentence adjustment unit 112 can be configured to include, for example, a small-scale language model that receives as input the question sentence input from the user terminal 200 and the candidate sentences acquired by the candidate sentence acquisition unit 111 and is trained to output summarized candidate sentences.

[0058] 12 is a flowchart showing an example of the operation of the sentence generation unit 10 according to this embodiment configured as described above. The flowchart shown in FIG. 12 shows an outline of the processing procedure executed for one question sentence input to the LLM 1 from the user terminal 200.

[0059] First, the additional sentence generator 11 of the LLM1 inputs a question sentence from the user terminal 200 (step S1). When the additional sentence generator 11 inputs the question sentence, the candidate sentence acquisition unit 111 applies one or more of the first to fourth candidate sentence acquisition methods to acquire one or more candidate sentences related to the input question sentence (step S2).

[0060] Next, the sentence adjustment unit 112 determines whether the total number of characters, which is the sum of the number of characters in the question sentence input from the user terminal 200 and the number of characters in one or more candidate sentences acquired by the candidate sentence acquisition unit 111, exceeds the limit on the number of characters that can be input to the LLM 1 (step S3). If it is determined that the total number of characters exceeds the limit on the number of input characters, the sentence adjustment unit 112 applies either one or both of the first and second candidate sentence adjustment methods to reduce the number of characters in the candidate sentences so that the total number of characters falls within the limit on the number of input characters (step S4).

[0061] Here, the sentence adjustment unit 112, for example, adjusts all candidate sentences acquired by the candidate sentence acquisition unit 111 to reduce the number of characters, and then re-determines whether the total number of characters after the reduction exceeds the limit on the number of input characters. If the total number of characters still exceeds the limit on the number of input characters, the sentence adjustment unit 112 adjusts the candidate sentences again to reduce the number of characters. Alternatively, it may delete some of the candidate sentences acquired by the candidate sentence acquisition unit 111. By repeating this process, the total number of characters is adjusted to fall within the limit on the number of input characters. One or more candidate sentences adjusted in this manner are then determined as additional sentences for the question sentence.

[0062] When additional sentences for the question sentence are generated by adjusting the candidate sentences by the sentence adjustment unit 112 in the manner described above, the prompt generation unit 12 generates a prompt by adding the additional sentences generated by the sentence adjustment unit 112 in step S4 as reference information to the question sentence input from the user terminal 200 in step S1 (step S5).

[0063] If it is determined in step S3 above that the total number of characters does not exceed the limit on the number of input characters, the processing of the sentence adjustment unit 112 in step S4 is not performed, and the candidate sentence acquired by the candidate sentence acquisition unit 111 is directly determined as the additional sentence for the question. In this case, the prompt generation unit 12 generates a prompt by adding the candidate sentence (=additional sentence) acquired by the candidate sentence acquisition unit 111 in step S2 as reference information to the question input from the user terminal 200 in step S1 (step S5).

[0064] The prompt generator 12 then inputs the generated prompt to the answer generator 20 (step S6). The answer generator 20 uses the additional sentence included in the prompt input by the sentence generator 10 as reference information to generate an answer to the question included in the prompt, and outputs the generated answer to the user terminal 200 (step S7). This completes the processing of the flowchart shown in FIG.

[0065] As explained in detail above, in this embodiment, based on a question entered into the LLM1 from the user terminal 200, additional text related to the question is generated such that the total number of characters, including the number of characters in the question, does not exceed the character limit that can be entered into the answer generation unit 20 of the LLM1, and the generated additional text is added to the question as reference information, thereby generating a prompt to be entered into the answer generation unit 20.

[0066] According to this embodiment configured as described above, when generating a prompt by adding a sentence related to the input question, the additional sentence is generated so that the number of characters does not exceed the limit on the number of characters that can be input to the answer generation unit 20 as a prompt. Therefore, a prompt can be generated that adds valid sentences for the input question as reference information within the set character limit.

[0067] In the above embodiment, the LLM 1 is configured with the sentence generation unit 10, but the present invention is not limited to this. For example, the sentence generation unit 10 may be configured separately from the LLM 1.

[0068] In the above embodiment, the user may be able to select the output format of the answer sentence output by the answer generation unit 20. For example, the tone of the answer sentence may be selected. This can be achieved by specifying an additional sentence, such as "Answer in a certain tone of voice," when the prompt is generated by the sentence generation unit 10. Due to the nature of LLMs, if reference information is included in the prompt, the tone of voice specification tends to be ignored and the tone of the reference information takes precedence. To address this issue, an instruction to have the LLM output in two stages may be included as an additional sentence to the prompt: "First, enter a normal answer following 'Normal answer:', and then enter 'XX character:' and respond in a tone that reflects the character's tone of voice." In this case, by outputting the portion of the LLM output following 'XX character:', only the portion that imitates the character's tone of voice can be presented to the user. The format of the answer sentence may also be selected. For example, the answer may be output according to chapters such as "Summary," "Business Content," "Application Items," and "Additional Notes," in accordance with the format of government declaration documents. This can also be achieved by specifying additional text in the prompt.

[0069] Furthermore, the sentence DBs 2a to 2d or small-scale language models used in the above embodiments can be sold to companies. A lump-sum payment or a subscription model may be used. When selling the sentence DBs 2a to 2d or small-scale language models, personal information and confidential company information must be removed. This process can be performed manually or using an LLM created for the task. The above-mentioned answer sentence output format may also be available for sale to companies.

[0070] Furthermore, the above-described embodiments are merely examples of specific embodiments for carrying out the present invention, and the technical scope of the present invention should not be construed as being limited thereby. In other words, the present invention can be carried out in various forms without departing from the gist or main characteristics thereof.

[0071] REFERENCE SIGNS LIST 1 Large-scale language model (LLM) 2 Sentence DB 2a Factual information DB 2b Persona information DB 2c Correct answer example information DB 10 Sentence generation unit (sentence generation device) 11 Additional sentence generation unit 12 Prompt generation unit 20 Answer generation unit 111 Candidate sentence acquisition unit 111a Keyword extraction unit 111b Keyword search unit 111c Vector calculation unit 111d Vector search unit 111e Question sentence generation unit 111f Question generation example generation unit 111g Question and answer generation unit 111h Question sentence generation unit (question and answer generation unit) 111j Answer sentence acquisition unit (question and answer generation unit) 112 Sentence adjustment unit

Claims

1. A sentence generation device that generates a prompt to be input into a large-scale language model by adding reference information to an input question sentence, comprising: an additional sentence generation unit that generates additional sentence related to the question sentence based on the input question sentence, the total number of characters including the number of characters of the question sentence not exceeding the character limit that can be input into the large-scale language model; and a prompt generation unit that generates the prompt by adding the additional sentence generated by the additional sentence generation unit to the input question sentence as the reference information, wherein the additional sentence generation unit comprises: a candidate sentence acquisition unit that acquires candidate sentences related to the question sentence based on the input question sentence; and a sentence adjustment unit that generates the additional sentences by adjusting the candidate sentences acquired by the candidate sentence acquisition unit.

2. The text generation device described in claim 1, characterized in that the text adjustment unit generates the additional text using the text parts of the candidate text related to the question text by inputting the input question text and the candidate text acquired by the candidate text acquisition unit into a small-scale language model.

3. The text generation device according to claim 1, wherein the text adjustment unit generates the additional text by summarizing the candidate text acquired by the candidate text acquisition unit.

4. The text generation device according to claim 3, characterized in that the text adjustment unit generates the additional text by summarizing key points related to the input question text from the candidate text acquired by the candidate text acquisition unit.

5. The text generation device according to any one of claims 1 to 4, characterized in that the candidate text acquisition unit comprises: a keyword extraction unit which extracts a search keyword from the input question text; and a keyword search unit which uses the search keyword extracted by the keyword extraction unit to search a text database in which a plurality of texts are recorded, thereby acquiring a text including the search keyword from the text database as the candidate text.

6. The sentence generation device according to any one of claims 1 to 4, characterized in that the candidate sentence acquisition unit comprises: a vector calculation unit which calculates a feature vector of a sentence from the input question sentence; and a vector search unit which uses the feature vector calculated by the vector calculation unit to search a sentence database in which a plurality of sentences are recorded in advance in association with their respective feature vectors, thereby acquiring from the sentence database as the candidate sentence a sentence associated with a feature vector which satisfies a predetermined condition for similarity with the feature vector calculated by the vector calculation unit.

7. The text generation device according to claim 6, characterized in that the candidate text acquisition unit further comprises a question text generation unit which generates another question text from the input question text, the vector calculation unit calculates a feature vector of the input question text as well as a feature vector of the another question text generated by the question text generation unit, and the vector search unit searches a text database using the feature vector calculated from the input question text and the feature vector calculated from the another question text.

8. The text generation device according to any one of claims 1 to 4, characterized in that the candidate text acquisition unit is provided with a question / answer generation unit which generates a combination of another question text and an answer text as the candidate text based on the input question text using a small-scale language model.

9. A sentence generation method for generating a prompt to be input into a large-scale language model by adding reference information to an input question sentence, comprising: a first step in which an additional sentence generation unit of a computer generates additional sentence related to the question sentence based on the input question sentence, the total number of characters including the number of characters of the question sentence not exceeding the character limit that can be input into the large-scale language model; and a second step in which a prompt generation unit of the computer generates the prompt by adding the additional sentence generated by the additional sentence generation unit to the input question sentence as the reference information, wherein in the first step, the additional sentence generation unit obtains candidate sentences related to the question sentence based on the input question sentence, and generates the additional sentences by adjusting the obtained candidate sentences.

Citation Information

Patent Citations

  • Intention recognition method and device based on prompt learning and question answering method and device based on prompt learning

    CN115391527A

  • Persona chatbot control method and system

    JP2022180282A