Training methods, devices, and electronic equipment for meteorological service text generation models

By combining a training method that integrates a graph encoder, a data encoder, and a decoder, along with a coverage mechanism and a named entity recognition model, the accuracy problem of meteorological service text generation was solved, achieving improvements in flexibility and comprehensiveness.

CN117033663BActive Publication Date: 2026-03-06BEIJING HUAXIN TIANLI METEOROLOGICAL TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311175671.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-09-13
Publication Date
2026-03-06
Estimated Expiration
2043-09-13

AI Technical Summary

Technical Problem

Existing technologies cannot improve the accuracy of meteorological service text generation while ensuring flexibility and comprehensive functionality, especially when generating long-sequence weather feature descriptions and special weather descriptions.

Method used

A combination of graph encoder, data encoder and decoder is used, along with coverage mechanism, LSTM decoder and named entity recognition model. The system is trained by calculating numerical accuracy loss, coverage loss and cross-entropy loss to ensure the accuracy and flexibility of the generated text.

Benefits of technology

The robustness and accuracy of the meteorological service text generation model have been improved, ensuring the flexibility and comprehensiveness of the generated text and adapting to the needs of different service recipients and scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117033663B_ABST
    Figure CN117033663B_ABST
Patent Text Reader

Abstract

This invention provides a training method, apparatus, and electronic device for a meteorological service text generation model, belonging to the technical field of data processing. The training method for this meteorological service text generation model considers the numerical accuracy loss, coverage loss, and cross-entropy loss of the generated meteorological service text and the target meteorological service text. As a result, the meteorological service text generation model trained in this way has better robustness, improves the accuracy of the generated meteorological service text, and also ensures the flexibility and comprehensiveness of meteorological service text generation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of data processing technology, and in particular to a training method, apparatus, and electronic device for a meteorological service text generation model. Background Technology

[0002] Meteorological services are a widely accessible public service. Text-based meteorological service products can most directly reflect important weather information. However, due to their highly specialized nature and large demand, manual writing and simple template-based text generation methods cannot meet the increasingly diverse needs for text products. In recent years, China's weather warning issuance has evolved from general public warnings to specialized risk warnings issued by region and scenario. Meteorological service support for major events also increasingly emphasizes the risks and countermeasures brought by severe weather. These innovations have led to a significant increase in both the difficulty and quantity of writing meteorological service texts, requiring not only more professional knowledge but also separate writing for different service recipients. Furthermore, the depth of meteorological services is constantly increasing, encompassing more and more service areas and content, making available sample data for each specific area increasingly scarce. This makes generating meteorological service texts using machine learning methods challenging.

[0003] Data-to-text generation is a crucial problem in Natural Language Processing (NLP), aiming to automatically generate relevant natural language descriptive text from structured data. Early data-to-text generation employed template-based methods, utilizing schema-based approaches to create writing templates and automatically generate the main content. However, it lacked flexibility in areas requiring more nuanced writing, such as describing long-term weather patterns and special weather events, and its reusability was poor. The application of deep learning language models addressed the flexibility issue. Due to the stronger structure of meteorological text, data-to-text generation models have been most successful in weather forecasting, achieving good results on publicly available weather forecast datasets. However, deep learning language models still lag behind in accuracy and controllability. To improve controllability, knowledge graphs can be applied to deep learning language models. Knowledge graphs can provide background knowledge support during training, better controlling the generated text. However, even with knowledge graphs applied to deep learning language model training, the accuracy of the final trained model remains poor.

[0004] In summary, improving the accuracy of generated meteorological service texts while ensuring flexibility and comprehensive functionality has become an urgent technical problem to be solved. Summary of the Invention

[0005] In view of this, the purpose of the present invention is to provide a training method, apparatus and electronic device for a meteorological service text generation model, so as to alleviate the technical problem that the existing technology cannot improve the accuracy of the generated meteorological service text while ensuring flexibility and comprehensive functionality.

[0006] In a first aspect, embodiments of the present invention provide a training method for a meteorological service text generation model, the meteorological service text generation model comprising: a graph encoder, a data encoder, and a decoder, the method comprising:

[0007] Acquire data samples in the field of meteorological services, wherein the data samples include: knowledge graphs, structured meteorological data samples, and target meteorological service texts corresponding to the structured meteorological data samples;

[0008] The knowledge graph is encoded using the graph encoder to obtain a graph feature vector, and the structured meteorological data sample is encoded using the data encoder to obtain a data feature vector;

[0009] The decoder is used to decode the map feature vector and the data feature vector to obtain the meteorological service generated text. The decoder includes a coverage mechanism to avoid repeated words at the end of sentences in the meteorological service generated text.

[0010] A named entity recognition model is used to extract the numerical values ​​and their corresponding entities from the generated meteorological service text, as well as the numerical values ​​and their corresponding entities from the target meteorological service text.

[0011] The numerical accuracy of each entity is calculated based on the numerical values ​​and their corresponding entities in the generated meteorological service text, and the numerical values ​​and their corresponding entities in the target meteorological service text.

[0012] The numerical accuracy loss is calculated based on the numerical accuracy of each entity, and the total loss is calculated based on the numerical accuracy loss, coverage loss, and cross-entropy loss of the meteorological service generated text and the target meteorological service text.

[0013] The graph encoder, the data encoder, and the decoder are trained based on the total loss until a preset condition is met, resulting in a trained meteorological service text generation model.

[0014] Furthermore, the encoding method of the graph encoder is linear encoding;

[0015] The decoder also includes an LSTM decoder, which includes a copy mechanism to prevent the loss of important information in the generated meteorological service text.

[0016] The named entity recognition models include BERT, BiLSTM, and CRF models.

[0017] Furthermore, the data encoder includes: a first transformer encoder and a second transformer encoder. The data encoder is used to encode the structured meteorological data sample, including:

[0018] The first transformer encoder is used to encode the entities in the structured meteorological data sample to obtain the first sub-data feature vector;

[0019] The second transformer encoder is used to encode the entities and their corresponding numerical values ​​in the structured meteorological data sample to obtain the second sub-data feature vector;

[0020] The data feature vector is calculated based on the first sub-data feature vector and the second sub-data feature vector.

[0021] Furthermore, the numerical accuracy of each entity is calculated based on the numerical values ​​and their corresponding entities in the generated meteorological service text, and the numerical values ​​and their corresponding entities in the target meteorological service text, including:

[0022] Calculation formula based on numerical accuracy Calculate the numerical accuracy of each entity, where, Representing entities Numerical accuracy, This refers to entities in the target meteorological service text. The value, This represents the entity in the text generated by the meteorological service. The value, Indicates the weight.

[0023] Furthermore, the numerical accuracy loss is calculated based on the numerical accuracy of each entity, and the total loss is calculated based on the numerical accuracy loss, coverage loss, and cross-entropy loss of the generated meteorological service text and the target meteorological service text, including:

[0024] Calculation formula based on numerical accuracy loss Calculate the numerical accuracy loss, where, This indicates the loss of accuracy of the stated value. This indicates the numerical accuracy of each entity.

[0025] Calculation formula based on total loss Calculate the total loss, where, This represents the total loss. The weights representing the cross-entropy loss are... This represents the cross-entropy loss. , This represents the i-th character. Indicates sentence length. This represents the probability distribution of the i-th character in the target meteorological service text. This represents the probability distribution of the i-th character in the text generated by the meteorological service. The weights representing the coverage loss are... This represents the coverage loss. , This represents the weight at time t. This represents the cumulative weight at time t. The weight representing the loss of numerical accuracy, This indicates the loss of accuracy of the numerical value.

[0026] Furthermore, the method also includes:

[0027] Obtain target scene data samples, wherein the target scene data samples include: target scene knowledge graph, target scene structured meteorological data samples, and target scene target meteorological service text corresponding to the target scene structured meteorological data samples;

[0028] The meteorological service text generation model is retrained using the target scenario data samples to obtain a meteorological service text generation model suitable for the target scenario.

[0029] Furthermore, the method also includes:

[0030] Acquire structured meteorological data;

[0031] The meteorological service text generation model is used to generate meteorological service text from the structured meteorological data to obtain the corresponding meteorological service text.

[0032] Secondly, embodiments of the present invention also provide a training apparatus for a meteorological service text generation model, the meteorological service text generation model comprising: a graph encoder, a data encoder, and a decoder, the apparatus comprising:

[0033] The acquisition unit is used to acquire data samples in the field of meteorological services, wherein the data samples include: knowledge graphs, structured meteorological data samples, and target meteorological service text corresponding to the structured meteorological data samples;

[0034] The encoding unit is used to encode the knowledge graph using the graph encoder to obtain a graph feature vector, and to encode the structured meteorological data sample using the data encoder to obtain a data feature vector;

[0035] A decoding unit is used to decode the map feature vector and the data feature vector using the decoder to obtain meteorological service generated text, wherein the decoder includes a coverage mechanism to avoid repeated words at the end of sentences in the meteorological service generated text;

[0036] The extraction unit is used to extract the numerical values ​​and their corresponding entities from the meteorological service generated text and the numerical values ​​and their corresponding entities from the target meteorological service text using a named entity recognition model.

[0037] The first calculation unit is used to calculate the numerical accuracy of each entity based on the numerical values ​​and their corresponding entities in the meteorological service generated text and the numerical values ​​and their corresponding entities in the target meteorological service text.

[0038] The second calculation unit is used to calculate the numerical accuracy loss based on the numerical accuracy of each entity, and to calculate the total loss based on the numerical accuracy loss, coverage loss and cross-entropy loss of the meteorological service generated text and the target meteorological service text.

[0039] The training unit is used to train the map encoder, the data encoder and the decoder according to the total loss until the preset conditions are met, so as to obtain the trained meteorological service text generation model.

[0040] Thirdly, embodiments of the present invention also provide an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the method described in any of the first aspects above.

[0041] Fourthly, embodiments of the present invention also provide a computer-readable storage medium storing machine-executable instructions, which, when invoked and executed by a processor, cause the processor to perform the method described in any of the first aspects above.

[0042] In this embodiment of the invention, a training method for a meteorological service text generation model is provided. The meteorological service text generation model includes a graph encoder, a data encoder, and a decoder. The method includes: acquiring data samples in the meteorological service domain, wherein the data samples include a knowledge graph, structured meteorological data samples, and target meteorological service text corresponding to the structured meteorological data samples; encoding the knowledge graph using the graph encoder to obtain a graph feature vector, and encoding the structured meteorological data samples using the data encoder to obtain a data feature vector; and decoding the graph feature vector and the data feature vector using the decoder to obtain the generated meteorological service text. The decoder includes a coverage mechanism, which is used for... To avoid repetitive words at the end of sentences in the generated meteorological service text, a named entity recognition model is used to extract numerical values ​​and their corresponding entities from the generated meteorological service text and the target meteorological service text. The numerical accuracy of each entity is calculated based on the numerical values ​​and their corresponding entities in both the generated and target meteorological service texts. The numerical accuracy loss is calculated based on the numerical accuracy of each entity, and the total loss is calculated based on the numerical accuracy loss, coverage loss, and cross-entropy loss of the generated and target meteorological service texts. The graph encoder, data encoder, and decoder are trained based on the total loss until preset conditions are met, resulting in a trained meteorological service text generation model. As described above, the training method for the meteorological service text generation model of this invention considers the numerical accuracy loss, coverage loss, and cross-entropy loss of the generated and target meteorological service texts. This results in a more robust meteorological service text generation model, improving the accuracy of the generated meteorological service text, while also ensuring the flexibility and comprehensiveness of meteorological service text generation. This alleviates the technical problem of existing technologies being unable to improve the accuracy of generated meteorological service text while maintaining flexibility and comprehensiveness of functionality. Attached Figure Description

[0043] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0044] Figure 1 A flowchart illustrating the training method for the meteorological service text generation model provided in this embodiment of the invention;

[0045] Figure 2Knowledge graph provided for embodiments of the present invention<h, r, t> Schematic diagram of the triplet linear encoding process;

[0046] Figure 3 This is a schematic diagram of the copy mechanism provided in an embodiment of the present invention;

[0047] Figure 4 This is a schematic diagram of the coverage mechanism provided in an embodiment of the present invention;

[0048] Figure 5 This is a schematic diagram of the NER model structure of BERT + BiLSTM + CRF provided in an embodiment of the present invention;

[0049] Figure 6 This is a schematic diagram of the structure of the meteorological service text generation model provided in an embodiment of the present invention;

[0050] Figure 7 Examples of three model inference results and target results provided in embodiments of the present invention;

[0051] Figure 8 A schematic diagram of a training device for a meteorological service text generation model provided in an embodiment of the present invention;

[0052] Figure 9 This is a schematic diagram of an electronic device provided in an embodiment of the present invention. Detailed Implementation

[0053] The technical solution of the present invention will be clearly and completely described below with reference to the embodiments. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0054] Existing technologies cannot improve the accuracy of generated meteorological service texts while ensuring flexibility and comprehensive functionality.

[0055] Based on this, the training method of the meteorological service text generation model of the present invention considers the numerical accuracy loss, coverage loss and cross-entropy loss of the generated meteorological service text and the target meteorological service text. In this way, the meteorological service text generation model trained in the end has better robustness, improves the accuracy of the generated meteorological service text, and also ensures the flexibility and comprehensiveness of meteorological service text generation.

[0056] To facilitate understanding of this embodiment, a training method for a meteorological service text generation model disclosed in this embodiment of the invention will first be described in detail.

[0057] Example 1:

[0058] According to an embodiment of the present invention, an embodiment of a training method for a meteorological service text generation model is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.

[0059] Figure 1 This is a flowchart of a training method for a meteorological service text generation model according to an embodiment of the present invention, such as... Figure 1 As shown, the method includes the following steps:

[0060] Step S102: Obtain data samples in the meteorological service field, wherein the data samples include: knowledge graph, structured meteorological data samples, and target meteorological service text corresponding to the structured meteorological data samples;

[0061] In this embodiment of the invention, the meteorological service text generation model includes a graph encoder, a data encoder, and a decoder. The aforementioned knowledge graph (i.e., a knowledge graph storing background knowledge in a graph structure) serves as a guide and aid in generating meteorological service text. If it is not present, it can be omitted, and meteorological service text can be generated solely through structured meteorological data samples. The aforementioned structured meteorological data samples can be hourly meteorological data from meteorological stations or grid points, for example, the 8:00 AM meteorological data from Beijing's 54511 meteorological station (including specific values ​​for each meteorological element, such as temperature, humidity, and wind speed).

[0062] Step S104: The knowledge graph is encoded using a graph encoder to obtain graph feature vectors, and the structured meteorological data samples are encoded using a data encoder to obtain data feature vectors.

[0063] Step S106: The decoder is used to decode the map feature vector and the data feature vector to obtain the meteorological service generated text. The decoder includes a coverage mechanism to avoid repeated words at the end of sentences in the meteorological service generated text.

[0064] Step S108: Use a named entity recognition model to extract the numerical values ​​and their corresponding entities from the meteorological service generated text, and the numerical values ​​and their corresponding entities from the target meteorological service text.

[0065] The aforementioned named entity recognition model is a pre-trained model that extracts commonly used entities in the meteorological field. These entities may include: time-related entities, location-related entities, meteorological element-related entities, weather phenomenon-related entities, etc.

[0066] Step S110: Calculate the numerical accuracy of each entity based on the numerical values ​​and their corresponding entities in the meteorological service generated text and the numerical values ​​and their corresponding entities in the target meteorological service text.

[0067] The inventors considered that meteorological services have high requirements for data quality. Evaluating the quality of meteorological service documents requires not only considering lexical accuracy and semantic completeness, but also focusing on the accuracy of numerical values. In solving the problem of meteorological service text generation, a model method is needed to independently evaluate the accuracy of numerical values ​​in the generated text. This method can be used to penalize numerical calculation errors during the training of the meteorological service text generation model and to evaluate the performance of the model.

[0068] The calculation process for the numerical accuracy of the entity will be described in detail below, and will not be repeated here.

[0069] Step S112: Calculate the numerical accuracy loss based on the numerical accuracy of each entity, and calculate the total loss based on the numerical accuracy loss, coverage loss, and cross-entropy loss of the meteorological service generated text and the target meteorological service text.

[0070] Step S114: Train the map encoder, data encoder, and decoder according to the total loss until the preset conditions are met, and obtain the trained meteorological service text generation model.

[0071] The aforementioned preset conditions may be that the number of training iterations reaches a preset threshold, or that the total loss no longer changes, etc. The embodiments of the present invention do not impose specific restrictions on the aforementioned preset conditions.

[0072] In this embodiment of the invention, a training method for a meteorological service text generation model is provided. The meteorological service text generation model includes a graph encoder, a data encoder, and a decoder. The method includes: acquiring data samples in the meteorological service domain, wherein the data samples include a knowledge graph, structured meteorological data samples, and target meteorological service text corresponding to the structured meteorological data samples; encoding the knowledge graph using the graph encoder to obtain a graph feature vector, and encoding the structured meteorological data samples using the data encoder to obtain a data feature vector; and decoding the graph feature vector and the data feature vector using the decoder to obtain the generated meteorological service text. The decoder includes a coverage mechanism, which is used for... To avoid repetitive words at the end of sentences in the generated meteorological service text, a named entity recognition model is used to extract numerical values ​​and their corresponding entities from the generated meteorological service text and the target meteorological service text. The numerical accuracy of each entity is calculated based on the numerical values ​​and their corresponding entities in both the generated and target meteorological service texts. The numerical accuracy loss is calculated based on the numerical accuracy of each entity, and the total loss is calculated based on the numerical accuracy loss, coverage loss, and cross-entropy loss of the generated and target meteorological service texts. The graph encoder, data encoder, and decoder are trained based on the total loss until preset conditions are met, resulting in a trained meteorological service text generation model. As described above, the training method for the meteorological service text generation model of this invention considers the numerical accuracy loss, coverage loss, and cross-entropy loss of the generated and target meteorological service texts. This results in a more robust meteorological service text generation model, improving the accuracy of the generated meteorological service text, while also ensuring the flexibility and comprehensiveness of meteorological service text generation. This alleviates the technical problem of existing technologies being unable to improve the accuracy of generated meteorological service text while maintaining flexibility and comprehensiveness of functionality.

[0073] The above provides a brief overview of the training method for the meteorological service text generation model of the present invention. The specific details involved are described in detail below.

[0074] In an optional embodiment of the present invention, the map encoder uses a linear encoding method;

[0075] The data encoder includes a first transformer encoder and a second transformer encoder. The data encoder is used to encode structured meteorological data samples, specifically including the following steps:

[0076] (1) The first transformer encoder is used to encode the entities in the structured meteorological data sample to obtain the first sub-data feature vector;

[0077] (2) The second transformer encoder is used to encode the entities and their corresponding values ​​in the structured meteorological data samples to obtain the second sub-data feature vector;

[0078] (3) Calculate the data feature vector based on the first sub-data feature vector and the second sub-data feature vector.

[0079] Specifically, the graph encoder needs to map the knowledge graph onto a representation space for encoding. In this step, a linear mapping model (i.e., linear encoding) is used to encode the knowledge graph.<h, r, t> Triples are mapped to a high-dimensional representation space, and it is ensured that the rank of the matrix in the high-dimensional vector space is the same as the rank of the matrix in the high-dimensional vector space.<h, r, t> The triples represent consistency; the projection of the tail entity (t) is closer to the head entity (h). Linear mapping models are designed for extracting short-chain relationships in knowledge graphs, offering good semantic consistency and high efficiency. For example... Figure 2 As shown, h is the head entity, t is the tail entity, r is the relation, and F r (h,t) represents the desired mapping result.

[0080] The data encoder in the weather service text generation model based on the transformer architecture encodes structured weather data samples. A transformer encoder is used as the encoder, employing a two-level attention mechanism (i.e., a first transformer encoder and a second transformer encoder). Specifically, the first-level attention mechanism (i.e., the first transformer encoder) encodes the field names (i.e., entities) in the structured weather data samples. Since each record in a single structured weather data sample input has the same field names (e.g., all including temperature, humidity, and wind speed), and each input differs only in length, it is believed that extracting features from the field names alone can enhance the quality of the generated text and achieve faster fitting. The first sub-data feature vector—attention (Attention1, i.e., ...)—is calculated using the formula. (), where e is the number of entities, t is the number of times an entity is repeated, and z is the number of records in the data. For a single record entered, This is the score for scores encoded only by field names.

[0081]

[0082] The second attention mechanism (i.e., the second transformer encoder) encodes entities and their corresponding numerical values. This requires associating field names (i.e., entities) with data to construct key-value pairs (kv pairs). The second sub-data feature vector is then processed by attention (Attention2, i.e....). The calculation is based on the following formula, where K(e, t) is the field name, V(e,t) is the value, and z is the record in the data.

[0083]

[0084] By combining two attention mechanisms, we obtain the data encoder attention mechanism, which is the data feature vector. The formula:

[0085]

[0086] In an optional embodiment of the present invention, the decoder further includes an LSTM decoder, which includes a copy mechanism to prevent the loss of important information in the generated meteorological service text.

[0087] Specifically, the RNN-based decoder structure in this invention is as follows: The decoder's task is to decode the graph feature vector and the data feature vector, constructed using an LSTM decoder + coverage attention method. LSTM has better accuracy in long-chain feature extraction compared to traditional RNN models. Addressing the common problems of ignoring low-probability words and repeated generation in text generation, this decoder utilizes copy and coverage mechanisms to improve the quality of text generation. The copy mechanism (the number of copies should be between 1 and 3 to avoid performance degradation due to excessive copying) adds Attentive Read and Selective Read pairs to the LSTM decoder, and considers the generation probability and copy probability of the predicted character during the result prediction stage. This can effectively improve the prediction accuracy for rare and uncommon characters. The copy mechanism operation process is as follows: Figure 3 As shown in the figure, Prob(word | g) represents the probability of a word appearing in the generation mode, Prob(word | c) represents the probability of a word appearing in the copy mode, and Prob(word) represents the final probability of a word appearing. Furthermore, natural language generation tasks are often plagued by the "repetition problem." A coverage attention mechanism is used to record words already attended by the decoder and add them to the attention of the current step to avoid continuously attending to the same word. The coverage is obtained by accumulating the vectors recorded at that moment, as shown in the following formula, where C... tLet a be the coverage value at time t. i The coverage mechanism operates as follows, representing the vector prediction result at time i. Figure 4 As shown in the figure, c represents the vector of the historical sequence, and a i For the attention mechanism at time i, update is the function that updates c, h and φ represent the information of the input vector, and t i Information for time-i decoder inference.

[0088]

[0089] In an optional embodiment of the present invention, the named entity recognition model includes: BERT, BiLSTM, and CRF models.

[0090] Specifically, comparing the numerical values ​​in the generated meteorological service text and the target meteorological service text requires accurately extracting the numerical values ​​and their described entities from the aforementioned statements. This can be viewed as a Named Entity Recognition (NER) problem. This invention uses a BERT + BiLSTM + CRF model for solution. The task of CRF (Conditional Random Field) is to use a dynamic programming algorithm to perform inverse decoding according to the formula, where E is the emission matrix, T is the transition matrix, i is the i-th character in the sentence, and y... i Let y be the label of the i-th character. i+1 The label for the (i+1)th character. For y i The label represents the score for word i. To transition from y1 to y i+1 The score of the tag.

[0091]

[0092] By continuously optimizing T, the value of y that maximizes the objective function P (the likelihood probability of sequence y) is obtained according to the formula, denoted as y. ,in, For what is required The corresponding sequence score, with the denominator being the score of all possible label sequences.

[0093]

[0094] Simultaneously, BERT + BiLSTM is used to train the emission matrix E during this process to enhance the training effect of CRF. For example... Figure 5 As shown. Specifically, a pre-trained language model (i.e., BERT) can be used as the emission matrix of the CRF to enhance the training effect of the model.

[0095] In an optional embodiment of the present invention, the numerical accuracy of each entity is calculated based on the numerical values ​​and their corresponding entities in the meteorological service generated text, and the numerical values ​​and their corresponding entities in the target meteorological service text. This specifically includes the following steps:

[0096] Calculation formula based on numerical accuracy Calculate the numerical accuracy of each entity, where, Representing entities Numerical accuracy, Represents entities in the target meteorological service text The value, Represents entities in the text generated by the meteorological service. The value, Indicates the weight.

[0097] Specifically, numerical accuracy refers to the difference between the meteorological service text automatically generated by the meteorological service text generation model and the target meteorological service text in describing the same object of data during a writing task. The BERT + BiLSTM + CRF model is used to extract numerical values ​​from both the meteorological service text and the target meteorological service text. Based on the extraction results, the overall target accuracy of the meteorological service text generation is calculated using a formula. In the following formula, For each entity The numerical accuracy, where ele is the entity being sought, and T ele Entities in the target meteorological service text The value of G ele Generate entities in text for meteorological services The value of λ is given by k, which is the penalty factor (taken as 1 in subsequent experiments of this invention), and λ is the weight of non-numerical entities (taken as 2 in subsequent experiments of this invention). In the following formula... The overall target accuracy for generating text for meteorological services, where n is the total number of entities to be determined.

[0098]

[0099]

[0100] In an optional embodiment of the present invention, the numerical accuracy loss is calculated based on the numerical accuracy of each entity, and the total loss is calculated based on the numerical accuracy loss, coverage loss, and cross-entropy loss of the meteorological service generated text and the target meteorological service text. Specifically, this includes the following steps:

[0101] (1) Calculation formula based on numerical accuracy loss Calculate the loss of numerical accuracy, where, Indicates the loss of numerical accuracy. Indicates the accuracy of the numerical values ​​for each entity;

[0102] (2) Calculate the total loss using the formula. Calculate the total loss, where, Indicates the total loss. The weights representing the cross-entropy loss, Represents cross-entropy loss, , This represents the i-th character. Indicates sentence length. Let represent the probability distribution of the i-th character in the target meteorological service text. Let represent the probability distribution of the i-th character in the text generated by the weather service. The weights representing the coverage loss. Indicates coverage loss. , This represents the weight at time t. This represents the cumulative weight at time t. The weights representing the loss of numerical accuracy This indicates a loss of numerical accuracy.

[0103] Specifically, the loss of the meteorological service text generation model is divided into three aspects: Cross Entropy Loss, Coverage Loss, and Data Precision Loss. These losses penalize three types of errors that occur during training: inaccurate words and semantics, redundant repetitions at the end of sentences, and numerical calculation biases. The total loss is calculated using the formula below, where K1, K2, and K3 are the weights of the three losses, which can be adjusted according to the specific problem.

[0104]

[0105] Cross Entropy Loss: Cross entropy is a common way to evaluate text similarity. It measures the difference between two different probability distributions of the same random variable. The cross entropy loss function represents the difference between the true probability distribution and the predicted probability distribution, and is often used in supervised machine learning model training tasks. During training, the probability distribution P(x) of the i-th character in the predicted target weather service text is known. The cross entropy between the predicted result and the expected result is calculated using the following formula as the loss function. The smaller the cross entropy value, the better the model's prediction performance. This represents the i-th character. Indicates sentence length. Let represent the probability distribution of the i-th character in the target meteorological service text. This represents the probability distribution of the i-th character in the text generated by the meteorological service.

[0106]

[0107] Coverage loss: Due to the introduction of the coverage mechanism, a coverage loss needs to be added to the loss to penalize repetition at the end of the sentence. In the inference of each word (called a time step), the minimum value of the cumulative weight of all previous time steps and the weight of the current time step is obtained, as shown in the formula below. This method comprehensively considers both the multiple occurrences of a word in previous time steps and the situation where a word has the highest probability of appearing in the current state. It is neither entirely biased towards words that appear multiple times, nor does it overemphasize the word with the highest probability of appearing in the current state. Let be the weight at time t. Let be the cumulative weight at time t.

[0108]

[0109] Data Precision Loss: The meteorological service text generation model involves numerical calculations. This model achieves quality control of numerical accuracy by penalizing inaccurate calculations in the loss function. Through a numerical accuracy evaluation method, numerical values ​​are extracted from each generated meteorological service text and the target meteorological service text. The numerical accuracy loss is calculated using the following formula: This refers to the numerical accuracy of each entity.

[0110]

[0111] like Figure 6As shown, the meteorological service text generation model is trained using the mainstream Encoder-Decoder structure of neural networks. The model's input consists of a knowledge graph storing background knowledge and structured meteorological data (hourly meteorological data from stations or grid points). The input data is encoded by an encoder. A graph encoder is constructed to encode the knowledge graph using a linear mapping model, and a data encoder is constructed to encode the structured meteorological data samples. The output of the meteorological service text generation model is natural language description text. During training, a decoder is constructed to decode the text and calculate the loss function between the generated meteorological service text and the target meteorological service text. The model is then trained on a large amount of data. The training process is constrained and adjusted using the loss function. Since the commonly used cross-entropy loss function is not sensitive to numerical accuracy, while meteorology requires high numerical accuracy, a numerical accuracy evaluation method and a numerical accuracy loss function are constructed to control the model's training process. The model is trained using massive aligned data in the meteorological service field (i.e., structured meteorological data samples correspond one-to-one with target meteorological service texts, and the data samples in the meteorological service field consist of meteorological warnings from the past 5 years and meteorological news and service reports from the past 10 years). When facing specific application scenarios, fine-tuning can be performed on this model to make the output content meet the needs of the application scenario with a relatively small number of samples.

[0112] In an optional embodiment of the present invention, the method further includes:

[0113] (1) Obtain target scene data samples, wherein the target scene data samples include: target scene knowledge graph, target scene structured meteorological data samples and target scene target meteorological service text corresponding to the target scene structured meteorological data samples;

[0114] (2) The meteorological service text generation model is retrained using target scenario data samples to obtain a meteorological service text generation model suitable for the target scenario.

[0115] Due to the complexity and diversity of the meteorological service field, models still face certain challenges in coping with new scenarios and demands. To address these challenges, this invention employs a pre-training + retraining (fine-tuning) method to adapt to entirely new service scenarios. Specifically, the model is first pre-trained using a large-scale dataset (as described in steps S102 to S114 above), thereby enhancing its generalization ability and adaptability. Then, it is retrained on small-scale data within a specific domain to further improve its performance in that domain. In the fine-tuning process for extended applications, if there are entity categories not trained in the numerical accuracy evaluation model (i.e., the named entity recognition model), fine-tuning of the numerical accuracy evaluation model (i.e., the named entity recognition model) is performed first, followed by fine-tuning of the text generation model (i.e., the meteorological service text generation model).

[0116] Based on the model structure of this invention, pre-training was performed with different model sizes (12 attention heads and 12 stacked layers per layer for two-stage transformers, and 6 attention heads and 6 stacked layers per layer for two-stage transformers, with the number of attention heads and stacked layers in the two-stage transformers being equal) and datasets (data samples from the meteorological service field consisting of weather warnings from the past 5 years and weather news and service reports from the past 10 years), resulting in four pre-trained weights (including Chinese and English). The number of stacked transformer layers, the number of attention heads in the self-attention mechanism, and the corresponding languages ​​all vary, catering to different service scenarios and servers with different performance levels, or serving as a basis for training.

[0117] In an optional embodiment of the present invention, the method further includes:

[0118] (1) Acquire structured meteorological data;

[0119] (2) Meteorological service text generation model is used to generate meteorological service text from structured meteorological data to obtain the corresponding meteorological service text.

[0120] To illustrate the experimental results of this invention, an experiment was conducted using the meteorological service of a certain sports event as the experimental scenario. The sports event meteorological service knowledge base was used as the source of the knowledge graph required by the model, and weather bulletins and corresponding structured meteorological data samples were obtained for the experiment. The specific dataset is as follows:

[0121] To build an intelligent engine for meteorological services for the Games, the meteorological bureau constructed a knowledge graph based on expert knowledge related to the Games. This resulted in a knowledge graph of meteorological services for the Games, containing hierarchical relationships and complex constraints among elements such as event-related meteorological factors, threshold indicators, and event organization. Nodes and relationships related to the impact of weather on the Games were selected from this knowledge graph to form sub-knowledge graphs for model training. These sub-knowledge graphs contain approximately 90 nodes, including events, venues, stations, meteorological factors, and thresholds, totaling over 130 relationships. During the Games, a large number of meteorological service articles were accumulated based on the two daily weather forecast announcements. Furthermore, structured meteorological data samples from the Games' meteorological stations were preserved at the time of these announcements. These, along with the meteorological service articles, were used to construct an aligned dataset of Games meteorological service articles. The dataset comprises approximately 800 sets of aligned structured meteorological forecast data plus meteorological service article sets.

[0122] To verify the effectiveness of the meteorological service text generation model, an experiment was designed on the sports meet meteorological service writing dataset to compare the model of this invention with current mainstream models in academia and similar models in industry. The academic models used were the Enhanced Transformer model, which improves the input structure and assists in content selection model optimization; and the Hierarchical Data-to-Text Generation model, which uses a distributed method to encode structured data and improves the feature extraction effect of the input. The industry model used was a rule-based manuscript generation model applied during the sports meet. The three evaluation metrics of the NMT (Neural Machine Translation) model mentioned above were used for evaluation, and the model was assessed from the perspectives of sentence generation functionality, controllability, and flexibility. Examples automatically generated by the three deep learning models were compared, such as... Figure 7 As shown in Tables 1 and 2, the local accuracy of the meteorological service-generated text was evaluated using the ROUGE-N method, and the overall accuracy was evaluated using the ROUGE-L method. The overall semantic accuracy of the meteorological service-generated text was evaluated using the BERT+cosine similarity method, and the results are shown in Table 3. The numerical accuracy of the meteorological service-generated text was tested using numerical accuracy methods, and the results are shown in Table 4. Finally, the performance of the model of this invention and the template writing model in the above aspects were compared, and the results are shown in Table 5.

[0123] The experimental results show that, in terms of local accuracy, the model of this invention, used for text generation tasks in the meteorological service field, outperforms the E-Transformer and H-Data2Text models in terms of recall, precision, and F1-score. In terms of overall accuracy, the model of this invention outperforms the E-Transformer and H-Data2Text models, and the trends in recall, precision, and F1-score remain unchanged for all three models. Regarding numerical accuracy, this invention is better than the H-Data2Text and E-Transformer models. A comparison between this invention's model and the model of this invention (k3=0) shows that the data accuracy loss penalizes erroneous data during model training, thus calibrating the data. From the perspective of model functionality and performance, the model of this invention is very close to the XMLs model in performance, and both objectively reach a high level. Furthermore, this invention's model is capable of providing the 4-10 day writing function that the XMLs model lacks. From a business application perspective, the training process of this invention's model is far more automated than that of the XMLs model, while the XMLs model can respond more quickly to small-scale needs and does not rely on data foundation support.

[0124] Table 1. Quality assessment of generated text – ROUGE-N method (N takes values ​​of 2, 3, or 4)

[0125]

[0126] Table 2. Quality Assessment of Generated Text – ROUGE-L Method

[0127]

[0128] Table 3. Quality Evaluation of Generated Text – BERT Method

[0129]

[0130] Table 4. Quality Evaluation of Generated Text – Numerical Accuracy Test Results

[0131]

[0132] Table 5. Comparison of experimental results between the model of this invention and the XML template writing model.

[0133]

[0134] This invention primarily utilizes a deep learning model to generate short meteorological service texts, and optimizes the generated results through a series of methods to achieve accurate short meteorological service text generation. This automatic generation of short meteorological service texts mainly relies on an encoder-decoder structure to achieve end-to-end data-to-text generation. A neural network structure is constructed to address the characteristics of meteorological text generation problems, integrating knowledge graphs and developing a numerical accuracy evaluation method. This results in the automatic generation of short meteorological texts with high accuracy, flexible content formats, and wide application scenarios, achieving higher accuracy than similar methods.

[0135] Example 2:

[0136] This invention also provides a training device for a meteorological service text generation model. This training device is mainly used to execute the training method for the meteorological service text generation model provided in Embodiment 1 of this invention. The following is a detailed description of the training device for the meteorological service text generation model provided in this invention.

[0137] Figure 8 This is a schematic diagram of a training device for a meteorological service text generation model according to an embodiment of the present invention, such as... Figure 8 As shown, the device mainly includes: an acquisition unit 10, an encoding unit 20, a decoding unit 30, an extraction unit 40, a first calculation unit 50, a second calculation unit 60, and a training unit 70, wherein:

[0138] The acquisition unit is used to acquire data samples in the field of meteorological services. The data samples include: knowledge graphs, structured meteorological data samples, and target meteorological service texts corresponding to the structured meteorological data samples.

[0139] The encoding unit is used to encode the knowledge graph using a graph encoder to obtain graph feature vectors, and to encode the structured meteorological data samples using a data encoder to obtain data feature vectors.

[0140] The decoding unit is used to decode the map feature vector and data feature vector using a decoder to obtain the meteorological service generated text. The decoder includes a coverage mechanism to avoid repeated words at the end of sentences in the meteorological service generated text.

[0141] The extraction unit is used to extract numerical values ​​and their corresponding entities from the meteorological service generated text and the target meteorological service text using a named entity recognition model.

[0142] The first calculation unit is used to calculate the numerical accuracy of each entity based on the numerical values ​​and their corresponding entities in the meteorological service generated text and the numerical values ​​and their corresponding entities in the target meteorological service text.

[0143] The second calculation unit is used to calculate the numerical accuracy loss based on the numerical accuracy of each entity, and to calculate the total loss based on the numerical accuracy loss, coverage loss and cross-entropy loss of the meteorological service generated text and the target meteorological service text.

[0144] The training unit is used to train the map encoder, data encoder, and decoder based on the total loss until the preset conditions are met, thus obtaining the trained meteorological service text generation model.

[0145] In this embodiment of the invention, a training device for a meteorological service text generation model is provided. The meteorological service text generation model includes a graph encoder, a data encoder, and a decoder. The device includes: acquiring data samples in the meteorological service domain, wherein the data samples include a knowledge graph, structured meteorological data samples, and target meteorological service text corresponding to the structured meteorological data samples; encoding the knowledge graph using the graph encoder to obtain a graph feature vector, and encoding the structured meteorological data samples using the data encoder to obtain a data feature vector; and decoding the graph feature vector and the data feature vector using the decoder to obtain the generated meteorological service text. The decoder includes a coverage mechanism, which is used for... To avoid repetitive words at the end of sentences in the generated meteorological service text, a named entity recognition model is used to extract numerical values ​​and their corresponding entities from the generated meteorological service text and the target meteorological service text. The numerical accuracy of each entity is calculated based on the numerical values ​​and their corresponding entities in both the generated and target meteorological service texts. The numerical accuracy loss is calculated based on the numerical accuracy of each entity, and the total loss is calculated based on the numerical accuracy loss, coverage loss, and cross-entropy loss of the generated and target meteorological service texts. The graph encoder, data encoder, and decoder are trained based on the total loss until preset conditions are met, resulting in a trained meteorological service text generation model. As described above, the training device for the meteorological service text generation model of this invention considers the numerical accuracy loss, coverage loss, and cross-entropy loss of the generated and target meteorological service texts. This results in a more robust meteorological service text generation model, improving the accuracy of the generated meteorological service text, while also ensuring the flexibility and comprehensiveness of meteorological service text generation. This alleviates the technical problem of existing technologies being unable to improve the accuracy of generated meteorological service text while maintaining flexibility and comprehensiveness of functionality.

[0146] Optionally, the graph encoder uses linear encoding; the decoder also includes an LSTM decoder, which includes a copy mechanism to prevent the loss of important information in the generated meteorological service text; the named entity recognition model includes BERT, BiLSTM and CRF models.

[0147] Optionally, the data encoder includes: a first transformer encoder and a second transformer encoder. The encoding unit is further configured to: encode entities in the structured meteorological data sample using the first transformer encoder to obtain a first sub-data feature vector; encode entities and their corresponding numerical values ​​in the structured meteorological data sample using the second transformer encoder to obtain a second sub-data feature vector; and calculate a data feature vector based on the first sub-data feature vector and the second sub-data feature vector.

[0148] Optionally, the first calculation unit is also used to: calculate the formula based on the numerical accuracy. Calculate the numerical accuracy of each entity, where, Representing entities Numerical accuracy, Represents entities in the target meteorological service text The value, Represents entities in the text generated by the meteorological service. The value, Indicates the weight.

[0149] Optionally, the second calculation unit is also used to: calculate the formula based on the loss of numerical accuracy. Calculate the loss of numerical accuracy, where, Indicates the loss of numerical accuracy. Indicates the numerical accuracy of each entity; calculates the total loss using the formula. Calculate the total loss, where, Indicates the total loss. The weights representing the cross-entropy loss, Represents cross-entropy loss, , This represents the i-th character. Indicates sentence length. Let represent the probability distribution of the i-th character in the target meteorological service text. Let represent the probability distribution of the i-th character in the text generated by the weather service. The weights representing the coverage loss. Indicates coverage loss. , This represents the weight at time t. This represents the cumulative weight at time t. The weights representing the loss of numerical accuracy This indicates a loss of numerical accuracy.

[0150] Optionally, the device is further configured to: acquire target scene data samples, wherein the target scene data samples include: a target scene knowledge graph, a target scene structured meteorological data sample, and a target scene target meteorological service text corresponding to the target scene structured meteorological data sample; and retrain the meteorological service text generation model using the target scene data samples to obtain a meteorological service text generation model suitable for the target scene.

[0151] Optionally, the device is also used to: acquire structured meteorological data; and generate meteorological service text from the structured meteorological data using a meteorological service text generation model to obtain the corresponding meteorological service text.

[0152] The device provided in this embodiment of the invention has the same implementation principle and technical effect as the aforementioned method embodiment. For the sake of brevity, any parts not mentioned in the device embodiment can be referred to the corresponding content in the aforementioned method embodiment.

[0153] like Figure 9 As shown in the embodiment of this application, an electronic device 600 includes a processor 601, a memory 602, and a bus. The memory 602 stores machine-readable instructions that can be executed by the processor 601. When the electronic device is running, the processor 601 communicates with the memory 602 via the bus. The processor 601 executes the machine-readable instructions to perform the steps of the training method for the meteorological service text generation model described above.

[0154] Specifically, the memory 602 and processor 601 mentioned above can be general-purpose memory and processor, without any specific limitations. When the processor 601 runs the computer program stored in the memory 602, it can execute the training method of the meteorological service text generation model mentioned above.

[0155] The processor 601 may be an integrated circuit chip with signal processing capabilities. In implementation, each step of the above method can be completed by the integrated logic circuitry in the hardware of the processor 601 or by instructions in software form. The processor 601 may be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose processor may be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this application can be directly manifested as execution by a hardware decoding processor, or execution by a combination of hardware and software modules in the decoding processor. The software module can reside in a mature storage medium in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, or registers. This storage medium is located in memory 602, and processor 601 reads the information from memory 602 and, in conjunction with its hardware, completes the steps of the above method.

[0156] Corresponding to the training method of the meteorological service text generation model described above, this application embodiment also provides a computer-readable storage medium storing machine-executable instructions. When the machine-executable instructions are called and run by a processor, the machine-executable instructions cause the processor to run the steps of the training method of the meteorological service text generation model described above.

[0157] The training device for the meteorological service text generation model provided in this application embodiment can be specific hardware on the device or software or firmware installed on the device. The device provided in this application embodiment has the same implementation principle and technical effects as the aforementioned method embodiment. For the sake of brevity, any parts not mentioned in the device embodiment can be referred to the corresponding content in the aforementioned method embodiment. Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can all be referred to the corresponding processes in the above method embodiments, and will not be repeated here.

[0158] In the embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. The apparatus embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. Furthermore, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Additionally, the displayed or discussed mutual couplings, direct couplings, or communication connections may be through some communication interfaces; indirect couplings or communication connections between devices or units may be electrical, mechanical, or other forms.

[0159] For example, the flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than those marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram and / or flowchart, and combinations of blocks in block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.

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

[0161] In addition, the functional units in the embodiments provided in this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.

[0162] If the aforementioned function is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause an electronic device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the vehicle marking method described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0163] It should be noted that similar labels and letters in the following figures indicate similar items. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. In addition, the terms "first", "second", "third", etc. are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.

[0164] Finally, it should be noted that the above-described embodiments are merely specific implementations of this application, used to illustrate the technical solutions of this application, and not to limit them. The protection scope of this application is not limited thereto. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments, or make equivalent substitutions for some of the technical features, within the scope of the technology disclosed in this application; and these modifications, changes, or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application. All should be covered within the protection scope of this application. Therefore, the protection scope of this application should be determined by the protection scope of the claims.

Claims

1. A method for training a weather service text generation model, characterized by, The weather service text generation model comprises a graph encoder, a data encoder and a decoder, and the method comprises: obtaining data samples in the field of weather services, wherein the data samples comprise a knowledge graph, structured weather data samples and target weather service texts corresponding to the structured weather data samples; encoding the knowledge graph using the graph encoder to obtain a graph feature vector, and encoding the structured weather data samples using the data encoder to obtain a data feature vector; decoding the graph feature vector and the data feature vector using the decoder to obtain weather service generated texts, wherein the decoder comprises a coverage mechanism for avoiding repeated words at the end of the weather service generated texts; extracting values and corresponding entities in the weather service generated texts and values and corresponding entities in the target weather service texts using a named entity recognition model; calculating the value accuracy of each entity according to the values and corresponding entities in the weather service generated texts and the values and corresponding entities in the target weather service texts; calculating a value accuracy loss according to the value accuracy of each entity, and calculating a total loss according to the value accuracy loss, a coverage loss and a cross-entropy loss of the weather service generated texts and the target weather service texts; training the graph encoder, the data encoder and the decoder according to the total loss until a preset condition is reached to obtain a trained weather service text generation model, wherein the weather service text generation model is used to automatically generate natural language texts containing weather element descriptions from structured weather data, improving the accuracy and flexibility of weather service text generation; wherein calculating the value accuracy of each entity according to the values and corresponding entities in the weather service generated texts and the values and corresponding entities in the target weather service texts comprises: According to the numerical accuracy calculation formula calculating the numerical accuracy of each entity, wherein, representing the numerical accuracy of an entity , representing the numerical value of an entity in the target meteorological service text, representing the numerical value of an entity in the meteorological service generated text, representing the weight.

2. The method of claim 1, wherein, the encoding mode of the graph encoder is linear encoding; the decoder further comprises an LSTM decoder, which comprises a copy mechanism for avoiding loss of important information in the generated weather service generated texts; the named entity recognition model comprises a BERT, a BiLSTM and a CRF model.

3. The method of claim 1, wherein, The data encoder comprises a first transformer encoder and a second transformer encoder, and encoding the structured weather data samples using the data encoder comprises: encoding entities in the structured weather data samples using the first transformer encoder to obtain a first sub-data feature vector; encoding entities in the structured weather data samples and values corresponding to the entities using the second transformer encoder to obtain a second sub-data feature vector; The data feature vector is calculated according to the first sub-data feature vector and the second sub-data feature vector.

4. The method of claim 1, wherein, The numerical accuracy loss is calculated according to the numerical accuracy of each entity, and the total loss is calculated according to the numerical accuracy loss, the coverage loss and the cross-entropy loss of the weather service generation text and the target weather service text, including: According to a numerical accuracy loss calculation formula calculating the numerical accuracy loss, wherein, denotes the numerical accuracy loss, denotes the numerical accuracy of the respective entity; According to the total loss calculation formula Calculate the total loss, wherein, denotes the total loss, denotes the weight of the cross-entropy loss, denotes the cross-entropy loss, , denotes the i-th word, denotes the sentence length, denotes the probability distribution of the i-th word in the target meteorological service text, denotes the probability distribution of the i-th word in the meteorological service generated text, denotes the weight of the coverage loss, denotes the coverage loss, , denotes the weight at time t, denotes the cumulative weight at time t, denotes the weight of the numerical accuracy loss, denotes the numerical accuracy loss.

5. The method of claim 1, wherein, The method further comprises: obtaining a target scene data sample, wherein the target scene data sample comprises a target scene knowledge graph, a target scene structured weather data sample and a target scene target weather service text corresponding to the target scene structured weather data sample; retraining the weather service text generation model using the target scene data sample to obtain a weather service text generation model suitable for a target scene.

6. The method of claim 1, wherein, The method further comprises: obtaining structured weather data; generating a weather service text from the structured weather data using the weather service text generation model to obtain a corresponding weather service text. 7.A device for training a weather service text generation model, characterized by, The weather service text generation model comprises a graph encoder, a data encoder and a decoder, and the device comprises: an obtaining unit configured to obtain data samples in the field of weather services, wherein the data samples comprise a knowledge graph, a structured weather data sample and a target weather service text corresponding to the structured weather data sample; an encoding unit configured to encode the knowledge graph using the graph encoder to obtain a graph feature vector, and encode the structured weather data sample using the data encoder to obtain a data feature vector; a decoding unit configured to decode the graph feature vector and the data feature vector using the decoder to obtain a weather service generation text, wherein the decoder comprises a coverage mechanism configured to avoid repeated words at the end of the weather service generation text; an extracting unit configured to extract numerical values and corresponding entities in the weather service generation text and numerical values and corresponding entities in the target weather service text using a named entity recognition model; a first calculating unit configured to calculate the numerical accuracy of each entity according to the numerical values and corresponding entities in the weather service generation text and the numerical values and corresponding entities in the target weather service text; a second calculating unit configured to calculate a numerical accuracy loss according to the numerical accuracy of each entity, and calculate a total loss according to the numerical accuracy loss, a coverage loss and a cross-entropy loss of the weather service generation text and the target weather service text; a training unit configured to train the graph encoder, the data encoder and the decoder according to the total loss until a preset condition is met to obtain a trained weather service text generation model, wherein the weather service text generation model is configured to automatically generate natural language texts containing weather element descriptions from structured weather data, and improve the accuracy and flexibility of weather service text generation. The first calculation unit is further configured to calculate the numerical accuracy according to a numerical accuracy calculation formula The numerical accuracy of each entity is calculated, wherein The numerical accuracy of the entity The numerical accuracy of the entity The numerical accuracy of the entity The numerical accuracy of the entity The numerical accuracy of the entity The numerical accuracy of the entity The numerical accuracy of the entity 8. An electronic device comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, The processor implements the steps of the method in any one of claims 1-6 when executing the computer program.

9. A computer-readable storage medium, characterized in that, The computer readable storage medium stores machine executable instructions, which when invoked and run by a processor, cause the processor to run the method in any one of claims 1-6.

Citation Information

Patent Citations

  • Method and device for determining toxic heavy gas leakage concentration distribution in urban environment and medium

    CN111144055A

  • Method and device for obtaining meteorological service knowledge

    CN113254473A