Text processing method, electronic equipment and computer readable storage medium

By retrieving and executing target program code from the database within a large language model, the problem of low accuracy of large language models in domain numerical computation is solved, ensuring the stability and accuracy of the computation results.

CN122019616APending Publication Date: 2026-05-12ALIBABA (CHINA) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
ALIBABA (CHINA) CO LTD
Filing Date
2024-11-08
Publication Date
2026-05-12

AI Technical Summary

Technical Problem

Large language models generate different answers in domain numerical computation, resulting in lower accuracy and greater influence from user input questions.

Method used

By retrieving target knowledge data and program code that match the text data from the database, executing the target program code to perform numerical calculations, and generating the final text data based on the numerical calculation results and knowledge data, the accuracy of the calculation results is ensured.

Benefits of technology

It improves the accuracy of numerical calculations in the domain, avoids the influence of the problem content on the calculation results, and achieves stable numerical calculation results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122019616A_ABST
    Figure CN122019616A_ABST
Patent Text Reader

Abstract

The invention discloses a text processing method, electronic equipment and a computer readable storage medium, and relates to the field of large model technology and data processing. The method comprises the steps of obtaining first text data; target knowledge data and target program codes matched with the first text data are retrieved from a database, and multiple pieces of knowledge data and program codes corresponding to different pieces of knowledge data are stored in the database; executing the target program code based on a target parameter contained in the first text data to obtain a numerical calculation result corresponding to the target parameter; and generating second text data corresponding to the first text data based on the first text data, the numerical calculation result and the target knowledge data. The technical problem that the accuracy of numerical calculation in the field is low in the prior art is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to large model technology and data processing, and more specifically, to a text processing method, an electronic device, and a computer-readable storage medium. Background Technology

[0002] In domain-specific numerical computation scenarios, when a user inputs a question, the processing system first retrieves relevant domain knowledge from the knowledge base, then feeds the knowledge and the question together to a large language model for answering. However, the language model often fails to strictly adhere to the logical descriptions of the knowledge documents when answering questions about the same domain knowledge. This results in different answers generated by the large language model for different descriptions of the same domain knowledge, meaning the content generated by the large language model is significantly influenced by the user's input question. This leads to lower accuracy in domain-specific numerical computation.

[0003] There is currently no effective solution to the above problems. Summary of the Invention

[0004] This application provides a text processing method, an electronic device, and a computer-readable storage medium to at least solve the technical problem of low accuracy in numerical calculations in related technologies.

[0005] According to one aspect of the embodiments of this application, a text processing method is provided, comprising: acquiring first text data, wherein the first text data includes target parameters for performing numerical calculations; retrieving target knowledge data and target program code matching the first text data from a database, wherein the database stores multiple knowledge data and program codes corresponding to different knowledge data, the program codes being used to perform numerical calculations based on the corresponding knowledge data; executing the target program code based on the target parameters included in the first text data to obtain a numerical calculation result corresponding to the target parameters; and generating second text data corresponding to the first text data based on the first text data, the numerical calculation result, and the target knowledge data.

[0006] According to another aspect of the embodiments of this application, a training method for a code generation model is also provided, comprising: acquiring a training knowledge dataset; performing multiple iterations of training on an initial generation model using the training knowledge dataset to obtain a code generation model, wherein the code generation model is used to generate program code corresponding to different knowledge data, and the program code is used to perform numerical calculations based on the corresponding knowledge data; wherein the target loss function used in any iteration of training is determined based on the probability that the current generation model generates a first type of program code, the probability that the current generation model generates a second type of program code, the probability that the initial generation model generates a first type of program code, and the probability that the initial generation model generates a second type of program code, the current generation model is the initial generation model or the generation model trained in the previous iteration of training, the accuracy of the first type of program code used for numerical calculation is greater than the accuracy of the second type of program code used for numerical calculation, and the first type of program code and the second type of program code are generated based on the same knowledge data in the training knowledge dataset.

[0007] According to another aspect of the embodiments of this application, a text processing method is also provided, comprising: responding to an input instruction acting on an operation interface, determining first text data corresponding to the input instruction, wherein the first text data includes target parameters for performing numerical calculations; retrieving target program code matching the first text data from a database, wherein the database stores multiple knowledge data and program codes corresponding to different knowledge data, the program codes being used to perform numerical calculations based on the corresponding knowledge data; executing the target program code based on the target parameters included in the first text data to obtain a numerical calculation result corresponding to the target parameters; generating second text data corresponding to the first text data based on the first text data, the numerical calculation result, and the target knowledge data corresponding to the target program code; and outputting the second text data.

[0008] According to another aspect of the embodiments of this application, a text processing method is also provided, comprising: acquiring inquiry text data, wherein the inquiry text data includes target parameters for performing numerical calculations; retrieving target legal provisions data and target program code that match the inquiry text data from a database, wherein the database stores multiple legal provisions data and program codes corresponding to different legal provisions data, the program codes being used to perform numerical calculations based on the corresponding legal provisions data; executing the target program code based on the target parameters contained in the inquiry text data to obtain a numerical calculation result corresponding to the target parameters; and generating response text data based on the inquiry text data, the numerical calculation result, and the target legal provisions data.

[0009] According to another aspect of the embodiments of this application, a text processing method is also provided, comprising: obtaining first text data by calling a first interface, wherein the first interface includes a first parameter, the parameter value of the first parameter includes the first text data, and the first text data includes a target parameter for performing numerical calculations; retrieving target knowledge data and target program code matching the first text data from a database, wherein the database stores multiple knowledge data and program code corresponding to different knowledge data, and the program code is used to perform numerical calculations based on the corresponding knowledge data; executing the target program code based on the target parameter contained in the first text data to obtain a numerical calculation result corresponding to the target parameter; generating second text data corresponding to the first text data based on the first text data, the numerical calculation result, and the target knowledge data; and outputting the second text data by calling a second interface, wherein the second interface includes a second parameter, the parameter value of the second parameter includes the second text data.

[0010] According to another aspect of the embodiments of this application, a text processing apparatus is also provided, comprising: an acquisition module for acquiring first text data, wherein the first text data includes target parameters for performing numerical calculations; a retrieval module for retrieving target knowledge data and target program code matching the first text data from a database, wherein the database stores multiple knowledge data and program codes corresponding to different knowledge data, and the program codes are used to perform numerical calculations based on the corresponding knowledge data; a processing module for executing the target program code based on the target parameters included in the first text data to obtain a numerical calculation result corresponding to the target parameters; and a generation module for generating second text data corresponding to the first text data based on the first text data, the numerical calculation result, and the target knowledge data.

[0011] According to another aspect of the embodiments of this application, a training apparatus for a code generation model is also provided, comprising: an acquisition module for acquiring a training knowledge dataset; and a training module for iteratively training an initial generation model using the training knowledge dataset to obtain a code generation model, wherein the code generation model is used to generate program code corresponding to different knowledge data, and the program code is used to perform numerical calculations based on the corresponding knowledge data; wherein the target loss function used in any iteration of training is determined based on the probability that the current generation model generates a first type of program code, the probability that the current generation model generates a second type of program code, the probability that the initial generation model generates a first type of program code, and the probability that the initial generation model generates a second type of program code, the current generation model is the initial generation model or the generation model trained in the previous iteration of training, the accuracy of the first type of program code used for numerical calculation is greater than the accuracy of the second type of program code used for numerical calculation, and the first type of program code and the second type of program code are generated based on the same knowledge data in the training knowledge dataset.

[0012] According to another aspect of the embodiments of this application, a text processing apparatus is also provided, comprising: a determining module, configured to respond to an input instruction acting on an operation interface and determine first text data corresponding to the input instruction, wherein the first text data includes target parameters for performing numerical calculations; a retrieving module, configured to retrieve target program code matching the first text data from a database, wherein the database stores multiple knowledge data and program codes corresponding to different knowledge data, the program codes being used to perform numerical calculations based on the corresponding knowledge data; a processing module, configured to execute the target program code based on the target parameters included in the first text data to obtain a numerical calculation result corresponding to the target parameters; a generating module, configured to generate second text data corresponding to the first text data based on the first text data, the numerical calculation result, and the target knowledge data corresponding to the target program code; and output the second text data.

[0013] According to another aspect of the embodiments of this application, a text processing apparatus is also provided, comprising: an acquisition module for acquiring inquiry text data, wherein the inquiry text data includes target parameters for numerical calculation; a retrieval module for retrieving target legal provisions data and target program code matching the inquiry text data from a database, wherein the database stores multiple legal provisions data and program codes corresponding to different legal provisions data, the program codes being used to perform numerical calculations based on the corresponding legal provisions data; a processing module for executing the target program code based on the target parameters contained in the inquiry text data to obtain numerical calculation results corresponding to the target parameters; and a generation module for generating response text data based on the inquiry text data, the numerical calculation results, and the target legal provisions data.

[0014] According to another aspect of the embodiments of this application, a text processing apparatus is also provided, comprising: an acquisition module, configured to acquire first text data by calling a first interface, wherein the first interface includes a first parameter, the parameter value of the first parameter includes the first text data, and the first text data includes a target parameter for performing numerical calculations; a retrieval module, configured to retrieve target knowledge data and target program code matching the first text data from a database, wherein the database stores multiple knowledge data and program code corresponding to different knowledge data, and the program code is used to perform numerical calculations based on the corresponding knowledge data; a processing module, configured to execute the target program code based on the target parameter included in the first text data to obtain a numerical calculation result corresponding to the target parameter; a generation module, configured to generate second text data corresponding to the first text data based on the first text data, the numerical calculation result, and the target knowledge data; and an output module, configured to output the second text data by calling a second interface, wherein the second interface includes a second parameter, and the parameter value of the second parameter includes the second text data.

[0015] According to another aspect of the embodiments of this application, an electronic device is also provided, including: a memory storing an executable program; and a processor for running the program, wherein the program executes the methods in various embodiments of this application when it runs.

[0016] According to another aspect of the embodiments of this application, a computer-readable storage medium is also provided, the computer-readable storage medium including a stored executable program, wherein, when the executable program is running, it controls the device where the computer-readable storage medium is located to perform the methods of various embodiments of this application.

[0017] According to another aspect of the embodiments of this application, a computer program product is also provided, including a computer program that, when executed by a processor, implements the methods of various embodiments of this application.

[0018] According to another aspect of the embodiments of this application, a computer program product is also provided, including a non-volatile computer-readable storage medium storing a computer program that, when executed by a processor, implements the methods in various embodiments of this application.

[0019] According to another aspect of the embodiments of this application, a computer program is also provided, which, when executed by a processor, implements the methods of the various embodiments of this application.

[0020] In this embodiment, the method involves: acquiring first text data, which includes target parameters for numerical calculation; retrieving target knowledge data and target program code matching the first text data from a database, wherein the database stores multiple knowledge data sets and corresponding program codes for different knowledge data sets, the program codes being used to perform numerical calculations based on the corresponding knowledge data; executing the target program code based on the target parameters contained in the first text data to obtain the numerical calculation result corresponding to the target parameters; and generating second text data corresponding to the first text data based on the first text data, the numerical calculation result, and the target knowledge data. It is noteworthy that by pre-generating program codes corresponding to different knowledge data and processing complex logical rules and conditional judgments through the execution of the program code, the goal of performing numerical calculations based on target parameters is achieved. Regardless of how the description of the first text data changes, as long as the target parameters remain unchanged, the numerical calculation result will not change, thereby avoiding the influence of the problem content on the domain numerical calculation process. This achieves the technical effect of improving the accuracy of domain numerical calculations, thus solving the technical problem of low accuracy in domain numerical calculations in related technologies.

[0021] It is worth noting that the general description above and the detailed description that follow are merely for illustrative purposes and do not constitute a limitation on this application. Attached Figure Description

[0022] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:

[0023] Figure 1 This is a schematic diagram of an application scenario according to an embodiment of this application;

[0024] Figure 2 This is a flowchart of a text processing method according to an embodiment of this application;

[0025] Figure 3 This is a schematic diagram of an optional user interface according to an embodiment of this application;

[0026] Figure 4 This is a schematic diagram illustrating an optional classification of program code according to an embodiment of this application;

[0027] Figure 5 This is a schematic diagram of an optional DCKIP framework according to an embodiment of this application;

[0028] Figure 6 This is a flowchart of a training method for a code generation model according to an embodiment of this application;

[0029] Figure 7 This is a flowchart of a text processing method according to an embodiment of this application;

[0030] Figure 8 This is a flowchart of a text processing method according to an embodiment of this application;

[0031] Figure 9 This is a flowchart of a text processing method according to an embodiment of this application;

[0032] Figure 10 This is a schematic diagram of a text processing apparatus according to an embodiment of this application;

[0033] Figure 11 This is a schematic diagram of a training apparatus for a code generation model according to an embodiment of this application;

[0034] Figure 12 This is a schematic diagram of a text processing apparatus according to an embodiment of this application;

[0035] Figure 13 This is a schematic diagram of a text processing apparatus according to an embodiment of this application;

[0036] Figure 14 This is a schematic diagram of a text processing apparatus according to an embodiment of this application;

[0037] Figure 15 This is a structural block diagram of an electronic device according to an embodiment of this application. Detailed Implementation

[0038] To enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present application, and not all embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative effort should fall within the scope of protection of the present application.

[0039] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0040] The technical solution provided in this application is mainly implemented using large-scale model technology. Here, "large-scale model" refers to a deep learning model with a large number of parameters, typically containing hundreds of millions, tens of billions, hundreds of billions, trillions, or even tens of trillions of parameters. Large-scale models can also be called foundational models. They are pre-trained using large-scale unlabeled corpora to produce pre-trained models with hundreds of millions of parameters. Such models can adapt to a wide range of downstream tasks and have good generalization ability. Examples include Large Language Models (LLMs) and Multimodal Pre-training Models.

[0041] It should be noted that, in practical applications, large models can be fine-tuned using a small number of samples to adapt them to different tasks. For example, large models can be widely used in Natural Language Processing (NLP), computer vision, and speech processing. Specifically, they can be applied to computer vision tasks such as Visual Question Answering (VQA), Image Captioning (IC), and Image Generation, as well as NLP tasks such as text-based sentiment classification, text summarization, and machine translation. Therefore, the main application scenarios for large models include, but are not limited to, digital assistants, intelligent robots, search, online education, office software, e-commerce, and intelligent design. In this embodiment, the use of a large language model for data processing in a domain-specific numerical computation scenario is taken as an example for explanation.

[0042] First, some nouns or terms that appear in the description of the embodiments of this application shall be interpreted as follows:

[0043] Domain-specific numerical computation: Similar in form to general domain mathematical application problems, but with the difference that it involves some vertical domain knowledge. This knowledge provides the necessary conditions for solving the problem, and the mathematical problem cannot be solved without knowing this vertical domain knowledge.

[0044] Retrieval Augmentation (RAG) retrieves relevant knowledge fragments from an existing database based on the question, and then feeds them as contextual input to the larger model. Assuming the retrieved content is c, and the question is q, the input prompt text for the larger model might be: "{c} Based on the above knowledge, please answer the following question: {q}. Answer: ···".

[0045] Direct Preference Optimization (DPO) is a training method based on contrastive learning, which can be used to train the model's preferences.

[0046] According to an embodiment of this application, a text processing method is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.

[0047] Considering the large number of model parameters in large models and the limited computing resources of mobile terminals, the text processing method provided in this application can be applied to, for example, Figure 1 The application scenarios shown are not limited to these. Figure 1 This is a schematic diagram of an application scenario according to an embodiment of this application, such as... Figure 1 As shown, the large model is deployed in server 10. Server 10 can connect to one or more client devices 20 via a local area network (LAN), wide area network (WAN), internet connection, or other types of data network. These client devices 20 may include, but are not limited to, smartphones, tablets, laptops, PDAs, personal computers, smart home devices, and in-vehicle devices. Client devices 20 can interact with users through a graphical user interface to invoke the large model, thereby implementing the method provided in this embodiment.

[0048] In this embodiment, the system consisting of a client device and a server can perform the following steps: The client device displays second text data on the operation interface. The server performs the following: acquiring first text data, wherein the first text data contains target parameters for numerical calculation; retrieving target knowledge data and target program code matching the first text data from a database, wherein the database stores multiple knowledge data and program code corresponding to different knowledge data, and the program code is used to perform numerical calculation based on the corresponding knowledge data; executing the target program code based on the target parameters contained in the first text data to obtain the numerical calculation result corresponding to the target parameters; and generating second text data corresponding to the first text data based on the first text data, the numerical calculation result, and the target knowledge data. It should be noted that, provided that the operating resources of the client device can meet the deployment and operation conditions of the large model, this embodiment can be performed on the client device.

[0049] Under the aforementioned operating environment, this application provides the following: Figure 2 The text processing method shown. Figure 2 This is a flowchart of a text processing method according to an embodiment of this application. Figure 2 As shown, the method may include the following steps:

[0050] Step S202: Obtain first text data, wherein the first text data contains target parameters for numerical calculation.

[0051] The aforementioned first text data can be a query input by a user or technician in the operating interface for performing domain numerical calculations. The application domains of the text data can include, but are not limited to, the financial, scientific research, engineering, medical, economic, and legal fields. Specific application domains are not limited in this embodiment and can be set according to actual usage needs. This embodiment uses numerical calculations in the legal field as an example, but it is not limited to this. In the legal field, the application scenarios for domain numerical calculations can include, but are not limited to, calculations of damages in litigation cases, property distribution calculations, tax calculations, contract dispute calculations, and intellectual property infringement calculations. The first text data must include at least a target parameter, which is used for numerical calculations. For example, if the first text data is "I am a freelancer, and my average monthly salary for the past three years was 11,000, 12,000, and 13,000 yuan respectively. I want to know how much compensation I can receive in this situation?", the target parameters could be: the past three years, average monthly salary, 11,000 yuan, 12,000 yuan, 13,000 yuan, and compensation, but are not limited to these.

[0052] The aforementioned user interface is used to receive instructions and execute corresponding operations based on those instructions. This user interface can be a client-side interface or a server-side interface; the specific type of user interface is not limited in this embodiment. The client-side interface may include, but is not limited to, tablet computers, mobile phones, and personal computers. The server-side interface may include, but is not limited to, local servers, edge servers, and cloud servers. The aforementioned input instructions can be instructions generated by the user or technician based on data entered in the input area of ​​the user interface. Figure 3 This is a schematic diagram of an optional user interface according to an embodiment of this application, such as... Figure 3 As shown, the operation interface 31 includes a display area 32 and an input area 33. When a user or technician inputs data into the input area 33, such as inputting text data or inputting voice data, the operation interface 31 can generate an input command based on the user's input operation. Furthermore, the operation interface 31 can determine the corresponding first text data based on the input command.

[0053] In one optional embodiment, in different domain numerical calculation scenarios, the related technology suffers from low accuracy in domain numerical calculations. To address this issue, this embodiment takes the application scenario of calculating damages in litigation cases in the legal field as an example. When a user inputs first text data into the user's interface on the client or server, the interface generates an input command based on the user's input. Then, the interface can obtain the first text data input by the user based on the input command, and can extract target parameters from the first text data. For example, target parameters can be extracted using an extraction model. The first text data includes at least the target parameters. For example, such as... Figure 3 As shown, when a user enters "I am a freelancer, and my average monthly salary for the past three years was 11,000, 12,000, and 13,000 yuan respectively in the input area 33 of the operation interface 31, I want to know how much compensation I can get in this situation?", the operation interface 31 will first respond to the user's input operation and generate an input instruction, then determine the content of the first text data corresponding to the input instruction, and finally extract the first text data through the extraction model in the client or server to obtain the target parameters as: past three years, average monthly salary, 11,000 yuan, 12,000 yuan, 13,000 yuan, and compensation.

[0054] Step S204: Retrieve target knowledge data and target program code that match the first text data from the database. The database stores multiple knowledge data and program codes corresponding to different knowledge data. The program codes are used to perform numerical calculations based on the corresponding knowledge data.

[0055] The aforementioned database stores multiple knowledge data sets and corresponding program codes for each set of knowledge data. This provides more textual support for data processing, reducing the influence of user-input questions on the generated answers and improving the accuracy of domain-specific numerical calculations. The database can be pre-configured by the user, manually set, or automatically set using a pre-trained offline program generation (OPG) model. In the legal field, these multiple knowledge data sets can be specific contents from various codes, clauses, and guidelines, such as legal provisions or documents from different laws, regulations, and ethical norms.

[0056] The aforementioned target knowledge data can be legal provisions or documents in a database that match the first text data. This provides textual support for generating answers, reducing the impact of user-input questions on the generated answers and improving the accuracy of domain-specific numerical calculations. The aforementioned target program code can be the target program code corresponding to the target knowledge data that matches the first text data. It should be noted that the aforementioned program code is a Knowledge-Intensive Program (KIP), which includes at least: knowledge references, parameter definitions and descriptions, and logical calculations. Knowledge references explain what the described knowledge data (e.g., legal provisions or documents) is about, such as the specific legal provisions in the Civil Code mentioned above. Parameter definitions and descriptions, for all input and output parameters, are commented out in the knowledge-intensive program to specify the actual meaning, unit of calculation, and data type in a high-level programming language (e.g., Python, JavaScript, C++, Ruby, etc., but not limited to these). This information helps the extraction and summarization models better understand how to apply functions. Logical computation is the core of the program. The difficulty encountered by most current methods lies in their inability to strictly adhere to the complex logic and domain-specific conditions stipulated in documents / legal provisions. This application addresses this issue by running the program. For lines of code involving conditional judgments and logical execution, this application utilizes a model to reference the original wording of legal provisions, thereby ensuring the authenticity of the logic and consistency with the original legal provisions. Specifically, the extraction model is used to extract target parameters from the first text data, and the summarization model is used to generate second text data corresponding to the first text data based on the first text data, numerical calculation results, and target knowledge data corresponding to the target program code.

[0057] In one optional embodiment, given the first text data and target parameters, a retrieval tool can first retrieve target knowledge data matching the first text data from a database. For example, based on the target parameters of the first text data, the content of codes, articles, and guidelines that the target parameters conform to (i.e., target knowledge data) can be determined. Alternatively, the target knowledge data that the first text data conforms to can be directly determined based on the first text data. Or, a pre-written text similarity algorithm can be used to calculate the similarity between the first text data and multiple knowledge data sets to determine the target knowledge data, but this is not limited to these methods. Secondly, the retrieval tool can retrieve the target program code corresponding to the target knowledge data from the database. For example, given the first text data as "I am a freelancer, and my average monthly salary over the past three years was 11,000, 12,000, and 13,000 yuan respectively. I want to know how much compensation I can receive in this situation?", the target parameters can be: past three years, average monthly salary, 11,000 yuan, 12,000 yuan, 13,000 yuan, and compensation. First, a search engine can be used to retrieve the target knowledge data matching the target parameters from the database, which is a specific article from the Tort Liability Law. Second, the search engine can retrieve the target program code corresponding to that specific article from the database. Alternatively, a pre-written text similarity algorithm can be used to search the database to obtain the target program code corresponding to the target knowledge data, but this is not the only option.

[0058] It's important to note that the aforementioned retrieval system can be a small model trained using Bidirectional Encoder Representations from Transformers (BERT). The retriever generates an embedding for both the question (text data) and the legal provision (knowledge data), retrieves the legal provision using vector similarity, and then obtains the corresponding code, as the code is generated by a large language model based on a specific legal provision. Embedding refers to the process of mapping high-dimensional data to a low-dimensional space, typically used to convert text, images, or other types of data into vector representations for processing and analysis in machine learning models. Embedding helps models better understand the relationships and features between data, thereby improving model performance and accuracy.

[0059] Step S206: Execute the target program code based on the target parameters contained in the first text data to obtain the numerical calculation results corresponding to the target parameters.

[0060] The numerical calculation results described above represent the raw answer of the first text data generated after executing the program code. This is not merely a numerical value, but can also include the actual meaning that the value should embody. This raw answer has not undergone any expansion or modification through natural language processing. The numerical calculation results are in text format.

[0061] In one optional embodiment, upon obtaining the target program code corresponding to the first text data, an executor can execute the target program code based on the target parameters to obtain the numerical calculation result corresponding to the target parameters. For example, if the target parameters are: the past three years, average monthly salary, 11,000 yuan, 12,000 yuan, 13,000 yuan, and compensation, the executor can execute the target program code based on the target parameters to obtain the numerical calculation result corresponding to the target parameters. The calculation result not only includes the numerical value of the compensation amount but also the actual meaning that the value should reflect, namely, "the compensation amount obtained under different salary levels."

[0062] Step S208: Based on the first text data, numerical calculation results, and target knowledge data, generate the second text data corresponding to the first text data.

[0063] The aforementioned second text data can be natural language text data that the operation interface ultimately returns to the user or technician. For example, it can be numerical text data in the numerical calculation result, or it can be text data obtained by describing the result of processing the numerical value in natural language, which is the final answer required by the user.

[0064] In one optional embodiment, upon obtaining the numerical calculation result of the first text data, a summarization model can be used to judge the numerical calculation result. If the numerical calculation result is determined to be the final answer required by the user, it can be identified as the second text data, which can then be directly output by the summarization model. If the numerical calculation result is determined not to be the final answer required by the user, the summarization model can analyze and calculate based on the first text data, the numerical calculation result, and the target knowledge data to generate the second text data. For example, if the first text data is "If you want compensation in 24 installments, how much will you need to pay in each installment?", and the numerical calculation result is the total compensation amount, the summarization model can perform some simple analysis and calculation based on the question, domain documents / legal provisions (i.e., target knowledge data), and the result obtained from the query according to the legal provisions (i.e., the numerical calculation result). That is, the summarization model can divide the total compensation amount by 24 and then modify and expand the calculated result using natural language to obtain the second text data as: "If compensation is paid in 24 installments, the amount you need to pay in each installment is ××× yuan."

[0065] In another optional embodiment, given the first text data, numerical calculation results, and target knowledge data, the first text data can first be analyzed using a large language model to obtain a processing strategy that makes the first text data more consistent with natural language. Secondly, the large language model can expand and integrate the first text data based on the processing strategy and target knowledge data to obtain the second text data. For example, if the first text data is "I am a freelancer, and my average monthly salary over the past three years was 11,000, 12,000, and 13,000 yuan respectively. I want to know how much compensation I can receive in this situation?", the large language model can determine the processing strategy as follows: explain the relevant legal provisions to the user or technician, provide the actual compensation amount required by the user or technician, and ensure that the user or technician can understand the answer. At this point, the large language model can further refine and expand the first text data "compensation amount is ××× yuan" using natural language based on the processing strategy and target knowledge data to obtain the second text data "By referring to ××× content in ××× legal provision, I have calculated your average salary and determined that the compensation you can receive is ××× yuan."

[0066] In this embodiment, the method involves: acquiring first text data, which includes target parameters for numerical calculation; retrieving target knowledge data and target program code matching the first text data from a database, wherein the database stores multiple knowledge data sets and corresponding program codes for different knowledge data sets, the program codes being used to perform numerical calculations based on the corresponding knowledge data; executing the target program code based on the target parameters contained in the first text data to obtain the numerical calculation result corresponding to the target parameters; and generating second text data corresponding to the first text data based on the first text data, the numerical calculation result, and the target knowledge data. It is noteworthy that by pre-generating program codes corresponding to different knowledge data and processing complex logical rules and conditional judgments through the execution of the program code, the goal of performing numerical calculations based on target parameters is achieved. Regardless of how the description of the first text data changes, as long as the target parameters remain unchanged, the numerical calculation result will not change, thereby avoiding the influence of the problem content on the domain numerical calculation process. This achieves the technical effect of improving the accuracy of domain numerical calculations, thus solving the technical problem of low accuracy in domain numerical calculations in related technologies.

[0067] In the above embodiments of this application, retrieving target knowledge data and target program code that match the first text data from the database includes: matching the first text data with multiple knowledge data in the database to obtain target knowledge data that matches the first text data; and obtaining the program code corresponding to the target knowledge data from the database to obtain the target program code.

[0068] The aforementioned target knowledge data can be legal provisions or documents that conform to the first text data in a database, used to provide textual support for generating answers, reduce the impact of user-input questions on the generated answers, and improve the accuracy of domain numerical calculations.

[0069] In one optional embodiment, given the first text data and its target parameters, the first text data can first be matched with multiple knowledge databases in the database to obtain target knowledge data that matches the first text data. For example, matching can be performed using vector similarity, but it is not limited to this; matching can also be performed using text similarity. Finally, the program code corresponding to the target knowledge data can be obtained from the database using a retrieval tool, thus obtaining the target program code.

[0070] In the above embodiments of this application, executing target program code based on target parameters contained in the first text data to obtain numerical calculation results corresponding to the target parameters includes: converting the target parameters based on the target format requirements corresponding to the target program code to obtain converted parameters; and executing target program code based on the converted parameters to obtain numerical calculation results.

[0071] The target format requirements mentioned above can be formats required in the program code, used to facilitate simpler and more accurate calculations by the executor. These target format requirements can be based on code comments or can be format requirements set by technical personnel when generating the code. These target format requirements may include, but are not limited to, specifying which parameters to input and their types. The code executor mentioned above is a high-level programming language, such as Python, but not limited to it.

[0072] In one optional embodiment, after obtaining the first text data, the target parameters can first be converted by the code executor based on the target format requirements corresponding to the target program code to obtain the converted parameters. Then, the target program code can be executed by the code executor based on the converted parameters to obtain the numerical calculation result.

[0073] In the above embodiments of this application, generating second text data corresponding to the first text data based on the first text data, the numerical calculation result, and the target knowledge data corresponding to the target program code includes: converting the numerical calculation result into text form to obtain the result text data; inputting the first text data, the result text data, and the target knowledge data into a text generation model, and using the text generation model to generate the second text data.

[0074] In one optional embodiment, when numerical calculation results are obtained, the numerical calculation results can first be converted into text form to obtain result text data. The first text data, result text data, and target knowledge data are then input into the text generation model (i.e., the summary model mentioned above). Secondly, the text generation model can generate second text data based on the first text data, result text data, and target knowledge data after performing some simple analysis and calculations.

[0075] In the above embodiments of this application, the target program code is the result of generating code from the target knowledge data using a code generation model. The target program code includes at least knowledge reference data, target format requirements, and logical calculation code for numerical calculation. The knowledge reference data is used to describe the target knowledge data, and the logical calculation code matches the logic and calculation conditions in the target knowledge data.

[0076] The aforementioned knowledge reference data describes the content of the target knowledge data, such as specific legal provisions in the Civil Code. The target format requires the actual meaning, unit of calculation, and data type in a high-level programming language for the input and output parameters—that is, the parameter definitions and descriptions. This information helps the extraction and summarization models better understand how to apply functions. The logical calculation code is the coded representation of the logic and calculation conditions of the target knowledge data. In this embodiment, the returned result is not just a specific number, but a dictionary containing all the results that can be potentially inferred from the legal provisions and their corresponding actual meanings.

[0077] In one optional embodiment, the target program code is the result of generating code from the target knowledge data using an offline code generation model (OPG). The target program code includes at least knowledge reference data, target format requirements, and logical calculation code for numerical calculation. The knowledge reference data describes the target knowledge data, and the logical calculation code matches the logic and calculation conditions in the target knowledge data.

[0078] In the above embodiments of this application, the code generation model is obtained by iteratively training an initial generation model using a training knowledge dataset. The target loss function used in any iteration of training is determined based on the probability that the current generation model generates the first type of program code, the probability that the current generation model generates the second type of program code, the probability that the initial generation model generates the first type of program code, and the probability that the initial generation model generates the second type of program code. The current generation model is the initial generation model or the generation model trained in the previous iteration. The accuracy of the first type of program code in numerical calculation is greater than the accuracy of the second type of program code in numerical calculation. The first type of program code and the second type of program code are generated based on the same knowledge data in the training knowledge dataset.

[0079] The aforementioned training knowledge dataset contains multiple knowledge data sets, each corresponding to different specific contents within legal codes, clauses, and guidelines. Iteratively training the initial generation model using this dataset improves the computational accuracy of the code generation model in performing domain-specific numerical calculations on the knowledge data. These knowledge data sets can be obtained legally from the internet, or through model simulation, but are not limited to these methods.

[0080] The aforementioned target loss function can be a loss function that achieves the preset accuracy set by the technician. With the target loss function obtained, it can be determined that the performance of the code generation model meets the requirements. The first type of program code mentioned above can be executable program code with relatively good accuracy. The second type of program code mentioned above can be program code that cannot run or reports errors. The initial generation model mentioned above can be the code generation model before training, used to correct the code generation model from excessive deviation in language modeling. In an optional embodiment, the code generation model actually has relatively high requirements; it needs to faithfully reproduce the logic of the legal provisions and also needs to meet the program syntax of high-level programming languages. Therefore, this embodiment designs a training process for the code generation model. Due to the lack of code labels, we use DPO for preference learning, that is, we let the current generation model generate code multiple times for a legal provision (i.e., knowledge data), and then tell the current generation model which of the generated code is good and which is bad. By iteratively executing this training process, the current generation model will correct the distribution of the generated code, thereby improving the accuracy of the generated code, and thus obtaining the code generation model. Figure 4 This is a schematic diagram illustrating an optional classification of program code according to an embodiment of this application, such as... Figure 4 As shown, multiple program codes can first be generated based on the same knowledge data using an initial generative model, such as... Figure 4 f1 to f shown n Secondly, since the training dataset contains specific answers to different questions, running the entire process can also calculate the results calculated by different program codes, and whether they are correct. At this point, the accuracy rate (i.e., the accuracy used for numerical calculations) can be statistically calculated for different program codes f, denoted as S. Here, "statistic" refers to a program code answering x questions correctly in the training dataset, with a total of n questions using that program code, and the accuracy rate being x / n. Then, all program codes can be sorted according to their accuracy rates, resulting in the first type of program code pairs (pairs), such as... Figure 4 The code and accuracy of the square border shown, as well as the second type of code pair, such as Figure 4 The program code and accuracy of the circular border shown.

[0081] in, Figure 4 A circular border indicates a program that cannot run and will report an error (i.e., code P of type 2). l These programs are of poor quality. Among them, the code P of type I programs is... w In the text, f3 and f1 indicate that the program can run, but the accuracy is relatively poor. Figure 4 S3 and S1, f ·.· and f nThis indicates that the program can run and has good accuracy, such as... Figure 4 S in ·.· and S n .

[0082] It should be noted that multiple program codes can be classified according to their accuracy in numerical calculations, resulting in a first type of program code and a second type of program code. Alternatively, multiple program codes can be classified according to their quantity and proportion, resulting in a first type of program code and a second type of program code.

[0083] In another alternative embodiment, the target loss function L can be obtained by the following formula. G :

[0084]

[0085] in, Let d be the loss function of DPO, d be the knowledge data (i.e., legal provisions), σ be the activation function, β be the hyperparameter, and θ be the inequality. G (P w |d) is the probability that the current generative model generates the first type of program code, θ ref (P w |d) is the probability that the initial generative model generates the first type of program code, θ G (P l |d) is the probability that the current generative model generates the second type of program code, θ ref (P l |d) is the probability that the initial generation model generates the second type of program code.

[0086] This application proposes a framework based on knowledge-intensive programming: Domain-Specific Calculation with Knowledge-Intensive Programs (DCKIP). Figure 5 This is a schematic diagram of an optional DCKIP framework according to an embodiment of this application, as shown below. Figure 5As shown, firstly, an offline code generation model can convert all domain-specific legal provisions or documents in the knowledge base into corresponding knowledge-intensive programs (i.e., program code). Secondly, when a user inputs a query, a retriever can first retrieve the legal provisions and corresponding code from the database based on the question. Then, based on the code comments, an extractor can extract relevant parameters from the query (i.e., variable extraction), and input them into the system executor according to the required format. This is essentially Python running the code, and then the results are organized into text format and input into a summary model. The model then summarizes the query question, domain documents or legal provisions, and the results obtained from the query according to the legal provisions. After some simple analysis and calculation, the final result is obtained. If the function output is the answer the user needs, it can be returned directly; otherwise, some simple processing is required. For example, if the function returns the total compensation amount, but the user asks how much each period should be if they want compensation in 24 installments, then the total compensation amount needs to be divided by 24. In this embodiment, the offline code generation model is a large language model.

[0087] The knowledge-intensive program proposed in this application targets an entire document or legal provision, rather than a query. Therefore, it can average out the bias caused by the query through methods such as voting. Moreover, the generated code can be used continuously without needing to be regenerated. The program's execution is robust to the query; regardless of how the query is expressed, as long as the input parameters are consistent, it can follow the logical provisions of the legal provision. This approach is very useful for handling scenarios with complex logic.

[0088] This application introduces the concept of a "knowledge-intensive program," which, compared to the previous Program of Thought (PoT) method, is oriented towards the entire document or legal provisions and can handle complex logical provisions and conditional judgments. Through this knowledge-intensive program, the DCKIP framework is designed, which can effectively improve the domain-specific numerical computation accuracy of the model.

[0089] According to an embodiment of this application, a method for training a code generation model is also provided. Figure 6 This is a flowchart illustrating a training method for a code generation model according to an embodiment of this application. Figure 6 As shown, the method includes:

[0090] Step S602: Obtain the training knowledge dataset;

[0091] Step S604: The initial generation model is trained iteratively multiple times using the training knowledge dataset to obtain a code generation model. The code generation model is used to generate program code corresponding to different knowledge data, and the program code is used to perform numerical calculations based on the corresponding knowledge data. The target loss function used in any iteration of training is determined based on the probability that the current generation model generates the first type of program code, the probability that the current generation model generates the second type of program code, the probability that the initial generation model generates the first type of program code, and the probability that the initial generation model generates the second type of program code. The current generation model is the initial generation model or the generation model trained in the previous iteration. The accuracy of the first type of program code in numerical calculations is greater than the accuracy of the second type of program code in numerical calculations. The first type of program code and the second type of program code are generated based on the same knowledge data in the training knowledge dataset.

[0092] The aforementioned training knowledge dataset contains multiple knowledge data sets, each corresponding to different specific contents within legal codes, clauses, and guidelines. Iteratively training the initial generation model using this dataset improves the computational accuracy of the code generation model in performing domain-specific numerical calculations on the knowledge data. These knowledge data sets can be obtained legally from the internet, or through model simulation, but are not limited to these methods.

[0093] In one optional embodiment, in different domain numerical calculation scenarios, the related technology suffers from low accuracy in domain numerical calculations. To address this issue, this embodiment takes the application scenario of damage calculation in litigation cases in the legal field as an example. First, a training knowledge dataset can be obtained. Second, the initial generation model can be iteratively trained using the training knowledge dataset to obtain a code generation model. This code generation model is used to generate program code corresponding to different knowledge data, and the program code is used to perform accurate numerical calculations based on the corresponding knowledge data.

[0094] In any iteration of training, the target loss function is determined based on the probability that the current generative model generates the first type of program code, the probability that the current generative model generates the second type of program code, the probability that the initial generative model generates the first type of program code, and the probability that the initial generative model generates the second type of program code. The current generative model is either the initial generative model or the generative model trained in the previous iteration. The accuracy of the first type of program code in numerical calculation is greater than that of the second type of program code in numerical calculation. The first type of program code and the second type of program code are generated based on the same knowledge data in the training knowledge dataset.

[0095] In the above embodiments of this application, during any iteration of training, the method includes: generating multiple first program codes multiple times using an initial generation model on the same knowledge data, and generating multiple second program codes multiple times using the current generation model on the same knowledge data; performing numerical calculations using the multiple first program codes to determine the accuracy of the multiple first program codes, and performing numerical calculations using the multiple second program codes to determine the accuracy of the multiple second program codes; determining the type of the multiple first program codes based on the accuracy of the multiple first program codes, and determining the type of the multiple second program codes based on the accuracy of the multiple second program codes; generating a target loss function based on the probability that the current generation model generates program codes of the first type, the probability that the current generation model generates program codes of the second type, the probability that the initial generation model generates program codes of the first type, and the probability that the initial generation model generates program codes of the second type.

[0096] In one optional embodiment, during any iteration of training, firstly, the same knowledge data can be generated multiple times using the initial generation model to obtain multiple first program codes, and then the same knowledge data can be generated multiple times using the current generation model to obtain multiple second program codes. Secondly, numerical calculations can be performed using the multiple first program codes to determine their accuracy, and numerical calculations can be performed using the multiple second program codes to determine their accuracy. Then, based on the accuracy of the multiple first program codes, the type of the multiple first program codes can be determined, and based on the accuracy of the multiple second program codes, the type of the multiple second program codes can be determined. Finally, a target loss function can be generated based on the probability that the current generation model generates first-type program codes, the probability that the current generation model generates second-type program codes, the probability that the initial generation model generates first-type program codes, and the probability that the initial generation model generates second-type program codes.

[0097] According to an embodiment of this application, a text processing method is also provided. Figure 7This is a flowchart of a text processing method according to an embodiment of this application, such as... Figure 7 As shown, the method includes:

[0098] Step S702: In response to an input command applied to the operation interface, determine the first text data corresponding to the input command, wherein the first text data contains target parameters for numerical calculation.

[0099] Step S704: Retrieve the target program code that matches the first text data from the database. The database stores multiple knowledge data and program codes corresponding to different knowledge data. The program code is used to perform numerical calculations based on the corresponding knowledge data.

[0100] Step S706: Execute the target program code based on the target parameters contained in the first text data to obtain the numerical calculation results corresponding to the target parameters;

[0101] Step S708: Based on the first text data, the numerical calculation results, and the target knowledge data corresponding to the target program code, generate the second text data corresponding to the first text data;

[0102] Step S7010: Display the second text data on the operation interface.

[0103] In an optional embodiment, to address the technical problem of low accuracy in domain-specific numerical calculations in related technologies, this embodiment takes the application scenario of damage calculation in litigation cases in the legal field as an example. When a user inputs first text data into the operation interface on the client or server, the operation interface generates an input command based on the user's input. Then, the operation interface can obtain the first text data input by the user based on the input command. Next, the operation interface can retrieve the target program code matching the first text data from the database. Then, it can execute the target program code based on the target parameters contained in the first text data to obtain the numerical calculation result corresponding to the target parameters. Finally, based on the first text data, the numerical calculation result, and the target knowledge data corresponding to the target program code, it can generate second text data corresponding to the first text data. Upon obtaining the second text data, such as... Figure 3 As shown, the second text data can be displayed through the display area 32 of the operation interface 31, so that users or technicians can intuitively see the required answer.

[0104] The first text data contains target parameters for numerical calculations. The database stores multiple knowledge data and corresponding program codes for different knowledge data. The program codes are used to perform numerical calculations based on the corresponding knowledge data.

[0105] According to an embodiment of this application, a text processing method is also provided. Figure 8 This is a flowchart of a text processing method according to an embodiment of this application, such as... Figure 8 As shown, the method includes:

[0106] Step S802: Obtain query text data, wherein the query text data contains target parameters for numerical calculation;

[0107] Step S804: Retrieve target legal provisions data and target program code that match the query text data from the database. The database stores multiple legal provisions data and program codes corresponding to different legal provisions data. The program codes are used to perform numerical calculations based on the corresponding legal provisions data.

[0108] Step S806: Execute the target program code based on the target parameters contained in the query text data to obtain the numerical calculation results corresponding to the target parameters;

[0109] Step S808: Generate response text data based on the query text data, numerical calculation results, and target legal provision data.

[0110] The aforementioned query text data can be questions entered by the user in the user interface.

[0111] In an optional embodiment, in order to solve the technical problem of low accuracy in domain numerical calculations in related technologies, this embodiment takes the application scenario of damage calculation in litigation cases in the legal field as an example. When a user inputs query text data in the operation interface of the client or server, the query text data corresponding to the input instruction can be obtained first. Then, the target program code matching the query text data can be retrieved from the database. Then, the target program code can be executed based on the target parameters contained in the query text data to obtain the numerical calculation result corresponding to the target parameters. Then, the response text data can be generated based on the query text data, the numerical calculation result, and the target legal provisions data corresponding to the target program code.

[0112] The query text data contains target parameters for numerical calculations. The database stores multiple legal provisions and corresponding program codes for different legal provisions. The program codes are used to perform numerical calculations based on the corresponding legal provisions.

[0113] According to an embodiment of this application, a text processing method is also provided. Figure 9 This is a flowchart of a text processing method according to an embodiment of this application, such as... Figure 9 As shown, the method includes:

[0114] Step S902: Obtain first text data by calling the first interface, wherein the first interface includes a first parameter, the parameter value of the first parameter includes the first text data, and the first text data contains target parameters for numerical calculation.

[0115] Step S904: Retrieve target knowledge data and target program code that match the first text data from the database. The database stores multiple knowledge data and program codes corresponding to different knowledge data. The program codes are used to perform numerical calculations based on the corresponding knowledge data.

[0116] Step S906: Execute the target program code based on the target parameters contained in the first text data to obtain the numerical calculation results corresponding to the target parameters;

[0117] Step S908: Based on the first text data, numerical calculation results, and target knowledge data, generate the second text data corresponding to the first text data;

[0118] Step S9010: Output second text data by calling the second interface, wherein the second interface includes a second parameter, and the parameter value of the second parameter includes the second text data.

[0119] The first interface described above can be an interface for obtaining first text data from a user or technician. The second interface described above can be an interface for outputting second text data to a user or technician.

[0120] In an optional embodiment, in order to solve the technical problem of low accuracy of domain numerical calculation in related technologies, this embodiment takes the application scenario of damage compensation calculation in litigation cases in the legal field as an example. First, the first text data can be obtained by calling the first interface. Second, the target program code that matches the first text data can be retrieved from the database. Then, the target program code can be executed based on the target parameters contained in the first text data to obtain the numerical calculation result corresponding to the target parameters. Then, the second text data corresponding to the first text data can be generated based on the first text data, the numerical calculation result and the target knowledge data corresponding to the target program code. Finally, the second text data can be output by calling the second interface.

[0121] The first interface includes a first parameter, the value of which includes first text data. The first text data contains target parameters for numerical calculation. The database stores multiple knowledge data and program code corresponding to different knowledge data. The program code is used to perform numerical calculation based on the corresponding knowledge data. The second interface includes a second parameter, the value of which includes second text data.

[0122] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, use and processing of the relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and corresponding operation portals are provided for users to choose to authorize or refuse.

[0123] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that this application is not limited to the described order of actions, as some steps may be performed in other orders or simultaneously according to this application. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions and modules involved are not necessarily essential to this application.

[0124] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, they can also be implemented by hardware. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of this application.

[0125] According to an embodiment of this application, a text processing apparatus for implementing the above-described text processing method is also provided. Figure 10 This is a schematic diagram of a text processing apparatus according to an embodiment of this application, such as... Figure 10 As shown, the device includes: an acquisition module 1002, a retrieval module 1004, a processing module 1006, and a generation module 1008.

[0126] The module comprises: an acquisition module for acquiring first text data, which includes target parameters for numerical calculation; a retrieval module for retrieving target knowledge data and target program code that match the first text data from a database, wherein the database stores multiple knowledge data sets and corresponding program codes for different knowledge data sets, and the program codes are used to perform numerical calculations based on the corresponding knowledge data; a processing module for executing the target program code based on the target parameters contained in the first text data to obtain the numerical calculation results corresponding to the target parameters; and a generation module for generating second text data corresponding to the first text data based on the first text data, the numerical calculation results, and the target knowledge data.

[0127] It should be noted that the acquisition module 1002, retrieval module 1004, processing module 1006, and generation module 1008 correspond to steps S202 to S208 in the above embodiments. The four modules and their corresponding steps implement the same instances and application scenarios, but are not limited to the content disclosed in the above embodiments. It should be noted that the above modules or units can be hardware or software components stored in memory and processed by one or more processors. The above modules can also run as part of the device in the server 10 provided in the above embodiments.

[0128] In the above embodiments of this application, the retrieval module includes a matching unit and an acquisition unit.

[0129] The matching unit is used to match the first text data with multiple knowledge data in the database to obtain target knowledge data that matches the first text data; the acquisition unit is used to obtain the program code corresponding to the target knowledge data from the database to obtain the target program code.

[0130] In the above embodiments of this application, the processing module includes: a first conversion unit and an execution unit.

[0131] The first conversion unit is used to convert the target parameters based on the target format requirements corresponding to the target program code to obtain the converted parameters; the execution unit is used to execute the target program code based on the converted parameters to obtain the numerical calculation results.

[0132] In the above embodiments of this application, the generation module includes a second conversion unit and a generation unit.

[0133] The second conversion unit is used to convert the numerical calculation results into text form to obtain the result text data; the generation unit is used to input the first text data, the result text data and the target knowledge data into the text generation model, and use the text generation model to generate the second text data.

[0134] In the above embodiments of this application, the target program code is the result of generating code from the target knowledge data using a code generation model. The target program code includes at least knowledge reference data, target format requirements, and logical calculation code for numerical calculation. The knowledge reference data is used to describe the target knowledge data, and the logical calculation code matches the logic and calculation conditions in the target knowledge data.

[0135] In the above embodiments of this application, the code generation model is obtained by iteratively training an initial generation model using a training knowledge dataset. The target loss function used in any iteration of training is determined based on the probability that the current generation model generates the first type of program code, the probability that the current generation model generates the second type of program code, the probability that the initial generation model generates the first type of program code, and the probability that the initial generation model generates the second type of program code. The current generation model is the initial generation model or the generation model trained in the previous iteration. The accuracy of the first type of program code in numerical calculation is greater than the accuracy of the second type of program code in numerical calculation. The first type of program code and the second type of program code are generated based on the same knowledge data in the training knowledge dataset.

[0136] According to an embodiment of this application, a training apparatus for a code generation model used to implement the training method of the above-described code generation model is also provided. Figure 11 This is a schematic diagram of a training apparatus for a code generation model according to an embodiment of this application, such as... Figure 11 As shown, the device includes: an acquisition module 1102 and a training module 1104.

[0137] The acquisition module is used to acquire the training knowledge dataset. The training module is used to iteratively train the initial generation model using the training knowledge dataset to obtain a code generation model. The code generation model is used to generate program code corresponding to different knowledge data, and the program code is used to perform numerical calculations based on the corresponding knowledge data. The target loss function used in any iteration of training is determined based on the probability that the current generation model generates the first type of program code, the probability that the current generation model generates the second type of program code, the probability that the initial generation model generates the first type of program code, and the probability that the initial generation model generates the second type of program code. The current generation model is the initial generation model or the generation model trained in the previous iteration. The accuracy of the first type of program code in numerical calculations is greater than that of the second type of program code in numerical calculations. The first type of program code and the second type of program code are generated based on the same knowledge data in the training knowledge dataset.

[0138] It should be noted that the acquisition module 1102 and training module 1104 mentioned above correspond to steps S602 to S604 in the above embodiments. The two modules and their corresponding steps implement the same instances and application scenarios, but are not limited to the content disclosed in the above embodiments. It should be noted that the above modules or units can be hardware or software components stored in memory and processed by one or more processors. The above modules can also be part of the device and run in the server 10 provided in the above embodiments.

[0139] In the above embodiments of this application, during any iteration of training, the training module includes: a first generation unit, a calculation unit, a determination unit, and a second generation unit.

[0140] The system comprises the following components: a first generation unit, which generates multiple first program codes from the same knowledge data using an initial generation model, and generates multiple second program codes from the same knowledge data using the current generation model; a calculation unit, which performs numerical calculations using the multiple first program codes to determine their accuracy, and performs numerical calculations using the multiple second program codes to determine their accuracy; a determination unit, which determines the type of the multiple first program codes based on their accuracy, and determines the type of the multiple second program codes based on their accuracy; and a second generation unit, which generates a target loss function based on the probability of the current generation model generating first-type program codes, the probability of the current generation model generating second-type program codes, the probability of the initial generation model generating first-type program codes, and the probability of the initial generation model generating second-type program codes.

[0141] According to an embodiment of this application, a text processing apparatus for implementing the above-described text processing method is also provided. Figure 12 This is a schematic diagram of a text processing apparatus according to an embodiment of this application, such as... Figure 12 As shown, the device includes: a determining module 1202, a retrieving module 1204, a processing module 1206, a generating module 1208, and a display module 12010.

[0142] The system comprises the following modules: a determination module, a retrieval module, and a display module. The determination module responds to input commands applied to the user interface and determines the first text data corresponding to the input command. The first text data contains target parameters for numerical calculation. The retrieval module retrieves target program code matching the first text data from a database containing multiple knowledge data sets and corresponding program codes. The program codes are used to perform numerical calculations based on the corresponding knowledge data. The processing module executes the target program code based on the target parameters contained in the first text data to obtain the numerical calculation result corresponding to the target parameters. The generation module generates second text data corresponding to the first text data based on the first text data, the numerical calculation result, and the target knowledge data corresponding to the target program code. The display module displays the second text data on the user interface.

[0143] It should be noted that the aforementioned determining module 1202, retrieval module 1204, processing module 1206, generation module 1208, and display module 12010 correspond to steps S702 to S7010 in the above embodiments. The five modules and their corresponding steps implement the same instances and application scenarios, but are not limited to the content disclosed in the above embodiments. It should also be noted that the aforementioned modules or units can be hardware or software components stored in memory and processed by one or more processors. These modules can also run as part of a device within the server 10 provided in the above embodiments.

[0144] According to an embodiment of this application, a text processing apparatus for implementing the above-described text processing method is also provided. Figure 13 This is a schematic diagram of a text processing apparatus according to an embodiment of this application, such as... Figure 13 As shown, the device includes: an acquisition module 1302, a retrieval module 1304, a processing module 1306, and a generation module 1308.

[0145] The system comprises the following modules: an acquisition module for acquiring inquiry text data, which includes target parameters for numerical calculation; a retrieval module for retrieving target legal provisions and target program code that match the inquiry text data from a database, which stores multiple legal provisions and corresponding program codes for different legal provisions, with the program codes used for numerical calculations based on the corresponding legal provisions; a processing module for executing the target program code based on the target parameters contained in the inquiry text data to obtain the numerical calculation results corresponding to the target parameters; and a generation module for generating response text data based on the inquiry text data, the numerical calculation results, and the target legal provisions.

[0146] It should be noted that the acquisition module 1302, retrieval module 1304, processing module 1306, and generation module 1308 mentioned above correspond to steps S802 to S808 in the above embodiments. The four modules and their corresponding steps implement the same instances and application scenarios, but are not limited to the content disclosed in the above embodiments. It should be noted that the above modules or units can be hardware or software components stored in memory and processed by one or more processors. The above modules can also run as part of the device in the server 10 provided in the above embodiments.

[0147] According to an embodiment of this application, a text processing apparatus for implementing the above-described text processing method is also provided. Figure 14 This is a schematic diagram of a text processing apparatus according to an embodiment of this application, such as... Figure 14 As shown, the device includes: an acquisition module 1402, a retrieval module 1404, a processing module 1406, a generation module 1408, and an output module 14010.

[0148] The system comprises the following modules: an acquisition module for acquiring first text data by calling a first interface, wherein the first interface includes a first parameter whose value includes the first text data, and the first text data contains target parameters for numerical calculation; a retrieval module for retrieving target knowledge data and target program code matching the first text data from a database, wherein the database stores multiple knowledge data sets and corresponding program codes for different knowledge data sets, and the program codes are used for numerical calculation based on the corresponding knowledge data; a processing module for executing the target program code based on the target parameters contained in the first text data to obtain the numerical calculation result corresponding to the target parameters; a generation module for generating second text data corresponding to the first text data based on the first text data, the numerical calculation result, and the target knowledge data corresponding to the target program code; and an output module for outputting the second text data by calling a second interface, wherein the second interface includes a second parameter whose value includes the second text data.

[0149] It should be noted that the acquisition module 1402, retrieval module 1404, processing module 1406, generation module 1408, and output module 14010 mentioned above correspond to steps S902 to S9010 in the above embodiments. The five modules and their corresponding steps implement the same instances and application scenarios, but are not limited to the content disclosed in the above embodiments. It should also be noted that the modules or units mentioned above can be hardware or software components stored in memory and processed by one or more processors. These modules can also run as part of a device in the server 10 provided in the above embodiments.

[0150] It should be noted that the preferred embodiments involved in the above embodiments of this application are the same as the solutions, application scenarios and implementation processes provided in the above embodiments, but are not limited to the solutions provided in the above embodiments.

[0151] Embodiments of this application may provide an electronic device, which may be any one of a group of electronic devices. Optionally, in this embodiment, the aforementioned electronic device may also be replaced by a terminal device such as a mobile terminal.

[0152] Optionally, in this embodiment, the aforementioned electronic device may be located in at least one of a plurality of network devices in a computer network.

[0153] In this embodiment, the electronic device described above can execute the program code in the method.

[0154] Optionally, Figure 15 This is a structural block diagram of an electronic device according to an embodiment of this application. Figure 15As shown, the electronic device A may include: one or more (only one is shown in the figure) processors 1502, memory 1504, memory controller, and peripheral interfaces, wherein the peripheral interfaces are connected to the radio frequency module, the audio module, and the display.

[0155] The memory can be used to store software programs and modules, such as the program instructions / modules corresponding to the methods and apparatus in the embodiments of this application. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory, thereby implementing the methods in the above embodiments. The memory may include high-speed random access memory, and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory may further include memory remotely located relative to the processor, and these remote memories can be connected to terminal A via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.

[0156] The processor can invoke information and application programs stored in memory via a transmission device to perform the following steps: acquiring first text data, wherein the first text data contains target parameters for numerical calculation; retrieving target knowledge data and target program code matching the first text data from a database, wherein the database stores multiple knowledge data and program codes corresponding to different knowledge data, the program codes being used to perform numerical calculations based on the corresponding knowledge data; executing the target program code based on the target parameters contained in the first text data to obtain the numerical calculation result corresponding to the target parameters; and generating second text data corresponding to the first text data based on the first text data, the numerical calculation result, and the target knowledge data.

[0157] Optionally, the processor may also execute program code that performs the following steps: matching the first text data with multiple knowledge data in the database to obtain target knowledge data that matches the first text data; retrieving the program code corresponding to the target knowledge data from the database to obtain the target program code.

[0158] Optionally, the processor may also execute program code that performs the following steps: converts the target parameters based on the target format requirements corresponding to the target program code to obtain the converted parameters; and executes the target program code based on the converted parameters to obtain the numerical calculation results.

[0159] Optionally, the processor may also execute program code that performs the following steps: converts the numerical calculation results into text form to obtain the result text data; inputs the first text data, the result text data, and the target knowledge data into the text generation model, and uses the text generation model to generate the second text data.

[0160] Optionally, the processor may also execute program code with the following steps: the target program code is the result of generating code from the target knowledge data using a code generation model, wherein the target program code includes at least knowledge reference data, target format requirements, and logical calculation code for numerical calculation, the knowledge reference data is used to describe the target knowledge data, and the logical calculation code matches the logic and calculation conditions in the target knowledge data.

[0161] Optionally, the processor may also execute program code with the following steps: the code generation model is obtained by iteratively training an initial generation model using a training knowledge dataset. The target loss function used in any iteration of training is determined based on the probability that the current generation model generates the first type of program code, the probability that the current generation model generates the second type of program code, the probability that the initial generation model generates the first type of program code, and the probability that the initial generation model generates the second type of program code. The current generation model is either the initial generation model or the generation model trained in the previous iteration. The accuracy of the first type of program code in numerical calculation is greater than the accuracy of the second type of program code in numerical calculation. The first type of program code and the second type of program code are generated based on the same knowledge data in the training knowledge dataset.

[0162] This application provides a method for obtaining first text data, which includes target parameters for numerical calculation; retrieving target knowledge data and target program code matching the first text data from a database, wherein the database stores multiple knowledge data sets and program codes corresponding to different knowledge data sets, and the program codes are used to perform numerical calculations based on the corresponding knowledge data; executing the target program code based on the target parameters included in the first text data to obtain the numerical calculation result corresponding to the target parameters; and generating second text data corresponding to the first text data based on the first text data, the numerical calculation result, and the target knowledge data. It is noteworthy that by pre-generating program codes corresponding to different knowledge data and handling complex logical rules and conditional judgments by executing the program codes, the purpose of performing numerical calculations based on target parameters is achieved. Regardless of how the description of the first text data changes, as long as the target parameters do not change, the numerical calculation result will not change, thereby avoiding the influence of the problem content on the domain numerical calculation process. This achieves the technical effect of improving the accuracy of domain numerical calculations, and thus solves the technical problem of low accuracy in domain numerical calculations in related technologies.

[0163] It will be understood by those skilled in the art that the structure shown in the figure is merely illustrative, and the electronic device may also be a smartphone (such as an Android phone, an iOS phone, etc.), a tablet computer, a PDA, a mobile internet device (MID), a PAD, or other terminal device. This figure does not limit the structure of the aforementioned electronic device. For example, electronic device A may include more or fewer components (such as a network interface, a display device, etc.) than shown in the figure, or may have a different configuration than shown in the figure.

[0164] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing the hardware related to the terminal device. The program can be stored in a computer-readable storage medium, which may include: flash drive, read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.

[0165] Embodiments of this application also provide a computer-readable storage medium. Optionally, in this embodiment, the computer-readable storage medium can be used to store program code executed by the method provided in the above embodiments.

[0166] Optionally, in this embodiment, the storage medium may be located in any one of the electronic devices in the group of electronic devices in the computer network, or in any one of the mobile terminals in the group of mobile terminals.

[0167] Optionally, in this embodiment, the computer-readable storage medium is configured to store program code for performing the following steps: acquiring first text data, wherein the first text data includes target parameters for performing numerical calculations; retrieving target knowledge data and target program code matching the first text data from a database, wherein the database stores multiple knowledge data and program code corresponding to different knowledge data, the program code being used to perform numerical calculations based on the corresponding knowledge data; executing the target program code based on the target parameters contained in the first text data to obtain the numerical calculation result corresponding to the target parameters; and generating second text data corresponding to the first text data based on the first text data, the numerical calculation result, and the target knowledge data.

[0168] Optionally, the computer-readable storage medium is further configured to store program code for performing the following steps: matching first text data with multiple knowledge data in a database to obtain target knowledge data that matches the first text data; retrieving program code corresponding to the target knowledge data from the database to obtain target program code.

[0169] Optionally, the computer-readable storage medium is further configured to store program code for performing the following steps: converting target parameters based on target format requirements corresponding to the target program code to obtain converted parameters; and executing the target program code based on the converted parameters to obtain numerical calculation results.

[0170] Optionally, the computer-readable storage medium is further configured to store program code for performing the following steps: converting numerical calculation results into text form to obtain result text data; inputting the first text data, the result text data, and the target knowledge data into a text generation model, and using the text generation model to generate second text data.

[0171] Optionally, the computer-readable storage medium is further configured to store program code for performing the following steps: the target program code is the result of generating code from the target knowledge data using a code generation model, wherein the target program code includes at least knowledge reference data, target format requirements, and logical calculation code for performing numerical calculations, the knowledge reference data being used to describe the target knowledge data, and the logical calculation code matching the logic and calculation conditions in the target knowledge data.

[0172] Optionally, the computer-readable storage medium is further configured to store program code for performing the following steps: the code generation model is obtained by iteratively training an initial generation model using a training knowledge dataset, wherein the target loss function used in any iteration of training is determined based on the probability that the current generation model generates first-type program code, the probability that the current generation model generates second-type program code, the probability that the initial generation model generates first-type program code, and the probability that the initial generation model generates second-type program code, wherein the current generation model is the initial generation model or the generation model trained in the previous iteration, the accuracy of the first-type program code for numerical calculation is greater than the accuracy of the second-type program code for numerical calculation, and the first-type program code and the second-type program code are generated based on the same knowledge data in the training knowledge dataset.

[0173] Embodiments of this application also provide a computer program product. Optionally, in this embodiment, the computer program product may include a computer program that, when executed by a processor, implements the methods provided in the embodiments described above.

[0174] Embodiments of this application also provide a computer program product. Optionally, the computer program product may include a non-volatile computer-readable storage medium, which can be used to store a computer program that, when executed by a processor, implements the method provided in the above embodiments.

[0175] Embodiments of this application also provide a computer program. Optionally, in this embodiment, when the computer program is executed by a processor, it implements the method provided in the above embodiments.

[0176] In the above embodiments of this application, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.

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

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

[0179] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

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

[0181] The above description is only a preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.

Claims

1. A text processing method, characterized in that, include: Obtain first text data, wherein the first text data contains target parameters for numerical calculation; Target knowledge data and target program code that match the first text data are retrieved from the database. The database stores multiple knowledge data and program code corresponding to different knowledge data. The program code is used to perform numerical calculations based on the corresponding knowledge data. Based on the target parameters contained in the first text data, the target program code is executed to obtain the numerical calculation result corresponding to the target parameters; Based on the first text data, the numerical calculation result, and the target knowledge data, second text data corresponding to the first text data is generated.

2. The method according to claim 1, characterized in that, The step of retrieving target knowledge data and target program code from the database that match the first text data includes: The first text data is matched with the plurality of knowledge data in the database to obtain the target knowledge data that matches the first text data; The target program code is obtained by retrieving the program code corresponding to the target knowledge data from the database.

3. The method according to claim 1, characterized in that, The step of executing the target program code based on the target parameters contained in the first text data to obtain the numerical calculation result corresponding to the target parameters includes: The target parameters are converted based on the target format requirements corresponding to the target program code to obtain the converted parameters; The target program code is executed based on the converted parameters to obtain the numerical calculation result.

4. The method according to claim 1, characterized in that, The step of generating second text data corresponding to the first text data based on the first text data, the numerical calculation result, and the target knowledge data corresponding to the target program code includes: The numerical calculation results are converted into text format to obtain the result text data; The first text data, the result text data, and the target knowledge data are input into the text generation model, and the second text data is generated using the text generation model.

5. The method according to any one of claims 1 to 4, characterized in that, The target program code is the result of generating code from the target knowledge data using a code generation model. The target program code includes at least knowledge reference data, target format requirements, and logical calculation code for numerical calculation. The knowledge reference data describes the target knowledge data, and the logical calculation code matches the logic and calculation conditions in the target knowledge data.

6. The method according to claim 5, characterized in that, The code generation model is obtained by iteratively training an initial generation model using a training knowledge dataset. The target loss function used in any iteration is determined based on the probability that the current generation model generates the first type of program code, the probability that the current generation model generates the second type of program code, the probability that the initial generation model generates the first type of program code, and the probability that the initial generation model generates the second type of program code. The current generation model is either the initial generation model or the generation model trained in the previous iteration. The accuracy of the first type of program code in numerical calculation is greater than the accuracy of the second type of program code in numerical calculation. The first type of program code and the second type of program code are generated based on the same knowledge data in the training knowledge dataset.

7. A training method for a code generation model, characterized in that, include: Obtain the training knowledge dataset; The initial generation model is trained iteratively multiple times using the training knowledge dataset to obtain a code generation model, wherein the code generation model is used to generate program code corresponding to different knowledge data, and the program code is used to perform numerical calculations based on the corresponding knowledge data. In any iteration of training, the target loss function is determined based on the probability that the current generative model generates the first type of program code, the probability that the current generative model generates the second type of program code, the probability that the initial generative model generates the first type of program code, and the probability that the initial generative model generates the second type of program code. The current generative model is the initial generative model or the generative model trained in the previous iteration. The accuracy of the first type of program code in numerical calculation is greater than the accuracy of the second type of program code in numerical calculation. The first type of program code and the second type of program code are generated based on the same knowledge data in the training knowledge dataset.

8. The method according to claim 7, characterized in that, During any of the said training iterations, the method includes: The same knowledge data is generated multiple times using the initial generation model to obtain multiple first program codes, and the same knowledge data is generated multiple times using the current generation model to obtain multiple second program codes; Numerical calculations are performed using the plurality of first program codes to determine the accuracy of the plurality of first program codes, and numerical calculations are performed using the plurality of second program codes to determine the accuracy of the plurality of second program codes; Based on the accuracy of the plurality of first program codes, the type of the plurality of first program codes is determined, and based on the accuracy of the plurality of second program codes, the type of the plurality of second program codes is determined; The target loss function is generated based on the probability that the current generation model generates the first type of program code, the probability that the current generation model generates the second type of program code, the probability that the initial generation model generates the first type of program code, and the probability that the initial generation model generates the second type of program code.

9. A text processing method, characterized in that, include: In response to an input command applied to the user interface, the system determines the first text data corresponding to the input command, wherein the first text data includes target parameters for numerical calculation. The target program code that matches the first text data is retrieved from the database. The database stores multiple knowledge data and program codes corresponding to different knowledge data. The program code is used to perform numerical calculations based on the corresponding knowledge data. Based on the target parameters contained in the first text data, the target program code is executed to obtain the numerical calculation result corresponding to the target parameters; Based on the first text data, the numerical calculation result, and the target knowledge data corresponding to the target program code, generate the second text data corresponding to the first text data; Output the second text data.

10. A text processing method, characterized in that, include: Obtain query text data, wherein the query text data contains target parameters for numerical calculation; The database retrieves target legal provisions and target program code that match the query text data. The database stores multiple legal provisions and program codes corresponding to different legal provisions. The program codes are used to perform numerical calculations based on the corresponding legal provisions. Based on the target parameters contained in the query text data, the target program code is executed to obtain the numerical calculation result corresponding to the target parameters; Based on the query text data, the numerical calculation results, and the target legal provision data, a response text data is generated.

11. A text processing method, characterized in that, include: First text data is obtained by calling a first interface, wherein the first interface includes a first parameter, the parameter value of the first parameter includes the first text data, and the first text data contains a target parameter for numerical calculation. Target knowledge data and target program code that match the first text data are retrieved from the database. The database stores multiple knowledge data and program code corresponding to different knowledge data. The program code is used to perform numerical calculations based on the corresponding knowledge data. Based on the target parameters contained in the first text data, the target program code is executed to obtain the numerical calculation result corresponding to the target parameters; Based on the first text data, the numerical calculation result, and the target knowledge data, generate second text data corresponding to the first text data; The second text data is output by calling the second interface, wherein the second interface includes a second parameter, and the parameter value of the second parameter includes the second text data.

12. An electronic device, characterized in that, include: Memory, which stores executable programs; A processor for running the program, wherein the program, when running, performs the method according to any one of claims 1 to 11.

13. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a stored executable program, wherein, when the executable program is executed, it controls the device on which the computer-readable storage medium is located to perform the method according to any one of claims 1 to 11.

14. A computer program product, characterized in that, It includes a computer program that, when executed by a processor, implements the method described in any one of claims 1 to 11.