Operational optimization method, device, medium and program product based on large language model
By using solution assisted data in operation optimization to assist large language model calculations, the problem of insufficient solution efficiency and accuracy of large language models in operation optimization in the prior art is solved, and more efficient and accurate operation optimization calculations are achieved.
Patent Information
- Application Number
- CN202410272160.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-11
- Publication Date
- 2024-11-29
- Estimated Expiration
- 2044-03-11
AI Technical Summary
In the field of operation optimization, it is difficult for the existing technology to effectively improve the solution efficiency and calculation accuracy of large language models in operation optimization, especially in the process of fine adjustment, which requires a large amount of data and computing resources, and there are many types of large language models and it is difficult to update synchronously. .
Ensure the accuracy of the calculation process by assisting large language models by using solution assisted data such as modeling snippets and code snippets, thereby improving the accuracy of planning results. The specific steps include matching the problem to be solved by the user input to obtain the corresponding solution auxiliary data, inputting the data into the large language model to generate the solution code, and inputting the code to the solver to obtain the planning result.
By using solution auxiliary data in the modeling and code generation stages, the calculation accuracy and efficiency of large language models are significantly improved, ensuring high-quality solutions to operational optimization problems.
Smart Images

Figure CN118132708B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of operations research and optimization, and specifically to an operations research and optimization method, device, medium and program product based on a large language model. Background Art
[0002] Operational optimization is a professional field involving mathematical skills, reasoning ability and domain knowledge. In related technologies, in order to ensure the application effect of large language models in the field of operational optimization, data related to operational optimization is usually used to fine-tune the large language models. However, in the process of fine-tuning, a large amount of operational optimization training data and sufficient computing resources are required. In addition, there are many types of large language models, and it is impossible to conveniently keep the large language models updated synchronously. At the same time, the fine-tuning effect cannot be guaranteed. Therefore, the efficiency of the solution and the accuracy of the calculation cannot be guaranteed.
[0003] Therefore, how to ensure the efficiency and accuracy of operations research optimization becomes a problem that needs to be solved. Summary of the invention
[0004] The embodiments of the present application provide an operations research optimization method, device, medium and program product based on a large language model. Through some embodiments of the present application, the calculation process of the large language model can be assisted at least by solving auxiliary data, thereby ensuring the accuracy of the calculation process and improving the accuracy of the planning results.
[0005] In a first aspect, the present application provides an operations research optimization method based on a large language model, the method comprising: matching auxiliary solution data based on a problem to be solved input by a current user, wherein the auxiliary solution data is used to assist mathematical modeling and generate solution code; inputting the auxiliary solution data into a large language model, using the auxiliary solution data to assist the large language model in performing calculations to obtain the solution code; inputting the solution code into a solver to obtain a planning result corresponding to the problem to be solved.
[0006] Therefore, unlike the technical solution in the related art in which the large language model is fine-tuned before solving the problem, the embodiment of the present application inputs the auxiliary data for solving the problem corresponding to the problem to be solved into the large language model as auxiliary data for the calculation process, which can ensure the accuracy of the solution code generated by the large language model, thereby ensuring the accuracy of the obtained planning results.
[0007] In combination with the first aspect, in one embodiment of the present application, the solution auxiliary data includes a modeling fragment and a code fragment; the matching of the solution auxiliary data based on the problem to be solved input by the current user includes: matching the problem to be solved to obtain at least one modeling fragment; inputting the at least one modeling fragment and the problem to be solved into a large language model for calculation to obtain a mathematical model; matching the mathematical model to obtain the code fragment; the inputting of the solution auxiliary data into the large language model, using the solution auxiliary data to assist the large language model in calculating, and obtaining the solution code, includes: inputting the mathematical model and the code fragment into the large language model, using the code fragment to assist the large language model in calculating the mathematical model, and obtaining the solution code.
[0008] Therefore, the embodiment of the present application can assist the calculation process of the large language model by inputting modeling snippets in the modeling stage and inputting code snippets in the solution code generation stage, thereby effectively improving the modeling accuracy and code generation accuracy.
[0009] In combination with the first aspect, in one embodiment of the present application, before matching the auxiliary data for solving the problem to be solved based on the current user input, the method also includes: establishing a modeling pattern library and a code pattern library, wherein the modeling pattern library is used to match modeling fragments for the problem to be solved, and the code pattern library is used to match code fragments for mathematical models.
[0010] Therefore, the embodiment of the present application establishes a modeling pattern library and a code pattern library in advance, which can be directly obtained during the solution process, thereby ensuring the solution efficiency.
[0011] In combination with the first aspect, in one embodiment of the present application, matching the problem to be solved to obtain the at least one modeling fragment includes: calculating the problem feature vector of the problem to be solved; calculating the similarity value between the problem feature vector and the feature vectors of each candidate modeling fragment, wherein the feature vector of each candidate modeling fragment is represented by the feature vector of the corresponding constraint description, and the modeling pattern library includes multiple candidate modeling fragments; selecting the at least one modeling fragment from the multiple candidate modeling fragments based on the similarity value.
[0012] Therefore, the embodiment of the present application can ensure that the modeling fragment input into the large language model is the modeling fragment that matches the current problem to be solved by searching for at least one modeling fragment that matches the problem to be solved, thereby being able to correct the large language model in a more targeted manner and improve calculation accuracy.
[0013] In combination with the first aspect, in one embodiment of the present application, after inputting the at least one modeling fragment and the problem to be solved into a large language model for calculation to obtain a mathematical model, the method also includes: confirming the part to be adjusted in the mathematical model, and determining a model modification instruction for the part to be adjusted; inputting the mathematical model, the part to be adjusted, and the model modification instruction into a large language model for calculation to obtain a target mathematical model; matching the mathematical model to obtain the code fragment includes: matching the target mathematical model to obtain the code fragment.
[0014] Therefore, the embodiment of the present application can further ensure the accuracy of mathematical modeling by adjusting the mathematical model.
[0015] In combination with the first aspect, in one embodiment of the present application, before inputting the at least one modeling fragment and the problem to be solved into the large language model for calculation to obtain the mathematical model, the method also includes: inputting the problem to be solved into the large language model to obtain a preliminary mathematical model; inputting the at least one modeling fragment and the problem to be solved into the large language model for calculation to obtain the mathematical model includes: inputting the at least one modeling fragment, the problem to be solved and the preliminary mathematical model into the large language model for calculation to obtain the mathematical model.
[0016] Therefore, the embodiment of the present application can also ensure the accuracy of modeling by inputting expert knowledge into the large language model in stages.
[0017] In combination with the first aspect, in one embodiment of the present application, before matching the auxiliary data for solving the problem to be solved based on the current user input, the method also includes: updating the parameter part of the solution code to obtain the code after the updated parameters; inputting the code after the updated parameters into the solver to obtain a test result; and looping the above steps until the test result meets the preset conditions to obtain a large language model.
[0018] Therefore, the embodiments of the present application can improve the accuracy of calculation of large language models in the direction of operations optimization.
[0019] In a second aspect, the present application provides an operations optimization device based on a large language model, the device comprising:
[0020] A matching module, configured to match auxiliary solution data based on the problem to be solved currently input by the user, wherein the auxiliary solution data is used to assist mathematical modeling and generate solution codes;
[0021] A calculation module is configured to input the auxiliary solution data into a large language model, assist the large language model in performing calculations with the auxiliary solution data, and obtain the solution code;
[0022] The solution module is configured to input the solution code into the solver to obtain the planning result corresponding to the problem to be solved.
[0023] In combination with the second aspect, in one embodiment of the present application, the solution-assisting data includes a modeling fragment and a code fragment; the matching module is further configured to: match the problem to be solved to obtain at least one modeling fragment; input the at least one modeling fragment and the problem to be solved into a large language model for calculation to obtain a mathematical model; match the mathematical model to obtain the code fragment; the calculation module is further configured to: input the mathematical model and the code fragment into a large language model, and use the code fragment to assist the large language model in calculating the mathematical model to obtain the solution code.
[0024] In combination with the second aspect, in one embodiment of the present application, the matching module is further configured to: establish a modeling pattern library and a code pattern library, wherein the modeling pattern library is used to match modeling fragments for the problem to be solved, and the code pattern library is used to match code fragments for the mathematical model.
[0025] In combination with the second aspect, in one embodiment of the present application, the matching module is further configured to: calculate the problem feature vector of the problem to be solved; calculate the similarity value between the problem feature vector and the feature vector of each candidate modeling fragment, wherein the feature vector of each candidate modeling fragment is represented by the feature vector of the corresponding constraint description, and the modeling pattern library includes multiple candidate modeling fragments; select the at least one modeling fragment from the multiple candidate modeling fragments based on the similarity value.
[0026] In combination with the second aspect, in one embodiment of the present application, the matching module is further configured to: confirm the part to be adjusted in the mathematical model, and determine the model modification instruction for the part to be adjusted; input the mathematical model, the part to be adjusted and the model modification instruction into the large language model for calculation to obtain the target mathematical model; the matching module is further configured to: match the target mathematical model to obtain the code snippet.
[0027] In combination with the second aspect, in one embodiment of the present application, the matching module is further configured to: input the problem to be solved into a large language model to obtain a preliminary mathematical model; the calculation module is further configured to: input the at least one modeling fragment, the problem to be solved and the preliminary mathematical model into the large language model for calculation to obtain the mathematical model.
[0028] In combination with the second aspect, in one embodiment of the present application, the matching module is further configured to: update the parameter part of the solution code to obtain the code after the updated parameters; input the code after the updated parameters into the solver to obtain a test result; and loop through the above steps until the test result meets the preset conditions to obtain a large language model.
[0029] In a third aspect, the present application provides an electronic device comprising: a processor, a memory and a bus; the processor is connected to the memory via the bus, the memory stores a computer program, and when the computer program is executed by the processor, it can implement the method described in any embodiment of the first aspect.
[0030] In a fourth aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, which, when executed, can implement the method described in any embodiment of the first aspect.
[0031] In a fifth aspect, the present application provides a computer program product, which, when executed, can implement the method described in any embodiment of the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] Figure 1 This is a schematic diagram of an operations optimization scenario based on a large language model shown in this application;
[0033] Figure 2 This is one of the flow charts of the operations optimization method based on the large language model shown in this application;
[0034] Figure 3 This is the second flow chart of the operations optimization method based on the large language model shown in this application;
[0035] Figure 4 A display interface shown for this application;
[0036] Figure 5 This is the third flow chart of the operations optimization method based on a large language model shown in this application;
[0037] Figure 6 Another display interface shown in this application;
[0038] Figure 7 This is a schematic diagram of the composition of the operations optimization device based on the large language model shown in this application;
[0039] Figure 8 This is a schematic diagram of the composition of an electronic device shown in this application. DETAILED DESCRIPTION
[0040] In order to make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the technical scheme in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all the embodiments. The components of the embodiments of the present application generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the application claimed for protection, but merely represents the selected embodiments of the present application. Based on the embodiments of the present application, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present application.
[0041] In the related art, using operations research and optimization to solve practical problems includes two main steps: mathematical modeling and calling the solver, where calling the solver usually converts the mathematical model into a model file in a standard format, or into a solution code for calling the solver. In order to use a large language model to complete mathematical modeling and call the solver to obtain a solution to the problem, the related art completely relies on the capabilities of the large language model itself. However, since operations research and optimization place high demands on the model in terms of mathematics, reasoning, and domain knowledge, the direct use of a large language model is usually not competent. Another solution is to use a large amount of training data in the field of operations research and optimization to fine-tune the large language model to enhance the capabilities of operations research and optimization.
[0042] However, the fine-tuning process requires a large amount of operational optimization training data and sufficient computing resources and time. In addition, there are many types of large language models, and it is not easy to keep the large language models updated synchronously. At the same time, the fine-tuning effect cannot be guaranteed, and thus the solution efficiency and calculation accuracy cannot be guaranteed.
[0043] Therefore, in order to solve the above problems, the present application provides an operations research optimization method based on solving auxiliary data (ie, expert pattern library) and a large language model.
[0044] The embodiments of the present application can be applied to a scenario in which a problem to be solved input by a user is solved to obtain a planning result.
[0045] The method steps in the embodiments of the present application are described in detail below with reference to the accompanying drawings.
[0046] Figure 1 An operations optimization scenario based on a large language model in some embodiments of the present application is provided, and the scenario includes: a client 110 and a server 120. Specifically, a user inputs a problem to be solved in an input interface of the client 110, and then the client 110 sends the problem to be solved to the server 120. After receiving the problem to be solved, the server 120 solves the problem to be solved and obtains a planning result.
[0047] The following uses a server as an example to illustrate an operations optimization method based on a large language model provided by some embodiments of the present application. It can be understood that the execution subject of the present application can be any device that can execute the operations optimization method based on a large language model. The above-mentioned server is only an example, and the execution subject of the present application is not limited thereto.
[0048] At least to solve the problems in the background technology, such as Figure 2 As shown, some embodiments of the present application provide an operations research optimization method based on a large language model, the method comprising:
[0049] S210, matching the auxiliary data for solving the problem to be solved based on the current user input. S220, inputting the auxiliary data for solving the problem into the large language model, using the auxiliary data for solving the problem to assist the large language model in calculation, and obtaining a calling solving code. S230, inputting the solving code into the solver, and obtaining a planning result corresponding to the problem to be solved.
[0050] It should be noted that the auxiliary data for solution is used to assist mathematical modeling and generate solution codes. The auxiliary data for solution includes modeling fragments and code fragments. The modeling fragments are used in the process of establishing mathematical models, and the code fragments are used in the process of generating solution codes.
[0051] That is to say, Figure 3 As shown, first, the user describes the problem in natural language. The user describes the problem that needs to be solved by operations optimization. According to the user's problem description, a matching algorithm (for example, the matching algorithm includes: similarity matching, keyword matching, vector database, etc.) is used to extract relevant modeling fragments from the modeling pattern library of the expert pattern library, and the large language model is called. The matched modeling fragments and the user's problem description are input into the large language model to generate a mathematical model, wherein the data model can also be further adjusted and updated according to the large language model. Then, a matching algorithm (for example, similarity matching, keyword matching, etc.) is used to search for code fragments matching the mathematical model in the code pattern library, and the large language model is called. The code fragments and the mathematical model are input into the large language model for calculation, and a solution code is generated, wherein the solution code is used to call the solver (for example, the Python code that calls SCIP). Finally, the solution code is run, and the corresponding operations optimization solver (for example, SCIP, Gurobi, etc.) is called to obtain the planning result of the problem.
[0052] It should be noted that before solving the problem, this application also tests it through a large language model to determine whether the modeling is accurate.
[0053] The following will describe in detail the solution process of an operations research optimization method based on a large language model provided by this application in steps.
[0054] S1, establishing a modeling pattern library and a code pattern library, wherein the modeling pattern library is used to match modeling fragments for the problem to be solved, and the code pattern library is used to match code fragments for the mathematical model.
[0055] It can be understood that the present application uses a modeling pattern library and a code pattern library to enhance the operational optimization solving capability of a large language model.
[0056] Specifically for the modeling pattern library, the modeling pattern library includes skills and knowledge related to modeling, and the stored content includes modeling prompts, modeling fragment key-value pairs, etc.
[0057] For example, a modeling hint might be "Unless otherwise specified, assume that each employee can perform multiple tasks in series."
[0058] For example, the modeling fragment key-value pair can be "{each employee performs at most one task, forall(einEmployees)sum(j in Tasks)(sum(x[e][j]))<=1}". Among them, "each employee performs at most one task" is a constraint description, and forall(e in Employees)sum(j in Tasks)x[e][j]<=1} is the mathematical expression after modeling, Employees represents the set of all employees, Tasks represents the set of all tasks, x[e][j] is a 0-1 decision variable, 1 means that employee e performs task j, and the formula means that for each employee, the number of tasks performed does not exceed 1.
[0059] That is to say, before using the large language model for modeling, find the modeling fragments that match the problem description from the modeling pattern library, and then input the modeling fragments and the problem description into the large language model together to obtain a more accurate mathematical model.
[0060] Specifically, with respect to the code pattern library, the code pattern library mainly includes skills and knowledge related to converting mathematical models into codes, and the stored content includes: model solution code prompts, solution code key-value pairs, and the like.
[0061] Before using the large language model to generate solution codes, code snippets that match the mathematical model are found from the code pattern library, and then the code snippets and the mathematical model are input into the large language model together to obtain more accurate solution codes.
[0062] It is understandable that a large language model can also be used to automatically generate a relevant expert pattern library, but the planning results obtained using this solution depend on the quality of the expert pattern library generated by the large language model.
[0063] S2, matching the problem to be solved to obtain at least one modeling fragment.
[0064] First, obtain the pending issues entered by the user in the client.
[0065] Specifically, the user enters a problem description in the client's display interface, for example, "Assign 3 jobs to 4 workers and 5 machines. Each job must be assigned to a worker and a machine. Each worker and machine can only be used for at most one job. The cost of the job depends on the assigned workers and machines. The goal is to minimize the cost." "cost[i][m][j] represents the cost required for worker i to complete job j on machine m. ” .
[0066] Then, the problem feature vector of the problem to be solved is calculated.
[0067] Specifically, the text embedding method can be used as a matching algorithm to match modeling fragments similar to the above problem description from the expert model library. Specifically, for all modeling fragment key-value pairs in the expert modeling library, a text embedding model, such as the open source model sbert-base-chinese-nli in HuggingFace, is used to calculate the feature vector of the constraint description (i.e., the key in the key-value pair) in each modeling fragment.
[0068] For each sentence in the problem description input by the user, the above text embedding model is used to calculate, so as to vectorize the features of the problem to be solved and obtain the problem feature vector.
[0069] It is understandable that the feature vector of the constraint description in each modeling segment can be stored in advance, and when the problem to be solved is obtained, the problem feature vector is calculated and then matched directly.
[0070] Next, the similarity value between the problem feature vector and the feature vector of each candidate modeling segment is calculated, wherein the feature vector of each candidate modeling segment is represented by the feature vector of the corresponding constraint description, and the modeling pattern library includes multiple candidate modeling segments.
[0071] Specifically, the feature vector of the constraint description can be matched with the feature vector of the question. For each feature vector of the constraint description, the cosine similarity between it and each sentence in the user's question description is calculated, and the maximum cosine value is selected as the similarity of the corresponding modeling segment. The cosine similarity formula is:
[0072]
[0073] Among them, A represents the eigenvector of any constraint description, and B represents the problem eigenvector.
[0074] Finally, at least one modeling segment is selected from the plurality of candidate modeling segments based on the similarity value.
[0075] Specifically, k pieces with the highest similarity are selected from the expert pattern library as the modeling fragments used in this mathematical modeling, where k is a preset parameter value (for example, k is set to 2).
[0076] S3, inputting the problem to be solved into the large language model to obtain a preliminary mathematical model. S4, inputting at least one modeling segment, the problem to be solved and the preliminary mathematical model into the large language model for calculation to obtain a mathematical model.
[0077] In one embodiment of the present application, expert knowledge can be input into the large language model in stages. That is, the problem to be solved can be first input into the large language model for calculation to obtain a preliminary mathematical model, and then the preliminary data model can be corrected using expert knowledge to obtain a mathematical model.
[0078] In another embodiment of the present application, at least one modeling fragment and a problem to be solved are input into a large language model for direct calculation to obtain a mathematical model.
[0079] S5, confirming the part to be adjusted in the mathematical model, and determining the model modification instruction for the part to be adjusted.
[0080] That is to say, after the mathematical model is obtained, it can be further adjusted and updated through the large language model as needed.
[0081] Specifically, at least one modeling fragment of a large language model and the problem to be solved are input, such as Figure 4 As shown, after the large language model is calculated, the returned mathematical model includes variables, objectives and at least one constraint, wherein the variables can represent the allocation of workers and machines to jobs, the objectives can represent minimizing the total cost, and at least one constraint can represent that each job must be allocated to some workers and machines, each worker can only be used for at most one job, and each machine can only be used for at most one job.
[0082] Select the part of the model that needs to be changed, which can be the overall mathematical model, or the goal, constraint, etc. For example, when the mathematical model is selected, determine the instruction for modifying the mathematical model, such as "add a constraint, requiring it to be E", "modify the constraint to F", "add a piece of data, G", where "E, F and G" are determined according to the model modification requirements. For example, the requirement is "add a constraint, requiring each machine to be used for at most one job".
[0083] S6, inputting the mathematical model, the part to be adjusted and the model modification instruction into the large language model for calculation to obtain the target mathematical model.
[0084] That is to say, after determining the content of the adjustment, the original mathematical model, the selected part to be adjusted and the model modification instructions are combined and input into the large language model, and then the calculation is continued to obtain the target mathematical model.
[0085] That is to say, Figure 5 As shown, in one implementation of obtaining the target mathematical model, the user problem description is input into the large language model to generate a preliminary mathematical model, and then the preliminary mathematical model and the modeling fragment are input into the large language model to generate a mathematical model, and then the mathematical model, the part to be adjusted and the model modification instruction are input into the large language model to generate the target mathematical model.
[0086] S7, matching the target mathematical model to obtain the code fragment.
[0087] Specifically, expert code snippets related to the target mathematical model are extracted from the expert code pattern library. For all code snippet key-value pairs in the expert code library, the feature vector of the constraint expression (i.e., the key in the key-value pair) of each code snippet is calculated using the text embedding model. The feature vector of each constraint expression in the target mathematical model is calculated using the text embedding model. For each constraint expression in the target mathematical model, the cosine similarity is used to find the code snippet with the highest similarity to the constraint expression.
[0088] S8, inputting the target mathematical model and the code snippet into the large language model, using the code snippet to assist the large language model in calculating the target mathematical model, and obtaining a solution code.
[0089] S9, inputting the solution code into the solver to obtain the planning result corresponding to the problem to be solved.
[0090] That is, after obtaining a code snippet such as Figure 6 As shown, the target mathematical model (e.g., AAA) and at least one code snippet (e.g., code snippet 1 and code snippet 2) are input into the large language model to generate a solution code for calling the solver. For example, the large language model returns Python code that uses SCIP to solve the mathematical model. The solution code is then input into the solver to obtain the corresponding planning result. That is, the solver code is run, and the corresponding operations research optimization solver (e.g., SCIP, Gurobi, etc.) is called to obtain the planning result of the problem.
[0091] For example, the planning result returned by the solver may be: the minimum cost is 6.0, where worker W1 is assigned to machine M5 to perform job J3, worker W2 is assigned to machine M2 to perform job J1, and worker W4 is assigned to machine M3 to perform job J2.
[0092] Therefore, fine-tuning a large language model requires a large amount of operational optimization training data, as well as sufficient computing resources and time. Using an expert pattern library can directly use the existing large language model, use professional knowledge outside the large language model, and do not require specific fine-tuning operations for the large language model. Fine-tuning a large language model requires careful selection of fine-tuning parameters and data types based on the characteristics of the large model, and it is usually not easy to achieve accurate results. Using an expert pattern library and using matching algorithms to find relevant modeling patterns and code patterns can effectively improve modeling accuracy and code generation accuracy. When a new model needs to be replaced, the method of fine-tuning the large model needs to be re-fine-tuned for the new model, while the expert pattern library can directly replace the new model.
[0093] The following will describe in detail the testing process of an operations research optimization method based on a large language model provided by this application in steps.
[0094] In one embodiment of the present application, the testing process includes: first, updating the parameter part of the solution code to obtain the code after the updated parameters, and then inputting the code after the updated parameters into the solver to obtain the test results.
[0095] That is to say, before executing the above-mentioned operations research optimization method based on the large language model, it is necessary to test whether the large language model meets the requirements. The solution code generated in S8 includes a model part and a parameter part, wherein the parameter part represents specific data outside the abstract mathematical model, for example, the number of jobs, workers, and machines, and the cost of workers completing different jobs on different machines. In order to verify the correctness of the model, different parameters are generated using the large language model to obtain new parameter data. Afterwards, run the solution code after updating the parameters, call the corresponding operations research optimization solver, and check whether the generated results are accurate. If not, continue to optimize the parameters. If the generated results are accurate, it is determined that the current large language model meets the requirements and can be used to execute the operations research optimization method based on the large language model.
[0096] Therefore, this application uses the expert pattern library to improve the modeling ability of operations research optimization. Use the expert pattern library to improve the model solving code generation ability of operations research optimization. Use the large language model to update the mathematical model through natural language interaction. Use the large language model to generate test data to improve the efficiency of model correctness testing.
[0097] The above describes an implementation of an operations research optimization method based on a large language model. The following describes an operations research optimization device based on a large language model.
[0098] like Figure 7 As shown, some embodiments of the present application provide an operations optimization device 700 based on a large language model, and the device includes: a matching module 710, a calculation module 720 and a solution module 730.
[0099] A matching module 710 is configured to match auxiliary solution data based on the problem to be solved currently input by the user, wherein the auxiliary solution data is used to assist mathematical modeling and generate solution codes;
[0100] A calculation module 720 is configured to input the auxiliary solution data into a large language model, assist the large language model in performing calculations with the auxiliary solution data, and obtain the solution code;
[0101] The solution module 730 is configured to input the solution code into a solver to obtain a planning result corresponding to the problem to be solved.
[0102] In one embodiment of the present application, the solution auxiliary data includes a modeling fragment and a code fragment; the matching module is further configured to: match the problem to be solved to obtain at least one modeling fragment; input the at least one modeling fragment and the problem to be solved into a large language model for calculation to obtain a mathematical model; match the mathematical model to obtain the code fragment; the calculation module is further configured to: input the mathematical model and the code fragment into the large language model, and use the code fragment to assist the large language model in calculating the mathematical model to obtain the solution code.
[0103] In one embodiment of the present application, the matching module is further configured to: establish a modeling pattern library and a code pattern library, wherein the modeling pattern library is used to match modeling fragments for the problem to be solved, and the code pattern library is used to match code fragments for the mathematical model.
[0104] In one embodiment of the present application, the matching module is further configured to: calculate the problem feature vector of the problem to be solved; calculate the similarity value between the problem feature vector and the feature vector of each candidate modeling fragment, wherein the feature vector of each candidate modeling fragment is represented by the feature vector of the corresponding constraint description, and the modeling pattern library includes multiple candidate modeling fragments; select the at least one modeling fragment from the multiple candidate modeling fragments based on the similarity value.
[0105] In one embodiment of the present application, the matching module is further configured to: confirm the part to be adjusted in the mathematical model, and determine the model modification instruction for the part to be adjusted; input the mathematical model, the part to be adjusted and the model modification instruction into the large language model for calculation to obtain the target mathematical model; the matching module is further configured to: match the target mathematical model to obtain the code fragment.
[0106] In one embodiment of the present application, the matching module is further configured to: input the problem to be solved into a large language model to obtain a preliminary mathematical model; the calculation module is further configured to: input the at least one modeling fragment, the problem to be solved and the preliminary mathematical model into the large language model for calculation to obtain the mathematical model.
[0107] In one embodiment of the present application, the matching module is further configured to: update the parameter part of the solution code to obtain the code after the updated parameters; input the code after the updated parameters into the solver to obtain the test result; and execute the above steps in a loop until the test result meets the preset conditions to obtain the large language model.
[0108] In the embodiments of the present application, Figure 7 The modules shown can achieve Figures 1 to 6 Each process in the method embodiment. Figure 7 The operations and / or functions of each module in Figures 1 to 6 For details, please refer to the description in the above method embodiment. To avoid repetition, detailed description is appropriately omitted here.
[0109] like Figure 8 As shown, an embodiment of the present application provides an electronic device 800, including: a processor 810, a memory 820 and a bus 830, wherein the processor is connected to the memory via the bus, and the memory stores computer-readable instructions. When the computer-readable instructions are executed by the processor, they are used to implement a method as described in any one of the above embodiments. For details, please refer to the description in the above method embodiments. To avoid repetition, the detailed description is appropriately omitted here.
[0110] Among them, the bus is used to realize the direct connection and communication of these components. Among them, the processor in the embodiment of the present application can be an integrated circuit chip with signal processing capabilities. The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The disclosed methods, steps and logic block diagrams in the embodiments of the present application can be implemented or executed. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc.
[0111] The memory may be, but is not limited to, a random access memory (RAM), a read only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable read-only memory (EEPROM), etc. The memory stores computer-readable instructions, and when the computer-readable instructions are executed by the processor, the method described in the above embodiment may be executed.
[0112] Understandably, Figure 8 The structure shown is for illustration only and may also include Figure 8 More or fewer components as shown, or with Figure 8 Different configurations are shown. Figure 8 Each component shown in the figure can be implemented by hardware, software or a combination thereof.
[0113] An embodiment of the present application also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a server, any method described in any of the above-mentioned embodiments is implemented. For details, please refer to the description in the above-mentioned method embodiments. To avoid repetition, the detailed description is appropriately omitted here.
[0114] The above description is only a preferred embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the protection scope of the present application. It should be noted that similar numbers and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in the subsequent drawings.
[0115] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. An operations research optimization method based on a large language model, characterized in that: The method comprises: Matching solution auxiliary data based on the problem to be solved currently input by the user, wherein the solution auxiliary data is used to assist mathematical modeling and generate solution code; Inputting the auxiliary solution data into a large language model, using the auxiliary solution data to assist the large language model in performing calculations, and obtaining the solution code; Inputting the solution code into the solver to obtain a planning result corresponding to the problem to be solved; The solution auxiliary data includes a modeling fragment and a code fragment; The matching of the auxiliary data for solving the problem to be solved based on the current user input includes: Matching the problem to be solved to obtain at least one modeling fragment; Inputting the problem to be solved into the large language model to obtain a preliminary mathematical model, inputting the at least one modeling fragment, the problem to be solved and the preliminary mathematical model into the large language model for calculation to obtain a mathematical model, wherein the mathematical model includes variables, an objective and at least one constraint; Matching the mathematical model to obtain the code snippet; The step of inputting the auxiliary solution data into a large language model, using the auxiliary solution data to assist the large language model in performing calculations, and obtaining the solution code comprises: The mathematical model and the code snippet are input into a large language model, and the code snippet is used to assist the large language model in performing calculations on the mathematical model to obtain the solution code.
2. The method according to claim 1, characterized in that Before matching the auxiliary data for solving the problem to be solved based on the current user input, the method further includes: A modeling pattern library and a code pattern library are established, wherein the modeling pattern library is used to match modeling fragments for problems to be solved, and the code pattern library is used to match code fragments for mathematical models.
3. The method according to claim 2, characterized in that The matching the problem to be solved to obtain the at least one modeling fragment includes: Calculate the problem feature vector of the problem to be solved; Calculating a similarity value between the problem feature vector and a feature vector of each candidate modeling segment, wherein the feature vector of each candidate modeling segment is characterized by a feature vector of a corresponding constraint description, and the modeling pattern library includes a plurality of candidate modeling segments; The at least one modeling segment is selected from the plurality of candidate modeling segments based on the similarity value.
4. The method according to claim 2 or 3, characterized in that: In the step of inputting the problem to be solved into the large language model to obtain a preliminary mathematical model, inputting the at least one modeling segment, the problem to be solved and the preliminary mathematical model into the large language model for calculation to obtain the mathematical model, the method further comprises: Confirming a portion of the mathematical model to be adjusted, and determining a model modification instruction for the portion to be adjusted; Inputting the mathematical model, the part to be adjusted and the model modification instruction into a large language model for calculation to obtain a target mathematical model; The step of matching the mathematical model to obtain the code snippet includes: The target mathematical model is matched to obtain the code fragment.
5. The method according to claim 2 or 3, characterized in that: Before matching the auxiliary data for solving the problem to be solved based on the current user input, the method further includes: The following steps are executed repeatedly until the test results meet the preset conditions and a large language model is obtained: Update the parameter part of the solution code to obtain the code after the updated parameters; The code after updating the parameters is input into the solver to obtain the test result.
6. An operations optimization device based on a large language model, characterized in that: The device comprises: A matching module, configured to match auxiliary solution data based on the problem to be solved currently input by the user, wherein the auxiliary solution data is used to assist mathematical modeling and generate solution codes; A calculation module is configured to input the auxiliary solution data into a large language model, assist the large language model in performing calculations with the auxiliary solution data, and obtain the solution code; A solution module is configured to input the solution code into a solver to obtain a planning result corresponding to the problem to be solved; The solution auxiliary data includes a modeling fragment and a code fragment; The matching module is specifically used for: Matching the problem to be solved to obtain at least one modeling fragment; Inputting the problem to be solved into the large language model to obtain a preliminary mathematical model, inputting the at least one modeling fragment, the problem to be solved and the preliminary mathematical model into the large language model for calculation to obtain a mathematical model, wherein the mathematical model includes variables, an objective and at least one constraint; Matching the mathematical model to obtain the code snippet; The calculation module is specifically used for: The mathematical model and the code snippet are input into a large language model, and the code snippet is used to assist the large language model in performing calculations on the mathematical model to obtain the solution code.
7. An electronic device, characterized in that: include: processor, memory, and bus; The processor is connected to the memory via the bus, the memory stores a computer program, and the computer program, when executed by the processor, can implement the method as claimed in any one of claims 1 to 5.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, which, when executed, can implement the method as claimed in any one of claims 1 to 5.
9. A computer program product, characterized in that When the computer program product is executed, the method according to any one of claims 1 to 5 can be implemented.
Citation Information
Patent Citations
Task execution method and task execution optimization method
CN116579339A
Large language model-based operation planning optimization method and system, electronic equipment and storage medium
CN117273005A
