Ancient Chinese text processing method, device and storage medium based on language model

By processing multiple different types of tasks in a single language model architecture, the problem that the language model in the existing technology can only perform a single task is solved, and the technical effect of making it easier for readers to read ancient Chinese texts is achieved.

CN118095266BActive Publication Date: 2024-08-27BEIJING NORMAL UNIVERSITY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410295431.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-03-15
Publication Date
2024-08-27
Estimated Expiration
2044-03-15

AI Technical Summary

Technical Problem

Existing language models can only perform one type of task and cannot handle multiple different types of tasks at the same time. As a result, readers need to use multiple different models when reading ancient Chinese texts, which is very inconvenient.

Method used

An ancient Chinese text processing method based on a language model is used to determine the ancient Chinese text to be processed and the corresponding instruction text, and input them into a single model architecture with multiple different types of task processing capabilities, and output the corresponding processing result.

Benefits of technology

It realizes the ability to handle multiple different types of tasks under a single model architecture, simplifies the process of readers using the model and reading ancient Chinese texts, and improves processing efficiency and accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118095266B
    Figure CN118095266B
Patent Text Reader

Abstract

The present application discloses a method, device and storage medium for processing ancient Chinese text based on a language model. The method comprises: determining a first ancient Chinese text to be processed and a first instruction text corresponding to the first ancient Chinese text, wherein the first instruction text is used to indicate any one of a plurality of different types of tasks; inputting the first ancient Chinese text and the first instruction text into a first language model, wherein the first language model has a single model architecture capable of processing a plurality of different types of tasks; and using the first language model, outputting a first processing result corresponding to the first ancient Chinese text and the first instruction text.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of language information processing, and in particular to an ancient Chinese text processing method, device and storage medium based on a language model. Background Art

[0002] Chinese traditional culture is one of the most important objects of cultural inheritance and innovation. As the carrier of Chinese traditional culture, ancient Chinese is of vital importance to the development of ancient culture.

[0003] However, since ancient Chinese is usually connected word by word, there are few breaks in the middle. And because there are great differences between ancient Chinese and modern languages, it is still difficult for readers to understand even after adding punctuation marks and / or adding annotations manually. Therefore, readers currently have the following problems when reading ancient Chinese texts: 1. Since most of the ancient books are still in an unsorted state, the ancient Chinese texts in these ancient books often have the problem of missing punctuation marks; 2. For most of the existing ancient books, there are no interpretations of the words in the ancient Chinese texts, so it is difficult to understand the specific meaning of some ancient Chinese words in the ancient books; 3. Since most of the existing ancient books do not have modern language translations for the full text of ancient Chinese, it is very difficult for people who do not have the foundation of ancient Chinese text reading to read ancient Chinese texts; 4. Since most of the existing ancient books do not have the source of allusions, people often cannot understand the profound meaning of ancient Chinese texts when reading ancient books.

[0004] Although readers can use existing language models to solve the above problems, on the one hand, there are only language models for adding punctuation marks and language models for translating ancient Chinese texts, and there are no language models for interpreting words and marking the source of allusions. On the other hand, different language models can only solve one of the above problems (that is, they can only handle one type of task) and do not have the ability to solve multiple different types of problems (that is, they cannot handle multiple different types of tasks). Therefore, if readers want to solve the multiple different types of problems listed above, they can only use multiple different language models to solve the corresponding problems respectively. For example, one language model can only interpret the words in the ancient Chinese text, and cannot mark the source of allusions. Another language model can only mark the source of allusions, and cannot interpret the words in the ancient Chinese text. Therefore, if readers want to understand the interpretation of words in the ancient Chinese text and want to determine the source of allusions in the ancient Chinese text, they can only use two different language models to solve the above problems respectively. Therefore, this is very inconvenient for readers to read ancient Chinese texts.

[0005] The existing language models in the above-mentioned prior art can only perform one type of task and cannot perform multiple different types of tasks. Therefore, for ancient Chinese texts, if readers need to solve multiple different types of problems, multiple different language models are required. This is a very inconvenient technical problem for readers, and no effective solution has been proposed yet. Summary of the invention

[0006] The embodiments of the present disclosure provide a method, device and storage medium for processing ancient Chinese text based on a language model, so as to at least solve the problem that the existing language models in the prior art can only perform one type of task but cannot perform multiple different types of tasks. Therefore, for ancient Chinese text, if the reader needs to solve multiple different types of problems, multiple different language models are required, which is a very inconvenient technical problem for the reader.

[0007] According to one aspect of an embodiment of the present disclosure, a method for processing ancient Chinese text based on a language model is provided, comprising: determining a first ancient Chinese text to be processed and a first instruction text corresponding to the first ancient Chinese text, wherein the first instruction text is used to indicate any one of a plurality of different types of tasks; inputting the first ancient Chinese text and the first instruction text into a first language model, wherein the first language model has a single model architecture capable of processing a plurality of different types of tasks; and using the first language model, outputting a first processing result corresponding to the first ancient Chinese text and the first instruction text.

[0008] According to another aspect of an embodiment of the present disclosure, a storage medium is further provided, the storage medium including a stored program, wherein when the program is running, a processor executes any one of the methods described above.

[0009] According to another aspect of an embodiment of the present disclosure, there is also provided a device for predicting ancient Chinese text based on a language model, comprising: a first instruction text determination module, used to determine a first ancient Chinese text to be processed and a first instruction text corresponding to the first ancient Chinese text, wherein the first instruction text is used to indicate any one of a plurality of different types of tasks; a text input module, used to input the first ancient Chinese text and the first instruction text into a first language model, wherein the first language model has a single model architecture capable of processing a plurality of different types of tasks; and a processing result output module, used to output a first processing result corresponding to the first ancient Chinese text and the first instruction text using the first language model.

[0010] According to another aspect of an embodiment of the present disclosure, there is also provided a device for predicting ancient Chinese text based on a language model, comprising: a processor; and a memory connected to the processor, for providing the processor with instructions for processing the following processing steps: determining a first ancient Chinese text to be processed and a first instruction text corresponding to the first ancient Chinese text, wherein the first instruction text is used to indicate any one of a plurality of different types of tasks; inputting the first ancient Chinese text and the first instruction text into a first language model, wherein the first language model has a single model architecture capable of processing a plurality of different types of tasks; and using the first language model, outputting a first processing result corresponding to the first ancient Chinese text and the first instruction text.

[0011] The present application provides a method for processing ancient Chinese text based on a language model. First, a processor determines a first ancient Chinese text to be processed and a first instruction text corresponding to the first ancient Chinese text. The first instruction text is used to indicate any one of a plurality of different types of tasks. Then, the processor inputs the first ancient Chinese text and the first instruction text into a first language model. The first language model has a single model architecture capable of processing a plurality of different types of tasks. Finally, the processor uses the first language model to output a first processing result corresponding to the first ancient Chinese text and the first instruction text.

[0012] Since the first instruction text in the present application is used to indicate any one of a plurality of different types of tasks, and the first language model has a single model architecture capable of processing a plurality of different types of tasks, when the first ancient Chinese text and the first instruction text corresponding to the first ancient Chinese text are input into the first language model, the first language model can output the corresponding first processing result based on the task type corresponding to the first instruction text and the first ancient Chinese text. Therefore, if the reader needs to use the first language model to perform different types of tasks, it only needs to input the ancient Chinese text and the instruction text for indicating any one of a plurality of different types of tasks into the first language model, and the corresponding processing result can be output, thus achieving the technical effect of facilitating readers to use the model and read the ancient Chinese text.

[0013] This solves the problem that the existing language models in the prior art can only perform one type of task but cannot perform multiple different types of tasks. Therefore, for ancient Chinese texts, if readers need to solve multiple different types of problems, they need multiple different language models, which is a very inconvenient technical problem for readers. BRIEF DESCRIPTION OF THE DRAWINGS

[0014] The drawings described herein are used to provide a further understanding of the present disclosure and constitute a part of the present application. The illustrative embodiments of the present disclosure and their descriptions are used to explain the present disclosure and do not constitute an improper limitation on the present disclosure. In the drawings:

[0015] Figure 1 is a hardware structure block diagram of a computing device for implementing the method according to Embodiment 1 of the present disclosure;

[0016] Figure 2 is a schematic diagram of an ancient Chinese text processing system based on a language model according to Embodiment 1 of the present disclosure;

[0017] Figure 3 is a flow chart of the ancient Chinese text processing method based on the language model according to Embodiment 1 of the present disclosure;

[0018] Figure 4 is a schematic diagram of a deep learning language model according to Embodiment 1 of the present disclosure;

[0019] Figure 5 is a schematic diagram of the first language model service stage according to Embodiment 1 of the present application;

[0020] Figure 6 is a schematic diagram of an ancient Chinese text processing device based on a language model according to Embodiment 2 of the present disclosure; and

[0021] Figure 7 It is a schematic diagram of the ancient Chinese text processing device based on the language model according to Example 3 of the present disclosure. DETAILED DESCRIPTION

[0022] In order to enable those skilled in the art to better understand the technical solutions of the present disclosure, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only embodiments of a part of the present disclosure, not all of the embodiments. Based on the embodiments in the present disclosure, all other embodiments obtained by ordinary technicians in this field without making creative work should fall within the scope of protection of the present disclosure.

[0023] It should be noted that the terms "first", "second", etc. in the specification and claims of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present disclosure described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product, or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products, or devices.

[0024] Example 1

[0025] According to this embodiment, a method embodiment of ancient Chinese text processing based on a language model is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0026] The method embodiment provided in this embodiment can be executed in a mobile terminal, a computer terminal, a server or a similar computing device. Figure 1 FIG. 1 shows a hardware structure block diagram of a computing device for implementing ancient Chinese text processing based on a language model. Figure 1 As shown, the computing device may include one or more processors (the processor may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory for storing data, a transmission device for communication functions, and an input / output interface. The memory, the transmission device, and the input / output interface are connected to the processor via a bus. In addition, it may also include: a display, a keyboard, and a cursor control device connected to the input / output interface. A person skilled in the art can understand that Figure 1 The structure shown is only for illustration and does not limit the structure of the above electronic device. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations shown.

[0027] It should be noted that the one or more processors and / or other data processing circuits described above may generally be referred to herein as "data processing circuitry". The data processing circuitry may be embodied in whole or in part as software, hardware, firmware, or any other combination thereof. In addition, the data processing circuitry may be a single independent processing module, or may be incorporated in whole or in part into any of the other components of the computing device. As involved in the embodiments of the present disclosure, the data processing circuitry acts as a processor control (e.g., selection of a variable resistor terminal path connected to an interface).

[0028] The memory can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the ancient Chinese text processing method based on the language model in the embodiment of the present disclosure. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory, that is, the ancient Chinese text processing method based on the language model of the above-mentioned application is realized. The memory may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory may further include a memory remotely arranged relative to the processor, and these remote memories can be connected to the computing device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof.

[0029] The transmission device is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the computing device. In one example, the transmission device includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device can be a radio frequency (Radio Frequency, RF) module, which is used to communicate with the Internet wirelessly.

[0030] The display may be, for example, a touch screen liquid crystal display (LCD) that may enable a user to interact with a user interface of the computing device.

[0031] It should be noted that, in some optional embodiments, the above Figure 1 The computing device shown may include hardware elements (including circuits), software elements (including computer code stored on a computer-readable medium), or a combination of both hardware elements and software elements. Figure 1 This is merely one example of a particular embodiment and is intended to illustrate the types of components that may be present in the computing devices described above.

[0032] Figure 2 Schematic diagram of the ancient Chinese text processing system based on the language model according to this embodiment. Figure 2 As shown, the system includes: a terminal device 100 and a processor 200.

[0033] The terminal device 100 is used to receive the first ancient Chinese text input by the reader and the first instruction text corresponding to the first ancient Chinese text, and send the first ancient Chinese text and the first instruction text to the processor 200 .

[0034] The processor 200 is used to determine a first ancient Chinese text to be processed and a first instruction text corresponding to the first ancient Chinese text, and input the first ancient Chinese text and the first instruction text into a first language model. The processor 200 is also used to output a first processing result corresponding to the first ancient Chinese text and the first instruction text.

[0035] It should be noted that the terminal device 100 and the processor 200 in the system can both be applicable to the hardware structure described above.

[0036] Under the above operating environment, according to the first aspect of this embodiment, a method for processing ancient Chinese text based on a language model is provided. The method comprises Figure 2 The processor 200 shown in FIG. Figure 3 A schematic diagram showing the process of the method is shown in FIG. Figure 3 As shown, the method includes:

[0037] S302: Determine a first ancient Chinese text to be processed and a first instruction text corresponding to the first ancient Chinese text, wherein the first instruction text is used to indicate any one of a plurality of different types of tasks;

[0038] S304: inputting the first ancient Chinese text and the first instruction text into a first language model, wherein the first language model has a single model architecture capable of processing multiple different types of tasks; and

[0039] S306: Using the first language model, output a first processing result corresponding to the first ancient Chinese text and the first instruction text.

[0040] Specifically, first, the reader sends the first ancient Chinese text and the first instruction text corresponding to the first ancient Chinese text to the processor 200 through the terminal device 100. Thus, the processor 200 determines the first ancient Chinese text and the first instruction text to be processed (S302).

[0041] The first instruction text is used to indicate any one of a plurality of different types of tasks. The plurality of different types of tasks mentioned above include but are not limited to "add punctuation marks to the above text", "translate the above text into a modern language text", "interpret the words in the above text", and "identify the allusions cited in the above text". Thus, the first instruction text can be any one of "add punctuation marks to the above text", "translate the above text into a modern language text", "interpret the words in the above text", or "identify the allusions cited in the above text".

[0042] In addition, the first instruction text is not limited to the examples given above, as long as it can achieve the purpose of processing the corresponding task. For example, in addition to "translate the above text into a modern language text", the first instruction text can also be "translate the above text into vernacular", "translate the above text into modern Chinese", "translate the above text", and "translate the above text into vernacular", etc.

[0043] Further, for example, if the reader wants to know the modern language text of "Ji Ji Fu Ji Ji, Mulan Dang Hu Zhi", the reader sends "Ji Ji Fu Ji Ji, Mulan Dang Hu Zhi" (i.e., the first ancient Chinese text) and "Translate the above text into vernacular Chinese" (i.e., the first instruction text) corresponding to "Ji Ji Fu Ji Ji, Mulan Dang Hu Zhi" to the processor 200 through the terminal device 100. Thus, the processor 200 determines "Ji Ji Fu Ji Ji, Mulan Dang Hu Zhi" (i.e., the first ancient Chinese text) to be processed, and "Translate the above text into vernacular Chinese" (i.e., the first instruction text).

[0044] For another example, after understanding the modern language text of "Jiji Fujiji, Mulan Danghuzhi", the reader also wants to know the meaning of the word "Jizhu" in "Buwen Jizhu Sheng, Weiwen Nv Tanxi". Then the reader sends "Buwen Jizhu Sheng, Weiwen Nv Tanxi" (i.e., the first ancient Chinese text) and "Interpret the 'Jizhu' in the above text" (i.e., the first instruction text) corresponding to "Buwen Jizhu Sheng, Weiwen Nv Tanxi" to the processor 200 through the terminal device 100. Thus, the processor 200 determines "Buwen Jizhu Sheng, Weiwen Nv Tanxi" (i.e., the first ancient Chinese text) and "Interpret the 'Jizhu' in the above text" (i.e., the first instruction text) to be processed.

[0045] Afterwards, the processor 200 inputs the first ancient Chinese text and the first instruction text into the first language model (S304). The first language model has a single model architecture that can handle multiple different types of tasks. Finally, the processor 200 uses the first language model to output a first processing result corresponding to the first ancient Chinese text and the first instruction text (S306).

[0046] Thus, it can be seen from the above that the processor 200 can process multiple different types of tasks using only the first language model and output the corresponding first processing result. Referring to the example described above, after the processor 200 determines "Chi Ji Fu Chi Ji, Mulan Dang Hu Zhi" (i.e., the first ancient Chinese text) and "Translate the above text into vernacular" (i.e., the first instruction text), it inputs "Chi Ji Fu Chi Ji, Mulan Dang Hu Zhi" (i.e., the first ancient Chinese text) and "Translate the above text into vernacular" (i.e., the first instruction text) into the first language model. The first language model determines the task type based on "Translate the above text into vernacular" (i.e., the first instruction text), and translates "Chi Ji Fu Chi Ji, Mulan Dang Hu Zhi" into "Sighs one after another, Mulan is facing the door to weave cloth" (i.e., the modern language text) according to the determined task type, and sends it to the processor 200. Finally, the processor 200 outputs "Sighs one after another, Mulan is facing the door to weave cloth" (i.e., the modern language text).

[0047] Further referring to the example described above, when the processor 200 receives “I do not hear the sound of the loom, but only hear the sigh of the woman” (i.e., the first ancient Chinese text) and the corresponding “interpret the meaning of ‘loom’ in the above text” (i.e., the first instruction text), it inputs “I do not hear the sound of the loom, but only hear the sigh of the woman” (i.e., the first ancient Chinese text) and “interpret the meaning of ‘loom’ in the above text” (i.e., the first instruction text) into the first language model. The first language model determines the task type based on “interpret the meaning of ‘loom’ in the above text” (i.e., the first instruction text), and interprets the “loom” in “I do not hear the sound of the loom, but only hear the sigh of the woman” according to the determined task type, and sends the interpretation result to the processor 200. Finally, the processor 200 outputs the word interpretation corresponding to “loom” in “I do not hear the sound of the loom, but only hear the sigh of the woman”.

[0048] As described in the background technology, although readers can use existing language models to solve the above problems, different language models can only solve one of the above problems (i.e., can only handle one type of task), and do not have the ability to solve multiple different types of problems (i.e., cannot handle multiple different types of tasks). Therefore, if readers want to solve the multiple different types of problems listed above, they can only use multiple different language models to solve the corresponding problems respectively.

[0049] In view of this, the present application provides an ancient Chinese text processing method based on a language model, and also provides a first language model. The first language model has the ability to process multiple different types of tasks, so when a first ancient Chinese text and a first instruction text corresponding to the first ancient Chinese text are input into the first language model, the first language model can determine the task type corresponding to the first instruction text, and output the corresponding first processing result based on the determined task type and the first ancient Chinese text.

[0050] Furthermore, since the present application processes multiple different types of tasks not by utilizing multiple different language models or by utilizing different model architectures in one language model, but by utilizing only a first language model having a single model architecture, it is possible to process multiple different types of tasks. Therefore, when readers need to utilize the first language model to solve different types of problems, they only need to input the ancient Chinese text and the instruction text for indicating any one of the multiple different types of tasks into the first language model, and the corresponding processing results can be output, thereby achieving the technical effect of facilitating readers to use the model and read the ancient Chinese text.

[0051] This solves the problem that the existing language models in the prior art can only perform one type of task but cannot perform multiple different types of tasks. Therefore, for ancient Chinese texts, if readers need to solve multiple different types of problems, they need multiple different language models, which is a very inconvenient technical problem for readers.

[0052] In addition, the first language model provided by the present application can achieve better results than language models that can only add punctuation marks and language models that translate ancient Chinese texts, especially for marking the source of allusions and interpreting words, which is achieved in an automated way for the first time.

[0053] Optionally, the method also includes: constructing a first sample set, wherein the first sample of the first sample set includes a second ancient Chinese text, a second instruction text, and a first target result corresponding to the second ancient Chinese text and the second instruction text, wherein the second instruction text is used to instruct the execution of any one of a plurality of different types of tasks on the second ancient Chinese text; constructing a second language model, wherein the second language model is a model generated by pre-training; and using the first sample of the first sample set to train the second language model and generate the first language model.

[0054] Specifically, before the processor 200 applies the first language model, it is also necessary to construct the first language model. Thus, first, the processor 200 collects the second ancient Chinese text and the first target result corresponding to the second ancient Chinese text. For example, the second ancient Chinese text collected by the processor 200 includes: "There is a Yellow Crane Tower in the southwest corner of the state city", "There is a Yellow Crane Tower in the southwest corner of the state city", "Liu Zhen has only air, Guan Lu alone has no years", "Ji Ji Ji Ji Ji, Mulan weaves in front of the door" and "No loom sound, only hear the sigh of the woman", etc. The first target result corresponding to the second ancient Chinese text collected by the processor 200 includes "In the southwest corner of Ezhou City, there is a building called the Yellow Crane Tower", "Corner: Corner", "Liu Zhen has only air, using the allusion Liu Zhen sick, referring to the poor and ugly bedridden", "Sighs one after another, Mulan is weaving facing the door" and "Loom: loom", etc.

[0055] Then, the processor 200 processes the second ancient Chinese text and the first target result corresponding to the second ancient Chinese text into an instruction form, and constructs a first sample set. Among them, the first sample of the first sample set includes the second ancient Chinese text, the second instruction text, and the first target result corresponding to the second ancient Chinese text and the second instruction text. For example, the second ancient Chinese text\nthe second instruction text\nthe first target result, or the second instruction text\nthe second ancient Chinese text\nthe first target result. Among them, \n is a line break. And among them, the second instruction text is used to indicate the execution of any one of a plurality of different types of tasks on the second ancient Chinese text.

[0056] Further, for example, the first sample in the first sample set is "There is a Yellow Crane Tower in the southwest corner of the state city\nAdd punctuation marks to the above text\nThere is a Yellow Crane Tower in the southwest corner of the state city", "There is a Yellow Crane Tower in the southwest corner of the state city\nTranslate the above text into a modern language text\nIn the southwest corner of Ezhou City, there is a tower called the Yellow Crane Tower", "There is a Yellow Crane Tower in the southwest corner of the state city\nInterpret the 'corner' in the above text\nCorner: corner", "Liu Zhen has only air, Guan Lu alone has no years\nIdentify the allusions in the above text\nLiu Zhen has only air, using the allusion Liu Zhen is sick, which refers to being sick and poor and ugly", "Jiji, Jiji, Mulan weaves by the door\nTranslate the above text into a modern language text\nSighs one after another, Mulan is weaving facing the door" and "No sound of the loom, only the sigh of the woman\nInterpret the 'loom' in the above text\nLoom: loom", etc.

[0057] Then, the processor 200 constructs a second language model. The second language model is a model generated by pre-training. The above content will be described in detail later, so it will not be repeated here.

[0058] Finally, the processor 200 uses the first sample of the first sample set to train the second language model and generate the first language model. The above content will be described in detail later, so it will not be repeated here.

[0059] As can be seen from the above, the first sample set constructed by the present application includes a plurality of different types of second instruction texts, and a first target result corresponding to the second ancient Chinese text and the second instruction text. Thus, when the second language model is trained using the above first sample set and the first language model is generated, the first language model has the ability to handle different types of tasks. Thus, by constructing a first sample set including the second instruction texts for a plurality of different types of tasks, the second ancient Chinese text, and the first target result corresponding to the second instruction text and the second ancient Chinese text, a technical effect of providing rich data for training the second language model is achieved, thereby ensuring that the generated first language model can handle different types of tasks.

[0060] Optionally, the operation of training the second language model and generating the first language model using the first sample of the first sample set includes: using the second ancient Chinese text and the second instruction text of the first sample as input information of the second language model, and training the second language model using the first target result of the first sample, thereby generating the first language model. Further optionally, the operation of training the second language model and generating the first language model using the first sample of the first sample set also includes: selecting m first samples from the first sample set, where m is an integer and m is greater than 1; inputting the input information of the m first samples to the second language model respectively, thereby obtaining the corresponding second processing results; determining the distance between the second processing results of the m first samples and the corresponding first target results respectively; selecting n first samples with less influence on the second language model from the m first samples according to the gradient information of the distance of the m first samples, where n<m; and training the second language model using the n first samples.

[0061] Specifically, first, the processor 200 extracts m first samples from the first sample set P. The first samples include input information x i And the first target result y i , and i = 1 to m. And where the input information x i It includes a second ancient Chinese text and a second instruction text corresponding to the second ancient Chinese text.

[0062] Then, the processor 200 converts the m input information x into i (i.e., m second ancient Chinese texts and m second instruction texts corresponding to the second ancient Chinese texts) are input into the second language model, thereby obtaining the m input information x iThe corresponding second processing result f(x i ).

[0063] Then the processor 200 determines m second processing results f(x i ) and the corresponding first target result y i The distance between ||f(x i )-y i || 2 .

[0064] Further, the processor 200 determines the second processing result f(x i ) and the corresponding first target result y i The gradient information A of the distance between i The calculation formula is as follows:

[0065]

[0066] Among them, x i Represents input information, y i represents the first target result, f represents the second language model, f(x i ) represents the second processing result, ||f(x i )-y i || 2 represents the difference between the second processing result and the first target result under the L2 norm, and w represents the parameters of the second language model.

[0067] And among them, A i The larger the input information x i The greater the impact on the second language model; i The smaller the input information x i The smaller the impact on the second language model. However, due to the scarcity of the second ancient Chinese text in the first sample, if the impact of individual input information on the second language model is huge, it will lead to insufficient training of the second language model on other input information. Therefore, it is necessary to minimize the input information x i The impact on the second language model, that is, A i Need to be as small as possible. Therefore, in this application, according to The weight of is used to extract n first samples (i.e., n input information and the first target result corresponding to the m input information) with smaller images for the second language model from the m first samples (i.e., m input information and the first target result corresponding to the m input information). Where n<m.

[0068] Finally, the processor 200 inputs the n first samples into the second language model in batches and trains the second language model. For example, the processor 200 brings the n first samples into the second language model and updates the parameter w of the second language model according to the back propagation algorithm. Iterates multiple times until the second language model converges, thereby generating a first language model capable of processing multiple different types of tasks.

[0069] Therefore, since the present application does not use all the first samples in the first sample set to train the second language model during the training of the second language model, but selects some of the first samples that have less impact on the second language model to train the second language model, the above method is more sufficient for training the second language model compared to using all the first samples in the first sample set to train the second language model. Therefore, during the application process, the generated first language model can output a more accurate first processing result (that is, the first processing result is more consistent with the first target result).

[0070] Optionally, the method also includes: constructing a second sample set, wherein the second sample of the second sample set includes a third ancient Chinese text and a second target result corresponding to the third ancient Chinese text; constructing a deep learning language model; and using the second sample of the second sample set to train the deep learning language model and generate a second language model.

[0071] Specifically, before training the second language model and generating the first language model, it is also necessary to generate the second language model.

[0072] First, the processor 200 constructs a second sample set, wherein the second sample of the second sample set includes a third ancient Chinese text and a second target result corresponding to the third ancient Chinese text.

[0073] Then, the processor 200 constructs a deep learning language model. Figure 4 A schematic diagram of a deep learning language model according to an embodiment of the present application is shown. Figure 4As shown, the deep learning language model adopts the Transformer (decoderonly) architecture. And the deep learning language model is composed of N transformer blocks. Among them, each transformer block can generate three matrices Q, K, and V based on the input data (that is, the data output by the previous transformer block), and can merge the three matrices Q, K, and V with the Alibi position encoding, and then input the merged data into the flash attention. Afterwards, the data output from the flash attention passes through the fully connected layer 1, the SwiGLU activation function, and the fully connected layer 2, and is input to the next transformer block. Among them, the initial input data can be, for example, the second sample in the second sample set.

[0074] Thus, after randomly initializing the model parameters of the second language model, the processor 200 uses the second sample in the second sample set to train the deep learning language model, thereby obtaining the second language model. Among them, the second language model can encode the ancient Chinese text to provide a knowledge representation basis for the subsequent training of the second language model. In addition, since the second sample set includes modern language text (i.e., the second target result), the second language model has the ability to translate ancient Chinese text into modern language text, and thus has a greater advantage in translating ancient Chinese text into modern language text.

[0075] Therefore, it can be seen from the above that the second language model in the present application is obtained by training the deep learning language model using the second sample set. And because the second sample of the second sample set includes both the third ancient Chinese text and the second target result (for example, modern language text) corresponding to the third ancient Chinese text, the second language model has the ability to translate the ancient Chinese text into the modern language text, and thus has a greater advantage in translating the ancient Chinese text into the modern language text, thereby providing the necessary basic conditions for the subsequent generation of the first language model.

[0076] Advantages of this application:

[0077] 1. The technical solution disclosed in this application can process a variety of different types of tasks based on a first language model that only includes a single model mechanism;

[0078] 2. The technical solution disclosed in this application improves the accuracy of translating ancient Chinese texts into modern language texts, interpreting words in ancient Chinese texts, and identifying allusions cited in ancient Chinese texts;

[0079] 3. The technical solution of the present disclosure adopts two methods to solve the problem of insufficient learning of small samples (i.e., a small number of samples): First, reduce the impact of individual first samples on the training of the second language model, improve the efficiency of scarce samples, so that the second language model can still be fully trained when the number of first samples is small, thereby obtaining a better first language model. Second, the second sample in the second sample set includes a second target result corresponding to the third ancient Chinese text, so that the second language model has a greater advantage in translating the ancient Chinese text into a modern language text; and

[0080] 4. The technical solution disclosed in this disclosure can assist readers in analyzing and understanding ancient Chinese texts.

[0081] In addition, this application also provides the first language model service stage:

[0082] 1. Configure the PyTorch service description file, start the PyTorch service to load the exported first language model, and access the first language model service through the interface;

[0083] 2. Build an ancient Chinese text automatic analysis service based on the first language model service to achieve the purpose of user access interface. Figure 5 is a schematic diagram of the first language model service stage according to an embodiment of the present application. Figure 5 As shown, the reader sends the first ancient Chinese text and the first instruction text to the automatic analysis service through the interface. The ancient Chinese text automatic analysis service converts the first ancient Chinese text and the first instruction text into a format that can be processed by the first language model, and sends the corresponding data to the first language model service. After the first language model completes the processing and returns, the ancient Chinese text automatic analysis service gives the processing result;

[0084] 3. Establish an ancient Chinese text automatic analysis platform. Input the first ancient Chinese text and the first instruction text into the automatic analysis service interface on the platform, and after receiving the first processing result, display it in a visual Web-based manner.

[0085] Thus, according to the first aspect of this embodiment, the technical effect of facilitating readers to use the model and read ancient Chinese texts is achieved.

[0086] First, the processor 200 constructs a second sample set and a deep learning language model, thereby using the second sample of the second sample set to train the deep learning language model and generate a second language model. Then, the processor 200 constructs a first sample set, and uses the first sample of the first sample set to train the second language model and generate a first language model. After that, the processor 200 determines the first ancient Chinese text to be processed and the first instruction text corresponding to the first ancient Chinese text. Further, the processor 200 inputs the first ancient Chinese text and the first instruction text into the first language model. Finally, the processor 200 uses the first language model to output a first processing result corresponding to the first ancient Chinese text and the first instruction text.

[0087] In addition, reference Figure 1 As shown, according to the second aspect of this embodiment, a storage medium is provided, wherein the storage medium includes a stored program, wherein when the program is run, a processor executes any one of the above methods.

[0088] Therefore, according to this embodiment, the technical effect of facilitating readers to use the model and read ancient Chinese texts is achieved.

[0089] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity, they are all described as a series of action combinations, but those skilled in the art should know that the present invention is not limited by the described action sequence, because according to the present invention, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present invention.

[0090] Through the description of the above implementation methods, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for enabling a terminal device (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present invention.

[0091] Example 2

[0092] Figure 6 FIG. 6 shows an ancient Chinese text processing device 600 based on a language model according to this embodiment, and the device 600 corresponds to the method according to Embodiment 1. Figure 6As shown, the device 600 includes: a first instruction text determination module 610, used to determine a first ancient Chinese text to be processed and a first instruction text corresponding to the first ancient Chinese text, wherein the first instruction text is used to indicate any one of a plurality of different types of tasks; a text input module 620, used to input the first ancient Chinese text and the first instruction text into a first language model, wherein the first language model has a single model architecture capable of processing a plurality of different types of tasks; and a processing result output module 630, used to output a first processing result corresponding to the first ancient Chinese text and the first instruction text using the first language model.

[0093] Optionally, the device 600 also includes: a first sample set construction module, used to construct a first sample set, wherein the first sample of the first sample set includes a second ancient Chinese text, a second instruction text, and a first target result corresponding to the second ancient Chinese text and the second instruction text, wherein the second instruction text is used to instruct the execution of any one of a plurality of different types of tasks on the second ancient Chinese text; a first language model construction module, used to construct a second language model, wherein the second language model is a model generated by pre-training; and a first language model generation module, used to train the second language model using the first sample of the first sample set, and generate a first language model.

[0094] Optionally, the first language model generation module includes: a first language model generation submodule, which is used to use the second ancient Chinese text and the second instruction text of the first sample as input information of the second language model, and train the second language model using the first target result of the first sample, so as to generate the first language model.

[0095] Optionally, the first language model generation module further includes: a first sample selection module, used to select m first samples from the first sample set, where m is an integer and m is greater than 1; a processing result generation module, used to input the input information of the m first samples into the second language model respectively, so as to obtain the corresponding second processing results; a distance determination module, used to respectively determine the distance between the second processing results of the m first samples and the corresponding first target results; a second sample selection module, used to select n first samples with less influence on the second language model from the m first samples according to the gradient information of the distance of the m first samples, where n<m; and a model training module, used to train the second language model using the n first samples.

[0096] Optionally, the device 600 also includes: a second sample set construction module, used to construct a second sample set, wherein the second sample of the second sample set includes a third ancient Chinese text and a second target result corresponding to the third ancient Chinese text; a second language model construction module, used to construct a deep learning language model; and a second language model generation module, used to train the deep learning language model using the second sample of the second sample set and generate a second language model.

[0097] Therefore, according to this embodiment, the technical effect of facilitating readers to use the model and read ancient Chinese texts is achieved.

[0098] Example 3

[0099] Figure 7 FIG. 7 shows an ancient Chinese text processing device 700 based on a language model according to this embodiment, and the device 700 corresponds to the method according to Embodiment 1. Figure 7 As shown, the device 700 includes: a processor 710; and a memory 720, connected to the processor 710, for providing the processor 710 with instructions for processing the following processing steps: determining a first ancient Chinese text to be processed and a first instruction text corresponding to the first ancient Chinese text, wherein the first instruction text is used to indicate any one of a plurality of different types of tasks; inputting the first ancient Chinese text and the first instruction text into a first language model, wherein the first language model has a single model architecture capable of processing a plurality of different types of tasks; and using the first language model, outputting a first processing result corresponding to the first ancient Chinese text and the first instruction text.

[0100] Optionally, the device 700 also includes: constructing a first sample set, wherein the first sample of the first sample set includes a second ancient Chinese text, a second instruction text, and a first target result corresponding to the second ancient Chinese text and the second instruction text, wherein the second instruction text is used to instruct the execution of any one of a plurality of different types of tasks on the second ancient Chinese text; constructing a second language model, wherein the second language model is a model generated by pre-training; and using the first sample of the first sample set to train the second language model and generate the first language model.

[0101] Optionally, the operation of training the second language model using the first sample of the first sample set and generating the first language model includes: taking the second ancient Chinese text and the second instruction text of the first sample as input information of the second language model, and training the second language model using the first target result of the first sample, thereby generating the first language model.

[0102] Optionally, the operation of training the second language model using the first sample of the first sample set and generating the first language model further includes: selecting m first samples from the first sample set, where m is an integer and m is greater than 1; inputting input information of the m first samples into the second language model respectively, thereby obtaining corresponding second processing results; determining the distances between the second processing results of the m first samples and the corresponding first target results respectively; selecting n first samples having less influence on the second language model from the m first samples according to gradient information of the distances of the m first samples, where n<m; and training the second language model using the n first samples.

[0103] Optionally, the device 700 also includes: constructing a second sample set, wherein the second sample of the second sample set includes a third ancient Chinese text and a second target result corresponding to the third ancient Chinese text; constructing a deep learning language model; and using the second sample of the second sample set to train the deep learning language model and generate a second language model.

[0104] Therefore, according to this embodiment, the technical effect of facilitating readers to use the model and read ancient Chinese texts is achieved.

[0105] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.

[0106] In the above embodiments of the present invention, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0107] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.

[0108] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0109] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0110] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk and other media that can store program codes.

[0111] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.

Claims

1. A method for processing ancient Chinese text based on a language model, characterized in that: include: Determining a first ancient Chinese text to be processed and a first instruction text corresponding to the first ancient Chinese text, wherein the first instruction text is used to indicate any one of a plurality of different types of tasks, and wherein the plurality of different types of tasks include translating the first ancient Chinese text into a modern language text, adding punctuation marks to the first ancient Chinese text, interpreting words in the first ancient Chinese text, and identifying allusions cited in the first ancient Chinese text; Inputting the first ancient Chinese text and the first instruction text into a first language model, wherein the first language model has a single model architecture capable of processing the multiple different types of tasks; as well as Using the first language model, outputting a first processing result corresponding to the first ancient Chinese text and the first instruction text, wherein The method further comprises: Constructing a first sample set, wherein a first sample of the first sample set includes a second ancient Chinese text, a second instruction text, and a first target result corresponding to the second ancient Chinese text and the second instruction text, wherein the second instruction text is used to instruct to perform any one of the multiple different types of tasks on the second ancient Chinese text; Constructing a second language model, wherein the second language model is a model generated by pre-training; and Using the first sample of the first sample set, the second language model is trained to generate the first language model, wherein The operation of training the second language model by using the first sample of the first sample set and generating the first language model includes: The second ancient Chinese text and the second instruction text of the first sample are used as input information of the second language model, and the second language model is trained using the first target result of the first sample, thereby generating the first language model, wherein The operation of training the second language model using the first sample of the first sample set and generating the first language model further includes: Selecting m first samples from the first sample set, where m is an integer and m is greater than 1; Inputting the input information of the m first samples into the second language model respectively, so as to obtain corresponding second processing results; respectively determining the distances between the second processing results of the m first samples and the corresponding first target results; According to the gradient information of the distances of the m first samples, n first samples having less influence on the second language model are selected from the m first samples, where n<m, and the calculation formula of the gradient information is as follows: Among them, x i Represents the input information, y i represents the first target result, f represents the second language model, f(x i ) represents the second processing result, ||f(x i )-y i || 2 represents the difference between the second processed result and the first target result under the L2 norm, and w represents the parameter of the second language model; and The second language model is trained using the n first samples.

2. The method according to claim 1, characterized in that The method also includes: Constructing a second sample set, wherein a second sample of the second sample set includes a third ancient Chinese text and a second target result corresponding to the third ancient Chinese text; Building deep learning language models; and The deep learning language model is trained using the second sample of the second sample set to generate the second language model.

3. A storage medium, characterized in that: The storage medium includes a stored program, wherein when the program is run, the processor executes the method according to any one of claims 1 to 2.

4. An ancient Chinese text processing device based on a language model, characterized in that: include: A first instruction text determination module, used for determining a first ancient Chinese text to be processed and a first instruction text corresponding to the first ancient Chinese text, wherein the first instruction text is used to indicate any one of a plurality of different types of tasks, and wherein the plurality of different types of tasks include translating the first ancient Chinese text into a modern language text, adding punctuation marks to the first ancient Chinese text, interpreting words in the first ancient Chinese text, and identifying allusions cited in the first ancient Chinese text; a text input module, configured to input the first ancient Chinese text and the first instruction text into a first language model, wherein the first language model has a single model architecture capable of processing the plurality of different types of tasks; as well as A processing result output module is used to output a first processing result corresponding to the first ancient Chinese text and the first instruction text using the first language model, wherein The device also includes: A first sample set construction module is used to construct a first sample set, wherein the first sample of the first sample set includes a second ancient Chinese text, a second instruction text, and a first target result corresponding to the second ancient Chinese text and the second instruction text, wherein the second instruction text is used to instruct to perform any one of the multiple different types of tasks on the second ancient Chinese text; A first language model construction module is used to construct a second language model, wherein the second language model is a model generated by pre-training; and A first language model generating module is used to train the second language model using the first sample of the first sample set and generate the first language model, wherein The first language model generation module includes: The first language model generation submodule is used to use the second ancient Chinese text and the second instruction text of the first sample as input information of the second language model, and train the second language model using the first target result of the first sample to generate the first language model, wherein The first language model generation module further includes: a first sample selection module, configured to select m first samples from the first sample set, where m is an integer and is greater than 1; a processing result generating module, used for inputting the input information of the m first samples into the second language model respectively, so as to obtain a corresponding second processing result; a distance determination module, used to respectively determine the distances between the second processing results of the m first samples and the corresponding first target results; The second sample selection module is used to select n first samples with less influence on the second language model from the m first samples according to the gradient information of the distance of the m first samples, wherein n<m, and the calculation formula of the gradient information is as follows: Among them, x i Represents the input information, y i represents the first target result, f represents the second language model, f(x i ) represents the second processing result, ||f(x i )-y i || 2 represents the difference between the second processed result and the first target result under the L2 norm, and w represents the parameter of the second language model; and A model training module is used to train the second language model using the n first samples.

5. A computing device, characterized in that: include: A memory, a processor, and computer instructions stored in the memory and executable on the processor, wherein the processor implements the steps of the method according to any one of claims 1 to 2 when executing the computer instructions.