Training method for poetry entity extraction model, poetry entity extraction method and device

By calculating the similarity and difference data between the poetry text information and the preset knowledge base, enriching the training set and training the model, the problem of insufficient accuracy of the poetry entity extraction model was solved, and higher accuracy of named entity type labeling was achieved.

CN120277219BActive Publication Date: 2025-09-09TIANJIN UNIV
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202510766367.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-06-10
Publication Date
2025-09-09
Estimated Expiration
2045-06-10

AI Technical Summary

Technical Problem

The existing poetry entity extraction model has inaccurate named entity type labeling due to the small number of training samples.

Method used

By calculating the cosine similarity data and the poetry level and tone difference data between the initial poetry text information and the poetry text information to be screened in the preset knowledge base, a comprehensive similarity is generated, and the poetry text information to be screened is determined under the preset conditions, the target poetry training set is enriched, and the pre-training model is trained using the target training set.

Benefits of technology

The accuracy of the poetry entity extraction model for named entity types is improved, solving the problem of poor prediction accuracy due to small samples.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120277219B_ABST
    Figure CN120277219B_ABST
Patent Text Reader

Abstract

The present application provides a training method for a poetry entity extraction model, a poetry entity extraction method and a device, the method comprising inputting the first poetry text information in an initial poetry training set into a pre-training model, outputting a first entity type label corresponding to each named entity in the first poetry text information; calculating cosine similarity data and poetry level and tone difference data between the first poetry text information and each poetry text information to be screened in a preset knowledge base; for each poetry text information to be screened, generating a comprehensive similarity based on the cosine similarity data and the poetry level and tone difference data; when the comprehensive similarity meets a first preset condition, determining the poetry text information to be screened as the second poetry text information corresponding to the first poetry text information; inputting the intermediate poetry training set into a preset language model to obtain a target poetry training set; and using the target poetry training set to train the pre-training model to obtain a trained poetry entity extraction model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and more specifically, to a training method for a poetry entity extraction model, a poetry entity extraction method, a training device for a poetry entity extraction model, a poetry entity extraction device, an electronic device, a computer-readable storage medium, and a computer program product. Background Art

[0002] Classical poetry is an important expression of spatial cognition in classical culture. Mining spatial information from poetry supports understanding the living environment, discovering regional cultural characteristics, and inheriting aesthetic philosophies. Spatial entities are texts that use natural language to describe spatial elements such as geographic locations, buildings and structures, and landscapes, as well as related activities and experiences. They are named entities with spatial location attributes and their extensions.

[0003] In the process of realizing the concept of this application, it was found that for poetry texts, due to the small number of training samples, the poetry entity extraction model trained thereby did not accurately mark the types of named entities when processing poetry data. Summary of the Invention

[0004] In view of this, the present application provides a training method for a poetry entity extraction model, a poetry entity extraction method, a training device for a poetry entity extraction model, a poetry entity extraction device, an electronic device, a computer-readable storage medium, and a computer program product.

[0005] One aspect of the present application provides a method for training a poetry entity extraction model, comprising:

[0006] Inputting the first poem text information in the initial poem training set into the pre-training model, and outputting a plurality of first entity type labels corresponding to each named entity in the first poem text information;

[0007] Calculating cosine similarity data and poetry level and tone difference data between the first poetry text information and each piece of poetry text information to be screened in a preset knowledge base, wherein the preset knowledge base also includes a second entity type label corresponding to each piece of poetry text information to be screened;

[0008] For each poem text to be screened, generate a comprehensive similarity based on the cosine similarity data and the poem level and tone difference data;

[0009] When the comprehensive similarity satisfies the first preset condition, the poem text information to be screened is determined to be the second poem text information corresponding to the first poem text information;

[0010] Inputting the intermediate poetry training set into a preset language model to obtain a target poetry training set, wherein the intermediate poetry training set includes a plurality of first poetry text information and a plurality of first entity type labels corresponding to each first poetry text information, a plurality of second poetry text information and a plurality of second entity type labels;

[0011] The pre-trained model is trained using the target poetry training set to obtain a trained poetry entity extraction model.

[0012] Another aspect of the present application provides a method for extracting poetry entities, comprising:

[0013] Obtaining a poem text to be identified, wherein the poem text to be identified includes at least one entity to be identified;

[0014] The above-mentioned poetry text to be identified is input into the poetry entity extraction model, and the predicted entity type corresponding to each of the above-mentioned entities to be identified is output.

[0015] Another aspect of the present application provides a training device for a poetry entity extraction model, comprising:

[0016] A first prediction module is configured to input the first poem text information in the initial poem training set into the pre-training model and output a plurality of first entity type labels corresponding to each named entity in the first poem text information;

[0017] a calculation module for calculating cosine similarity data and poetry level and tone difference data between the first poetry text information and each piece of poetry text information to be screened in a preset knowledge base, wherein the preset knowledge base also includes a second entity type label corresponding to each piece of poetry text information to be screened;

[0018] A generation module is used to generate a comprehensive similarity for each of the above-mentioned poetry text information to be screened based on the above-mentioned cosine similarity data and the poetry level and tone difference data;

[0019] a determination module, configured to determine the poem text information to be screened as second poem text information corresponding to the first poem text information, if the comprehensive similarity satisfies a first preset condition;

[0020] An obtaining module is used to input the intermediate poetry training set into a preset language model to obtain a target poetry training set, wherein the intermediate poetry training set includes a plurality of first poetry text information and a plurality of first entity type labels corresponding to each first poetry text information, a plurality of second poetry text information and a plurality of second entity type labels;

[0021] The training module is used to train the above-mentioned pre-trained model using the above-mentioned target poetry training set to obtain a trained poetry entity extraction model.

[0022] Another aspect of the present application provides a device for extracting poetry entities, comprising:

[0023] An acquisition module, configured to acquire a poem text to be recognized, wherein the poem text to be recognized includes at least one entity to be recognized;

[0024] The second prediction module is used to input the above-mentioned poetry text to be identified into the poetry entity extraction model, and output the predicted entity type corresponding to each of the above-mentioned entities to be identified.

[0025] Another aspect of the present application provides an electronic device, comprising:

[0026] one or more processors;

[0027] a memory for storing one or more programs,

[0028] When the one or more programs are executed by the one or more processors, the one or more processors implement the method as described above.

[0029] Another aspect of the present application provides a computer-readable storage medium storing computer-executable instructions, which are used to implement the method described above when executed.

[0030] Another aspect of the present application provides a computer program product, which includes computer-executable instructions. When the instructions are executed, the instructions are used to implement the method described above.

[0031] According to an embodiment of the present application, by calculating the cosine similarity data and the poetry level and tone difference data between each first poetry text information in the initial poetry training set and each poetry text information to be screened in the preset knowledge base, the comprehensive similarity generated by the cosine similarity data and the poetry level and tone difference data satisfies the first preset condition to determine whether the poetry text information to be screened is determined as the second poetry text information corresponding to the first poetry text information, and then the intermediate poetry training set containing the initial poetry training set and the second poetry text information is input into the preset language model to obtain the target poetry training set, and the pre-training model is trained using the target poetry training set to obtain the poetry entity extraction model. Since the second poetry text information is determined from the preset knowledge base through the cosine similarity data and the poetry level and tone difference data, and the preset language model is used to further enrich the number of samples in the target poetry training set, the problem of poor prediction accuracy of the poetry entity extraction model caused by the small number of poetry samples in the related art can be solved, thereby improving the accuracy of the poetry entity extraction model in extracting named entity types. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] The above and other objects, features and advantages of the present application will become more apparent through the following description of the embodiments of the present application with reference to the accompanying drawings, in which:

[0033] Figure 1 An exemplary system architecture of a training method for a poetry entity extraction model or a poetry entity extraction method according to an embodiment of the present application is shown;

[0034] Figure 2 A flowchart of a method for training a poetry entity extraction model according to an embodiment of the present application is shown;

[0035] Figure 3 The following is a processing flow chart of a poetry entity extraction model according to an embodiment of the present application;

[0036] Figure 4 A flowchart of a method for extracting poetry entities according to an embodiment of the present application is shown;

[0037] Figure 5 A block diagram of a training device for a poetry entity extraction model according to an embodiment of the present application is shown;

[0038] Figure 6 A block diagram of a training device for a poetry entity extraction model according to an embodiment of the present application is shown; and

[0039] Figure 7 A block diagram of an electronic device suitable for implementing the method described above according to an embodiment of the present application is shown. DETAILED DESCRIPTION

[0040] Hereinafter, embodiments of the present application will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the present application. In the detailed description below, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of the embodiments of the present application. However, it is apparent that one or more embodiments may also be implemented without these specific details. In addition, in the following description, descriptions of known structures and technologies are omitted to avoid unnecessarily confusing the concepts of the present application.

[0041] The terms used herein are only for describing specific embodiments and are not intended to limit the present application. The terms "comprise," "include," etc. used herein indicate the presence of features, steps, operations, and / or components, but do not exclude the presence or addition of one or more other features, steps, operations, or components.

[0042] All terms used herein (including technical and scientific terms) have the meanings commonly understood by those skilled in the art unless otherwise defined. It should be noted that the terms used herein should be interpreted as having a meaning consistent with the context of this specification and should not be interpreted in an idealized or overly rigid manner.

[0043] When expressions such as "at least one of A, B, and C, etc." are used, they should generally be interpreted in accordance with the meaning commonly understood by those skilled in the art (for example, "a system having at least one of A, B, and C" should include but is not limited to a system having A alone, B alone, C alone, A and B, A and C, B and C, and / or A, B, C, etc.).

[0044] Currently, commonly used methods for named entity recognition include rule-based methods, traditional machine learning methods, and deep learning methods. Rule-based methods require domain experts to develop, which is time-consuming. It is also difficult to manually exhaustively identify the rules and patterns of entity appearance, and they are unable to adapt to the complex and varied linguistic expressions of ancient poetry. Traditional machine learning methods primarily utilize large-scale annotated corpora for probabilistic model training. Traditional machine learning methods can automatically learn linguistic features and have stronger generalization capabilities. With the further development of machine learning, deep learning methods have garnered further attention. While they no longer require the manual selection of complex feature sets as model training sets, as traditional machine learning methods do, they do require larger corpora.

[0045] Related research has primarily focused on generating annotated corpora for modern vernacular text recognition. However, classical poetry differs significantly from modern texts and ordinary Chinese texts in terms of structure, sentence structure, and grammatical expression, and there is no readily available large-scale annotated corpus of classical poetry. Therefore, without sufficient annotated data, the effectiveness of traditional supervised learning methods is limited, and small-sample learning methods should be employed for further research.

[0046] In view of this, the embodiment of the present application provides a training method for a poetry entity extraction model, a poetry entity extraction method and a device, the method comprising: inputting the first poetry text information in the initial poetry training set into the pre-training model, outputting a plurality of first entity type labels corresponding to each named entity in the first poetry text information; calculating the cosine similarity data and poetry level difference data between the first poetry text information and each poetry text information to be screened in a preset knowledge base, wherein the preset knowledge base also includes a second entity type label corresponding to each poetry text information to be screened; for each poetry text information to be screened, calculating the cosine similarity data and poetry level difference data between the first poetry text information and each poetry text information to be screened in the preset knowledge base; calculating the cosine similarity data and poetry level difference data between the first poetry text information and each poetry text information to be screened; calculating the cosine similarity data and poetry level difference data between the first poetry text information and each poetry text information to be screened; calculating the cosine similarity data and poetry level difference data between the first poetry text information and the ... similar data and poetry prosody difference data to generate a comprehensive similarity; when the comprehensive similarity meets the first preset condition, the poetry text information to be screened is determined as the second poetry text information corresponding to the first poetry text information; the intermediate poetry training set is input into the preset language model to obtain the target poetry training set, wherein the intermediate poetry training set includes multiple first poetry text information and multiple first entity type labels corresponding to each first poetry text information, multiple second poetry text information and multiple second entity type labels; the target poetry training set is used to train the pre-trained model to obtain a trained poetry entity extraction model.

[0047] In the embodiments of this application, the collection, updating, analysis, processing, use, transmission, provision, disclosure, and storage of all data involved (including, but not limited to, user personal information) comply with relevant laws and regulations, are used for legitimate purposes, and do not violate public order and good morals. In particular, necessary measures have been taken to prevent unauthorized access to user personal information data and maintain the security of user personal information and network security.

[0048] Figure 1 The exemplary system architecture of the training method of the poetry entity extraction model or the poetry entity extraction method according to the embodiment of the present application is shown. It should be noted that, Figure 1 What is shown is merely an example of a system architecture to which the embodiments of the present application can be applied, to help those skilled in the art understand the technical content of the present application, but does not mean that the embodiments of the present application cannot be used in other devices, systems, environments or scenarios.

[0049] like Figure 1 As shown, the system architecture 100 according to this embodiment may include a first terminal device 101, a second terminal device 102, a third terminal device 103, a network 104, and a server 105. The network 104 is used as a medium for providing a communication link between the first terminal device 101, the second terminal device 102, the third terminal device 103, and the server 105. The network 104 may include various connection types, such as wired and / or wireless communication links, etc.

[0050] A user may use a first terminal device 101, a second terminal device 102, or a third terminal device 103 to interact with a server 105 via a network 104 to receive or send messages, etc. Various communication client applications may be installed on the first terminal device 101, the second terminal device 102, or the third terminal device 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, and / or social platform software (for example only).

[0051] The first terminal device 101 , the second terminal device 102 , and the third terminal device 103 may be various electronic devices having display screens and supporting web browsing, including but not limited to smart phones, tablet computers, laptop computers, desktop computers, and the like.

[0052] The server 105 may be a server that provides various services, such as a background management server (for example only) that supports websites browsed by users using the first terminal device 101, the second terminal device 102, and the third terminal device 103. The background management server may analyze and process received data such as user requests, and feed back processing results (e.g., web pages, information, or data obtained or generated based on user requests) to the terminal devices.

[0053] It should be noted that the training method of the poetry entity extraction model and the poetry entity extraction method provided in the embodiment of the present application can generally be executed by the server 105. Accordingly, the training device of the poetry entity extraction model and the poetry entity extraction device provided in the embodiment of the present application can generally be set in the server 105. The training method of the poetry entity extraction model and the poetry entity extraction method provided in the embodiment of the present application can also be executed by a server or server cluster that is different from the server 105 and can communicate with the first terminal device 101, the second terminal device 102, the third terminal device 103 and / or the server 105. Accordingly, the training device of the poetry entity extraction model and the poetry entity extraction device provided in the embodiment of the present application can also be set in a server or server cluster that is different from the server 105 and can communicate with the first terminal device 101, the second terminal device 102, the third terminal device 103 and / or the server 105. Alternatively, the training method for the poetry entity extraction model and the poetry entity extraction method provided in the embodiments of the present application may also be performed by the first terminal device 101, the second terminal device 102, or the third terminal device 103, or may also be performed by other terminal devices different from the first terminal device 101, the second terminal device 102, or the third terminal device 103. Accordingly, the training device for the poetry entity extraction model and the poetry entity extraction device provided in the embodiments of the present application may also be provided in the first terminal device 101, the second terminal device 102, or the third terminal device 103, or may be provided in other terminal devices different from the first terminal device 101, the second terminal device 102, or the third terminal device 103.

[0054] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is merely illustrative. Any number of terminal devices, networks and servers may be provided as required.

[0055] Figure 2 A flowchart of a method for training a poetry entity extraction model according to an embodiment of the present application is shown.

[0056] like Figure 2 As shown, the training method of the poetry entity extraction model includes operations S201~S206.

[0057] In operation S201, the first poem text information in the initial poem training set is input into the pre-training model, and a plurality of first entity type labels corresponding to each named entity in the first poem text information are output.

[0058] In operation S202, cosine similarity data and poetry level and tone difference data between the first poetry text information and each poetry text information to be filtered in the preset knowledge base are calculated, wherein the preset knowledge base also includes a second entity type label corresponding to each poetry text information to be filtered.

[0059] In operation S203, for each poetry text information to be screened, a comprehensive similarity is generated according to the cosine similarity data and the poetry prosody difference data.

[0060] In operation S204, when the comprehensive similarity meets the first preset condition, the poetry text information to be screened is determined as the second poetry text information corresponding to the first poetry text information.

[0061] In operation S205, the intermediate poetry training set is input into a preset language model to obtain a target poetry training set. The intermediate poetry training set includes multiple first poetry text information and multiple first entity type labels corresponding to each first poetry text information, multiple second poetry text information and multiple second entity type labels.

[0062] In operation S206, the pre-trained model is trained using the target poetry training set to obtain a trained poetry entity extraction model.

[0063] According to an embodiment of the present application, the first poetry text information can be ancient poems and / or modern poems downloaded from a poetry website, etc., or obtained by performing optical character recognition on a poetry book. In order to improve the text accuracy of the first poetry text information, preprocessing such as data cleaning can be performed on it to form an initial poetry training set using the cleaned first poetry text information. The poetry text information to be screened in the preset knowledge base can also be downloaded poems or poems recognized from books.

[0064] According to an embodiment of the present application, both the first entity type label and the second entity type label can refer to the type of the named entity. The types include locations, cultural landscapes, natural landscapes, spatial functions, spatial perceptions, etc. For example, "The guest house is green with <natural landscape>willows< / natural landscape>, fresh in color" or "<cultural landscape>Huqin< / cultural landscape>, pipa and Qiang flutes", where "< / natural landscape>willows" indicates that "willows" is a natural landscape. It should be noted that the types of named entity types can be specifically set according to the actual situation.

[0065] According to an embodiment of the present application, the preset language model can be any type of large language model (LLM), such as the LLaMA 3 model, etc. The pre-trained model can be constructed based on a bidirectional Transformer network, a bidirectional recurrent neural network, and a probabilistic graphical model.

[0066] According to an embodiment of the present application, for each calculated cosine similarity data and poetry level and tone difference data between the first poetry text information and each poetry text information to be screened in the preset knowledge base, a weighted sum of the cosine similarity data and the poetry level and tone difference data can be performed to obtain a comprehensive similarity between the first poetry text information and the poetry text information to be screened. If the comprehensive similarity meets the first preset condition, the poetry text information to be screened can be determined as the second poetry text information corresponding to the first poetry text information. Among them, meeting the first preset condition can refer to meeting the similarity threshold, and the similarity threshold can be specifically set according to actual needs, for example, it can be 0.8.

[0067] According to an embodiment of the present application, multiple first poetry text information in the initial poetry training set and multiple first entity type labels corresponding to each first poetry text information, multiple second poetry text information and multiple second entity type labels are used to form an intermediate poetry training set, and then the intermediate poetry training set is input into a preset language model to obtain a target poetry training set, wherein the target poetry training set includes not only the intermediate poetry training set, but also the predicted poetry text information output by the preset language model, thereby the target poetry training set can be used to train the pre-training model to obtain a trained poetry entity extraction model.

[0068] According to an embodiment of the present application, by calculating the cosine similarity data and the poetry level and tone difference data between each first poetry text information in the initial poetry training set and each poetry text information to be screened in the preset knowledge base, the comprehensive similarity generated by the cosine similarity data and the poetry level and tone difference data satisfies the first preset condition to determine whether the poetry text information to be screened is determined as the second poetry text information corresponding to the first poetry text information, and then the intermediate poetry training set containing the initial poetry training set and the second poetry text information is input into the preset language model to obtain the target poetry training set, and the pre-training model is trained using the target poetry training set to obtain the poetry entity extraction model. Since the second poetry text information is determined from the preset knowledge base through the cosine similarity data and the poetry level and tone difference data, and the preset language model is used to further enrich the number of samples in the target poetry training set, the problem of poor prediction accuracy of the poetry entity extraction model caused by the small number of poetry samples in the related art can be solved, thereby improving the accuracy of the poetry entity extraction model in extracting named entity types.

[0069] According to an embodiment of the present application, calculating cosine similarity data and poetry prosody difference data between the first poetry text information and each piece of poetry text information to be screened in the preset knowledge base includes: performing semantic vector conversion and prosody encoding conversion on multiple pieces of first poetry text information to obtain a first poetry semantic vector and first poetry prosody encoding information corresponding to each piece of first poetry text information, and performing semantic vector conversion and prosody encoding conversion on multiple pieces of poetry text information to be screened to obtain a second poetry semantic vector and second poetry prosody encoding information corresponding to each piece of poetry text information to be screened; for each piece of first poetry text information and poetry text information to be screened, generating cosine similarity data and poetry prosody difference data between the first poetry text information and the poetry text information to be screened according to the first poetry semantic vector, the first poetry prosody encoding information, the second poetry semantic vector, and the second poetry prosody encoding information.

[0070] According to an embodiment of the present application, for the first poetry text information and / or the poetry text information to be screened, perform prosody encoding on it based on the prosody of the poetry. For example, the prosody encoding information of the poetry "ping ping ze ze ping" is [1, 1, 0, 0, 1]. At the same time, perform vector conversion on the semantics of the poetry, thereby obtaining a first poetry semantic vector corresponding to each piece of first poetry text information and a second poetry semantic vector corresponding to each piece of poetry text information to be screened.

[0071] According to an embodiment of the present application, for each piece of first poetry text information and poetry text information to be screened, generate cosine similarity data and poetry prosody difference data between the first poetry text information and the poetry text information to be screened according to the first poetry semantic vector, the first poetry prosody encoding information, the second poetry semantic vector, and the second poetry prosody encoding information.

[0072] According to an embodiment of the present application, generating cosine similarity data and poetry prosody difference data between the first poetry text information and the poetry text information to be screened according to the first poetry semantic vector, the first poetry prosody encoding information, the second poetry semantic vector, and the second poetry prosody encoding information includes: calculating cosine similarity data between the first poetry semantic vector and the second poetry semantic vector based on the cosine similarity function; calculating poetry prosody difference data between the first poetry prosody encoding information and the second poetry prosody encoding information.

[0073] According to an embodiment of the present application, the comprehensive similarity is calculated as shown in formula (1):

[0074] (1)

[0075] where The first poem level and tone encoding information representing the first poem text information q; EditDistance: the number of steps of difference between the first poem level and tone encoding information and the second poem level and tone encoding information calculated by the dynamic programming algorithm, i.e., the poem level and tone difference data; 、 They represent the first poem semantic vector of the first poem text information q and the second poem semantic vector of the jth poem text information to be screened, d j represents the jth poem text to be screened in the preset knowledge base, Represents cosine similarity data, 0.7 and 0.3 are weighting coefficients, and their values ​​can be modified and replaced as needed.

[0076] According to an embodiment of the present application, the second entity type label is generated in the following manner: for each piece of poetry text information to be screened, the poetry text information to be screened is input into a pre-training model, and a plurality of second entity type labels are output. The training method of the poetry entity extraction model also includes: for each piece of first poetry text information and each piece of second poetry text information, based on the first poetry text information and the second poetry text information, calculating the entity correlation data between the first poetry text information and the second poetry text information; when the entity correlation data meets the second preset condition, the second poetry text information corresponding to the entity correlation data is determined as the new second poetry text information, so as to construct an intermediate poetry training set using the new second poetry text information.

[0077] According to an embodiment of the present application, for each piece of poetry text information to be screened, the poetry text information to be screened is input into a pre-training model, and a plurality of second entity type labels are output.

[0078] After determining the second poem text information, multiple first entity type tags of the first poem text information and multiple second entity type tags of the second poem text information are used to calculate the entity correlation data between the first poem text information and the second poem text information. , as shown in formula (2):

[0079]

[0080] (2)

[0081] Among them, c i represents the second poem text information of the i-th; e k represents the kth named entity in the second poem text information; type(q) represents the type set of named entities in the first poem text information; type(e k ) represents the named entity e in the second poem text information k Type; Count(type(ek )∩type(q)) represents the number of intersections of the entity types of the second poem text information and the first poem text information; N is the total number of poem text information to be screened in the preset knowledge base, Indicates that it contains named entity e k The number of verses of poetry text information to be filtered.

[0082] According to an embodiment of the present application, when the entity relevance data satisfies the second preset condition, the second poetry text information corresponding to the entity relevance data is determined as new second poetry text information.

[0083] In a specific embodiment, the second preset condition may refer to entity correlation data Greater than a correlation threshold, such as 0.8.

[0084] In another specific embodiment, entity correlation data of multiple second poetry text information related to the first poetry text information can be Sorting is performed, and the first n (for example, the first 5) second poem text information in the numerical sorting from large to small are determined as new second poem text information, that is, the second preset condition is met.

[0085] According to an embodiment of the present application, the intermediate poetry training set is input into a preset language model to obtain a target poetry training set, including: for each first poetry text information in the intermediate poetry training set, a first target prompt word is generated according to the first poetry text information, multiple first entity type labels and multiple second poetry text information corresponding to the first poetry text information and multiple second entity type labels; the first target prompt word is input into the preset language model, and the third poetry text information corresponding to the first poetry text information is output; based on the predicted poetry training set and the intermediate poetry training set, a target poetry training set is generated, wherein the predicted poetry training set includes multiple third poetry text information.

[0086] According to an embodiment of the present application, multiple second poetry text information or multiple new second poetry text information are combined with first poetry text information, multiple first entity type labels, and multiple second entity type labels through a dynamic template fuser to generate a structured prompt (i.e., a first target prompt word) and send it to a preset language model. The preset language model uses the multiple second poetry text information or multiple new second poetry text information as context information to automatically generate new third poetry text information with spatial entity recognition labels. Finally, a target poetry training set is generated based on the predicted poetry training set and the intermediate poetry training set.

[0087] According to an embodiment of the present application, the first target prompt word As shown in formula (3):

[0088] (3)

[0089] Among them, E q represents the set of types of named entities of the first poem text information q; c in C = {c1,..., c K} K represents the text information formed according to the k-th second poem text information (or the k-th new second poem text information) and its multiple entity type tags. C is a set formed by k text information, where the size of k is equal to the number of multiple second poem text information or multiple new second poem text information. For example, k ≤ 5; represents a special separator; [CTX i ] represents a context position identifier. For example, [CTX1] represents the position identifier of the first named entity recognized; represents a concatenation operator, which concatenates all processed position identifiers in order; represents an entity highlighting mark.

[0090] In a specific embodiment, the set of types of named entities E q is defined as [TYPE: Human Landscape, Natural Landscape]; the first poem text information is [QRY] Why should the Qiang flute complain about the willows; the context position identifiers are as follows:

[0091] [CTX1] <Human Landscape> Huqin < / Human Landscape> Pipa and Qiang flute

[0092] [CTX2] The guest house is green <Natural Landscape> Willow < / Natural Landscape> is new

[0093] [CTX3] Outside Yumen Pass <Natural Landscape> Snow < / Natural Landscape> is flying

[0094] According to an embodiment of the present application, a first target prompt is generated based on the above information , and it is input into a preset language model to obtain a third poem text information.

[0095] According to an embodiment of the present application, before generating the target poem training set, it further includes: inputting a self-check instruction into the preset language model, so that the preset language model responds to the self-check instruction to perform a self-check operation on multiple third poem text information, and obtains the self-checked third poem text information, where the self-check operation includes checking the third poem text information based on the number of words and entity type tags.

[0096] According to an embodiment of the present application, after generating the third poetry text information, a self-checking instruction is appended, and the compliance of entity organization, type matching, and word length structure are self-checked through a preset language model. Then, the "PASS / FAIL" determination is output through self-reflection of the preset language model, and the incorrect samples are rejected to obtain the self-checked third poetry text information, and thus a target poetry training set can be obtained.

[0097] According to an embodiment of the present application, the first poetry text information in the initial poetry training set is input into a pre-trained model to output the first entity type label corresponding to each named entity in the first poetry text information, including: for each first poetry text information, according to the first poetry text information, poetry text examples, and task logic, a second target prompt is generated, where the poetry text examples include example text information and entity type examples corresponding to each named entity in the example text information; the second target prompt is input into the pre-trained model to output the initial type label corresponding to each named entity in the first poetry text information; based on the sequence annotation method, the first poetry text information is subjected to position marking processing using multiple initial type labels to obtain position encoding information corresponding to each initial type label; and according to the multiple initial type labels and the multiple position encoding information, the first entity type label is generated.

[0098] According to an embodiment of the present application, the sequence annotation method may refer to the BIOES label marking method. The BIOES label marking method is a sequence annotation method commonly used in natural language processing tasks, mainly used in scenarios such as named entity recognition and word segmentation. It marks the boundary positions and entity types of each word in the text through different letter combinations to help the machine understand the sentence structure. The BIOES annotation method includes five basic labels: B: the start position of the entity; I: the internal position of the entity; O: non-entity word; E: the end position of the entity; S: a single word that forms an independent entity.

[0099] For example, the poem line "A ferry boat drifts idly where no passenger is in sight" can be annotated as "野 / B-RW渡 / E-RW无 / O人 / O舟 / S-RW自 / O横 / O".

[0100] For example, the sentence "I went to the Polytechnic University" can be annotated as "我 / S-PEOPLE去 / O了 / O理 / B-ORG工 / I-ORG大 / I-ORG学 / E-ORG". Here, "我" is used as an independent person with the S label, and "理工大学" as an institution name is split into a B-I-E structure.

[0101] According to an embodiment of the present application, for each first poem text information, a prompt word project is used to generate a second target prompt word based on the first poem text information, poem text examples and task logic, and the second target prompt word is input into a preset language model to identify and classify named entities in part of the ancient poem text data set, thereby outputting the initial type label corresponding to each named entity in the first poem text information.

[0102] In a specific embodiment, according to the type of named entity, the fewshot prompt word technology in the prompt word project and the langchain library in Python are used to determine the system prompt word and generate customized instructions. The second target prompt word is generated by the customized instructions according to the specific identity, task logic, task case example, and task output format requirements. The second target prompt word is then input into the pre-trained model to obtain the initial type label corresponding to each named entity in the first poem text information.

[0103] According to an embodiment of the present application, based on the BIOES tagging method, the first poem text information is positionally tagged using multiple initial type tags to obtain position coding information corresponding to each initial type tag. The initial type tags may refer to cultural landscapes, natural landscapes, etc. A first entity type tag is generated based on the multiple initial type tags and the multiple position coding information.

[0104] Figure 3 A processing flow chart of the poetry entity extraction model according to an embodiment of the present application is shown.

[0105] According to an embodiment of the present application, a pre-trained model is trained using a target poetry training set to obtain a trained poetry entity extraction model, including: for any poetry training sample in the target poetry training set, the poetry training sample is input into a multi-head attention mechanism layer, and context-aware features of each character in the poetry training sample that are fused with context information are output; multiple context-aware features are input into a gated recurrent network, and time series extraction features containing position information are output; the time series extraction features are input into a probability graph decoding layer, and a state transition matrix and an emission probability matrix are output, wherein the pre-trained model includes a multi-head attention mechanism layer, a gated recurrent network and a probability graph decoding layer; a predicted label sequence is generated based on the state transition matrix and the emission probability matrix, wherein the predicted label sequence includes a predicted type label for each named entity in the poetry training sample; a target loss result is calculated based on multiple predicted type labels and the entity type label of each named entity; the model parameters of the pre-trained model are iteratively adjusted based on the target loss result to obtain a poetry entity extraction model.

[0106] According to the embodiments of this application, see Figure 3, input a poem training sample in the target poem training set (such as "Seeing off guests, do not pass by the Wansui Bridge") into the pre-trained bidirectional Transformer network in the encoding layer, so as to fuse the bidirectional context semantic information of the sentences in the poem training sample through the multi-head self-attention mechanism layer, and generate the context-aware features of each character.

[0107] According to an embodiment of the present application, respectively input multiple context-aware features into the forward LSTM and backward LSTM in the feature extraction layer in the forward and reverse order of characters to obtain the bidirectional fusion feature vectors of each character, and then input the bidirectional fusion feature vectors into the gated recurrent network to filter out irrelevant noise information, and obtain the denoised time-series sensitive feature vector, that is, the time-series extraction feature.

[0108] According to an embodiment of the present application, generally speaking, input the time-series sensitive feature vector into the linear classification layer (i.e., the probability graph decoding layer) to generate the state transition matrix and emission probability matrix of each character. Model the state transition matrix and emission probability matrix through the conditional random field model, and combine the predefined transition rules to output the label transition path, that is, the state transition path. Based on the emission probability matrix and transition path in the label transition path, use the Viterbi dynamic programming algorithm to calculate the globally optimal path, obtain the globally optimal label sequence, and output the predicted label sequence, where the predicted label sequence includes multiple recognized namespaces.

[0109] According to an embodiment of the present application, specifically: map the high-dimensional time-series sensitive feature vector of each character obtained by the feature extraction layer to a low-dimensional space to generate the probability distribution of each character belonging to each entity label, and output the emission probability matrix.

[0110] In the predefined transition rules, it is stipulated that the start label (B-) of the named entity must precede the middle label (I-), the end label (E-) can only follow the B or I type label, and the independent label (S-) can only appear after the O type label or the E type label.

[0111] Generate an initial transition matrix (i.e., the state transition matrix) according to the emission probability matrix through the rule parser, and use the initial transition matrix as the basic constraint framework, input the label sequence of the poem training sample into the loss function calculation module of the conditional random field for constraint optimization learning, and output the optimized transition probability matrix integrating data features. Subsequently, combine the optimized initial transition matrix with the initial label transition rules, and force the illegal transition weight to be negative infinity through the hard constraint injection algorithm, and output the transition path that conforms to the annotation specification.

[0112] The emission probability matrix and the transition path are input into the Viterbi dynamic programming algorithm. Starting from the first character, the cumulative maximum score and path source of each label position are calculated based on the transition rule, and the maximum score path is traced back from the last character to ensure that the label sequence meets the transition constraints. The final output is the optimal label sequence that is strictly aligned with the character positions in the poetry training sample and conforms to the ancient poetry entity annotation specifications, that is, the predicted label sequence.

[0113] According to an embodiment of the present application, after obtaining a predicted label sequence, the multiple predicted type labels and the entity type label of each named entity are input into a loss function to calculate a target loss result. The loss function may be a mean squared error loss function, for example. The model parameters of the pre-trained model are then iteratively adjusted based on the target loss result to obtain a poetry entity extraction model.

[0114] Figure 4 A flowchart of a poetry entity extraction method according to an embodiment of the present application is shown.

[0115] like Figure 4 As shown, the poetry entity extraction method includes operations S401 to S402.

[0116] In operation S401, a poem text to be recognized is obtained, wherein the poem text to be recognized includes at least one entity to be recognized.

[0117] In operation S402 , the poem text to be recognized is input into a poem entity extraction model, and a predicted entity type corresponding to each entity to be recognized is output.

[0118] According to an embodiment of the present application, the poem to be identified can be any poem or line, such as "The Yellow River flows from heaven." By inputting the poem to be identified into a trained poem entity extraction model, the predicted entity type for each entity to be identified in the poem can be obtained. For example, the predicted entity type for "Yellow River" is "natural landscape."

[0119] According to an embodiment of the present application, by calculating the cosine similarity data and the poetry level and tone difference data between each first poetry text information in the initial poetry training set and each poetry text information to be screened in the preset knowledge base, the comprehensive similarity generated by the cosine similarity data and the poetry level and tone difference data satisfies the first preset condition to determine whether the poetry text information to be screened is determined as the second poetry text information corresponding to the first poetry text information, and then the intermediate poetry training set containing the initial poetry training set and the second poetry text information is input into the preset language model to obtain the target poetry training set, and the pre-training model is trained using the target poetry training set to obtain the poetry entity extraction model. Since the second poetry text information is determined from the preset knowledge base through the cosine similarity data and the poetry level and tone difference data, and the preset language model is used to further enrich the number of samples in the target poetry training set, the problem of poor prediction accuracy of the poetry entity extraction model caused by the small number of poetry samples in the related art can be solved, thereby improving the accuracy of the poetry entity extraction model in extracting named entity types.

[0120] Figure 5 A block diagram of a training device for a poetry entity extraction model according to an embodiment of the present application is shown.

[0121] like Figure 5 As shown, the training device 500 for the poetry entity extraction model includes a first prediction module 510, a calculation module 520, a generation module 530, a determination module 540, an acquisition module 550, and a training module 560.

[0122] The first prediction module 510 is used to input the first poem text information in the initial poem training set into the pre-training model, and output multiple first entity type labels corresponding to each named entity in the first poem text information.

[0123] The calculation module 520 is used to calculate the cosine similarity data and the poetry level and tone difference data between the first poetry text information and each poetry text information to be screened in the preset knowledge base, wherein the preset knowledge base also includes a second entity type label corresponding to each poetry text information to be screened.

[0124] The generation module 530 is used to generate a comprehensive similarity for each poem text information to be screened based on the cosine similarity data and the poem level and tone difference data.

[0125] The determination module 540 is configured to determine the poem text information to be filtered as the second poem text information corresponding to the first poem text information when the comprehensive similarity satisfies a first preset condition.

[0126] Obtain module 550, which is used to input the intermediate poetry training set into a preset language model to obtain a target poetry training set, wherein the intermediate poetry training set includes multiple first poetry text information and multiple first entity type labels corresponding to each first poetry text information, multiple second poetry text information and multiple second entity type labels.

[0127] The training module 560 is used to train the pre-trained model using the target poetry training set to obtain a trained poetry entity extraction model.

[0128] According to an embodiment of the present application, by calculating the cosine similarity data and the poetry level and tone difference data between each first poetry text information in the initial poetry training set and each poetry text information to be screened in the preset knowledge base, the comprehensive similarity generated by the cosine similarity data and the poetry level and tone difference data satisfies the first preset condition to determine whether the poetry text information to be screened is determined as the second poetry text information corresponding to the first poetry text information, and then the intermediate poetry training set containing the initial poetry training set and the second poetry text information is input into the preset language model to obtain the target poetry training set, and the pre-training model is trained using the target poetry training set to obtain the poetry entity extraction model. Since the second poetry text information is determined from the preset knowledge base through the cosine similarity data and the poetry level and tone difference data, and the preset language model is used to further enrich the number of samples in the target poetry training set, the problem of poor prediction accuracy of the poetry entity extraction model caused by the small number of poetry samples in the related art can be solved, thereby improving the accuracy of the poetry entity extraction model in extracting named entity types.

[0129] Figure 6 A block diagram of a training device for a poetry entity extraction model according to an embodiment of the present application is shown.

[0130] like Figure 6 As shown, the poetry entity extraction device 600 includes an acquisition module 610 and a second prediction module 620.

[0131] The acquisition module 610 is used to acquire the poem text to be recognized, wherein the poem text to be recognized includes at least one entity to be recognized.

[0132] The second prediction module 620 is used to input the poem text to be identified into the poem entity extraction model and output the predicted entity type corresponding to each entity to be identified.

[0133] According to an embodiment of the present application, by calculating the cosine similarity data and the poetry level and tone difference data between each first poetry text information in the initial poetry training set and each poetry text information to be screened in the preset knowledge base, the comprehensive similarity generated by the cosine similarity data and the poetry level and tone difference data satisfies the first preset condition to determine whether the poetry text information to be screened is determined as the second poetry text information corresponding to the first poetry text information, and then the intermediate poetry training set containing the initial poetry training set and the second poetry text information is input into the preset language model to obtain the target poetry training set, and the pre-training model is trained using the target poetry training set to obtain the poetry entity extraction model. Since the second poetry text information is determined from the preset knowledge base through the cosine similarity data and the poetry level and tone difference data, and the preset language model is used to further enrich the number of samples in the target poetry training set, the problem of poor prediction accuracy of the poetry entity extraction model caused by the small number of poetry samples in the related art can be solved, thereby improving the accuracy of the poetry entity extraction model in extracting named entity types.

[0134] According to the embodiments of the present application, any number of modules, submodules, units, and subunits, or at least part of the functions of any number of them, can be implemented in one module. According to the embodiments of the present application, any one or more of the modules, submodules, units, and subunits can be split into multiple modules for implementation. According to the embodiments of the present application, any one or more of the modules, submodules, units, and subunits can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on a chip, a system on a substrate, a system on a package, an application-specific integrated circuit (ASIC), or can be implemented by hardware or firmware in any other reasonable way of integrating or packaging the circuit, or can be implemented in any one of the three implementation methods of software, hardware, and firmware, or in any appropriate combination of any of them. Alternatively, according to the embodiments of the present application, one or more of the modules, submodules, units, and subunits can be at least partially implemented as a computer program module, which can perform the corresponding functions when the computer program module is executed.

[0135] It should be noted that the training device and the poetry entity extraction device of the poetry entity extraction model in the embodiments of the present application correspond to the training method and the poetry entity extraction method of the poetry entity extraction model in the embodiments of the present application. The description of the training device and the poetry entity extraction device of the poetry entity extraction model specifically refers to the training method and the poetry entity extraction method of the poetry entity extraction model, and will not be repeated here.

[0136] Figure 7 A block diagram of an electronic device suitable for implementing the method described above according to an embodiment of the present application is shown. Figure 7The electronic device shown is merely an example and should not limit the functions and scope of use of the embodiments of the present application.

[0137] like Figure 7 As shown, the electronic device 700 according to an embodiment of the present application includes a processor 701, which can perform various appropriate actions and processes according to a program stored in a read-only memory 702 or a program loaded from a storage unit 708 into a random access memory 703. The processor 701 may include, for example, a general-purpose microprocessor (e.g., a CPU), an instruction set processor and / or a related chipset and / or a special-purpose microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 701 may also include onboard memory for caching purposes. The processor 701 may include a single processing unit or multiple processing units for performing different actions of the method flow according to the embodiment of the present application.

[0138] Various programs and data required for the operation of the electronic device 700 are stored in the random access memory 703. The processor 701, the read-only memory 702, and the random access memory 703 are connected to each other via a bus 704. The processor 701 performs various operations of the method flow according to the embodiment of the present application by executing the programs in the read-only memory 702 and / or the random access memory 703. It should be noted that the program can also be stored in one or more memories other than the read-only memory 702 and the random access memory 703. The processor 701 can also perform various operations of the method flow according to the embodiment of the present application by executing the programs stored in the one or more memories.

[0139] According to an embodiment of the present application, electronic device 700 may further include an input / output interface 705, which is also connected to bus 704. Electronic device 700 may also include one or more of the following components connected to input / output interface 705: an input portion 706 including a keyboard, mouse, etc.; an output portion 707 including devices such as a cathode ray tube (CRT), liquid crystal display (LCD), and speakers; a storage portion 708 including a hard disk; and a communication portion 709 including a network interface card such as a LAN card or modem. Communication portion 709 performs communication processing via a network such as the Internet. A drive 710 is also connected to input / output interface 705 as needed. Removable media 711, such as a magnetic disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed in drive 710 as needed, so that computer programs read from the removable media can be installed into storage portion 708 as needed.

[0140] According to an embodiment of the present application, the method flow according to the embodiment of the present application can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a computer-readable storage medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 709, and / or installed from the removable medium 711. When the computer program is executed by the processor 701, the above-mentioned functions defined in the system of the embodiment of the present application are executed. According to an embodiment of the present application, the system, equipment, device, module, unit, etc. described above can be implemented by a computer program module.

[0141] This application also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments, or may exist independently and not be incorporated into the device / apparatus / system. The computer-readable storage medium carries one or more programs, and when the one or more programs are executed, the method according to the embodiments of this application is implemented.

[0142] According to embodiments of the present application, a computer-readable storage medium may be a non-volatile computer-readable storage medium. Examples include, but are not limited to, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present application, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.

[0143] An embodiment of the present application also includes a computer program product, which includes a computer program, which contains program code for executing the method provided by the embodiment of the present application. When the computer program product is run on an electronic device, the program code is used to enable the electronic device to implement the method provided by the embodiment of the present application.

[0144] When the computer program is executed by the processor 701, the above functions defined in the system / device of the embodiment of the present application are performed. According to the embodiment of the present application, the system, device, module, unit, etc. described above can be implemented by a computer program module.

[0145] According to an embodiment of the present application, the program code for executing the computer program provided by the embodiment of the present application can be written in any combination of one or more programming languages. Specifically, these computer programs can be implemented using high-level procedural and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages ​​include, but are not limited to, languages ​​such as Java, C++, Python, "C" or similar programming languages. The program code can be executed entirely on the user computing device, partially on the user device, partially on a remote computing device, or entirely on a remote computing device or server. In the case of a remote computing device, the remote computing device can be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computing device (for example, using an Internet service provider to connect via the Internet).

[0146] The embodiments of the present application have been described above. However, these embodiments are for illustrative purposes only and are not intended to limit the scope of the present application. Although each embodiment has been described separately above, this does not mean that the measures in each embodiment cannot be advantageously used in combination. The present application does not depart from the scope of the present application, and those skilled in the art may make various substitutions and modifications, which should all fall within the scope of the present application.

Claims

1. A training method for a poetry entity extraction model, characterized in that: include: Inputting the first poem text information in the initial poem training set into the pre-training model, and outputting a plurality of first entity type labels corresponding to each named entity in the first poem text information; Calculating cosine similarity data and poetry level and tone difference data between the first poetry text information and each poetry text information to be screened in a preset knowledge base, wherein the preset knowledge base also includes a second entity type label corresponding to each poetry text information to be screened; For each of the poetry text information to be screened, generating a comprehensive similarity based on the cosine similarity data and the poetry level and tone difference data; In the case where the comprehensive similarity satisfies a first preset condition, determining the poem text information to be screened as the second poem text information corresponding to the first poem text information; Inputting the intermediate poetry training set into a preset language model to obtain a target poetry training set, wherein the intermediate poetry training set includes a plurality of first poetry text information and a plurality of first entity type labels corresponding to each first poetry text information, a plurality of second poetry text information and a plurality of second entity type labels; The pre-trained model is trained using the target poetry training set to obtain a trained poetry entity extraction model; The intermediate poetry training set is input into the preset language model to obtain the target poetry training set, including: For each first poem text information in the intermediate poem training set, generating a first target prompt word according to the first poem text information, a plurality of first entity type labels, and a plurality of second poem text information corresponding to the first poem text information and a plurality of second entity type labels; Inputting the first target prompt word into the preset language model, and outputting third poem text information corresponding to the first poem text information; The target poetry training set is generated based on the predicted poetry training set and the intermediate poetry training set, wherein the predicted poetry training set includes a plurality of the third poetry text information.

2. The method according to claim 1, characterized in that Calculating cosine similarity data and prosodic difference data between the first poem text information and each poem text information to be screened in a preset knowledge base, including: Performing semantic vector conversion and level-tone coding conversion on the plurality of the first poetry text information to obtain a first poetry semantic vector and first poetry level-tone coding information corresponding to each of the first poetry text information, and performing semantic vector conversion and level-tone coding conversion on the plurality of the poetry text information to be screened to obtain a second poetry semantic vector and second poetry level-tone coding information corresponding to each of the poetry text information to be screened; For each of the first poetry text information and each of the poetry text information to be screened, cosine similarity data and poetry prosody difference data between the first poetry text information and the poetry text information to be screened are generated based on the first poetry semantic vector, the first poetry prosody coding information, the second poetry semantic vector and the second poetry prosody coding information.

3. The method according to claim 2, characterized in that Generating cosine similarity data and poetry level and tone difference data between the first poetry text information and the poetry text information to be screened according to the first poetry semantic vector, the first poetry level and tone coding information, the second poetry semantic vector, and the second poetry level and tone coding information, including: Calculating cosine similarity data between the first poem semantic vector and the second poem semantic vector based on a cosine similarity function; Calculate the poetry prosody difference data between the first poetry prosody coding information and the second poetry prosody coding information.

4. The method according to any one of claims 2 to 3, characterized in that The second entity type label is generated in the following manner: For each of the poetry text information to be screened, input the poetry text information to be screened into the pre-trained model, and output a plurality of second entity type labels; The method further comprises: For each first poem text information and each second poem text information, calculating entity correlation data between the first poem text information and the second poem text information based on multiple first entity type tags of the first poem text information and multiple second entity type tags of the second poem text information; In the case where the entity relevance data satisfies a second preset condition, determining the second poem text information corresponding to the entity relevance data as new second poem text information, so as to construct the intermediate poem training set using the new second poem text information; Among them, the entity-related data As shown below: (2) Among them, c i represents the second poem text information of the i-th; e k represents the kth named entity in the second poem text information; type(q) represents the type set of named entities in the first poem text information; type(e k ) represents the named entity e in the second poem text information k Type; Count(type(e k )∩type(q)) represents the number of intersections of the entity types of the second poem text information and the first poem text information; N is the total number of poem text information to be screened in the preset knowledge base, Indicates that it contains named entity e k The number of verses of poetry text information to be filtered.

5. The method according to claim 1, wherein Before generating the target poetry training set, the method further includes: A self-check instruction is input into the preset language model so that the preset language model performs a self-check operation on the plurality of third poetry text information in response to the self-check instruction to obtain the third poetry text information after self-check, wherein the self-check operation includes checking the third poetry text information based on the number of words and entity type labels.

6. The method according to claim 1, characterized in that Inputting the first poem text information in the initial poem training set into the pre-training model, and outputting the first entity type label corresponding to each named entity in the first poem text information, including: For each of the first poetry text information, generating a second target prompt word according to the first poetry text information, a poetry text sample, and task logic, wherein the poetry text sample includes sample text information and an entity type sample corresponding to each named entity in the sample text information; Inputting the second target prompt word into the pre-trained model, and outputting the initial type label corresponding to each named entity in the first poem text information; Based on a sequence labeling method, position tagging processing is performed on the first poem text information using the multiple initial type tags to obtain position coding information corresponding to each initial type tag; The first entity type label is generated according to the multiple initial type labels and the multiple position encoding information.

7. The method according to claim 1 or 6, characterized in that The pre-trained model is trained using the target poetry training set to obtain a trained poetry entity extraction model, including: For any poetry training sample in the target poetry training set, input the poetry training sample into the multi-head attention mechanism layer, and output the context-aware features of each character in the poetry training sample that are integrated with context information; Inputting the plurality of context-aware features into a gated recurrent network and outputting a temporal extraction feature containing position information; Inputting the time series extracted features into a probabilistic graph decoding layer and outputting a state transition matrix and an emission probability matrix, wherein the pre-trained model includes the multi-head attention mechanism layer, the gated recurrent network, and the probabilistic graph decoding layer; Generate a predicted label sequence according to the state transition matrix and the emission probability matrix, wherein the predicted label sequence includes a predicted type label for each of the named entities in the poetry training sample; Calculating a target loss result based on the plurality of predicted type labels and the entity type label of each of the named entities; The model parameters of the pre-trained model are iteratively adjusted according to the target loss result to obtain the poetry entity extraction model.

8. A method for extracting poetry entities, characterized in that: include: Acquire a poem text to be recognized, wherein the poem text to be recognized includes at least one entity to be recognized; Input the poem text to be identified into the poem entity extraction model, and output the predicted entity type corresponding to each entity to be identified; Wherein, the poetry entity extraction model is trained by the method described in any one of claims 1 to 7.

9. An electronic device comprising: one or more processors; a memory for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors are enabled to implement the method according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • A method for determining text similarity and a related device

    CN109597878A

  • Entity recognition model generation method, computing equipment and readable storage medium

    CN113378570A

  • Power grid fault plan entity identification method, device, equipment, medium and product

    CN119670754A