Meteorological query system and meteorological query method

By combining the large language model with real-time weather query tools and meteorological vector databases, the problem of large language models relying on static data in weather queries is solved, the transparency of real-time information acquisition and decision-making processes is achieved, and the accuracy of weather queries is improved. and user experience.

CN118626575APending Publication Date: 2024-09-10WUHAN UNIV

Patent Information

Application Number
CN202410769171.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-14
Publication Date
2024-09-10

AI Technical Summary

Technical Problem

When querying weather-related knowledge, large language models rely on static training data, resulting in generated answers that are outdated and difficult to verify their reliability, and parameter complexity makes the decision-making process opaque.

Method used

By connecting the large language model with the real-time meteorological query tool, real-time meteorological data is obtained, and the fine-tuning module and meteorological vector database are used to enhance the model's professional knowledge and real-time information acquisition capabilities, and improve the interpretability of the decision-making process.

Benefits of technology

It realizes the real-time information acquisition capability of large language models in meteorological queries, improves the accuracy of answers and user experience, and makes the use of complex tools easier to operate and understand.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118626575A
    Figure CN118626575A
Patent Text Reader

Abstract

The invention discloses a meteorological query system and a meteorological query method, and belongs to the technical field of artificial intelligence. The meteorological query system comprises a large language model, the large language model is connected with a plurality of tools, and the plurality of tools comprise real-time meteorological query tools; the large language model is used for generating a first answer based on first query information input by a user; obtaining first meteorological data based on the first query information and a real-time meteorological query tool; and generating a second answer based on the first meteorological data and the first answer. According to the meteorological query system, accurate answers can be obtained based on the large language model when meteorological related knowledge is queried.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of artificial intelligence technology, and in particular to a weather query system and a weather query method. Background Art

[0002] At present, the technology of Large Language Models (LLMs) has gradually matured, and LLMs can also be used to query meteorological knowledge in the field of meteorology and transportation. LLMs are complex artificial intelligence systems built based on advanced deep learning technology, focusing on understanding and generating natural language text.

[0003] LLMs can perform accurate information retrieval, effective question answering, and generate contextually relevant and coherent responses. In addition, LLMs also have the ability to perform sentiment analysis and user intent recognition, thus better adapting to user needs and behaviors.

[0004] However, there are still some problems when using LLMs to query meteorological knowledge. For example, the training data of LLMs is static, so in meteorological queries that require the latest or real-time information, it can only rely on outdated data to generate answers, resulting in outdated answers. In some cases, outdated answers are actually wrong answers. For another example, LLMs encode knowledge in a huge set of parameters, making its decision-making process and the specific meaning of the parameters difficult for humans to understand, making it difficult to verify the reliability of the generated answers. Summary of the invention

[0005] The present disclosure provides a weather query system and a weather query method, which can obtain accurate answers based on a large language model when querying weather-related knowledge. The technical solution at least includes the following solutions:

[0006] In a first aspect, a weather query system is provided, comprising: a large language model, wherein the large language model is connected to a plurality of tools, wherein the plurality of tools include a real-time weather query tool; the large language model is used to generate a first answer based on first query information input by a user; based on the first query information and the real-time weather query tool, first weather data is obtained; and based on the first weather data and the first answer, a second answer is generated.

[0007] Optionally, the weather query system also includes: a fine-tuning module, which is connected to the large language model; the fine-tuning module is used to fine-tune the large language model based on low-rank adaptive LoRA technology.

[0008] Optionally, the large language model includes network parameters, and the fine-tuning module is used to implement the fine-tuning of the large language model based on LoRA technology in the following manner: based on different tools connected to the large language model, training a first bypass parameter and a second bypass parameter, the first bypass parameter and the second bypass parameter are used to fine-tune the network parameters, multiple parameters in the network parameters constitute a d-by-d matrix, multiple parameters in the first bypass parameters constitute an r-by-d matrix, and multiple parameters in the second bypass parameters constitute a d-by-r matrix.

[0009] Optionally, the first bypass parameter and the second bypass parameter are used to fine-tune the network parameter using the following formula:

[0010] W′=W+AB

[0011] Wherein, W′ is the fine-tuned network parameter, W is the network parameter, A is the first bypass parameter, and B is the second bypass parameter.

[0012] Optionally, the large language model is connected to a meteorological vector database, which includes multiple meteorological vectors, each of which corresponds to a meteorological data. The large language model is also used to convert the first query information into a first query vector, perform similarity calculation on the first query vector and the multiple meteorological vectors to determine the m meteorological vectors closest to the first query vector, obtain m meteorological data corresponding to the m meteorological vectors, and input the m meteorological data and the first query information into the large language model to obtain the first answer output by the large language model.

[0013] Optionally, the meteorological vector database is constructed in the following manner: obtaining multiple meteorological knowledge texts; dividing the multiple meteorological knowledge texts into multiple meteorological data, each meteorological data being a text block; and based on a first embedding model, converting the multiple meteorological data into the multiple meteorological vectors.

[0014] Optionally, the meteorological vector database also includes an index list, the index list includes multiple index information, the first index information is used to indicate a first meteorological vector, the first index information is any one of the multiple index information, the first index information includes characteristic information of the first meteorological vector, the meteorological data corresponding to the first meteorological vector, and the meteorological knowledge text to which the meteorological data corresponding to the first meteorological vector belongs.

[0015] Optionally, the large language model is also used to: perform sentence rewriting and sensitive information detection on the first answer and the second answer.

[0016] In a second aspect, a weather query method is also provided, including: obtaining first query information; inputting the first query information into a weather query system, the weather query system including: a large language model, the large language model is connected to multiple tools, the multiple tools include a real-time weather query tool, the large language model is used to generate a first answer based on the first query information input by a user, based on the first query information and the real-time weather query tool, obtain first weather data, based on the first weather data and the first answer, generate a second answer; obtain the second answer output by the weather query system.

[0017] The beneficial effects brought by the technical solution provided by the embodiments of the present disclosure include at least:

[0018] In the disclosed embodiment, since the large language model in the weather query system is connected to multiple tools, wherein the multiple tools include a real-time weather query tool, the weather query system can obtain real-time weather data (that is, the first weather data), and generate a second answer based on the answer of the large language model and the first weather data queried by the tool. In this way, the professional knowledge and real-time information acquisition capabilities of the large language model can be enhanced, and the existence of the first weather data makes the decision-making process of the large language model explainable, which can improve the user experience and make the use of complex tools easier to access and operate, thereby providing users with more accurate and personalized responses. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] In order to more clearly illustrate the technical solutions in the embodiments of the present disclosure, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0020] Figure 1 A schematic diagram of the structure of a weather query system provided by an exemplary embodiment of the present disclosure is shown;

[0021] Figure 2 A schematic diagram of the structure of a weather query system provided by another exemplary embodiment of the present disclosure is shown;

[0022] Figure 3 This is a schematic diagram of fine-tuning a large language model;

[0023] Figure 4 is a flow chart of a large language model generating a first answer based on first query information input by a user;

[0024] Figure 5 A flow chart of a weather query method provided by an exemplary embodiment of the present disclosure is shown;

[0025] Figure 6 It is a schematic diagram of the structure of a computer device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION

[0026] Unless otherwise defined, the technical or scientific terms used herein shall have the usual meanings understood by persons of ordinary skill in the field to which the present disclosure belongs. The words "first", "second", "third" and similar words used in the patent application specification and claims of the present disclosure do not indicate any order, quantity or importance, but are only used to distinguish different components. Similarly, words such as "one" or "one" do not indicate a quantitative limitation, but indicate the existence of at least one. Words such as "include" or "comprise" and similar words mean that the elements or objects appearing before "include" or "comprise" include the elements or objects listed after "include" or "comprise" and their equivalents, and do not exclude other elements or objects. Words such as "connect" or "connected" and similar words are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. A and / or B means that there are three situations: A, B, and A and B.

[0027] In order to make the objectives, technical solutions and advantages of the present disclosure more clear, the embodiments of the present disclosure will be further described in detail below with reference to the accompanying drawings.

[0028] Figure 1 A schematic diagram of the structure of a weather query system provided by an exemplary embodiment of the present disclosure is shown. Figure 1 The weather query system 100 includes a large language model 11, and the large language model 11 is connected to multiple tools 12, and the multiple tools 12 include a real-time weather query tool.

[0029] The large language model 11 is used to generate a first answer based on first query information input by a user, obtain first meteorological data based on the first query information and a real-time meteorological query tool, and generate a second answer based on the first meteorological data and the first answer.

[0030] In the disclosed embodiment, the large language model 11 is connected to the plurality of tools 12 via an API (Application Programming Interface).

[0031] Here, the first answer is generated based on the first query information input by the user, that is, the first query information input by the user is input into the large language model 11, and the output generated by the large language model 11 for the first query information is the first answer. Similarly, the second answer is generated based on the first meteorological data and the first answer, that is, the first meteorological data and the first answer are both input into the large language model 11, and the output generated by the large language model 11 for the first meteorological data and the first answer is the second answer.

[0032] Optionally, the real-time weather query tool is used to query real-time weather data, traffic data or weather traffic data. Here, weather traffic data is data related to the real-time monitoring and prediction of weather conditions along railways or highways.

[0033] Optionally, the real-time weather query tool includes but is not limited to an official weather website, an official traffic weather website, or software capable of querying weather data in an official traffic weather website, and the like.

[0034] For meteorological data, traffic data, or meteorological traffic data, the acquired data needs to be extremely timely to ensure accuracy. Meteorological conditions, traffic conditions, or meteorological traffic conditions are changing rapidly, and the weather forecast one hour ago may be inaccurate one hour later. Therefore, when querying meteorological data, traffic data, or meteorological traffic data through a large language model, it is necessary to ensure that the answer of the large language model is generated based on real-time data, rather than outdated data. If the answer of the large language model is generated based on outdated data, the generated answer may be inaccurate.

[0035] In the disclosed embodiment, since the large language model in the weather query system 100 is connected to multiple tools, wherein the multiple tools include a real-time weather query tool, the weather query system 100 can obtain real-time weather data (that is, the first weather data), and generate a second answer based on the answer of the large language model and the first weather data queried by the tool. In this way, the ability of LLMs to obtain real-time information can be enhanced, and the existence of the first weather data makes the decision-making process of LLMs explainable, which can improve the user experience and make the use of complex tools easier to access and operate, thereby providing users with more accurate and personalized responses.

[0036] Figure 2 A schematic diagram of the structure of a weather query system provided by another exemplary embodiment of the present disclosure is shown. Figure 2The weather query system 100 includes a large language model 11, a fine-tuning module 13 and a weather vector database 14. The large language model 11 is connected to the fine-tuning module 13, the weather vector database 14 and a plurality of tools 12 respectively. The plurality of tools 12 include a real-time weather query tool. The weather vector database 14 includes a plurality of weather vectors, each of which corresponds to a piece of weather data.

[0037] In the embodiment of the present disclosure, before the weather query system 100 obtains the first query information input by the user, it is necessary to establish a weather vector database 14.

[0038] The meteorological vector database 14 is a database system for storing and processing meteorological data in vector form. It supports efficient mathematical operations and fast data retrieval by converting meteorological knowledge text or other types of data into vector representations. This database can effectively improve processing efficiency when processing large-scale data sets, achieving fast query matching, and supporting complex query operations (such as fuzzy matching and semantic search). The meteorological vector database 14 uses machine learning models to convert meteorological knowledge text into semantically rich vectors. These vectors capture the deep semantic relationships of meteorological knowledge texts rather than just the literal meaning, so that when querying, even if there are lexical differences (such as synonyms), relevant results can be found.

[0039] Optionally, the meteorological vector database 14 is created using the following three steps:

[0040] The first step is to obtain multiple meteorological knowledge texts.

[0041] Multiple meteorological knowledge texts can be obtained from public data such as the meteorological bureau data and the China Meteorological Network data. Multiple meteorological knowledge texts include knowledge texts related to weather, climate, meteorological science and related fields.

[0042] Optionally, the first step also includes: constructing a plurality of meteorological knowledge texts into a meteorological knowledge text library.

[0043] The second step is to divide multiple meteorological knowledge texts into multiple meteorological data.

[0044] Each meteorological data is a text block.

[0045] Optionally, in the case where there is a meteorological knowledge text library, the second step includes: preprocessing the multiple meteorological knowledge in the meteorological knowledge text library.

[0046] Preprocessing multiple meteorological knowledge in the meteorological knowledge text library includes: selecting high-quality and highly relevant information from the meteorological knowledge text library, and retaining the source information of each meteorological knowledge text (such as which website or software each meteorological knowledge text comes from). Removing irrelevant information, repeated content, and possibly erroneous meteorological knowledge texts in the meteorological knowledge texts to improve the quality and accuracy of the meteorological knowledge texts stored in the meteorological knowledge text library. And performing preprocessing actions such as text segmentation and stop word removal to ensure the consistency and searchability of the meteorological knowledge texts.

[0047] After the preprocessing of text segmentation and stop word removal, the meteorological data that has been preliminarily divided can be obtained. However, the text lengths of these preliminarily divided meteorological data are not the same, and some of the texts are still quite large text blocks. If these large text blocks are directly used to build the meteorological vector database 14, a lot of noise and redundant context will be introduced, and the large language model is limited by the maximum context length and cannot process these large text blocks.

[0048] Therefore, it is necessary to divide these large text blocks into smaller text blocks through appropriate chunking strategies. Smaller text blocks are more able to focus on a single or a few concepts and reduce the interference of irrelevant information (that is, noise). In this way, more accurate and relevant information can be provided to users.

[0049] In the disclosed embodiment, the block division strategy is implemented by a sliding window. Exemplarily, the window size of the sliding window is 500 bytes and the step size is 100 bytes. The window size and step size of the sliding window can be set according to the requirements. For example, when the text blocks need to be divided into smaller ones, the window size of the sliding window can be reduced; and if more small text blocks need to be obtained based on a large text block, the step size of the sliding window can be reduced.

[0050] In the third step, based on the first embedding model, multiple meteorological data are converted into multiple meteorological vectors.

[0051] In machine learning and natural language processing, text embedding refers to representing words in a text as dense vectors of fixed length, also known as word vectors. Here, the first embedding model is used to convert meteorological data into multiple meteorological vectors by text embedding.

[0052] Optionally, the first embedding model is also used to perform an embedding query on each meteorological vector. The embedding query is used to query the distance between each meteorological vector and other meteorological vectors in multiple meteorological vectors. For example, if there are 100 meteorological vectors, it is necessary to query the distance between any meteorological vector and the other 99 meteorological vectors.

[0053] After determining the distance between each meteorological vector and other meteorological vectors, the correlation between each meteorological vector and other meteorological vectors in the meteorological vector database 14 can be determined based on the distance. For example, the distances between a certain meteorological vector and other meteorological vectors can be sorted in ascending order, and the first n vectors in the sorting are taken as vectors related to the meteorological vector. Wherein n is a positive integer. The specific value of n is set according to experience, and the embodiment of the present disclosure does not limit this.

[0054] By determining the correlation between each meteorological vector and other meteorological vectors in the meteorological vector database 14, the subsequent process of calculating the similarity between the first query vector and multiple meteorological vectors can be simplified.

[0055] In the embodiment of the present disclosure, the embedding model for performing text embedding in meteorological data and the embedding model for performing embedded query are the same embedding model, that is, the first embedding model.

[0056] Optionally, the first embedding model is thenlper / get-base-zh. thenlper / get-base-zh is pre-trained on a very large text corpus through tasks such as predicting the next word and predicting the masked token, which enables it to learn to represent tokens in N dimensions and capture semantic information.

[0057] There are many implementation methods of thenlper / get-base-zh in the related technologies, so detailed description is omitted here.

[0058] After obtaining the multiple meteorological vectors, the multiple meteorological vectors may be stored in the meteorological vector database 14 .

[0059] Optionally, in the case where the meteorological vector database 14 exists, an index list of multiple meteorological vectors in the meteorological vector database 14 may be established so that each meteorological vector can be quickly retrieved.

[0060] The index list includes a plurality of index information. For the first index information in the index list, the first index information is used to indicate the first meteorological vector. The first index information may include feature information of the first meteorological vector, meteorological data corresponding to the first meteorological vector, and meteorological knowledge text to which the meteorological data corresponding to the first meteorological vector belongs.

[0061] Here, the first index information is any one of the multiple index information in the index list. The structure of the other index information in the index list is the same as that of the first index information.

[0062] The characteristic information of the first meteorological vector is used to uniquely indicate the first meteorological vector, and may be, for example, the name or keyword of the first meteorological vector.

[0063] In implementation, an index list can be created using Postgres and pgvector, and the first index information is saved in the form of a triple, which includes: text, source, and embedding. The text is the meteorological data corresponding to the first meteorological vector, the source is the meteorological knowledge text to which the meteorological data corresponding to the first meteorological vector belongs, and the embedding is the feature information of the first meteorological vector.

[0064] There are many implementation methods of Postgres and pgvector in the related technologies, so detailed description is omitted here.

[0065] Optionally, the staff needs to manually update the meteorological vector database 14 every set number of days to improve the reliability of the meteorological vectors in the meteorological vector database 14. The set number of days may range from 1 to 15 days, for example, 1 day, 3 days, 5 days, 10 days or 15 days.

[0066] The large language model in the related art will not update the data after training is completed, and will only generate answers based on the existing data, which is equivalent to being completely out of time. In the embodiment of the present disclosure, by regularly updating the meteorological vector database 14, it is possible to regularly update the professional knowledge in the meteorological field, thereby improving the timeliness of the meteorological vector database 14.

[0067] When the large language model 11 is connected to multiple tools 12, different tools require different input data formats, and different tools output data formats are also different. Therefore, it is necessary to perform tool training through the large language model 11 so that the large language model 11 can accurately use different tools. Here, the large language model 11 uses different tools, which means that the large language model 11 can convert the data required to be input into the input data format required by the tool according to different tools.

[0068] For example, the data to be input into a tool is "query the weather forecast for a certain city on C month D day", and the data format required by the tool is: location, date. The large language model 11 trained by the tool can convert the data to be input into the data format required by the tool, that is, "a certain city, C month D day".

[0069] In the case of multiple tools 12, for the first query information input by the user, the large language model 11 needs to determine which tool is used to obtain meteorological data for the first query information. In addition, after the first query information is input into a tool, since the output of the tool is generally formatted output rather than an instruction that the large language model 11 can understand, the large language model 11 also needs to be able to understand the specific meaning of the content output by the tool.

[0070] The fine-tuning module 13 in the disclosed embodiment is used to train the large language model 11, so that the large language model can accurately determine which tool to input the query information based on the query information input by the user, and enable the large language model 11 to understand the specific meaning of the content output by the tool.

[0071] The fine-tuning module 13 is used to fine-tune the large language model 11 based on the Low Rank Adaption (LoRA) technology.

[0072] Optionally, the large language model includes network parameters. In this case, the fine-tuning module 13 fine-tunes the large language model based on the LoRA technology, including: training a first bypass parameter and a second bypass parameter based on different tools connected to the large language model 11, and the first bypass parameter and the second bypass are used to fine-tune the network parameters.

[0073] Among them, multiple parameters in the network parameters constitute a d-by-d matrix, multiple parameters in the first bypass parameters constitute an r-by-d matrix, and multiple parameters in the second bypass parameters constitute a d-by-r matrix.

[0074] In the disclosed embodiment, when the number of tools in the plurality of tools 12 increases or decreases, it is necessary to train the large language model 11 through the fine-tuning module 13. Since the number of network parameters of the large language model 11 is large, if the network parameters of the large language model 11 are retrained every time a tool is added or reduced, it will undoubtedly greatly increase the cost. Therefore, in the disclosed embodiment, the fine-tuning module 13 fine-tunes the large language model 11 by using the LoRA technology. When it is necessary to add or reduce tools, it is only necessary to train the first bypass parameter and the second bypass parameter, while the network parameters remain unchanged, and the fine-tuning of the network parameters is achieved through the trained first bypass parameter and the second bypass parameter.

[0075] Here, in the process of training a large language model, it is necessary to store the parameters to be trained. Then, the more parameters to be trained, the larger the amount of data to be stored, and the longer the time spent. In the embodiment of the present disclosure, multiple parameters in the network parameters constitute a d-by-d matrix, that is, there are d-by-d network parameters, and multiple parameters in the first bypass parameters constitute an r-by-d matrix, and multiple parameters in the second bypass parameters constitute a d-by-r matrix, that is, there are twice the d-by-r parameters in the first bypass parameters and the second bypass parameters. Then, when r is small enough, twice d times r is much smaller than d times d, that is, compared with training the entire network parameters, the number of parameters to be trained that need to be stored when training the first bypass parameters and the second bypass parameters is greatly reduced. Therefore, in the embodiment of the present disclosure, by training only the first bypass parameters and the second bypass parameters during fine-tuning, without training the network parameters, the amount of data required to be stored in the training process can be greatly reduced, the time required to be spent can be reduced, and the efficiency of fine-tuning can be improved.

[0076] Optionally, the first bypass parameter and the second bypass parameter are used to fine-tune the network parameters using formula (1):

[0077] W′=W+AB (1)

[0078] In formula (1), W′ is the fine-tuned network parameter, W is the network parameter, A is the first bypass parameter, and B is the second bypass parameter. It can be seen that when only the first bypass parameter and the second bypass parameter are trained to fine-tune the network parameter, the network parameter does not change. Since the multiple parameters in the first bypass parameter constitute an r-by-d matrix, and the multiple parameters in the second bypass parameter constitute a d-by-r matrix, the matrix obtained after AB is also a d-by-d matrix, so it can be added to W.

[0079] Optionally, after fine-tuning is completed, the fine-tuned network parameters are saved, for example, saved as low-rank weights.

[0080] Exemplarily, after the network parameters of the large language model 11 are fine-tuned, the large language model 11 is used to process input data using formula (2).

[0081] h=xW′=x(W+AB)=xW+xAB (2)

[0082] In formula (2), h is the data output by the large language model, and x is the data input to the large language model 11. The meanings of other parameters in formula (2) are the same as those in formula (1), and detailed description is omitted here.

[0083] Figure 3 is a schematic diagram of fine-tuning a large language model. Figure 3As shown, the input data x is a d-dimensional vector, multiple parameters in the network parameter W constitute a d-by-d matrix, multiple parameters in the first bypass parameter A constitute an r-by-d matrix, and multiple parameters in the second bypass parameter B constitute a d-by-r matrix. In the process of fine-tuning the large language model 11 by the fine-tuning module 13, the process of processing the input data x through the fine-tuned network parameters can be divided into two parts. One part is that x is processed by the network parameter W, and this step obtains xW in formula (2); the other part is that the input data x is processed by the first bypass parameter A and the second bypass parameter B, and this step obtains xAB in formula (2). Adding the two together, the data h output by the large language model is obtained. Figure 3 In the initial state, the first bypass parameter is a parameter with a mean of 0 and a variance of σ after random initialization, that is, A = N(0, σ 2 ); the second bypass parameter is initialized to 0, that is, B = 0. In the process of fine-tuning the large language model 11 by the fine-tuning module 13, the first bypass parameter and the second bypass parameter will gradually change until the appropriate first bypass parameter and the second bypass parameter are obtained.

[0084] In the disclosed embodiment, the fine-tuning module 13 fine-tunes the pre-trained large language model 11. The pre-trained large language model 11 can be loaded using the Transformers library of Hugging Face. In some examples, a word segmenter can also be loaded while loading the pre-trained large language model 11.

[0085] Exemplarily, the pre-trained large language model 11 may be a ChatGLM3-6B model.

[0086] When implementing the fine-tuning module 13, the data input to the large language model 11 can be converted into a format suitable for the model through preprocessing (the data input to the large language model 11 here is also the data used for training or verification), including input tensors (input_ids), attention masks (attn_mask) and labels (labels). Then, the model weights are adjusted through the LoRA (Low-Rank Adaptation) technology to optimize the responsiveness and generalization ability of the large language model 11. During the training process, the Accelerate library can be used to implement model training in a multi-GPU (Graphics Processing Unit, image processor) environment to improve processing efficiency. AdamW is used as the optimizer, combined with the cosine warm-up learning rate scheduling strategy to stably and efficiently advance the training process. Finally, the adjusted model weights are saved after the training is completed, laying a solid foundation for subsequent model reasoning and application.

[0087] Here, Hugging Face is a company that provides a Transformers library that includes multiple pre-trained large language models.

[0088] The Accelerate library is a library designed for PyTorch users that can help simplify the process of distributed training and mixed precision training. PyTorch is the python version of torch, an open source neural network framework specifically for GPU-accelerated deep neural network programming.

[0089] AdamW is an improved optimization algorithm that adds a weight decay mechanism to the Adam optimization algorithm. AdamW can effectively prevent model overfitting and improve the generalization ability of the model.

[0090] The cosine warm-up learning rate scheduling strategy is to train the learning rate by warm-up and adjust the learning rate by cosine annealing.

[0091] There are many related technologies about Huggingface's Transformers library, Accelerate library, AdamW, training learning rate by preheating, and adjusting learning rate by cosine annealing, which will not be described in detail here.

[0092] Through the fine-tuning module 13, it is ensured that the performance of the large language model 11 on specific tasks is significantly improved, that is, the large language model 11 can accurately determine which tool to input the first query information based on the user's first query information, while also improving the economy and efficiency of the training process.

[0093] In the disclosed embodiment, the large language model 11 is used to generate a first answer based on first query information input by a user, obtain first meteorological data based on the first query information and a real-time meteorological query tool, and generate a second answer based on the first meteorological data and the first answer.

[0094] Figure 4 This is a flowchart of the large language model generating a first answer based on the first query information input by the user, see Figure 4 The large language model 11 is used to generate a first answer based on the first query information input by the user by adopting the following steps ac:

[0095] Step a: converting the first query information into a first query vector.

[0096] Optionally, when converting the first query information into the first query vector, the first query information is converted into the first query vector by text embedding through the first embedding model.

[0097] In this way, it can be ensured that the first query vector and the multiple meteorological vectors stored in the meteorological vector database 14 are in the same dimensional space, so as to facilitate the subsequent similarity calculation of the meteorological vectors.

[0098] Step b: performing similarity calculation between the first query vector and multiple meteorological vectors to determine m meteorological vectors that are closest to the first query vector.

[0099] Optionally, a cosine similarity technique is used to calculate the similarity between the first query vector and a plurality of meteorological vectors, so that the similarity between the first query vector and each meteorological vector can be obtained.

[0100] After obtaining the similarity between the first query vector and each meteorological vector, these similarities can be sorted in ascending order, and the meteorological vectors corresponding to the first m similarities are taken as the m meteorological vectors closest to the first query vector for subsequent processing.

[0101] Step c: obtaining m meteorological data corresponding to the m meteorological vectors, and inputting the m meteorological data and the first query information into the large language model 11 to obtain a first answer output by the large language model 11.

[0102] Wherein, m is a positive integer. The specific value of m is set according to experience, and the embodiment of the present disclosure does not limit this.

[0103] The above steps ac are also called Retrieval-Augmented Generation (RAG) technology.

[0104] Optionally, before executing step c, the large language model 11 is also used to filter and simplify the m meteorological data corresponding to the m meteorological vectors to ensure that the filtered and simplified meteorological data are highly relevant to the first query information, thereby improving the accuracy of the first answer obtained.

[0105] In the case where there is filtered and simplified meteorological data, step c includes: inputting the filtered and simplified meteorological data and the first query information into the large language model 11 to obtain a first answer output by the large language model 11.

[0106] By filtering and streamlining the meteorological data, the accuracy and relevance of the first answer can be improved.

[0107] In the disclosed embodiment, when the first answer is generated by the above steps ac, the data in the meteorological vector database 14 is updated regularly, so the generated first answer has a certain timeliness. And because some professional knowledge is updated slowly, regularly updating the data in the meteorological vector database 14 can ensure that the professional knowledge in the meteorological vector database 14 is the latest (or newer) data. Therefore, in terms of professional knowledge, the first answer generated by the above steps ac has a strong timeliness.

[0108] After obtaining the first answer, the large language model 11 can execute based on the first query information and the real-time weather query tool to obtain the first weather data; based on the first weather data and the first answer, generate the second answer.

[0109] Since the large language model 11 has undergone the tool training process and the large language model 11 has been fine-tuned by the fine-tuning module 13, the large language model 11 can understand that the first query information needs to be input into the real-time meteorological query tool, and the large language model 11 can also accurately input the first query information into the real-time meteorological query tool to obtain the first meteorological data.

[0110] The real-time weather query tool can query the real-time updated weather data, such as the temperature, humidity and other parameters at a certain moment. Therefore, in terms of real-time weather data, the second answer generated based on the first weather data and the first answer has a strong timeliness. The stronger the timeliness, the higher the possibility that the second answer is accurate.

[0111] Optionally, the large language model 11 is also used to perform sentence rewriting and sensitive information detection on the first answer and the second answer.

[0112] Optionally, when sensitive information is detected by the sensitive information detection, the large language model 11 is further used to: filter the sensitive information in the first answer and / or the second answer.

[0113] When sensitive information exists in the first answer, the large language model 11 is used to filter the sensitive information in the first answer.

[0114] When sensitive information exists in the second answer, the large language model 11 is used to filter the sensitive information in the second answer.

[0115] When sensitive information exists in both the first answer and the second answer, the large language model 11 is used to filter the sensitive information in the first answer and the second answer.

[0116] In some cases, the generated answers may contain sensitive information and be difficult to understand. By rewriting the first answer and the second answer, the first answer and the second answer can be made easier to understand. By detecting sensitive information in the first answer and the second answer and filtering sensitive information when sensitive information is detected, the security of the generated answers can be improved.

[0117] In the disclosed embodiment, the first answer is generated by the search enhancement technology, and the second answer is generated by combining the professional knowledge queried by the tool, which not only enhances the professional knowledge and real-time information acquisition capabilities of the model, but also improves the interpretability and transparency of the decision-making process. When the staff obtains the second answer, they can trace it back to the first answer and the first meteorological data, thereby improving the interpretability and transparency of the generation process of the second answer.

[0118] In addition, by generating the first answer through the search enhancement technology and combining the professional knowledge queried through the tool to generate the second answer, the reliance on parameterized knowledge (such as data in the meteorological vector database 14) can be reduced. The existence of multiple tools 12 makes the large language model 11 more robust and less susceptible to adversarial attacks. In addition, the use process of professional tools in meteorology is relatively complex and has a high threshold. By inputting the first query information into the tool through the large language model 11, the use of complex tools can be made easier to access and operate, thereby providing users with more accurate and personalized responses.

[0119] It should be noted that: when the weather query system provided in the above embodiment is used to query the weather, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.

[0120] The division of modules in the embodiments of the present disclosure is schematic and is only a logical function division. There may be other division methods in actual implementation. In addition, each functional module in each embodiment of the present disclosure may be integrated into a processor, or may exist physically separately, or two or more modules may be integrated into one module. The above-mentioned integrated modules may be implemented in the form of hardware or in the form of software functional modules.

[0121] If the integrated module is implemented in the form of a software function module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present disclosure is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a terminal device (which can be a personal computer, a mobile phone, or a communication device, etc.) or a processor (processor) to perform all or part of the steps of the method of each embodiment of the present disclosure. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk and other media that can store program code.

[0122] The following is a method embodiment of the present application. For details not described in detail in the method embodiment, reference can be made to the above-mentioned weather query system embodiment.

[0123] Figure 5 A flowchart of a weather query method provided by an exemplary embodiment of the present disclosure is shown. The method can be executed by a computer device. Figure 5 , the method comprising:

[0124] In step 501, first query information is obtained.

[0125] In step 502, first query information is input into a weather query system.

[0126] The weather query system includes: a large language model, the large language model is connected to multiple tools, the multiple tools include a real-time weather query tool, the large language model is used to generate a first answer based on first query information input by a user, based on the first query information and the real-time weather query tool, obtain first weather data, based on the first weather data and the first answer, generate a second answer.

[0127] Here, the weather query system in step 502 can refer to the aforementioned Figure 1 or Figure 2 The weather query system 100 in the embodiment is not described in detail here.

[0128] In step 503, a second answer output by the weather query system is obtained.

[0129] Figure 6 Schematic diagram of the structure of the computer device provided by the embodiment of the present disclosure. Figure 6 As shown, the computer device 600 includes: a processor 601 and a memory 602 .

[0130] The processor 601 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 601 may be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). The processor 601 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a CPU (Central Processing Unit); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 601 may be integrated with a GPU, which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 601 may also include an AI (Artificial Intelligence) processor, which is used to process computing operations related to machine learning.

[0131] The memory 602 may include one or more computer-readable storage media, which may be non-transitory. The memory 602 may also include a high-speed random access memory and a non-volatile memory, such as one or more disk storage devices and flash memory storage devices. In some embodiments, the non-transitory computer-readable storage medium in the memory 602 is used to store at least one instruction, which is used to be executed by the processor 601 to implement the weather query method provided in the embodiment of the present disclosure.

[0132] Those skilled in the art will understand that Figure 6 The structure shown in the figure does not constitute a limitation on the computer device 600, and the computer device 600 may include more or less components than shown in the figure, or combine some components, or adopt a different arrangement of components.

[0133] The embodiment of the present disclosure also provides a non-temporary computer-readable storage medium. When the instructions in the storage medium are executed by the processor of a computer device, the computer device can execute the weather query method provided in the embodiment of the present disclosure.

[0134] The embodiments of the present disclosure also provide a computer program product, including a computer program / instruction, which implements the weather query method provided in the embodiments of the present disclosure when executed by a processor.

[0135] The above description is only an optional embodiment of the present disclosure and is not intended to limit the present disclosure. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present disclosure shall be included in the protection scope of the present disclosure.

Claims

1. A weather query system, It is characterized in that The weather query system includes: a large language model, the large language model is connected to a plurality of tools, the plurality of tools includes a real-time weather query tool; The large language model is used to generate a first answer based on first query information input by a user; Based on the first query information and the real-time weather query tool, obtaining first weather data; A second answer is generated based on the first weather data and the first answer.

2. The weather query system according to claim 1, It is characterized in that The weather query system further includes: a fine-tuning module, the fine-tuning module being connected to the large language model; The fine-tuning module is used to fine-tune the large language model based on low-rank adaptive LoRA technology.

3. The weather query system according to claim 2, It is characterized in that The large language model includes network parameters, and the fine-tuning module is used to implement the fine-tuning of the large language model based on the LoRA technology in the following manner: Based on different tools connected to the large language model, a first bypass parameter and a second bypass parameter are trained, the first bypass parameter and the second bypass parameter are used to fine-tune the network parameters, multiple parameters of the network parameters constitute a d-by-d matrix, multiple parameters of the first bypass parameters constitute an r-by-d matrix, and multiple parameters of the second bypass parameters constitute a d-by-r matrix.

4. The weather query system according to claim 3, It is characterized in that The first bypass parameter and the second bypass parameter are used to fine-tune the network parameter using the following formula: W′=W+AB Wherein, W′ is the fine-tuned network parameter, W is the network parameter, A is the first bypass parameter, and B is the second bypass parameter.

5. A weather query system according to any one of claims 2 to 4, It is characterized in that The large language model is connected to a meteorological vector database, which includes multiple meteorological vectors, each of which corresponds to a meteorological data. The large language model is also used to convert the first query information into a first query vector, perform similarity calculation on the first query vector and the multiple meteorological vectors to determine the m meteorological vectors closest to the first query vector, obtain m meteorological data corresponding to the m meteorological vectors, and input the m meteorological data and the first query information into the large language model to obtain the first answer output by the large language model.

6. The weather query system according to claim 5, It is characterized in that The meteorological vector database is constructed in the following manner: Obtain multiple meteorological knowledge texts; Dividing the plurality of meteorological knowledge texts into a plurality of meteorological data, each meteorological data being a text block; Based on the first embedding model, the plurality of meteorological data are converted into the plurality of meteorological vectors.

7. The weather query system according to claim 6, It is characterized in that The meteorological vector database also includes an index list, and the index list includes a plurality of index information. The first index information is used to indicate a first meteorological vector. The first index information is any one of the multiple index information. The first index information includes characteristic information of the first meteorological vector, meteorological data corresponding to the first meteorological vector, and meteorological knowledge text to which the meteorological data corresponding to the first meteorological vector belongs.

8. A weather query system according to any one of claims 2 to 4, It is characterized in that The large language model is also used to perform sentence rewriting and sensitive information detection on the first answer and the second answer.

9. A weather query method, It is characterized in that The method comprises: Obtaining first query information; Inputting the first query information into a weather query system, the weather query system comprising: a large language model, the large language model being connected to a plurality of tools, the plurality of tools comprising a real-time weather query tool, the large language model being used to generate a first answer based on the first query information input by a user, acquiring first weather data based on the first query information and the real-time weather query tool, and generating a second answer based on the first weather data and the first answer; The second answer output by the weather query system is obtained.

Citation Information

Patent Citations

  • Multi-round dialogue processing method, device and equipment based on RAG

    CN117743559A

  • Question and answer reply method and system based on large model, terminal and storage medium

    CN117851569A

Cited By

  • Query text data processing method and device, medium and electronic equipment

    CN119128110A

  • Meteorological data analysis method, device and equipment based on large model agent and medium

    CN119577097A

  • Weather question and answer method, device and equipment based on large language model and medium

    CN121459804A

  • Large language model (LLM) integration for scenario generation in a risk management platform

    US12608672B2

  • Large language model (LLM) integration for scenario generation in a risk management platform

    US20250124393A1