Financial question and answer method and device, electronic equipment and computer readable storage medium
By building data indexes in financial databases and using large language models to generate answers, the problem of users searching and analyzing financial information multiple times in search engines is solved, and efficient and accurate financial information query and analysis is achieved.
Patent Information
- Application Number
- CN202411499837.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-25
- Publication Date
- 2025-03-07
AI Technical Summary
When searching for financial information through search engines, users need to search and open different web pages multiple times, and they need to analyze the collected information themselves.
Establish a financial database and build a data index, receive financial questions input by users, match the target data index, query the reference data and generate prompt information, and enter a large language model to generate target answers.
No need for users to search and analyze information multiple times, improving the efficiency of information query and the accuracy, relevance, completeness and security of answers.
Smart Images

Figure CN119577074A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a financial question-answering method, device, electronic device and computer-readable storage medium. Background Art
[0002] In the financial field, timely acquisition of information and reasonable analysis and utilization of the acquired information are of great significance to investment decisions. In related technologies, for financial issues such as securities, users mainly obtain the required information by searching in search engines.
[0003] However, when searching for information through search engines, users may need to conduct multiple searches and open different web pages to find the information they need, as the search engines have complex results. In addition, since search engines do not have the ability to think logically and analyze, users need to analyze the collected information themselves after collecting it. Summary of the invention
[0004] In view of this, the embodiments of the present application provide a financial question-and-answer method, device, electronic device and computer-readable storage medium to solve the problem that when retrieving information through a search engine, a user needs to perform multiple searches and open different web pages to find the information he needs, and after collecting the information, the user needs to analyze the collected information by himself.
[0005] According to the first aspect of the present application, a financial question-and-answer method is provided, comprising: obtaining original financial data; constructing a financial database based on the original financial data, and establishing a data index corresponding to the original financial data in the financial database; receiving a financial question input by a user, and matching a target data index corresponding to the financial question in the financial database; querying reference data of the financial question in the financial database based on the target data index, and generating prompt information based on the reference data; inputting the prompt information into a large language model, generating a target answer corresponding to the financial question, and returning the target answer to the user.
[0006] According to a second aspect of the present application, a financial question-and-answer device is provided, comprising: a data acquisition module for acquiring original financial data; an index construction module for constructing a financial database based on the original financial data, and establishing a data index corresponding to the original financial data in the financial database; an index matching module for receiving a financial question input by a user, and matching a target data index corresponding to the financial question in the financial database; an information generation module for querying reference data of the financial question in the financial database based on the target data index, and generating prompt information based on the reference data; a financial question-and-answer module for inputting the prompt information into a large language model, generating a target answer corresponding to the financial question, and returning the target answer to the user.
[0007] According to a third aspect of the present application, an electronic device is provided, comprising: a processor; and a memory for storing a program, wherein the program comprises instructions which, when executed by the processor, cause the processor to perform the above-mentioned model reasoning optimization method.
[0008] According to a fourth aspect of the present application, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable the computer to execute the above-mentioned model reasoning optimization method.
[0009] The exemplary embodiments of the present application may have some or all of the following beneficial effects:
[0010] In the financial question-answering method provided in the example implementation of the present application, original financial data is obtained; a financial database is constructed based on the original financial data, and a data index corresponding to the original financial data in the financial database is established; a financial question input by a user is received, and a target data index corresponding to the financial question is matched in the financial database; reference data of the financial question is queried in the financial database based on the target data index, and prompt information is generated based on the reference data; the prompt information is input into the large language model, a target answer corresponding to the financial question is generated, and the target answer is returned to the user. The embodiment of the present application establishes a financial database and a corresponding data index based on the original financial data. When a financial question input by a user is received, information related to the financial question is retrieved from the financial database, without the need for the user to search multiple times in the search engine and open different web pages to retrieve the required information; in addition, after retrieving relevant information about the financial question input by the user in the financial database, the embodiment of the present application can also generate prompt information based on the retrieved information, so that the large language model generates an answer to the financial question based on the prompt information, thereby improving the data query analysis and information integration capabilities of the large language model in the financial field, and ensuring the accuracy, relevance, completeness and security of the answer. At the same time, the embodiment of the present application generates answers to financial questions through a large language model, without the need for the user to analyze the retrieved information by himself.
[0011] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] Further details, features and advantages of the present application are disclosed in the following description of exemplary embodiments in conjunction with the accompanying drawings, in which:
[0013] Figure 1 A flowchart of a financial question-answering method according to an exemplary embodiment of the present application is shown;
[0014] Figure 2 The overall technical framework diagram of another financial question-answering method according to an exemplary embodiment of the present application is shown;
[0015] Figure 3 A method flow chart of building a real-time securities database in another financial question-answering method according to an exemplary embodiment of the present application is shown;
[0016] Figure 4 A retrieval technology architecture diagram of another financial question-answering method according to an exemplary embodiment of the present application is shown;
[0017] Figure 5 A flowchart of entity recognition of another financial question-answering method according to an exemplary embodiment of the present application is shown;
[0018] Figure 6 A schematic block diagram of a financial question-answering device according to an exemplary embodiment of the present application is shown;
[0019] Figure 7 A structural block diagram of an exemplary electronic device that can be used to implement the embodiments of the present application is shown. DETAILED DESCRIPTION
[0020] The embodiments of the present application will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present application are shown in the accompanying drawings, it should be understood that the present application can be implemented in various forms and should not be construed as being limited to the embodiments described herein. Instead, these embodiments are provided to provide a more thorough and complete understanding of the present application. It should be understood that the drawings and embodiments of the present application are only for exemplary purposes and are not intended to limit the scope of protection of the present application.
[0021] It should be understood that the various steps described in the method implementation of the present application can be performed in different orders and / or performed in parallel. In addition, the method implementation may include additional steps and / or omit the steps shown. The scope of the present application is not limited in this respect.
[0022] The term "including" and its variations used in this document are open inclusions, that is, "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one other embodiment"; the term "some embodiments" means "at least some embodiments". Relevant definitions of other terms will be given in the description below. It should be noted that the concepts of "first", "second", etc. mentioned in this application are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.
[0023] It should be noted that the modifications of "one" and "plurality" mentioned in the present application are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more".
[0024] The names of the messages or information exchanged between multiple devices in the embodiments of the present application are only used for illustrative purposes and are not used to limit the scope of these messages or information.
[0025] The scheme of the present application is described below with reference to the accompanying drawings.
[0026] The present application embodiment first provides a financial question-answering method. Figure 1 As shown, the financial question-answering method specifically includes the following steps:
[0027] S110: Obtaining original financial data;
[0028] S120: constructing a financial database based on the original financial data, and establishing a data index corresponding to the original financial data in the financial database;
[0029] S130: receiving a financial question input by a user, and matching a target data index corresponding to the financial question in a financial database;
[0030] S140: Querying reference data of the financial problem in the financial database based on the target data index, and generating prompt information based on the reference data;
[0031] S150: Input the prompt information into the large language model, generate a target answer corresponding to the financial question, and return the target answer to the user.
[0032] The embodiment of the present application establishes a financial database and a corresponding data index based on the original financial data. When receiving the financial question input by the user, the information related to the financial question is retrieved from the financial database, without the need for the user to search multiple times in the search engine and open different web pages to retrieve the required information; in addition, after retrieving the relevant information of the financial question input by the user in the financial database, the embodiment of the present application can also generate prompt information based on the retrieved information, so that the large language model generates the answer to the financial question based on the prompt information, improving the data query analysis and information integration capabilities of the large language model in the financial field, and ensuring the accuracy, relevance, completeness and security of the answer. At the same time, the embodiment of the present application generates answers to financial questions through the large language model, without the need for the user to analyze the retrieved information by himself.
[0033] Next, in another embodiment, the above steps are described in more detail.
[0034] In step S110, original financial data is obtained.
[0035] In the embodiment of the present application, the above-mentioned original financial data may be financial data acquired from a financial application.
[0036] In the embodiment of the present application, the above-mentioned original financial data may include securities data. For example, the above-mentioned securities data may include multiple securities categories such as bank financial products, trusts, bonds, insurance products, A shares, Hong Kong stocks, US stocks, funds, futures, spot, exchange rates, etc., covering basic information, market data, market derivative data, equity data, financial data, corporate governance, transaction data, major events, mergers and acquisitions, company operating conditions, market size statistics, investor situation statistics, etc.
[0037] In step S120, a financial database is constructed based on the original financial data, and a data index corresponding to the original financial data in the financial database is established.
[0038] In an embodiment of the present application, the above-mentioned financial database is used to store the above-mentioned original financial data.
[0039] In the embodiment of the present application, the user can obtain the required financial information by searching the above-mentioned financial database.
[0040] In the embodiment of the present application, the above-mentioned construction of a financial database based on original financial data can be implemented as follows: filtering the original financial data to obtain target financial data; performing data correction on the target financial data based on the data type of the target financial data; and constructing a financial database based on the corrected target financial data.
[0041] In the embodiment of the present application, the above-mentioned target financial data is the financial data obtained after filtering the above-mentioned original financial data based on actual needs. Exemplarily, the financial data that needs to be paid attention to can be filtered out from the original data provided by the above-mentioned financial application through the product positioning of the financial product. For example, the securities classifications and securities data under the securities classifications that the securities product needs to pay attention to can be filtered out from multiple securities classifications and securities data under the securities classifications based on the product positioning of the securities product. Exemplarily, Table 1 shows some of the securities classifications and data under the securities classifications obtained by filtering:
[0042] Table 1:
[0043]
[0044] In the embodiment of the present application, the target financial data is modified based on the data type of the target financial data. For example, the data type of the target financial data may be stock data, index data, futures data or exchange rate data. Accordingly, different modifications may be made to target financial data of different data types as follows:
[0045] When the data type of the target financial data is the stock data mentioned above, since the same company may be listed in multiple trading markets, in order to improve the retrieval accuracy, the target financial data of the stock data type can be expanded. For example, the stock abbreviation of "Company A" in Hong Kong stocks can be expanded to "Company A Hong Kong Stocks".
[0046] When the data type of the target financial data is the above-mentioned index data, since the financial question related to the market index input by the user has no correlation with the index data abbreviation, the target financial data of the index data type needs to be rewritten. For example, "Shanghai Stock Index" is rewritten as "Stock Quotes" so that the user can retrieve the required financial data in the financial database through the input financial question.
[0047] When the data type of the target financial data is the above-mentioned futures data, since the relevant financial issues of the main futures input by the user have a low correlation with the futures abbreviation, in order to improve the retrieval accuracy, the abbreviation of the main futures needs to be expanded, for example, changing the "London Copper Main Continuation" futures to "London Copper" futures.
[0048] When the data type of the target financial data is the above exchange rate data, since the exchange rate data is different from the data of stocks, funds, etc., which have securities abbreviations and securities codes, in order to unify the format with other securities data, the two currency abbreviations are concatenated as the securities abbreviation.
[0049] It should be noted that the above scenarios are only exemplary descriptions, and other target financial data may also be modified accordingly based on their data types to achieve the purpose of improving retrieval accuracy or unifying data formats, etc. The embodiments of the present application do not make any special limitations on this.
[0050] In the embodiment of the present application, constructing a financial database based on the modified target financial data refers to storing the modified target financial data in the financial database.
[0051] In an embodiment of the present application, the financial database may include a cache (Redis) data table and a relational (MySQL) data table. The Redis data table is used to store real-time market data, for example, the real-time market data of the stock type or index type. The MySQL data table is used to store other target financial data in addition to the real-time market data.
[0052] In the embodiment of the present application, the above-mentioned data index is the index of the above-mentioned financial database. The data index is a structure for sorting the values of one or more columns in the database table. The financial information in the database table can be quickly accessed by using the index.
[0053] In the embodiment of the present application, after filtering out the securities classifications and securities data under the securities classifications that the securities product needs to pay attention to from the multiple securities classifications and securities data under the securities classifications based on the product positioning of the securities product, specifically, the data index corresponding to the original financial data in the financial database can be established as shown in Table 2 below:
[0054] Table 2:
[0055]
[0056] In the embodiment of the present application, after constructing a financial database and establishing a data index for the financial database, a user can query the financial database for required financial information based on the data index.
[0057] In step S130, a financial question input by a user is received, and a target data index corresponding to the financial question is matched in a financial database.
[0058] In the embodiment of the present application, the above financial questions are questions asked by users about the financial field. For example, the financial questions may be securities questions such as "What is the current market situation of company A's stock?" and "Should I buy stock B?"
[0059] In an embodiment of the present application, a user may input the above-mentioned financial questions into the financial question-and-answer system. The financial question-and-answer system generates answers to the above-mentioned financial questions by querying relevant financial information, integrating and analyzing the queried financial information, and returns the answers to the above-mentioned financial questions to the user.
[0060] In the embodiment of the present application, the question-and-answer system is an advanced form of information retrieval system, which can answer questions raised by users in natural language in accurate and concise natural language. The above-mentioned financial question-and-answer system is a question-and-answer system for the financial field based on artificial intelligence and other technologies.
[0061] In the embodiment of the present application, the financial database can be used as the knowledge base of the financial question-answering system. That is, after receiving the financial question input by the user, the financial question-answering system can retrieve the financial data related to the financial question input by the user from the financial database, generate the answer to the financial question based on the retrieved financial data, and return it to the user.
[0062] In the embodiment of the present application, the target data index is used to retrieve the financial information required to answer the financial question input by the user in the financial database. After receiving the financial question input by the user, the target data index corresponding to the financial question is determined in the data index of the financial database, and the required financial information is retrieved through the target data index, so that the efficiency of the retrieval can be improved.
[0063] In an embodiment of the present application, the above-mentioned matching of the target data index corresponding to the financial question in the financial database can be implemented as follows, illustratively: performing data preprocessing on the financial question; performing entity recognition on the financial question after data preprocessing; and matching the target data index in the financial database based on the entity recognition result.
[0064] In an embodiment of the present application, the above-mentioned process of data preprocessing for financial questions may include the following processing: clearing the time characters in the financial questions. For example, if the financial question input by the user is "the stock price trend of Company A in 2023", the above-mentioned operation of clearing the time characters rewrites the financial question as "the stock price trend of Company A". Through this operation, it is possible to avoid the time characters being mistakenly matched as stock codes in subsequent retrieval processes, thereby affecting the retrieval accuracy. It should be noted that the above-mentioned scenario is only an exemplary description, and the embodiment of the present application may also include other preprocessing processes for financial questions, which are not specifically limited in the embodiment of the present application.
[0065] In the embodiment of the present application, the main purpose of entity recognition is to identify entities with specific meanings from the financial question text input by the user, such as entities such as securities name, securities code, securities category, etc. For example, assuming that the financial question input by the user is "Should I buy the stock of Company B?", the entity identified by the entity recognition process is the securities name "Stock of Company B".
[0066] In an embodiment of the present application, after the entity in the financial problem is identified through the above-mentioned entity recognition process, further, the target data index can be matched in the data index of the financial database based on the result of entity recognition. Exemplarily, the matching process can be implemented as follows: searching for the data index in the financial database based on the result of entity recognition; if a data index consistent with the result of entity recognition is found, the searched data index consistent with the result of entity recognition is used as the target data index; if a data index consistent with the result of entity recognition is not found, the searched data index is sorted, and the target data index is determined based on the sorting result.
[0067] Specifically, taking the entity identified by the above-mentioned entity recognition process as the securities name "B Company Stock" as an example, if the data index "B Company Stock" can be found in the data index of the financial database, then the data index will be used as the target data index; if a completely consistent data index cannot be found, "B Company Stock" will be converted into a vector representation, and the cosine similarity between the entity vector and the vectors of each data index in the financial database will be calculated, and the data index with the highest similarity to the entity vector will be used as the target data index.
[0068] In the above process of determining the target data index by calculating the vector similarity, if the length of the identified financial entity is short, it may affect the matching accuracy of the target data index. Therefore, in order to provide accuracy, in the process of matching the target data index in the financial database, the above process of determining the target data index based on the sorting result based on similarity can also be implemented as follows: determine the confidence of each searched data index; re-sort the sorting results based on the confidence, and determine the target data index based on the re-sorted results.
[0069] Exemplarily, the confidence of the data index can be determined based on its length. For example, for an entity identified from a financial problem, if multiple data indexes related to it are searched from a financial database, then the corresponding confidence is assigned to it according to the length of the searched data index. Exemplarily, the confidence of the data index is positively correlated with its length; the target data index is determined based on the confidence of the searched data index and its similarity with the identified entity vector. Specifically, the product of the above confidence and the vector similarity can be calculated, and the sorting results obtained based on the vector similarity can be re-sorted based on the order of the product from large to small, and the data index with the largest product result is used as the target data index.
[0070] In the embodiment of the present application, in order to improve the search speed, if the above entity recognition results contain entity category information, the search scope can be narrowed according to the category information to improve the search efficiency. For example, if the financial question is a securities question, and the identified results include the securities type, the target data index can be searched in the data index under the securities type. By identifying the type of securities search in the financial question, the search scope can be narrowed and the search accuracy can be improved.
[0071] In step S140, reference data of the financial problem is searched in the financial database based on the target data index, and prompt information is generated based on the reference data.
[0072] In the embodiment of the present application, the reference data is financial data retrieved from a financial database based on the matched target data index.
[0073] In an embodiment of the present application, the above-mentioned querying of reference data of financial problems in a financial database based on a target data index can be implemented as follows: querying real-time market data related to the target data index in a Redis data table through a database query statement, and querying other financial data related to the target data index in a MySQL data table.
[0074] In the embodiment of the present application, the above prompt information is a prompt word input into a large language model (Large Language Model, LLM), and by providing examples, the answer generated by the large language model is more accurate.
[0075] In an embodiment of the present application, the above-mentioned large language model is used to analyze and integrate the above-mentioned queried financial data based on the above-mentioned prompt information, generate answers corresponding to financial questions, and return them to the user.
[0076] In the embodiment of the present application, taking the above-mentioned financial question as a securities question as an example, the prompt information generated according to the queried financial data may be as follows:
[0077] You are an excellent stock lookup and analyst, answering questions I had about a particular stock.
[0078] The answer ends with "Entering the market is risky and investment should be cautious."
[0079] Please answer the question: ###{user_query}###
[0080] The latest data on the Internet is: ###{retrieval_data}###
[0081] If a specific stock is not mentioned in the question, do not refer to the latest data.
[0082] If the stock name in the question is "{sec_name}", please combine your understanding and refer to the latest data; otherwise, please answer directly based on your knowledge.
[0083] Be careful not to let me know if you refer to the latest data.
[0084] Please note that my question is: ###{user_query}###
[0085] Be careful to answer my question and don't deviate from the scope of the question.
[0086] Keep your answer short and avoid unnecessary analysis.
[0087] In step S150, the prompt information is input into the large language model, a target answer corresponding to the financial question is generated, and the target answer is returned to the user.
[0088] In an embodiment of the present application, the target answer is an answer to the financial question generated by the large language model based on the prompt information.
[0089] In an embodiment of the present application, after the prompt information is generated, the generated prompt information is input into the large language model. The large language model can generate the target answer based on the prompt information and return it to the user.
[0090] The embodiment of the present application establishes a financial database and a corresponding data index based on the original financial data. When receiving the financial question input by the user, the information related to the financial question is retrieved from the financial database, without the need for the user to search multiple times in the search engine and open different web pages to retrieve the required information; in addition, after retrieving the relevant information of the financial question input by the user in the financial database, the embodiment of the present application can also generate prompt information based on the retrieved information, so that the large language model generates the answer to the financial question based on the prompt information, improving the data query analysis and information integration capabilities of the large language model in the financial field, and ensuring the accuracy, relevance, completeness and security of the answer. At the same time, the embodiment of the present application generates answers to financial questions through the large language model, without the need for the user to analyze the retrieved information by himself.
[0091] Next, in another embodiment, taking the securities scenario as an example, Figures 2 to 5 , the above financial question-and-answer method is explained in detail:
[0092] Figure 2 The overall technical framework diagram of the above financial problem method is as follows: Figure 2As shown, the above-mentioned financial question method can be implemented as follows: receiving a securities question input by a user, wherein the securities question is a securities-related question that the user wants to retrieve, for example, the securities question may be "the stock price trend of Company A in 2023"; in the retrieval module 210, querying relevant securities data in the securities real-time database based on the securities question input by the user; generating prompt information based on the queried securities data, and inputting the generated prompt information into the large language model; generating an answer to the securities question through the large language model, and returning it to the user.
[0093] Among them, Figure 3 As shown, the above securities real-time database can be constructed by following steps S310 to S340, and the securities real-time database corresponds to Figure 1 The financial database in the financial question answering method shown:
[0094] In step S310, original data is obtained.
[0095] In the embodiment of the present application, the above raw data corresponds to Figure 1 Raw financial data from the Financial Question Answering method shown.
[0096] In the embodiment of the present application, the above raw data can be provided by a securities application. For example, the raw data can include 300 securities categories such as bank financial products, trusts, bonds, insurance products, A shares, Hong Kong stocks, US stocks, funds, futures, spot, exchange rates, etc., covering basic information, market data, market derivative data, equity data, financial data, corporate governance, transaction data, major events, mergers and acquisitions, company operations, market size statistics, investor statistics, and other rich data.
[0097] In step S320, data cleaning is performed on the original data.
[0098] In an embodiment of the present application, for example, since there may be multiple stocks of the same company, the original data can be filtered based on the listing status, listing sector and trading market in the stock data to obtain the securities classification that needs attention and the data under each securities data.
[0099] In step S330, data preprocessing is performed on the cleaned data.
[0100] In the embodiment of the present application, the above data preprocessing process adopts different processing measures according to different data types. The specific implementation is as follows:
[0101] Stock data: Since the same company may be listed on multiple trading markets, the abbreviations of such stocks are expanded to improve the search accuracy. For example, the stock abbreviation of "Company A" in Hong Kong stocks is expanded to "Company A Hong Kong Stocks".
[0102] Index data: Since there is no correlation between the stock query of the market index and the abbreviation of the index, the abbreviations of these market indexes are manually expanded, such as "Shanghai Composite Index" is expanded to "Stock Quotes".
[0103] Futures data: Since the securities questions (queries) and futures abbreviations of the main futures have a low correlation and the retrieval accuracy is low, the abbreviations of the main futures are expanded, for example, "London Copper Main Continuation" futures are expanded to "London Copper" futures.
[0104] Exchange rate data: Since exchange rate data is different from stock, fund and other data in that it has securities abbreviations and securities codes, in order to unify the format with other securities data, the two currency abbreviations are concatenated as the securities abbreviation.
[0105] In step S340, an index is created.
[0106] In the embodiment of the present application, the preprocessed data is stored in the securities real-time database, and an index of the securities real-time database is established, as shown in Table 2 above.
[0107] After establishing a real-time securities database and creating an index, you can Figure 2 The information required to answer the above securities question is queried through the securities real-time database in the retrieval module 210. The retrieval process in the retrieval module 210 is described in detail below:
[0108] Figure 4 To retrieve technical architecture diagrams, such as Figure 4 As shown, the retrieval process in the retrieval model 210 can be implemented as follows: rewriting the securities question input by the user, for example, the rewriting can be to remove the time character in the securities question; identifying the securities entity in the above securities question; determining the index corresponding to the securities entity based on the vector reasoning service, and the index corresponds to Figure 1 The target data index in the financial problem method shown in the figure; generate and execute a database statement based on the index corresponding to the securities entity to query the information required for the securities problem from the securities real-time database, for example, Figure 4 As shown, the securities real-time database may include a Redis data table and a MySQL data table. Based on the database query statement, the real-time market data of A shares and indexes can be obtained from the Redis data table, and other data can be obtained from the MySQL data table.
[0109] Next, combine Figure 5 , the securities question (Query) understanding process is explained in detail, such as Figure 5As shown, taking the original input Query as "A Company's stock price trend in 2023" as an example, the above-mentioned rewriting of the securities question input by the user into the index corresponding to the securities entity determined based on the vector reasoning service can be implemented as follows: rewrite the Query, specifically, clear the time characters in the Query, and rewrite "A Company's stock price trend in 2023" as "A Company's stock price trend"; identify the entities in the Query. Exemplarily, the index of the above-mentioned securities real-time database may include a securities vocabulary and a company name vocabulary. When the securities name, securities code or securities type in the Query is identified, the identified entity can be compared with the index in the securities vocabulary and the company name vocabulary to obtain the index corresponding to the entity.
[0110] Among them, if the securities real-time database can retrieve an index that is completely consistent with the identified entity, the searched entity will be used as the index corresponding to the entity; if no completely consistent index can be identified, the index corresponding to the entity will be further determined through vector reasoning. For example, the vector similarity between the original query vector and the securities name vector or the securities code vector can be calculated, and the index corresponding to the entity can be determined based on the vector similarity.
[0111] Exemplarily, through the above-mentioned vector reasoning process, multiple securities name indexes or securities code indexes corresponding to the entity can be recalled. The embodiment of the present application can sort the recall results based on vector similarity and determine the index corresponding to the entity. Furthermore, since the short length of the entity may affect the retrieval accuracy, the embodiment of the present application can re-arrange the recall results based on the complete match feature to improve the recall accuracy. Among them, the complete match feature refers to the part of the recalled index that is completely consistent with the identified entity. In addition, the embodiment of the present application can also narrow the search scope and improve the search accuracy by identifying the type of securities search in the Query.
[0112] In the embodiment of the present application, for example, taking into account factors such as accuracy, relevance, completeness, security, and length control of the answer, the prompt information (prompt) generated based on the information retrieved from the securities real-time database may be as follows:
[0113] You are an excellent stock lookup and analyst, answering questions I had about a particular stock.
[0114] The answer ends with "Entering the market is risky and investment should be cautious."
[0115] Please answer the question: ###{user_query}###
[0116] The latest data on the Internet is: ###{retrieval_data}###
[0117] If a specific stock is not mentioned in the question, do not refer to the latest data.
[0118] If the stock name in the question is "{sec_name}", please combine your understanding and refer to the latest data; otherwise, please answer directly based on your knowledge.
[0119] Be careful not to let me know if you refer to the latest data.
[0120] Please note that my question is: ###{user_query}###
[0121] Be careful to answer my question and don't deviate from the scope of the question.
[0122] Keep your answer short and avoid unnecessary analysis.
[0123] The present application embodiment provides a financial question-answering device. Figure 6 As shown, the financial question-answering device 600 may include a data acquisition module 610, an index construction module 620, an index matching module 630, an information generation module 640 and a financial question-answering module 650, wherein:
[0124] A data acquisition module 610 is used to acquire original financial data;
[0125] An index building module 620 is used to build a financial database based on the original financial data and to establish a data index corresponding to the original financial data in the financial database;
[0126] An index matching module 630 is used to receive a financial question input by a user and match a target data index corresponding to the financial question in a financial database;
[0127] An information generation module 640 is used to query reference data of financial issues in a financial database based on a target data index, and to generate prompt information based on the reference data;
[0128] The financial question-answering module 650 is used to input prompt information into the large language model, generate a target answer corresponding to the financial question, and return the target answer to the user.
[0129] In the embodiment of the present application, the above-mentioned index construction module is specifically used to: filter the original financial data to obtain target financial data; modify the target financial data based on the data type of the target financial data; and construct a financial database based on the modified target financial data.
[0130] In an embodiment of the present application, the above-mentioned index matching module is specifically used for: performing data preprocessing on financial issues; performing entity recognition on financial issues after data preprocessing; and matching target data indexes in a financial database based on entity recognition results.
[0131] In the embodiment of the present application, the above-mentioned index matching module is specifically used to: remove the time characters in financial questions.
[0132] In an embodiment of the present application, the above-mentioned index matching module is specifically used to: search for data indexes in a financial database based on entity recognition results; if a data index consistent with the entity recognition result is found, the searched data index consistent with the entity recognition result is used as the target data index; if a data index consistent with the entity recognition result is not found, the searched data index is sorted, and the target data index is determined based on the sorting result.
[0133] In an embodiment of the present application, the above-mentioned index matching module is specifically used to: calculate the similarity between the entity recognition result and each searched data index, and sort the searched data index in order from high to low based on the similarity; determine the target data index based on the sorting result of the similarity.
[0134] In an embodiment of the present application, the above-mentioned index matching module is specifically used to: determine the confidence of each searched data index; re-sort the sorting results based on the confidence, and determine the target data index based on the re-sorted results.
[0135] In addition, the specific implementation details of the above-mentioned financial question and answer device have been described in detail in the corresponding position of the financial question and answer method, so they will not be repeated here.
[0136] It should be noted that the division of modules in the embodiments of the present application is schematic and is merely a logical function division. There may be other division methods in actual implementation.
[0137] Figure 7 This is a schematic diagram of the structure of an electronic device in an embodiment of the present application. Figure 7 , which shows a structural schematic diagram of an electronic device 700 suitable for implementing the embodiments of the present application. Figure 7 The electronic device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0138] like Figure 7As shown, the electronic device 700 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 701, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 702 or a program loaded from a storage device 708 into a random access memory (RAM) 703 to implement the financial question-answering method of the embodiment described in the present application. In RAM 703, various programs and data required for the operation of the electronic device 700 are also stored. The processing device 701, ROM 702, and RAM 703 are connected to each other via a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.
[0139] Typically, the following devices may be connected to the I / O interface 705: an input device 706 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 707 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 708 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 709. The communication device 709 may allow the electronic device 700 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 7 The electronic device 700 is shown with various devices, but it should be understood that it is not required to implement or possess all the devices shown. More or fewer devices may be implemented or possessed instead.
[0140] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program contains program code for executing the method shown in the flowchart, thereby implementing the financial question-and-answer method as described above. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 709, or installed from the storage device 708, or installed from the ROM 702. When the computer program is executed by the processing device 701, the above-mentioned functions defined in the method of the embodiment of the present application are executed.
[0141] It should be noted that the computer-readable medium mentioned above in the present application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device or device. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program code. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer readable signal medium may also be any computer readable medium other than a computer readable storage medium, which may send, propagate or transmit a program for use by or in conjunction with an instruction execution system, apparatus or device. The program code contained on the computer readable medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0142] In some embodiments, the client and the server may communicate using any currently known or future developed network protocol such as HTTP (HyperTextTransferProtocol), and may be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an adhoc peer-to-peer network), as well as any currently known or future developed network.
[0143] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
[0144] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device:
[0145] Obtaining raw financial data;
[0146] Build a financial database based on the original financial data, and establish the data index corresponding to the original financial data in the financial database;
[0147] Receive a financial question input by a user, and match a target data index corresponding to the financial question in a financial database;
[0148] Querying reference data of financial issues in a financial database based on the target data index, and generating prompt information based on the reference data;
[0149] The prompt information is input into the large language model to generate the target answer corresponding to the financial question, and the target answer is returned to the user.
[0150] Optionally, when the above one or more programs are executed by the electronic device, the electronic device may also execute other steps described in the above embodiments.
[0151] Computer program code for performing the operations of the present application may be written in one or more programming languages or a combination thereof, including, but not limited to, object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a separate software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0152] The flow chart and block diagram in the accompanying drawings illustrate the possible architecture, function and operation of the system, method and computer program product according to various embodiments of the present application. In this regard, each square box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the module, the program segment or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two square boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0153] The units involved in the embodiments described in this application may be implemented by software or hardware, wherein the name of a unit does not, in some cases, constitute a limitation on the unit itself.
[0154] The functions described above herein may be performed at least in part by one or more hardware logic components. For example, without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), complex programmable logic devices (CPLDs), and the like.
[0155] In the context of the present application, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0156] The above description is only a preferred embodiment of the present application and an explanation of the technical principles used. Those skilled in the art should understand that the scope of disclosure involved in the present application is not limited to the technical solution formed by a specific combination of the above technical features, but should also cover other technical solutions formed by any combination of the above technical features or their equivalent features without departing from the above disclosed concept. For example, the above features are replaced with the technical features with similar functions disclosed in this application (but not limited to) by each other to form a technical solution.
[0157] In addition, although each operation is described in a specific order, this should not be construed as requiring these operations to be performed in the specific order shown or to be performed in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details are included in the above discussion, these should not be construed as limiting the scope of the application. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.
[0158] Although the subject matter has been described in language specific to structural features and / or methodological logical actions, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or actions described above. On the contrary, the specific features and actions described above are merely example forms of implementing the claims.
Claims
1. A financial question-answering method, characterized in that: include: Obtaining raw financial data; Building a financial database based on the original financial data, and establishing a data index corresponding to the original financial data in the financial database; Receiving a financial question input by a user, and matching a target data index corresponding to the financial question in the financial database; Querying the financial database for reference data of the financial problem based on the target data index, and generating prompt information based on the reference data; The prompt information is input into a large language model to generate a target answer corresponding to the financial question, and the target answer is returned to the user.
2. The financial question-and-answer method according to claim 1, characterized in that: The step of constructing a financial database based on original financial data includes: Filtering the original financial data to obtain target financial data; Performing data correction on the target financial data based on the data type of the target financial data; The financial database is constructed based on the corrected target financial data.
3. The financial question-and-answer method according to claim 1, characterized in that: The matching of the target data index corresponding to the financial problem in the financial database includes: Performing data preprocessing on the financial problem; Performing entity recognition on the financial problem after data preprocessing; The target data index is matched in the financial database based on the entity recognition result.
4. The financial inquiry method according to claim 3, characterized in that: The data preprocessing of the financial problem includes: Remove time characters from the financial questions.
5. The financial question-answering method according to claim 3, characterized in that: The matching the target data index in the financial database based on the entity recognition result includes: searching the data index in the financial database based on the entity recognition result; If the data index that is consistent with the entity recognition result is found, the data index that is consistent with the entity recognition result is used as the target data index; If the data index consistent with the entity recognition result cannot be found, the searched data index is sorted, and the target data index is determined based on the sorting result.
6. The financial question-answering method according to claim 5, characterized in that: The step of sorting the searched data indexes and determining the target data index based on the sorting result includes: Calculating the similarity between the entity recognition result and each of the searched data indexes, and sorting the searched data indexes in descending order based on the similarity; The target data index is determined based on the sorting result of the similarity.
7. The financial question-answering method according to claim 6, characterized in that: The determining the target data index based on the sorting result of the similarity includes: Determining the confidence level of each of the searched data indexes; The sorting results are re-sorted based on the confidence level, and the target data index is determined based on the re-sorted results.
8. A financial question-and-answer device, characterized in that: include: Data acquisition module, used to obtain original financial data; An index building module, used to build a financial database based on the original financial data, and to establish a data index corresponding to the original financial data in the financial database; An index matching module, configured to receive a financial question input by a user and match a target data index corresponding to the financial question in the financial database; An information generation module, configured to query the financial database for reference data of the financial problem based on the target data index, and generate prompt information based on the reference data; The financial question-answering module is used to input the prompt information into a large language model, generate a target answer corresponding to the financial question, and return the target answer to the user.
9. An electronic device, comprising: processor; as well as Memory for storing programs, The program includes instructions, which, when executed by the processor, cause the processor to perform the method according to any one of claims 1 to 7.
10. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1-7.
Citation Information
Cited By
Cross-document type retrieval method and system based on differentiated nested coding
CN121579664A
A cross-document type retrieval method and system based on differential nested encoding
CN121579664B