Poem entity extraction model training method, poem entity extraction method and poem entity extraction equipment

By calculating the cosine similarity data and the level and tone difference data between the text information of poetry, and enriching the training set with the preset language model, the problem of inaccurate labeling of named entities caused by insufficient samples of ancient poetry is solved, and the accuracy of the poetry entity extraction model is improved.

CN120277219AActive Publication Date: 2025-07-08TIANJIN UNIV
View PDF 11 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

Due to the small number of ancient poetry training samples, the existing poetry entity extraction model is not accurate enough when processing poetry data.

Method used

By calculating the cosine similarity data 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 when the preset conditions are met, the training set is enriched with the preset language model and model training is carried out.

Benefits of technology

The accuracy of the poetry entity extraction model for named entity types is improved, and the problem of poor prediction accuracy caused by small samples is solved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120277219A_ABST
    Figure CN120277219A_ABST
Patent Text Reader

Abstract

The invention provides a poem entity extraction model training method, a poem entity extraction method and equipment, and the method comprises the steps: inputting first poem text information in an initial poem training set into a pre-training model, and outputting a first entity type label corresponding to each named entity in the first poem text information; calculating cosine similar data and poem level and oblique pattern difference data between the first poem text information and each piece of to-be-screened poem text information in a preset knowledge base; aiming at each piece of to-be-screened poem text information, generating a comprehensive similarity according to the cosine similar data and the poem level and oblique difference data; under the condition that the comprehensive similarity meets a first preset condition, determining the to-be-screened poem text information as second poem text information corresponding to the first poem text information; inputting the middle poem training set into a preset language model to obtain a target poem training set; and training the pre-training model by using the target poem training set to obtain a trained poem entity extraction model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

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

[0002] Ancient Chinese poetry is an important spatial cognitive expression in classical culture. Mining the spatial information in poetry texts plays a supporting role in understanding the living environment, discovering regional cultural characteristics, and inheriting aesthetic ideas. A spatial entity is a text that uses natural language to describe spatial elements such as geographical locations, buildings and structures, and landscape features, as well as to describe related activities and feelings. It is a named entity with spatial position attributes and its extended parts.

[0003] In the process of implementing the concept of the present application, it is found that for poetry texts, due to the small number of training samples, the types of named entities marked by the poetry entity extraction model trained thereby are not accurate enough when processing poetry data. Summary of the Invention

[0004] In view of this, the present application provides a method for training a poetry entity extraction model, a method for extracting poetry entities, a device for training a poetry entity extraction model, a device for extracting poetry entities, 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, including:

[0006] Inputting the first poetry text information in the initial poetry training set into a pre-trained model, and outputting multiple first entity type tags corresponding to each named entity in the first poetry text information;

[0007] Calculating the cosine similarity data and the poetry prosody 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 further includes a second entity type tag corresponding to each poetry text information to be screened;

[0008] Generating a comprehensive similarity for each poetry text information to be screened according to the cosine similarity data and the poetry prosody difference data;

[0009] When the comprehensive similarity meets the first preset condition, determining the poetry text information to be screened as the second poetry text information corresponding to the first poetry text information;

[0010] Input the intermediate poetry training set into a preset language model to obtain a target poetry training set, where 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;

[0011] Use the target poetry training set to train a pre-trained model to obtain a trained poetry entity extraction model.

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

[0013] Obtain a poetry text to be recognized, where the poetry text to be recognized includes at least one entity to be recognized;

[0014] Input the poetry text to be recognized into the poetry entity extraction model, and output the predicted entity type corresponding to each entity to be recognized.

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

[0016] A first prediction module for inputting the first poetry text information in the initial poetry training set into the pre-trained model and outputting multiple first entity type labels corresponding to each named entity in the first poetry text information;

[0017] A calculation module for calculating the cosine similarity data and poetry prosody difference data between the first poetry text information and each poetry text information to be screened in the preset knowledge base, where the preset knowledge base also includes second entity type labels corresponding to each poetry text information to be screened;

[0018] A generation module for generating a comprehensive similarity for each poetry text information to be screened according to the cosine similarity data and poetry prosody difference data;

[0019] A determination module for determining the poetry text information to be screened as the second poetry text information corresponding to the first poetry text information when the comprehensive similarity meets the first preset condition;

[0020] An obtaining module for inputting the intermediate poetry training set into a preset language model to obtain a target poetry training set, where 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;

[0021] A training module for using the target poetry training set to train the pre-trained model to obtain a trained poetry entity extraction model.

[0022] Another aspect of the present application provides a poem entity extraction device, including:

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

[0024] A second prediction module, configured to input the poem text to be recognized into a poem entity extraction model and output a predicted entity type corresponding to each entity to be recognized.

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

[0026] One or more processors;

[0027] A memory, configured to store one or more programs,

[0028] wherein, when the one or more programs are executed by the one or more processors, the one or more processors are caused to 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 as described above when executed.

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

[0031] According to the embodiments of the present application, by calculating the cosine similarity data and the poem prosody difference data between each first poem text information in the initial poem training set and each poem text information to be screened in the preset knowledge base, and determining whether the comprehensive similarity generated according to the cosine similarity data and the poem prosody difference data meets the first preset condition, to determine whether to determine the poem text information to be screened as the second poem text information corresponding to the first poem text information, and then inputting the intermediate poem training set including the initial poem training set and the second poem text information into the preset language model to obtain the target poem training set, and using the target poem training set to train the pre-trained model to obtain the poem entity extraction model. Since the second poem text information is determined from the preset knowledge base through the cosine similarity data and the poem prosody difference data, and the preset language model is used to further enrich the number of samples in the target poem training set, the problem of poor prediction accuracy of the poem entity extraction model caused by fewer poem samples in the related art can be solved, thereby improving the accuracy of the poem entity extraction model in extracting the named entity type. Description of the Drawings

[0032] Through the following description of the embodiments of the present application with reference to the accompanying drawings, the above and other objects, features, and advantages of the present application will become clearer. In the drawings:

[0033] Figure 1 An exemplary system architecture is shown that can apply the training method or the poem entity extraction method of the poem entity extraction model according to an embodiment of the present application;

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

[0035] Figure 3 A processing flowchart of the poem entity extraction model according to an embodiment of the present application is shown;

[0036] Figure 4 A flowchart of the poem entity extraction method according to an embodiment of the present application is shown;

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

[0038] Figure 6 A block diagram of the training device of the poem 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 Embodiments

[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 merely exemplary and are not intended to limit the scope of the present application. In the following detailed description, for the sake of explanation, many specific details are set forth to provide a comprehensive understanding of the embodiments of the present application. However, obviously, one or more embodiments can also be implemented without these specific details. In addition, in the following description, descriptions of well-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 "including", "comprising", 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 of ordinary skill 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] In cases where expressions similar to "at least one of A, B, and C, etc." are used, generally, it should be interpreted according to the meaning commonly understood by those of ordinary skill in the art (for example, "a system having at least one of A, B, and C" should include, but not be limited to, a system having only A, only B, only C, having A and B, having A and C, having B and C, and / or having A, B, and C, etc.).

[0044] Currently, the commonly used methods for named entity recognition mainly include: rule-based methods, traditional machine learning-based methods, and deep learning-based methods. Rule-based methods need to rely on domain experts for compilation, which takes a long time, and it is difficult to exhaustively list all the rules and patterns of entity occurrences manually, and they cannot adapt to the complex and variable language expression forms of ancient Chinese poems. Traditional machine learning-based methods mainly use large-scale labeled corpora for probability model training. Traditional machine learning-based methods can automatically learn language features and have stronger generalization ability. With the further development of machine learning, deep learning-based methods have received further attention. Although it is no longer necessary to manually select complex feature sets as the model training set like traditional machine learning methods, a larger-scale corpus is required.

[0045] Related research mainly focuses on generating labeled corpora for the recognition of modern vernacular Chinese, but ancient Chinese poems are quite different from modern texts and ordinary Chinese texts in terms of structural patterns and grammatical expressions, and there is no directly available large-scale labeled corpus of ancient Chinese poems. Therefore, in the absence of sufficient labeled data, the effectiveness of traditional supervised learning methods is limited, and small-sample learning methods should be adopted for research.

[0046] In view of this, the embodiments of the present application provide a method for training a poetry entity extraction model, a poetry entity extraction method, and a device. The method includes inputting the first poetry text information in the initial poetry training set into a pre-trained model to output multiple first entity type tags corresponding to each named entity in the first poetry text information; calculating the cosine similarity data and the poetry tonal pattern difference data between the first poetry text information and each poetry text information to be screened in the preset knowledge base, where the preset knowledge base further includes a second entity type tag corresponding to each poetry text information to be screened; for each poetry text information to be screened, generating a comprehensive similarity according to the cosine similarity data and the poetry tonal pattern difference data; in the case where the comprehensive similarity meets the 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, where the intermediate poetry training set includes multiple first poetry text information and multiple first entity type tags corresponding to each first poetry text information, multiple second poetry text information, and multiple second entity type tags; and training the pre-trained model using the target poetry training set to obtain a trained poetry entity extraction model.

[0047] In the embodiments of the present application, in aspects such as the collection, update, analysis, processing, use, transmission, provision, disclosure, storage, etc. of the data involved (for example, including but not limited to user personal information), they all comply with the provisions of relevant laws and regulations, are used for legal purposes, and do not violate public order and good customs. In particular, necessary measures are taken for user personal information to prevent illegal access to user personal information data and to maintain the security of user personal information and network security.

[0048] Figure 1 It shows an exemplary system architecture to which the method for training a poetry entity extraction model or the poetry entity extraction method according to the embodiments of the present application can be applied. It should be noted that Figure 1 What is shown is only an example of the 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 it does not mean that the embodiments of the present application cannot be used in other devices, systems, environments, or scenarios.

[0049] As Figure 1 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 to provide a medium for 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] Users can interact with the server 105 via the network 104 using the first terminal device 101, the second terminal device 102, and the third terminal device 103 to receive or send messages, etc. Various communication client applications can be installed on the first terminal device 101, the second terminal device 102, and the third terminal device 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, and / or social platform software, etc. (for example only).

[0051] The first terminal device 101, the second terminal device 102, and the third terminal device 103 can be various electronic devices with a display screen and supporting web browsing, including but not limited to smartphones, tablets, laptop computers, and desktop computers, etc.

[0052] The server 105 can be a server providing various services, such as a background management server that supports the websites browsed by users using the first terminal device 101, the second terminal device 102, and the third terminal device 103 (for example only). The background management server can analyze and process data such as received user requests, etc., and feedback the processing results (such as web pages, information, or data obtained or generated according to user requests, etc.) to the terminal device.

[0053] It should be noted that the training method of the poetry entity extraction model and the poetry entity extraction method provided by the embodiments of the present application can generally be executed by the server 105. Correspondingly, the training device and the poetry entity extraction device of the poetry entity extraction model provided by the embodiments 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 by the embodiments of the present application can also be executed by a server or a server cluster different from the server 105 and capable of communicating with the first terminal device 101, the second terminal device 102, the third terminal device 103, and / or the server 105. Correspondingly, the training device and the poetry entity extraction device of the poetry entity extraction model provided by the embodiments of the present application can also be set in a server or a server cluster different from the server 105 and capable of communicating 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 of the poetry entity extraction model and the poetry entity extraction method provided by the embodiments of the present application can also be executed by the first terminal device 101, the second terminal device 102, or the third terminal device 103, or can also be executed by other terminal devices different from the first terminal device 101, the second terminal device 102, or the third terminal device 103. Correspondingly, the training device and the poetry entity extraction device of the poetry entity extraction model provided by the embodiments of the present application can also be set in the first terminal device 101, the second terminal device 102, or the third terminal device 103, or set 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 numbers of terminal devices, networks, and servers in

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

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

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

[0058] In operation S202, the cosine similarity data and the poetry prosody difference data between the first poetry text information and each to-be-screened poetry text information in the preset knowledge base are calculated, where the preset knowledge base further includes second entity type labels corresponding to each to-be-screened poetry text information.

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

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

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

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

[0063] According to an embodiment of the present application, the first poem text information may be ancient poems and / or modern poems downloaded from a poem website, etc., or obtained by performing optical character recognition on a poem book. In order to improve the text accuracy of the first poem text information, it can be pre-processed such as data cleaning, etc., so as to form an initial poem training set using the cleaned first poem text information. The poem text information to be screened in the preset knowledge base may 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 may refer to the type of the named entity, and the types include locations, cultural landscapes, natural landscapes, spatial functions, spatial perceptions, etc. For example, "The guest house is green with willows fresh" or "<Cultural landscape>Huqin< / Cultural landscape>, pipa and Qiang flutes", where "< / Natural landscape>willows" means 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 may be any type of large language model (LLM), such as the LLaMA 3 model, etc. The pre-trained model may 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 calculation of the cosine similarity data and the poem prosody difference data between the first poem text information and each piece of poem text information to be screened in the preset knowledge base, a weighted sum of the cosine similarity data and the poem prosody difference data can be obtained to get the comprehensive similarity between the first poem text information and the poem text information to be screened. If the comprehensive similarity meets the first preset condition, the poem text information to be screened can be determined as the second poem text information corresponding to the first poem text information. Among them, meeting the first preset condition can refer to meeting a 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, a plurality of first poem text information in the initial poem training set and a plurality of first entity type labels corresponding to each first poem text information, a plurality of second poem text information and a plurality of second entity type labels are used to form an intermediate poem training set. Then, the intermediate poem training set is input into a preset language model to obtain a target poem training set. Among them, the target poem training set not only includes the intermediate poem training set, but also includes the predicted poem text information output by the preset language model. Thus, the pre-trained model can be trained using the target poem training set to obtain a trained poem entity extraction model.

[0068] According to an embodiment of the present application, by calculating the cosine similarity data and the poem prosody difference data between each first poem text information in the initial poem training set and each piece of poem text information to be screened in the preset knowledge base, it is determined whether to determine the poem text information to be screened as the second poem text information corresponding to the first poem text information according to whether the comprehensive similarity generated based on the cosine similarity data and the poem prosody difference data meets the first preset condition. Then, the intermediate poem training set containing the initial poem training set and the second poem text information is input into a preset language model to obtain a target poem training set, and the target poem training set is used to train the pre-trained model to obtain a poem entity extraction model. Since the second poem text information is determined from the preset knowledge base through the cosine similarity data and the poem prosody difference data, and the preset language model is used to further enrich the number of samples in the target poem training set, the problem of poor prediction accuracy of the poem entity extraction model caused by fewer poem samples in the related art can be solved, thereby improving the accuracy of the poem entity extraction model in extracting the named entity type.

[0069] According to an embodiment of the present application, 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 are calculated, including: performing semantic vector conversion and level and tone coding conversion on multiple first poetry text information to obtain a first poetry semantic vector and a first poetry level and tone coding information corresponding to each first poetry text information, and performing semantic vector conversion and level and tone coding conversion on multiple poetry text information to be screened to obtain a second poetry semantic vector and a second poetry level and tone coding information corresponding to each poetry text information to be screened; for each first poetry text information and poetry text information to be screened, cosine similarity data and poetry level and tone difference data between the first poetry text information and the poetry text information to be screened are generated 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.

[0070] According to an embodiment of the present application, for the first poetry text information and / or the poetry text information to be screened, the poetry is encoded based on its level and tone. For example, the poetry level and tone encoding information of "平平仄仄平" is [1,1,0,0,1]. At the same time, the semantics of the poetry is converted into a vector, thereby obtaining a first poetry semantic vector corresponding to each first poetry text information and a second poetry semantic vector corresponding to each poetry text information to be screened.

[0071] According to an embodiment of the present application, for each first poem text information and poem text information to be screened, cosine similarity data and poem level and tone difference data between the first poem text information and the poem text information to be screened are generated based on the first poem semantic vector, the first poem level and tone coding information, the second poem semantic vector and the second poem level and tone coding information.

[0072] According to an embodiment of the present application, based on the first poem semantic vector, the first poem prosody coding information, the second poem semantic vector and the second poem prosody coding information, cosine similarity data and poem prosody difference data are generated between the first poem text information and the poem text information to be screened, including: calculating the cosine similarity data between the first poem semantic vector and the second poem semantic vector based on the cosine similarity function; calculating the poem prosody difference data between the first poem prosody coding information and the second poem prosody coding information.

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

[0074] (1)

[0075] in, The first poem prosody encoding information representing the first poem text information q; EditDistance: The number of different steps between the first poem prosody encoding information and the second poem prosody encoding information calculated by the dynamic programming algorithm, that is, the poem prosody difference data; , respectively represent the first poem semantic vector of the first poem text information q and the second poem semantic vector of the j-th poem text information to be screened, d j represents the j-th poem text to be screened in the preset knowledge base, represents the cosine similarity data, and 0.7 and 0.3 are weighting coefficients, and their values can be modified and replaced according to requirements.

[0076] According to an embodiment of the present application, the second entity type label is generated in the following manner: for each poem text information to be screened, the poem text information to be screened is input into a pre-trained model, and multiple second entity type labels are output. The training method of the poem entity extraction model further includes: for each first poem text information and each second poem text information, calculate the entity correlation data between the first poem text information and the second poem text information according to the first poem text information and the second poem text information; when the entity correlation data meets the second preset condition, determine the second poem text information corresponding to the entity correlation data as the new second poem text information, so as to construct an intermediate poem training set by using the new second poem text information.

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

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

[0079]

[0080] (2)

[0081] where c i represents the i-th second poem text information; e k represents the k-th named entity in the second poem text information; type(q) represents the set of types of named entities in the first poem text information; type(e k ) represents the type of the named entity e k in the second poem text information; 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, represents the poem lines of the poem text information to be screened that contain the named entity e k

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

[0083] In a specific embodiment, the second preset condition may refer to the entity correlation data being greater than the correlation threshold, for example, 0.8.

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

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

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

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

[0088] ​ (3)

[0089] Among them, E q represents the set of types of named entities of the first poetry text information q; c in C = {c1,..., c K} K represents the text information formed according to the k-th second poetry text information (or the k-th new second poetry 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 poetry text information or multiple new second poetry text information. For example, k ≤ 5; represents a special delimiter; [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 poetry 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> color is new

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

[0094] According to the 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 poetry text information.

[0095] According to the embodiment of the present application, before generating the target poetry 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 poetry text information, and obtain the self-checked third poetry text information, where the self-check operation includes checking the third poetry text information based on the number of words and entity type tags.

[0096] According to an embodiment of the present application, a self-check instruction is added after the third poetry text information is generated, and the entity organization compliance, type matching and word length structure are self-checked through a preset language model. The preset language model then self-reflects and outputs a "PASS / FAIL" judgment to reject erroneous samples, thereby obtaining the third poetry text information after self-check, and then the target poetry training set can be obtained.

[0097] According to an embodiment of the present application, the first poem text information in the initial poem training set is input into a pre-training model, and the first entity type label corresponding to each named entity in the first poem text information is output, including: for each first poem text information, a second target prompt word is generated according to the first poem text information, a poem text sample and task logic, wherein the poem text sample includes sample text information and an entity type sample corresponding to each named entity in the sample text information; the second target prompt word is input into the pre-training model, and the initial type label corresponding to each named entity in the first poem text information is output; based on the sequence labeling method, the first poem text information is positionally marked using multiple initial type labels to obtain position coding information corresponding to each initial type label; and a first entity type label is generated based on multiple initial type labels and multiple position coding information.

[0098] According to an embodiment of the present application, the sequence labeling method may refer to the BIOES tagging method, which is a sequence labeling method commonly used in natural language processing tasks, mainly used in named entity recognition, word segmentation and other scenarios. It uses different letter combinations to mark the boundary position and entity type of each word in the text to help the machine understand the sentence structure. The BIOES labeling method contains five basic tags: ‌B‌: the starting 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 is an independent entity.

[0099] For example, the line “The boat lies alone at the wild ferry” can be annotated as “The boat lies alone at the wild ferry”.

[0100] For example, the sentence "I went to Polytechnic University" can be labeled as "I / S-PEOPLE went / O to / O Polytechnic University / B-ORG Engineering / I-ORG University / I-ORG Study / E-ORG". Here, "I" is used as an independent person using the S label, and "Polytechnic University" as the name of an institution is split into a BIE structure.

[0101] According to an embodiment of the present application, for each first poem text information, using prompt engineering based on the first poem text information, poem text examples, and task logic, a second target prompt is generated, and the second target prompt is input into a preset language model to identify and classify named entities in a partial ancient poem text dataset, so as to output 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, using the few-shot prompt technique in prompt engineering and the langchain library in Python, a system prompt is determined, and a customized instruction is generated. Through the customized instruction, a second target prompt is generated by generating specific identities, task logic, task case examples, and task output format requirements. Then, the second target prompt is 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 tag marking method, the first poem text information is subjected to position marking processing using multiple initial type labels to obtain position encoding information corresponding to each initial type label, where the initial type label may refer to human landscapes, natural landscapes, etc. According to the multiple initial type labels and the multiple position encoding information, a first entity type label is generated.

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

[0105] According to an embodiment of the present application, the pre-trained model is trained using a target poem training set to obtain a trained poem entity extraction model, including: for any poem training sample in the target poem training set, inputting the poem training sample into the multi-head attention mechanism layer to output context-aware features with context information fused for each character in the poem training sample; inputting the multiple context-aware features into a gated recurrent network to output temporal extraction features including position information; inputting the temporal extraction features into a probabilistic graph decoding layer to output a state transition matrix and an emission probability matrix, where the pre-trained model includes a multi-head attention mechanism layer, a gated recurrent network, and a probabilistic graph decoding layer; generating a predicted label sequence according to the state transition matrix and the emission probability matrix, where the predicted label sequence includes the predicted type label of each named entity in the poem training sample; calculating a target loss result according to the multiple predicted type labels and the entity type label of each named entity; and iteratively adjusting the model parameters of the pre-trained model according to the target loss result to obtain the poem entity extraction model.

[0106] According to an embodiment of the present application, refer to Figure 3, input a poem training sample (such as "Seeing off guests, don't pass by the Wansui Bridge") in the target poem training set 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, 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 respectively, obtain the bidirectional fusion feature vector of each character, and then input the bidirectional fusion feature vector into the gated recurrent network to filter out irrelevant noise information, and obtain the noise-reduced 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, combine the predefined transition rules, 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, 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 incorporating data features. Subsequently, combine the optimized initial transition matrix with the initial label transition rules, and force the illegal transition weights to be negative infinity through the hard constraint injection algorithm, and output the transition path that conforms to the annotation specification.

[0112] Input the emission probability matrix and the transition path into the Viterbi dynamic programming algorithm. Starting from the first character, calculate the cumulative maximum score and the path source for each tag position based on the transition rules, and backtrack the maximum score path from the last character to ensure that the tag sequence satisfies the transition constraint conditions. Finally, output the optimal tag sequence that is strictly aligned with the character positions in the poem training sample and conforms to the ancient poem entity annotation specification, that is, the predicted tag sequence.

[0113] According to an embodiment of the present application, after obtaining the predicted tag sequence, input multiple predicted type tags and the entity type tags of each named entity into the loss function to calculate the target loss result. Among them, the loss function can be a mean square error loss function, etc. Then, iteratively adjust the model parameters of the pre-trained model according to the target loss result to obtain a poem entity extraction model.

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

[0115] As Figure 4 shown, the poem entity extraction method includes operation S401 to operation S402.

[0116] In operation S401, obtain the poem text to be recognized. Among them, the poem text to be recognized includes at least one entity to be recognized.

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

[0118] According to an embodiment of the present application, the poem text to be recognized can be any poem or sentence, such as "The Yellow River's water comes from the sky". Input this poem text to be recognized into the trained poem entity extraction model, and the predicted entity type of each entity to be recognized in this poem text to be recognized can be obtained. For example, the predicted entity type for "The Yellow River" is "natural landscape".

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

[0120] Figure 5 The block diagram of the training device of the poem entity extraction model according to an embodiment of the present application is shown.

[0121] As Figure 5 shown, the training device 500 of the poem entity extraction model includes a first prediction module 510, a calculation module 520, a generation module 530, a determination module 540, a obtaining module 550, and a training module 560.

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

[0123] The calculation module 520 is configured to calculate the cosine similarity data and the poem prosody difference data between the first poem text information and each to-be-screened poem text information in the preset knowledge base, wherein the preset knowledge base further includes a second entity type label corresponding to each to-be-screened poem text information.

[0124] The generation module 530 is configured to generate a comprehensive similarity for each to-be-screened poem text information according to the cosine similarity data and the poem prosody difference data.

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

[0126] A obtaining module 550 is configured to input an intermediate poetry training set into a preset language model to obtain a target poetry training set, where 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.

[0127] A training module 560 is configured to train a pre-trained model by 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 prosody difference data between each first poetry text information in the initial poetry training set and each to-be-screened poetry text information in a preset knowledge base, and determining whether the comprehensive similarity generated based on the cosine similarity data and the poetry prosody difference data meets a first preset condition, to determine whether to determine the to-be-screened poetry text information as the second poetry text information corresponding to the first poetry text information, and then inputting the intermediate poetry training set including the initial poetry training set and the second poetry text information into the preset language model to obtain a target poetry training set, and training the pre-trained model by using the target poetry training set to obtain a 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 prosody 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 fewer poetry samples in the related art can be solved, thereby improving the accuracy of the poetry entity extraction model in extracting the named entity type.

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

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

[0131] The acquisition module 610 is configured to acquire a to-be-recognized poetry text, where the to-be-recognized poetry text includes at least one to-be-recognized entity.

[0132] The second prediction module 620 is configured to input the to-be-recognized poetry text into the poetry entity extraction model and output a predicted entity type corresponding to each to-be-recognized entity.

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

[0134] It should be noted that any multiple of the modules, sub-modules, units, and sub-units according to the embodiments of the present application, or at least part of the functions of any multiple of them, can be implemented in one module. Any one or more of the modules, sub-modules, units, and sub-units according to the embodiments of the present application can be split into multiple modules for implementation. Any one or more of the modules, sub-modules, units, and sub-units according to the embodiments of the present application 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 chip, a system on substrate, a system on package, an application specific integrated circuit (ASIC), or can be implemented by any other reasonable way of integrating or packaging the circuit in hardware or firmware, or implemented in any one of the three implementation manners of software, hardware, and firmware, or in an appropriate combination of any several of them. Alternatively, one or more of the modules, sub-modules, units, and sub-units according to the embodiments of the present application can be at least partially implemented as a computer program module, and when the computer program module is run, the corresponding functions can be executed.

[0135] It should be noted that the training device of the poem entity extraction model and the poem entity extraction device part in the embodiments of the present application correspond to the training method of the poem entity extraction model and the poem entity extraction method part in the embodiments of the present application. For the description of the training device of the poem entity extraction model and the poem entity extraction device part, refer specifically to the training method of the poem entity extraction model and the poem entity extraction method part, and will not be elaborated here.

[0136] Figure 7 The 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 only an example and should not impose any limitations on the functions and usage scope of the embodiments of the present application.

[0137] As Figure 7 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 the read-only memory 702 or a program loaded from the storage section 708 into the random access memory 703. The processor 701 can include, for example, a general-purpose microprocessor (e.g., CPU), an instruction set processor, and / or a related chipset, and / or a dedicated microprocessor (e.g., an application-specific integrated circuit (ASIC)), and so on. The processor 701 can also include on-board memory for caching purposes. The processor 701 can include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present application.

[0138] In the random access memory 703, various programs and data required for the operation of the electronic device 700 are stored. 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 an 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 programs 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 an 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, the electronic device 700 may further include an input / output interface 705, and the input / output interface 705 is also connected to the bus 704. The electronic device 700 may further include one or more of the following components connected to the input / output interface 705: an input section 706 including a keyboard, a mouse, etc.; an output section 707 including, for example, a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 708 including a hard disk, etc.; and a communication section 709 including a network interface card such as a LAN card, a modem, etc. The communication section 709 performs communication processing via a network such as the Internet. A drive 710 is also connected to the input / output interface 705 as needed. A removable medium 711, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 710 as needed so that a computer program read from it can be installed into the storage section 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 program codes for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication part 709, and / or installed from a removable medium 711. When the computer program is executed by a processor 701, the above functions defined in the system of the embodiment of the present application are executed. According to an embodiment of the present application, the above-described system, device, apparatus, module, unit, etc. can be implemented by computer program modules.

[0141] The present application also provides a computer-readable storage medium, which may be included in the device / device / system described in the above embodiment; or may exist separately without being assembled into the device / device / system. The above computer-readable storage medium carries one or more programs, and when the above one or more programs are executed, the method according to the embodiment of the present application is implemented.

[0142] According to an embodiment of the present application, the computer-readable storage medium may be a non-volatile computer-readable storage medium. For example, it may include but is not limited to: portable computer disks, hard disks, random access memories (RAMs), read-only memories (ROMs), erasable programmable read-only memories (EPROMs or flash memories), portable compact disk read-only memories (CD-ROMs), optical storage devices, magnetic storage devices, or any suitable combination of the above. In the present application, the computer-readable storage medium may be any tangible medium that contains or stores a program, and the program can be used by or in combination with an instruction execution system, device, or device.

[0143] An embodiment of the present application also includes a computer program product, which includes a computer program, and the computer program includes program codes for executing the method provided by the embodiment of the present application. When the computer program product runs on an electronic device, the program codes are 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 a processor 701, the above functions defined in the system / apparatus of the embodiment of the present application are executed. According to an embodiment of the present application, the above-described system, apparatus, module, unit, etc. can be implemented by computer program modules.

[0145] According to embodiments of the present application, program code for executing the computer programs provided by the embodiments of the present application can be written in any combination of one or more programming languages. Specifically, these computing programs can be implemented using high-level procedural and / or object-oriented programming languages, and / or assembly / machine languages. The programming languages include, but are not limited to, such as Java, C++, Python, the "C" language 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 kind 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, by using an Internet service provider to connect through the Internet).

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

Claims

1. A training method for a poetry entity extraction model, characterized in that, Including: Input the first poem text information in the initial poem training set into the pre-trained model, and output multiple first entity type labels corresponding to each named entity in the first poem text information; Calculate the cosine similarity data and poem prosody difference data between the first poem text information and each poem text information to be screened in the preset knowledge base, wherein the preset knowledge base further includes second entity type labels corresponding to each poem text information to be screened; For each poem text information to be screened, generate a comprehensive similarity according to the cosine similarity data and poem prosody difference data; When the comprehensive similarity meets the first preset condition, determine the poem text information to be screened as the second poem text information corresponding to the first poem text information; Input the intermediate poem training set into the preset language model to obtain the target poem training set, wherein the intermediate poem training set includes multiple first poem text information and multiple first entity type labels corresponding to each first poem text information, multiple second poem text information and multiple second entity type labels; Use the target poem training set to train the pre-trained model to obtain a trained poem entity extraction model.

2. The method according to claim 1, characterized in that Calculating the cosine similarity data and poem prosody difference data between the first poem text information and each poem text information to be screened in the preset knowledge base includes: Perform semantic vector conversion and prosody coding conversion on multiple first poem text information to obtain a first poem semantic vector and first poem prosody coding information corresponding to each first poem text information, and perform semantic vector conversion and prosody coding conversion on multiple poem text information to be screened to obtain a second poem semantic vector and second poem prosody coding information corresponding to each poem text information to be screened; For each first poem text information and each poem text information to be screened, generate the cosine similarity data and poem prosody difference data between the first poem text information and the poem text information to be screened according to the first poem semantic vector, the first poem prosody coding information, the second poem semantic vector and the second poem prosody coding information.

3. The method according to claim 2, characterized in that, Generating the cosine similarity data and poem prosody difference data between the first poem text information and the poem text information to be screened according to the first poem semantic vector, the first poem prosody coding information, the second poem semantic vector and the second poem prosody coding information includes: Based on the cosine similarity function, calculate the cosine similarity data between the first poem semantic vector and the second poem semantic vector; Calculate the poem prosody difference data between the first poem prosody coding information and the second poem 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 by the following method: For each poem text information to be screened, input the poem text information to be screened into the pre-trained model and output multiple second entity type labels; Wherein, the method further includes: For each of the first poem text information and each of the second poem text information, calculate the entity correlation data between the first poem text information and the second poem text information according to the multiple first entity type tags of the first poem text information and the multiple second entity type tags of the second poem text information; When the entity correlation data meets the second preset condition, determine the second poem text information corresponding to the entity correlation data as the new second poem text information, so as to construct the intermediate poem training set by using the new second poem text information.

5. The method according to any one of claims 1 to 3, characterized in that, Input the intermediate poem training set into a preset language model to obtain a target poem training set, including: For each of the first poem text information in the intermediate poem training set, generate a first target prompt according to the first poem text information, the multiple first entity type tags, the multiple second poem text information corresponding to the first poem text information, and the multiple second entity type tags; Input the first target prompt into the preset language model, and output a third poem text information corresponding to the first poem text information; Generate the target poem training set according to the predicted poem training set and the intermediate poem training set, where the predicted poem training set includes multiple third poem text information.

6. The method according to claim 5, wherein Before generating the target poem training set, it further includes: Input a self-checking instruction into the preset language model, so that the preset language model responds to the self-checking instruction to perform a self-checking operation on the multiple third poem text information, and obtain the self-checked third poem text information, where the self-checking operation includes checking the third poem text information based on the number of characters and entity type tags.

7. The method according to claim 1, characterized in that, Input the first poem text information in the initial poem training set into a pre-trained model, and output the first entity type tag corresponding to each named entity in the first poem text information, including: For each of the first poem text information, generate a second target prompt according to the first poem text information, a poem text sample, and a task logic, where the poem text sample includes sample text information and entity type samples corresponding to each named entity in the sample text information; Input the second target prompt into the pre-trained model, and output the initial type tag corresponding to each named entity in the first poem text information; Based on the sequence annotation method, perform position marking processing on the first poem text information by using the multiple initial type tags to obtain position encoding information corresponding to each initial type tag; Generate the first entity type tag according to the multiple initial type tags and the multiple position encoding information.

8. The method according to claim 1 or 7, characterized in that Use the target poem training set to train the pre-trained model to obtain a trained poem entity extraction model, including: For any poem training sample in the target poem training set, input the poem training sample into the multi-head attention mechanism layer, and output the context-aware feature fused with context information of each character in the poem training sample; Input multiple context-aware features into a gated recurrent network to output sequential extraction features containing location information; Input the sequential extraction features into a probabilistic graph decoding layer to output a state transition matrix and an emission probability matrix, where 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, where the predicted label sequence includes predicted type labels of each named entity in the poetry training sample; Calculate a target loss result according to multiple predicted type labels and entity type labels of each named entity; Iteratively adjust the model parameters of the pre-trained model according to the target loss result to obtain the poetry entity extraction model.

9. A method for extracting poem entities, characterized in that, Comprising: Obtain a poetry text to be recognized, where the poetry text to be recognized includes at least one entity to be recognized; Input the poetry text to be recognized into the poetry entity extraction model to output predicted entity types corresponding to each entity to be recognized; Wherein, the poetry entity extraction model is trained by the method according to any one of claims 1 to 8.

10. An electronic device, comprising: One or more processors; A memory for storing one or more programs, Wherein, when the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 9.

Citation Information

Patent Citations

  • Classic poetry characteristic analysis method based on visualization

    CN106156005A

  • A method for determining text similarity and a related device

    CN109597878A

  • Poem generation quality optimization method and system based on neural network generation model

    CN110705284A

  • Method and device for obtaining training data and model training method and device

    CN111177373A

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

    CN113378570A