Small language model paraphrase generation method and device oriented to government affair information

Through small open source language models and LoRA fine-tuning training technology, the resource consumption and security issues of large language models in government information processing are solved, efficient government information interpretation generation is achieved in the local environment, and data privacy and security are ensured.

CN118798213APending Publication Date: 2024-10-18SHANDONG INSPUR SCI RES INST CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202410858375.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-28
Publication Date
2024-10-18

AI Technical Summary

Technical Problem

When processing government information, existing large-scale language models are difficult to efficiently process government information in a local environment due to their large parameter scale, consumption of computing resources, and poor deployment flexibility. They also face data privacy and security risks.

Method used

Using a small open source language pre-training model combined with the LoRA fine-tuning training method to optimize model performance, and through data set creation, paraphrase sentence generation, post-processing optimization, evaluation and deployment processes, paraphrase texts with correct grammar and diversified syntax are generated to reduce computing costs. , improve response speed, and deploy in a local environment to ensure data security.

Benefits of technology

It realizes the ability to efficiently process government information in resource-constrained environments, generates accurate and diverse interpretation texts, reduces operating costs, accelerates response speed, and ensures the privacy and security of government data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118798213A_ABST
    Figure CN118798213A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of artificial intelligence and text generation, and discloses a small language model paraphrase generation method and device oriented to government affair information. Comprising the steps of data set creation, paraphrasing sentence generation, model selection and training, post-processing optimization, evaluation and model deployment. According to the method, a government affair information paraphrase data set is constructed through multi-source data, paraphrases are generated and audited through a large model, and a small pre-training model is selected for optimization training. By adopting the method, the cost can be effectively reduced, the response speed can be improved, and the privacy security can be ensured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the fields of artificial intelligence technology and text generation technology, and for example, to a method and device for generating interpretations of a small language model for government information. Background Art

[0002] As an advanced natural language processing method, the core of interpretation generation technology lies in the ability of the machine to automatically generate new sentences that are semantically consistent with the input sentences but have different expressions. This technology is widely used in many fields, such as automatically generating news summaries, enriching the interpretation methods of legal documents to enhance understanding, and accurately capturing user query intentions in information retrieval. With the vigorous development of the e-government system, the demand for efficient processing of massive government data has become more urgent. Interpretation generation technology has emerged, providing strong support for government information retrieval, automatic analysis, policy document adaptation, and announcement content optimization, significantly improving processing efficiency and quality. At the same time, the interpretation function that supports multiple languages ​​promotes cross-language communication and further improves the internationalization level and intelligent process of government services.

[0003] However, although large language models have mastered rich language knowledge and rules with massive text data, their huge parameter scale (tens of billions) not only consumes huge computing resources, but also limits their deployment flexibility in local environments. What is particularly critical is that government information involves highly sensitive data privacy and security issues. If it relies on large cloud-based models for processing, it faces the potential risk of data leakage.

[0004] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present application, and therefore may include information that does not constitute the prior art known to ordinary technicians in the field. Summary of the invention

[0005] In order to provide a basic understanding of some aspects of the disclosed embodiments, a brief summary is given below. The summary is not an extensive review, nor is it intended to identify key / critical components or delineate the scope of protection of these embodiments, but rather serves as a prelude to the detailed description that follows.

[0006] The disclosed embodiments provide a method and device for generating interpretations of a small language model for government information, so as to efficiently process and understand government information in a resource-constrained environment, generate grammatically correct, syntactically and lexically diverse interpretation words and sentences, reduce computing costs and improve response speed.

[0007] In some embodiments, the method includes: S1, data set creation: using multiple data sources to obtain the interpretation word sentence pairs and officially published government-related information in the semantic data set, processing and producing government information sentence data in sentences, and arranging to obtain a complete government information interpretation data set;

[0008] S2. Generation of paraphrase sentences: Use appropriate instructions to call the API of the large language model service, input the government information sentence data obtained in step S1, generate syntactically diverse paraphrase sentences, and use the content review API to mark and filter inappropriate content to form government information paraphrase sentence pairs;

[0009] S3, Model selection and training: Select a small open source language pre-training model and use the LoRA fine-tuning training method to optimize model performance;

[0010] S4, post-processing optimization: When inferring the model trained in step S3, set post-processing hyperparameters to optimize model performance;

[0011] S5. Evaluation: The model's interpretation performance on sentences in the government information test set is evaluated quantitatively and qualitatively. The quantitative evaluation includes semantic similarity, syntactic diversity, and lexical diversity. The qualitative evaluation is performed using the Large Language Model service.

[0012] S6. Model deployment: Deploy the evaluated interpretation model to the local environment.

[0013] Optionally, in step S1, the processing of government information sentence data includes text merging, sentence segmentation, and removal of redundant information.

[0014] Optionally, in step S2, manual review is added; the manual review includes evaluating the accuracy and appropriateness of the paraphrase sentence, and regenerating the paraphrase sentence or retaining the original paraphrase sentence based on the review results.

[0015] Optionally, in step S3, select a small open source language pre-trained model with a parameter size of about 3 billion or less, and add rewritten keywords as input during training; use the LoRA fine-tuning training method, retain the weights of the pre-trained model, introduce a trainable low-rank decomposition matrix in each layer of the Transformer structure, and adjust the learning rate, dropout, rank and alpha parameters for training.

[0016] Optionally, during training, only parameters in the low-rank matrix are optimized.

[0017] Optionally, in step S4, the post-processing hyperparameter settings include setting the maximum number of new tokens generated, enabling early stopping indication, limiting n-gram repeated token configuration, setting temperature, and top-k and top-p parameters.

[0018] Optionally, in step S5, semantic similarity in the quantitative evaluation is measured by a word embedding model and a cosine similarity method, syntactic diversity is calculated by a syntax tree edit distance, and lexical diversity is calculated by a character diversity evaluation tool.

[0019] Optionally, in step S6, model deployment includes creating a service interface that accepts input text and returns paraphrased sentences generated by the model.

[0020] In some embodiments, the device includes a processor and a memory storing program instructions, and the processor is configured to execute the aforementioned method for generating interpretations of a small language model for government information when running the program instructions.

[0021] In some embodiments, the storage medium stores program instructions, and when the program instructions are run, they execute the aforementioned method for generating interpretations of the small language model for government information.

[0022] The method and device for generating interpretations of a small language model for government information provided by the embodiments of the present disclosure can achieve the following technical effects:

[0023] This paper uses a small language model to generate interpretations of government information, and cleverly uses knowledge distillation technology to "compress" the excellent performance of large models into small models, achieving dual guarantees of accuracy and efficiency. This small model is not only easy to integrate into existing government systems, but also can operate efficiently in a resource-limited environment, generating interpretation texts with rigorous grammar, rich and varied syntax and vocabulary, effectively reducing operating costs and accelerating response speed. More importantly, it firmly protects the privacy and security of government data, laying a solid foundation for the intelligent transformation of e-government.

[0024] The above general description and the following description are exemplary and explanatory only and are not intended to limit the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] One or more embodiments are exemplarily described by corresponding drawings, which do not limit the embodiments. Elements with the same reference numerals in the drawings are shown as similar elements, and the drawings do not constitute a scale limitation, and wherein:

[0026] Figure 1 It is a schematic diagram of a method for generating interpretation of a small language model for government affairs information provided by an embodiment of the present disclosure;

[0027] Figure 2 It is a schematic diagram of a device for generating interpretation of a small language model for government affairs information provided by an embodiment of the present disclosure. DETAILED DESCRIPTION

[0028] In order to be able to understand the features and technical contents of the embodiments of the present disclosure in more detail, the implementation of the embodiments of the present disclosure is described in detail below in conjunction with the accompanying drawings. The attached drawings are for reference only and are not used to limit the embodiments of the present disclosure. In the following technical description, for the convenience of explanation, a full understanding of the disclosed embodiments is provided through multiple details. However, one or more embodiments can still be implemented without these details. In other cases, to simplify the drawings, well-known structures and devices can be simplified for display.

[0029] The terms "first", "second", etc. in the embodiments of the present disclosure are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the terms used in this way can be interchanged where appropriate, so as to describe the embodiments of the present disclosure described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions.

[0030] Unless otherwise stated, the term "plurality" means two or more.

[0031] In the embodiment of the present disclosure, the character " / " indicates that the preceding and following objects are in an "or" relationship. For example, A / B indicates: A or B.

[0032] The term "and / or" is a description of the association relationship between objects, indicating that three relationships can exist. For example, A and / or B means: A or B, or, A and B.

[0033] The term "correspondence" may refer to an association relationship or a binding relationship. The correspondence between A and B means that there is an association relationship or a binding relationship between A and B.

[0034] The object of the present invention is to provide a method for generating interpretations of a small language model for government information, comprising the following steps:

[0035] S1: Dataset creation. By integrating multiple data sources such as the existing Chinese text retelling corpus and text matching dataset, and obtaining government-related information from local government websites, the data is processed and divided into sentences to produce sentence data, thus forming a complete dataset.

[0036] S2: Generation of paraphrase sentences. Use appropriate instructions to call the advanced large language model service to generate syntactically diverse paraphrase sentences for the government information sentence data obtained in step S1, and use the content review API to mark and filter inappropriate content to obtain paraphrase sentence pairs for government information.

[0037] S3: Model selection and training. A small open source language pre-trained model is selected and trained using the LoRA fine-tuning training method. During the training process, rewriting keywords such as "restate" and "rewrite" are added as input, and parameters such as learning rate, dropout, rank, and alpha are adjusted to obtain the best performance.

[0038] S4: Post-processing optimization. Set post-processing hyperparameters during model inference, including the maximum number of new tokens, early stopping flags, n-gram repeated token configuration, temperature, and top-k / top-p parameters, to optimize model performance.

[0039] S5: Evaluation. The model’s interpretation performance on the government information test set is evaluated through quantitative and qualitative evaluation methods to ensure the accuracy and diversity of the model.

[0040] S6: Model deployment. The evaluated interpretation model is deployed in the government system for tasks such as information retrieval, automatic parsing, policy document rewriting, and announcement content optimization of government information.

[0041] As an example, in step S1, in order to create a complete data set, multiple data sources are used. These data mainly include two parts. One part is the sentence pairs marked as paraphrases directly downloaded from existing Chinese text retelling corpus PKU, text semantic matching dataset GAIIC2021_Taske3, THS2021, AFQMC, SOHU_2021, multilingual interpretation recognition dataset PAWSX and other datasets, and sorted together. The other part is to obtain government-related information such as online questions and answers, policy documents, and announcement contents from local government websites. After merging the text, it is divided into sentences according to commas and periods to produce sentence data in units of sentences that include both long and short sentences (single sentence length does not exceed 256).

[0042] In step S2, use appropriate instructions to call the API of the current advanced large language model service. In this test case, considering the price factor, the model service used is OPENAI's gpt-3.5-turbo service. Input S1 to obtain each sentence data related to government information and generate a syntactically diverse interpretation sentence, and call OPENAI's content review API to mark inappropriate content. Then filter out the marked inappropriate content and organize the interpretation sentence pairs of government information into the data set. In order to improve the accuracy of the interpretation sentence, manual review can also be performed to evaluate the accuracy of the interpretation, and the sentences that are not satisfactory in the generated results can be discarded and regenerated.

[0043] In step S3, select a small open source language pre-training model with a parameter count of about 3 billion or less and perform LoRA fine-tuning training. The model selected in this test case is the 1.8B model of Qwen1.5. During training, add rewriting keywords such as "restate" and "rewrite" to the sentence prefix as input. When using the LoRA training method, retain the weights of the pre-trained model and introduce a trainable low-rank decomposition matrix in each layer of the Transformer structure. Then adjust the learning rate, dropout, rank, and alpha parameters during training to obtain the best performance. Perform training on a single NVIDIA A100 card. During training, only the parameters in the low-rank matrix are optimized while other parameters remain unchanged.

[0044] In step S4, when the model trained in step S3 is inferred, post-processing hyperparameters are set to optimize model performance, including setting the maximum number of new tokens (text) generated (such as 256), enabling early stopping to prevent unnecessary token generation, limiting n-gram repeated token configuration (such as 2) to prevent the model from generating repeated phrases, setting temperature (such as 0.7) to control the randomness of the output, and setting top-k and top-p parameters to 50000 and 0.75 respectively to control the randomness of sampling during generation.

[0045] In step S5, the model's paraphrase performance on the sentences of the government information test set using the post-processing optimization strategy of step S4 is evaluated quantitatively and qualitatively. In the quantitative evaluation, the high quality and diversity of the paraphrase words are evaluated from the three main features of semantic similarity, syntactic diversity, and lexical diversity. In the qualitative evaluation, the performance of the paraphrase sentences generated by the model is evaluated by sending an instruction to the advanced large language model service to provide a Likert 5-point scale after the four indicators of semantic similarity, lexical diversity, syntactic diversity, and grammatical correctness of the input sentence pairs.

[0046] Among them, semantic similarity is achieved by using the word embedding model bge-m3 to generate word embeddings for the original text and its paraphrased form of sentences, and then using the cosine similarity method to measure the similarity between these embeddings. Syntactic diversity is achieved by using the open source tool Stanza to build component syntax trees for the original and paraphrased sentences, using the NLTK library and regular expressions to convert the trees into bracket notation, and then using the APTED library to calculate the entire tree edit distance. Lexical diversity is achieved by evaluating the diversity of characters through the open source library SacreBLEU.

[0047] In step S6, the interpretation model evaluated in step S6 is deployed using a reasoning framework such as the vllm library, and a service interface is created to accept input text and return the output of the model.

[0048] Combination Figure 2As shown, the embodiment of the present disclosure provides a device 200 for generating interpretations of a small language model for government information, including a processor 204 and a memory 201. Optionally, the device may also include a communication interface 202 and a bus 203. The processor 204, the communication interface 202, and the memory 201 may communicate with each other through the bus 203. The communication interface 202 may be used for information transmission. The processor 204 may call the logic instructions in the memory 201 to execute the method for generating interpretations of a small language model for government information of the above embodiment.

[0049] In addition, the logic instructions in the memory 201 described above may be implemented in the form of software functional units and when sold or used as independent products, may be stored in a computer-readable storage medium.

[0050] The memory 201 is a computer-readable storage medium that can be used to store software programs and computer executable programs, such as program instructions / modules corresponding to the methods in the embodiments of the present disclosure. The processor 204 executes the function application and data processing by running the program instructions / modules stored in the memory 201, that is, implementing the method for ... in the above embodiments.

[0051] The memory 201 may include a program storage area and a data storage area, wherein the program storage area may store an operating system and an application required for at least one function; the data storage area may store data created according to the use of the terminal device, etc. In addition, the memory 201 may include a high-speed random access memory and may also include a non-volatile memory.

[0052] The embodiment of the present disclosure provides a computer-readable storage medium storing computer-executable instructions, wherein the computer-executable instructions are configured to execute the above-mentioned method for generating interpretations of a small language model for government information.

[0053] The computer-readable storage medium mentioned above may be a transient computer-readable storage medium or a non-transitory computer-readable storage medium.

[0054] The technical solution of the embodiment of the present disclosure can be embodied in the form of a software product, which is stored in a storage medium and includes one or more instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method described in the embodiment of the present disclosure. The aforementioned storage medium may be a non-transient storage medium, including: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk, and other media that can store program codes, or a transient storage medium.

[0055] The above description and accompanying drawings fully illustrate the embodiments of the present disclosure so that those skilled in the art can practice them. Other embodiments may include structural, logical, electrical, process and other changes. The embodiments represent possible changes only. Unless explicitly required, separate components and functions are optional, and the order of operation may vary. The parts and features of some embodiments may be included in or replace the parts and features of other embodiments. Moreover, the words used in this application are only used to describe the embodiments and are not used to limit the scope of protection. As used in the description in the text, unless the context clearly indicates, the singular forms of "a", "an" and "the" are intended to include plural forms as well. Similarly, the term "and / or" as used in this application refers to any and all possible combinations of listings containing one or more associated ones. In addition, when used in the present application, the term "comprise" and its variants "comprises" and / or comprising refer to the presence of stated features, wholes, steps, operations, elements, and / or components, but do not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or groups thereof. In the absence of further restrictions, the elements defined by the sentence "comprising a ..." do not exclude the presence of other identical elements in the process, method or device comprising the elements. In this article, each embodiment may focus on the differences from other embodiments, and the same and similar parts between the embodiments may refer to each other. For the methods, products, etc. disclosed in the embodiments, if they correspond to the method part disclosed in the embodiments, then the relevant parts can refer to the description of the method part.

[0056] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software may depend on the specific application and design constraints of the technical solution. The technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the embodiments of the present disclosure. The technicians may clearly understand that for the convenience and simplicity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here.

[0057] In the embodiments disclosed herein, the disclosed methods and products (including but not limited to devices, equipment, etc.) can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units can be only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between each other shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms. The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the units may be selected according to actual needs to implement this embodiment. In addition, each functional unit in the embodiment of the present disclosure may be integrated in a processing unit, or each unit may exist physically alone, or two or more units may be integrated in one unit.

[0058] The flowchart and block diagram in the accompanying drawings show the possible architecture, function and operation of the system, method and computer program product according to the embodiment of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of the code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. In some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, which can depend on the functions involved. In the description corresponding to the flowchart and the block diagram in the accompanying drawings, the operations or steps corresponding to different boxes can also occur in a different order from the order disclosed in the description, and sometimes there is no specific order between different operations or steps. For example, two consecutive operations or steps can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, which can depend on the functions involved. Each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, may be implemented by a dedicated hardware-based system that performs the specified functions or actions, or may be implemented by a combination of dedicated hardware and computer instructions.

Claims

1. A method for generating interpretations of a small language model for government information, characterized in that: include: S1. Dataset creation: Use multiple data sources to obtain the sentence pairs of interpretation words in the semantic dataset and the official government-related information, process and produce sentence-based government information sentence data, and organize them to obtain a complete government information interpretation dataset; S2. Paraphrase generation: Call the API of the large language model service, input the government information sentence data obtained in step S1, generate syntactically diverse paraphrase sentences, and mark and filter inappropriate content through the content review API to form government information paraphrase sentence pairs; S3, Model selection and training: Select a small open source language pre-training model and use the LoRA fine-tuning training method to optimize model performance; S4, post-processing optimization: When inferring the model trained in step S3, set post-processing hyperparameters to optimize model performance; S5. Evaluation: The model's interpretation performance on sentences in the government information test set is evaluated quantitatively and qualitatively. The quantitative evaluation includes semantic similarity, syntactic diversity, and lexical diversity. The qualitative evaluation is performed using the Large Language Model service. S6. Model deployment: Deploy the evaluated interpretation model to the local environment.

2. The method according to claim 1, characterized in that In step S1, the processing of government information sentence data includes text merging, sentence segmentation, and removal of redundant information.

3. The method according to claim 1, characterized in that In step S2, manual review is added; Manual review includes evaluating the accuracy and appropriateness of the paraphrase sentences, and regenerating the paraphrase sentences or retaining the original paraphrase sentences based on the review results.

4. The method according to claim 1, characterized in that: In the S3 step, Choose a small open source language pre-training model with 3 billion parameters or less, and add rewritten keywords as input during training; The LoRA fine-tuning training method is adopted to retain the weights of the pre-trained model, introduce a trainable low-rank decomposition matrix in each layer of the Transformer structure, and adjust the learning rate, dropout, rank and alpha parameters for training.

5. The method according to claim 4, characterized in that During training, only the parameters in the low-rank matrix are optimized.

6. The method according to claim 1, characterized in that In step S4, the post-processing hyperparameters are set including setting the maximum number of new tokens generated, enabling early stopping, limiting n-gram repeated token configuration, setting temperature, and top-k and top-p parameters.

7. The method according to claim 1, characterized in that In step S5, the semantic similarity in the quantitative evaluation is measured by the word embedding model and the cosine similarity method, the syntactic diversity is calculated by the syntax tree edit distance, and the lexical diversity is calculated by the character diversity evaluation tool.

8. The method according to claim 1, characterized in that In step S6, model deployment involves creating a service interface that accepts input text and returns paraphrased sentences generated by the model.

9. A device for generating interpretations of a small language model for government information, comprising a processor and a memory storing program instructions, characterized in that: The processor is configured to execute the method for generating interpretation of a small language model for government information as described in any one of claims 1 to 8 when running the program instructions.

10. A storage medium storing program instructions, characterized in that: When the program instructions are run, they execute the method for generating interpretations of a small language model for government information as described in any one of claims 1 to 8.

Citation Information

Cited By

  • Multi-point robot navigation system of fine-tuning adaptive small language model

    CN118862954A

  • A multi-point robot navigation system with fine-tuned adaptive small language model

    CN118862954B