A method and system for Zhuang language dialogue retrieval combined with generation

By constructing a Zhuang language dialogue system that combines retrieval and generation, and by optimizing the Transformer model using Zhuang language corpus and knowledge graph, the problems of data scarcity and cultural differences in Zhuang language dialogue systems are solved, resulting in a more accurate and personalized dialogue experience.

CN118503381BActive Publication Date: 2026-07-24GUANGXI UNIV FOR NATITIES +1
View PDF 5 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
GUANGXI UNIV FOR NATITIES
Filing Date
2024-05-27
Publication Date
2026-07-24

AI Technical Summary

Technical Problem

In existing technologies, Zhuang language open-domain dialogue systems suffer from problems such as data scarcity, cultural differences, and insufficient accuracy in user profiling, resulting in poor accuracy and personalized service for Zhuang language users.

Method used

A method combining retrieval and generation is adopted. By acquiring Zhuang language corpus, a pre-training dataset, a dialogue database, a document database, and a knowledge graph are constructed. The Transformer model is trained and optimized by combining reinforcement learning algorithm to generate candidate response texts that conform to the context.

Benefits of technology

It improves the accuracy and diversity of the Zhuang language dialogue system, providing natural, rich, and relevant dialogue content, enhancing the system's robustness and flexibility to adapt to different user needs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118503381B_ABST
    Figure CN118503381B_ABST
Patent Text Reader

Abstract

The application discloses a Zhuang language dialogue method and system combining retrieval and generation, and relates to the technical field of human-computer dialogue; the method comprises the following steps: obtaining a Zhuang language corpus; obtaining a pre-training data set, a dialogue database, a document database and a knowledge graph according to the Zhuang language corpus; constructing a generative model, fine-tuning after training using the pre-training data set, and then optimizing the strategy by using a reinforcement learning algorithm to obtain a Zhuang language dialogue model; obtaining a Zhuang language dialogue text, and obtaining candidate reply texts by using the Zhuang language dialogue model; meanwhile, the Zhuang language dialogue text is input into the dialogue database for retrieval to obtain the candidate reply texts; and the candidate reply texts are scored and sorted by using the model, and the candidate reply text with the highest score is output. The application can fully utilize the information in the knowledge base and combine the generative model to provide more accurate, rich and natural dialogue experience, and meet the needs and expectations of users.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of human-computer dialogue technology, specifically to a Zhuang language dialogue method and system that combines retrieval and generation. Background Technology

[0002] Open-domain dialogue systems are designed for free, multi-topic, multi-turn conversations with users. Unlike domain-specific dialogue systems, open-domain dialogue systems have no explicit limitations or constraints and can cover a wide range of topics and contexts. These systems are typically more flexible and can adapt to a variety of questions and topics raised by users.

[0003] Generative dialogue systems, based on generative models, autonomously generate responses rather than simply selecting from a predefined response library. They can flexibly generate diverse responses, but the generated responses may be unstable, sometimes deviating from expectations, and require substantial data and computational resources for training. Retrieval-based dialogue systems generate responses by selecting the most matching response from a predefined response library. The responses are relatively controllable and can ensure a certain degree of accuracy, but they are less adaptable to new domains or unknown problems.

[0004] Zhuang is the language of the Zhuang ethnic group in China, mainly spoken in Guangxi Zhuang Autonomous Region and other areas. As Zhuang is a minority language, relevant open-domain dialogue data and language resources are relatively limited. Zhuang has its own unique grammatical structure and expression, requiring a deep understanding of these linguistic characteristics to build a dialogue system. Users may ask questions related to Zhuang culture, history, and customs; therefore, the system needs to be able to acquire and understand knowledge in these areas.

[0005] The design and implementation of the intelligent dialogue system in Chinese patent document CN117609486A is more geared towards applications in Mandarin or Chinese, and may suffer from insufficient language adaptability for minority languages ​​like Zhuang. Zhuang's grammatical structure and vocabulary differ significantly from Chinese, thus requiring more specialized design and optimization for Zhuang processing. For intelligent dialogue systems targeting the psychological domain, their knowledge base may lean towards information and knowledge in psychology, with relatively insufficient coverage of psychological knowledge specific to Zhuang. This could limit the accuracy and effectiveness of the system in addressing the psychological needs of Zhuang users. Zhuang culture differs from Han culture in characteristics and customs, such as in expression and values. The design of the intelligent dialogue system needs to consider these cultural differences to ensure a more accurate and relevant understanding and response to Zhuang users.

[0006] Chinese patent document CN117520526A determines the mapping level of dialogue information by calculating the mapping hierarchy through feature words. However, for minority languages ​​like Zhuang, there may be difficulties in obtaining feature words and mapping the processing hierarchy, making it difficult to accurately determine the mapping level of dialogue information. When the mapping level of dialogue information cannot be determined, this method uses a basic connection model and expands it based on a pre-set database to obtain a predictive connection model. However, for minority languages ​​like Zhuang, there may be a problem of data scarcity, making it difficult to expand the database and obtain an accurate and reliable predictive connection model.

[0007] Chinese patent document CN117786079A may have an inaccurate user profile model for Zhuang language users. Due to limitations in data collection and cultural differences, the user profile model may not accurately reflect the characteristics and needs of Zhuang language users, thus affecting the personalized service effectiveness of the dialogue system. For Zhuang language dialogue systems, context awareness may also be insufficient. Due to the unique cultural background and language habits of Zhuang, understanding the context of Zhuang language users may be relatively difficult, leading to insufficient accuracy in context awareness and affecting the relevance and closeness of the system's dialogue. Summary of the Invention

[0008] The purpose of this invention is to propose a Zhuang language dialogue method and system that combines retrieval and generation, which can make full use of information in the knowledge base and combine it with a generative model to provide a more accurate, richer and more natural dialogue experience, meeting the needs and expectations of users.

[0009] According to a first aspect of the present disclosure, a Zhuang language dialogue retrieval and generation method is provided, comprising the following steps:

[0010] Obtain Zhuang language corpus;

[0011] Based on the Zhuang language corpus, a pre-training dataset, a dialogue database, a document database, and a knowledge graph were obtained;

[0012] A generative model is constructed, trained and fine-tuned using a pre-trained dataset, and then approached policy optimization through a reinforcement learning algorithm to obtain a Zhuang language dialogue model.

[0013] The Zhuang language dialogue text is retrieved, and it is determined whether relevant knowledge needs to be introduced to meet user needs. If relevant knowledge needs to be introduced, it is searched through the document database and knowledge graph. The search results, along with the first prompt template, historical dialogue records, and the current Zhuang language dialogue text, are input into the Zhuang language dialogue model to obtain candidate response texts. If relevant knowledge does not need to be introduced, the second prompt template, historical dialogue records, and the current Zhuang language dialogue text are input into the Zhuang language dialogue model to obtain candidate response texts. At the same time, after retrieving the Zhuang language dialogue text, it is input into the dialogue database for retrieval to obtain candidate response texts.

[0014] The evaluation model scores and ranks the candidate response texts, and outputs the candidate response text with the highest score. If the candidate response text with the highest score is generated by the Zhuang language dialogue model, then the dialogue data for this session is entered into the dialogue database.

[0015] Furthermore, the Zhuang language corpus is processed to obtain the pre-training dataset in the following way:

[0016] Language filtering removes non-Zhuang language text;

[0017] Statistical filtering removes Zhuang language text that is statistically abnormal;

[0018] Keyword filtering excludes Zhuang language text containing certain keywords;

[0019] Classifier filtering: Use a machine learning classifier to filter out high-quality Zhuang language text;

[0020] Sensitive content filtering filters out Zhuang language text containing toxic and private content;

[0021] Data deduplication is performed at different levels: at the sentence level, duplicate sentences are removed from Zhuang text; at the document level, duplicate documents are removed to ensure that no two Zhuang documents are exactly the same; at the dataset level, duplicate Zhuang data is removed to avoid repeatedly integrating the same Zhuang data when integrating data from different sources.

[0022] Lexicalization involves breaking down Zhuang language texts into lexical units.

[0023] Furthermore, a dialogue database was obtained from the Zhuang language corpus, including: the participants in the dialogue, the rounds of the dialogue, and the text content of each round.

[0024] Furthermore, the document database is obtained by processing the Zhuang language corpus as follows:

[0025] The Zhuang language corpus is processed, including word segmentation, stop word removal, and stemming, to convert the Zhuang language corpus into a set of terms; an empty inverted index data structure is created, which is represented by a hash table or tree structure; each term is assigned a corresponding inverted list to store a list of documents containing that term;

[0026] For each document, iterate through the terms and update the inverted index; for each term, add it to the inverted list corresponding to the inverted index.

[0027] Furthermore, the knowledge graph is obtained by processing the Zhuang language corpus as follows:

[0028] The Zhuang language corpus is cleaned by removing duplicates, correcting spelling errors, and standardizing text format; the cleaned Zhuang language corpus is annotated, including part-of-speech tagging, entity recognition, and syntactic analysis; entities and the relationships between them are stored in the form of a graph.

[0029] Extract entities, attributes, and relationships, and organize them into a knowledge graph.

[0030] Furthermore, the generative model is constructed as follows:

[0031] Obtain a Transformer model, pre-train it using a pre-training dataset, and perform a self-supervised learning task; optimize a given text sequence x = x1…x n Maximum likelihood estimation L PT :

[0032]

[0033] In the formula, k represents the model window size, based on k historical words x. i-k …x i-1 Predict the word x at the current moment i θ represents the parameters of the Transformer model, and the likelihood function is optimized using stochastic gradient descent.

[0034] Questions are extracted from the dialogue database, and expected responses are manually entered to construct a high-quality Zhuang language dialogue training set. Using the questions and expected responses, the pre-trained Transformer model is fine-tuned in a supervised manner, with the cross-entropy criterion used as the loss function during the fine-tuning process.

[0035] Furthermore, the candidate response files output by the generative model are manually labeled to obtain the evaluation dataset. The evaluation model is then trained with the goal of finding the parameter set θ of the evaluation model that minimizes the overall loss on the evaluation dataset.

[0036] S w =r θ (x,y w (2)

[0037] S l =r θ (x,y l (3)

[0038] loss = -log(σ(S) w -S l (4)

[0039] x represents the input Zhuang language dialogue text, y w It is a relatively high-quality generative model output, y l It is the output of a generative model with relatively poor quality, S w S is the score given by the evaluation model to the relatively high-quality output. l It is the score given by the evaluation model for outputs with relatively poor quality; σ is the Sigmoid function.

[0040] Furthermore, the first objective function of the reinforcement learning algorithm's Proximal Policy Optimization (PPO) is:

[0041]

[0042] Let the input Zhuang language dialogue text be x, LLM SFT The question is whether the output of the fine-tuned generative model is equal to the probability of y. It determines whether the output of the reinforcement learning model equals the probability of y; for each evaluation model, the input text is x. RL Then, a reinforcement learning model is used to obtain the output of the input text, denoted as . KL divergence is introduced to prevent the fine-tuned generative model from deviating too much from the reinforcement learning model. β is the scaling parameter that constrains the KL divergence; φ is the parameter of the reinforcement learning model; after multiple rounds of reinforcement learning, the Zhuang language dialogue model is obtained.

[0043] Let x be the input text of the fine-tuned generative model. pretrain The second objective function is the reinforcement learning model's response to the input text x. pretrain The output of the lower-order model is better than the output of the fine-tuned generative model, specifically:

[0044]

[0045] Here, γ is adjusted according to the environment, starting from 0.99;

[0046] Therefore, the objective function of the Zhuang language dialogue model is:

[0047]

[0048] Among them, D RL It is the distribution of the input text used to evaluate the model, D pretrain It represents the distribution of the pre-training dataset for the fine-tuned generative model; E represents the mathematical expectation, x ~ DRL Indicates that x follows D RL Distribution, x ~ D pretrain Indicates that x follows D pretrain distributed.

[0049] Furthermore, when Zhuang language dialogue text is input into the dialogue database for retrieval, it needs to be combined with the document database: for each query term, the corresponding dialogue list is searched in the inverted index to obtain the dialogues containing the term; the inverted lists of all query terms are merged and then sorted, and the top n dialogue texts are used as candidate response texts.

[0050] According to a second aspect of the present disclosure, a Zhuang language dialogue system combining retrieval and generation is provided, comprising:

[0051] The collection module is used to acquire Zhuang language corpus;

[0052] The database acquisition module obtains a pre-training dataset, a dialogue database, a document database, and a knowledge graph based on the Zhuang language corpus.

[0053] The model acquisition module constructs a generative model, trains it using a pre-trained dataset, fine-tunes it, and then uses a reinforcement learning algorithm to approach policy optimization, thus obtaining a Zhuang language dialogue model.

[0054] The candidate response text acquisition module retrieves the Zhuang language dialogue text and determines whether relevant knowledge needs to be introduced to meet user requirements. If relevant knowledge needs to be introduced, it searches through the document database and knowledge graph, and inputs the search results, along with the first prompt template, historical dialogue records, and the current Zhuang language dialogue text, into the Zhuang language dialogue model to obtain candidate response texts. If relevant knowledge does not need to be introduced, it inputs the second prompt template, historical dialogue records, and the current Zhuang language dialogue text into the Zhuang language dialogue model to obtain candidate response texts. Simultaneously, after acquiring the Zhuang language dialogue text, it is input into the dialogue database for retrieval to obtain candidate response texts.

[0055] The evaluation module uses an evaluation model to score and rank candidate response texts, and outputs the candidate response text with the highest score.

[0056] According to a third aspect of the present disclosure, an electronic device is provided, including a memory, a processor, and a computer program stored in the memory and running on the memory, wherein the processor executes the program to implement the Zhuang language dialogue method that combines retrieval and generation.

[0057] According to a fourth aspect of the present disclosure, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements the Zhuang language dialogue method that combines retrieval and generation.

[0058] Compared with existing technologies, the technical solutions adopted in this invention have the following advantages: By using a dialogue database, the system can retrieve the most relevant response from a large amount of existing dialogue data, providing accurate and related answers. The Zhuang language dialogue model can generate more natural and context-appropriate responses based on the retrieved responses and the current dialogue context, further improving accuracy and relevance. When the dialogue database cannot find a suitable response, the Zhuang language dialogue model can provide alternative responses, thereby improving overall robustness and reliability. This invention can also flexibly choose between retrieval-based or generative methods depending on different situations, ensuring that the system provides effective responses in various circumstances. The Zhuang language dialogue model can create diverse responses, avoiding repetitive and monotonous dialogue patterns. By combining with a dialogue database, richer and more diverse dialogue content can be generated, making the dialogue more vivid and interesting. Attached Figure Description

[0059] The accompanying drawings, which form part of this application, are used to provide a further understanding of this application. The illustrative embodiments of this application and their descriptions are used to explain this application and do not constitute an undue limitation of this application.

[0060] Figure 1 This is a flowchart of a Zhuang language dialogue method that combines retrieval and generation. Specific implementation methods

[0061] The present disclosure will be further described below with reference to the accompanying drawings and embodiments.

[0062] It should be noted that the following detailed descriptions are illustrative and intended to provide further explanation of this application. Unless otherwise specified, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains.

[0063] It should be noted that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the exemplary embodiments according to this application. As used herein, the singular form is intended to include the plural form as well, unless the context clearly indicates otherwise. Furthermore, it should be understood that when the terms "comprising" and / or "including" are used in this specification, they indicate the presence of features, steps, operations, devices, components, and / or combinations thereof.

[0064] It should be noted that the flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of methods and systems according to various embodiments of this disclosure. It should be noted that each block in a flowchart or block diagram may represent a module, segment, or portion of code, which may include one or more executable instructions for implementing the logical functions specified in the various embodiments. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than that shown in the drawings. For example, two consecutively represented blocks may actually be executed substantially in parallel, or they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the flowcharts and / or block diagrams, and combinations of blocks in the flowcharts and / or block diagrams, may be implemented using a dedicated hardware-based system that performs the specified functions or operations, or using a combination of dedicated hardware and computer instructions.

[0065] Example 1:

[0066] This embodiment provides a Zhuang language dialogue retrieval and generation method, including the following steps:

[0067] S1. Obtain Zhuang language corpus;

[0068] Specifically, web scraping techniques are used to crawl Zhuang language data, identifying the data sources and target websites, including Zhuang language forums, blogs, news websites, and social media. Appropriate web scraping tools, such as Scrapy, Beautiful Soup, and Selenium, are selected based on the characteristics and needs of the target websites. Zhuang language books are scanned, and OCR (Optical Character Recognition) technology is used to recognize and convert the written Zhuang text.

[0069] S2. Based on the Zhuang language corpus, a pre-training dataset, a dialogue database, a document database, and a knowledge graph are obtained;

[0070] Pre-training dataset: The collected raw Zhuang language corpus usually contains noise and irrelevant information, therefore quality filtering is required, including: language filtering to ensure all text is in Zhuang language and remove non-Zhuang language content; statistical filtering to remove statistically abnormal Zhuang text, such as documents that are too long or too short; keyword filtering to exclude Zhuang text containing certain keywords that may be irrelevant to the target task or misleading; classifier filtering to use machine learning classifiers to select high-quality Zhuang text; and sensitive content filtering to filter out data containing toxic content (such as hate speech and violent descriptions) and private content (such as personally identifiable information) in order to comply with laws and regulations and protect user privacy. Data deduplication: Removing duplicate content is crucial for improving the model's generalization ability. Deduplication can be performed at different levels: sentence level, removing duplicate sentences in the text; document level, ensuring that there are no completely identical documents in the document library; and dataset level, avoiding the repeated integration of the same data when integrating datasets from different sources. Lexicalization (word segmentation): Decomposing Zhuang text into smaller units (lexicals), which are the smallest text fragments that the model can understand.

[0071] Dialogue databases include participants, rounds of dialogue, and text content for each round. They can be public dialogue datasets, such as movie script dialogues, social media dialogues, or public question-and-answer pairs; or they can be domain-specific dialogues, such as customer service dialogue records.

[0072] The document database is a collection of text documents, including books, articles, reports, and web page content. Preprocessing of the Zhuang language corpus involves operations such as word segmentation, stop word removal, and stemming to transform the document corpus into a collection of terms. An empty inverted index data structure is created, represented using a hash table or tree structure. Each term corresponds to an inverted list storing a list of documents containing that term. For each document, the terms are traversed, and the inverted index is updated. For each term, it is added to the corresponding inverted list within the inverted index.

[0073] Knowledge Graph: The collected Zhuang language corpus is cleaned, including removing duplicates, correcting spelling errors, and standardizing text formatting to ensure the quality and consistency of the corpus. The corpus is labeled, including part-of-speech tagging, entity recognition, and syntactic analysis. Entities (such as people, places, and organizations) and the relationships between them are stored in the form of a graph. Entities, attributes, and relationships are extracted from the corpus and organized into a knowledge graph.

[0074] S3. Construct a generative model, train it using a pre-trained dataset, fine-tune it, and then use a reinforcement learning algorithm to approach policy optimization to obtain a Zhuang language dialogue model;

[0075] Specifically, choose an appropriate Transformer model architecture, such as BERT, GPT, or T5. Select the model type and size based on task requirements and data characteristics. Pre-train the selected Transformer model using a pre-training dataset. Self-supervised learning tasks can be used, such as Masked Language Model (MLM) or NextSentence Prediction (NSP).

[0076] Questions are extracted from a dialogue database, and expected responses are manually entered to construct a high-quality Zhuang language dialogue training set (prompt, response). Using the questions and expected responses, a supervised fine-tuning of the generative model is performed, with the cross-entropy criterion used as the training loss function. This ensures that the model outputs as little harmful or useless content as possible.

[0077] S4. Obtain the Zhuang language dialogue text and determine whether relevant knowledge needs to be introduced to meet user needs: If relevant knowledge needs to be introduced, search through the document database and knowledge graph, and input the search results, the first prompt template, historical dialogue records, and the current Zhuang language dialogue text into the Zhuang language dialogue model to obtain candidate response texts; if relevant knowledge does not need to be introduced, input the second prompt template, historical dialogue records, and the current Zhuang language dialogue text into the Zhuang language dialogue model to obtain candidate response texts; at the same time, after obtaining the Zhuang language dialogue text, input it into the dialogue database for retrieval to obtain candidate response texts.

[0078] The Zhuang language dialogue text input by the user is processed, including word segmentation, part-of-speech tagging, and named entity recognition. Entity recognition identifies entities in the user's input, such as names of people, places, times, and products. Based on these entities, k entities are selected to construct corresponding query statements. The constructed query statements are then sent to a document database and a knowledge graph to retrieve relevant knowledge.

[0079] When searching an existing dialogue database, for each query term, the corresponding dialogue list is looked up in the inverted index to retrieve dialogues containing that term. All inverted lists of query terms are merged and sorted as needed. The first n Zhuang language dialogue texts are selected as candidate responses.

[0080] S5. The evaluation model scores and ranks the candidate response texts, and outputs the candidate response text with the highest score. If the candidate response text with the highest score is generated by the Zhuang language dialogue model, then the dialogue data for this session is entered into the dialogue database.

[0081] This invention addresses potential semantic biases or uncertainties in generative methods by retrieving relevant information from a pre-built dialogue database and providing accurate answers. This includes queries for information on Zhuang language vocabulary, cultural background, history, geography, etc. Since the dialogue database is based on existing data and can be updated independently, it can provide timely updates without requiring retraining the entire model. To accommodate the diversity of user input, the Zhuang language dialogue model generates context-aware responses, better understanding user needs and intentions. The generated responses are typically more natural and fluent, mimicking human language expression.

[0082] Example 2:

[0083] This embodiment provides a Zhuang language dialogue system that combines retrieval and generation, including:

[0084] The collection module is used to acquire Zhuang language corpus;

[0085] The database acquisition module obtains a pre-training dataset, a dialogue database, a document database, and a knowledge graph based on the Zhuang language corpus.

[0086] The model acquisition module constructs a generative model, trains it using a pre-trained dataset, fine-tunes it, and then uses a reinforcement learning algorithm to approach policy optimization, thus obtaining a Zhuang language dialogue model.

[0087] The candidate response text acquisition module retrieves the Zhuang language dialogue text and determines whether relevant knowledge needs to be introduced to meet user requirements. If relevant knowledge needs to be introduced, it searches through the document database and knowledge graph, and inputs the search results, along with the first prompt template, historical dialogue records, and the current Zhuang language dialogue text, into the Zhuang language dialogue model to obtain candidate response texts. If relevant knowledge does not need to be introduced, it inputs the second prompt template, historical dialogue records, and the current Zhuang language dialogue text into the Zhuang language dialogue model to obtain candidate response texts. Simultaneously, after acquiring the Zhuang language dialogue text, it is input into the dialogue database for retrieval to obtain candidate response texts.

[0088] The evaluation module uses an evaluation model to score and rank candidate response texts, and outputs the candidate response text with the highest score.

[0089] Example 3:

[0090] An electronic device includes a memory, a processor, and a computer program stored in the memory and running thereon. When the processor executes the program, it implements the aforementioned Zhuang language dialogue method combining retrieval and generation, comprising:

[0091] Obtain Zhuang language corpus;

[0092] Based on the Zhuang language corpus, a pre-training dataset, a dialogue database, a document database, and a knowledge graph were obtained;

[0093] A generative model is constructed, trained and fine-tuned using a pre-trained dataset, and then approached policy optimization through a reinforcement learning algorithm to obtain a Zhuang language dialogue model.

[0094] The Zhuang language dialogue text is retrieved, and it is determined whether relevant knowledge needs to be introduced to meet user needs. If relevant knowledge needs to be introduced, it is searched through the document database and knowledge graph. The search results, along with the first prompt template, historical dialogue records, and the current Zhuang language dialogue text, are input into the Zhuang language dialogue model to obtain candidate response texts. If relevant knowledge does not need to be introduced, the second prompt template, historical dialogue records, and the current Zhuang language dialogue text are input into the Zhuang language dialogue model to obtain candidate response texts. At the same time, after retrieving the Zhuang language dialogue text, it is input into the dialogue database for retrieval to obtain candidate response texts.

[0095] The evaluation model scores and ranks the candidate response texts, and outputs the candidate response text with the highest score. If the candidate response text with the highest score is generated by the Zhuang language dialogue model, then the dialogue data for this session is entered into the dialogue database.

[0096] Example 4:

[0097] A computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the aforementioned Zhuang language dialogue method combining retrieval and generation, comprising:

[0098] Obtain Zhuang language corpus;

[0099] Based on the Zhuang language corpus, a pre-training dataset, a dialogue database, a document database, and a knowledge graph were obtained;

[0100] A generative model is constructed, trained and fine-tuned using a pre-trained dataset, and then approached policy optimization through a reinforcement learning algorithm to obtain a Zhuang language dialogue model.

[0101] The Zhuang language dialogue text is retrieved, and it is determined whether relevant knowledge needs to be introduced to meet user needs. If relevant knowledge needs to be introduced, it is searched through the document database and knowledge graph. The search results, along with the first prompt template, historical dialogue records, and the current Zhuang language dialogue text, are input into the Zhuang language dialogue model to obtain candidate response texts. If relevant knowledge does not need to be introduced, the second prompt template, historical dialogue records, and the current Zhuang language dialogue text are input into the Zhuang language dialogue model to obtain candidate response texts. At the same time, after retrieving the Zhuang language dialogue text, it is input into the dialogue database for retrieval to obtain candidate response texts.

[0102] The evaluation model scores and ranks the candidate response texts, and outputs the candidate response text with the highest score. If the candidate response text with the highest score is generated by the Zhuang language dialogue model, then the dialogue data for this session is entered into the dialogue database.

[0103] Those skilled in the art will understand that the modules or steps described above can be implemented using general-purpose computer devices. Optionally, they can be implemented using computer-executable program code, which can then be stored in a storage device for execution by a computer device. Alternatively, they can be fabricated as separate integrated circuit modules, or multiple modules or steps can be fabricated as a single integrated circuit module. This disclosure is not limited to any particular combination of hardware and software.

[0104] The above description is merely a preferred embodiment of this application and is not intended to limit this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.

[0105] While the specific embodiments of this disclosure have been described above in conjunction with the accompanying drawings, this is not intended to limit the scope of protection of this disclosure. Those skilled in the art should understand that various modifications or variations that can be made by those skilled in the art without creative effort based on the technical solutions of this disclosure are still within the scope of protection of this disclosure.

Claims

1. A Zhuang language dialogue method combining retrieval and generation, characterized in that, Includes the following steps: Obtain Zhuang language corpus; Based on the Zhuang language corpus, a pre-training dataset, a dialogue database, a document database, and a knowledge graph were obtained; A generative model is constructed, trained and fine-tuned using a pre-trained dataset, and then approached policy optimization through a reinforcement learning algorithm to obtain a Zhuang language dialogue model. Obtain Zhuang language dialogue text and determine whether relevant knowledge needs to be introduced to meet user needs: if relevant knowledge needs to be introduced, search through document database and knowledge graph, input the search results, first prompt template, historical dialogue records, and current Zhuang language dialogue text into Zhuang language dialogue model to obtain candidate response text; If no relevant knowledge needs to be introduced, the second prompt template, historical dialogue records, and current Zhuang dialogue text are input into the Zhuang dialogue model to obtain candidate response texts; at the same time, after obtaining the Zhuang dialogue text, it is input into the dialogue database for retrieval to obtain candidate response texts. The evaluation model scores and ranks the candidate response texts, and outputs the candidate response text with the highest score. If the candidate response text with the highest score is generated by the Zhuang language dialogue model, then the dialogue data for this time is entered into the dialogue database. The generative model is constructed as follows: A Transformer model is obtained, pre-trained using a pre-training dataset, and a self-supervised learning task is employed; the given text sequence is then optimized. Maximum likelihood estimation function : In the formula, Indicates the size of the model window, based on A historical term Predict the word at the current moment ; The parameters of the Transformer model are represented by the maximum likelihood estimation function, which is optimized using stochastic gradient descent. Questions are extracted from the dialogue database, expected responses are manually entered, a high-quality Zhuang language dialogue training set is constructed, and the pre-trained Transformer model is fine-tuned in a supervised manner using questions and expected responses. The loss function in the fine-tuning process adopts the cross-entropy criterion. The first objective function of the reinforcement learning algorithm for approaching the Proximal Policy Optimization is: Let the input Zhuang language dialogue text be... , The question is whether the output of the fine-tuned generative model is equal to the probability of y. It checks whether the output of the reinforcement learning model equals the probability of y; for each evaluation model, the input text is... Then, a reinforcement learning model is used to obtain the output of the input text, denoted as . , KL divergence is introduced to prevent the fine-tuned generative model from deviating too much from the reinforcement learning model. Scaling parameters to constrain KL divergence; The parameters of the reinforcement learning model are used; after multiple rounds of reinforcement learning, a Zhuang language dialogue model is obtained. Let the input text of the fine-tuned generative model be... The second objective function is the reinforcement learning model's response to the input text. The output of the lower-order model is better than the output of the fine-tuned generative model, specifically: in, It is adjusted according to the environment, starting from 0.99; Therefore, the objective function of the Zhuang language dialogue model is: in, It is the distribution of the input text used to evaluate the model. It represents the distribution of the pre-training dataset for the fine-tuned generative model; E represents the expected value. express obey distributed, express obey distributed.

2. The Zhuang language dialogue method combining retrieval and generation according to claim 1, characterized in that, The method for processing Zhuang language corpus to obtain pre-training dataset is as follows: Language filtering removes non-Zhuang language text; Statistical filtering removes Zhuang language text that is statistically abnormal; Keyword filtering excludes Zhuang language text containing certain keywords; Classifier filtering: Use a machine learning classifier to filter out high-quality Zhuang language text; Sensitive content filtering filters out Zhuang language text containing toxic or private content; Data deduplication is performed at different levels: at the sentence level, duplicate sentences in Zhuang text are removed; at the document level, duplicate documents are removed to ensure that there are no completely identical Zhuang documents. At the dataset level, duplicate Zhuang language data is removed to avoid repeatedly integrating the same Zhuang language data when integrating data from different sources. Lexicalization involves breaking down Zhuang language texts into lexical units.

3. The Zhuang language dialogue method combining retrieval and generation according to claim 1, characterized in that, A dialogue database was obtained from the Zhuang language corpus, including: the participants in the dialogue, the rounds of the dialogue, and the text content of each round.

4. The Zhuang language dialogue method combining retrieval and generation according to claim 1, characterized in that, The method for processing Zhuang language corpora to obtain a document database is as follows: The Zhuang language corpus is processed, including word segmentation, stop word removal, and stemming, to convert the Zhuang language corpus into a set of terms; an empty inverted index data structure is created, which is represented by a hash table or tree structure; each term is assigned a corresponding inverted list to store a list of documents containing that term; For each document, iterate through the terms and update the inverted index; for each term, add it to the inverted list corresponding to the inverted index.

5. The Zhuang language dialogue method combining retrieval and generation according to claim 1, characterized in that, The method for processing Zhuang language corpus to obtain knowledge graphs is as follows: The Zhuang language corpus is cleaned by removing duplicates, correcting spelling errors, and standardizing text format; the cleaned Zhuang language corpus is annotated, including part-of-speech tagging, entity recognition, and syntactic analysis; entities and the relationships between them are stored in the form of a graph. Extract entities, attributes, and relationships, and organize them into a knowledge graph.

6. The Zhuang language dialogue method combining retrieval and generation according to claim 1, characterized in that, The candidate response files output by the generative model are manually labeled to obtain the evaluation dataset. The evaluation model is then trained with the goal of finding the parameter set of the evaluation model. This minimizes the overall loss on the evaluation dataset: This indicates the input Zhuang language dialogue text. It is a relatively high-quality generative model output. It is the output of a generative model of relatively poor quality. It is the score given by the evaluation model to the relatively high-quality output. It is the score given by the evaluation model for outputs with relatively poor quality; This is the Sigmoid function.

7. The Zhuang language dialogue method combining retrieval and generation according to claim 1, characterized in that, When Zhuang language dialogue text is input into the dialogue database for retrieval, it needs to be combined with the document database: for each query term, the corresponding dialogue list is searched in the inverted index to obtain the dialogues containing the term; the inverted lists of all query terms are merged and then sorted, and the top n dialogue texts are used as candidate response texts.

8. A Zhuang language dialogue system combining retrieval and generation, used to implement the method described in any one of claims 1-7, characterized in that, include: The collection module is used to acquire Zhuang language corpus; The database acquisition module obtains a pre-training dataset, a dialogue database, a document database, and a knowledge graph based on the Zhuang language corpus. The model acquisition module constructs a generative model, trains it using a pre-trained dataset, fine-tunes it, and then uses a reinforcement learning algorithm to approach policy optimization, thus obtaining a Zhuang language dialogue model. The candidate response text acquisition module acquires Zhuang language dialogue text and determines whether relevant knowledge needs to be introduced to meet user needs. If relevant knowledge needs to be introduced, it searches through the document database and knowledge graph, and inputs the search results, the first prompt template, historical dialogue records, and the current Zhuang language dialogue text into the Zhuang language dialogue model to obtain candidate response text. If no relevant knowledge needs to be introduced, the second prompt template, historical dialogue records, and current Zhuang dialogue text are input into the Zhuang dialogue model to obtain candidate response texts; at the same time, after obtaining the Zhuang dialogue text, it is input into the dialogue database for retrieval to obtain candidate response texts. The evaluation module scores and sorts the candidate response texts, and outputs the candidate response text with the highest score.