Text reasoning method and device for insurance service, equipment and medium
By performing string coding and prefix trees in the options of demand issues in insurance services, combined with the option constraint function, the problem of uncertain output of the Chinese text model output of traditional methods is solved, and the accuracy of text reasoning is improved.
Patent Information
- Application Number
- CN202411673810.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-20
- Publication Date
- 2025-01-21
AI Technical Summary
The traditional zero-sample classification method may not respond strictly to the options provided without mandatory constraints, resulting in the output generated by the model not meeting expectations and reducing the accuracy of text reasoning.
By string encoding all options corresponding to the requirement question, a prefix tree is constructed, and the option constraint function is used to limit the output of the text model to ensure that the generated results are within the provided options.
The result of effective control of text models improves the accuracy of model reasoning classification, and ensures that the output meets the expected options.
Smart Images

Figure CN119338008A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of insurance services, and in particular to a text reasoning method, device, equipment and medium for insurance services. Background Art
[0002] In the field of Natural Language Processing (NLP), with the rapid development of text models, the application of option classification based on text content has become more and more widespread. For example, the insurance service platform will collect insurance needs raised by customers or insurance brokers, and use the text big model to analyze the insurance needs and insurance products, so as to recommend corresponding insurance products to customers or insurance brokers.
[0003] Among them, the zero-shot classification task of the text model allows the model to directly classify the text without any specific category training. However, traditional zero-shot classification methods usually rely on providing a set of candidate options in the prompt and expecting the model to select one of the options as the model's inference classification result.
[0004] However, this method has certain uncertainties. In the absence of mandatory constraints, the model may not respond strictly according to the provided options, causing the model to generate outputs that do not meet expectations, thereby reducing the accuracy of text reasoning.
[0005] Therefore, how to control the results generated by the text model within the provided options and improve the accuracy of model reasoning and classification has become an urgent problem to be solved. Summary of the invention
[0006] The present invention provides a method and device for generating option constraints of a large text model based on a prefix tree, so as to solve the technical problem of how to control the result of text model generation to be within the provided options and improve the accuracy of model reasoning and classification.
[0007] In a first aspect, a text reasoning method for insurance services is provided, comprising: Obtain all options extracted from the insurance service product library for the demand problem, perform string encoding on all options respectively, and obtain a string group corresponding to each option; Obtain an initialized root node, match corresponding strings as child nodes for the root node according to all string groups, form a prefix tree for all options, and determine the number of model reasoning steps based on the prefix tree; Obtaining an option constraint function in the text model, and for any node in the prefix tree, reading a child node corresponding to the node according to the option constraint function; Based on the text model and the selection constraint function, infer a target child node from the child nodes under the root node, and increase the number of steps by 1; Taking the target child node as the root node, returning to execute inference of a target child node from the child nodes under the root node until the number of steps reaches the number of model inference steps, and obtaining the target child node corresponding to the number of model inference steps; According to the character strings corresponding to all the target sub-nodes, the target options output by the text model for the requirement question are determined.
[0008] In a second aspect, a text reasoning device for insurance services is provided, comprising: The option encoding module is used to obtain all options set for the demand problem extracted from the insurance service product library, and perform string encoding on all options respectively to obtain a string group corresponding to each option; A prefix tree construction module is used to obtain an initialized root node, match corresponding strings as child nodes for the root node according to all string groups, form a prefix tree for all options, and determine the number of model reasoning steps based on the prefix tree; An option constraint module is used to obtain an option constraint function in a text model, and for any node in the prefix tree, read a child node corresponding to the node according to the option constraint function; A model inference module is used to infer a target subnode from the subnodes under the root node based on the text model and the selection constraint function, and increase the number of steps by 1; take the target subnode as the root node, return to execute inference of a target subnode from the subnodes under the root node until the number of steps reaches the model inference step number, and obtain the target subnode corresponding to the number of model inference steps; The option determination module is used to determine the target option output by the text model for the requirement question based on the character strings corresponding to all the target sub-nodes.
[0009] In a third aspect, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above-mentioned text reasoning method for insurance services when executing the computer program.
[0010] In a fourth aspect, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the above-mentioned text reasoning method for insurance services are implemented.
[0011] In the scheme implemented by the above-mentioned text reasoning method, device, equipment and medium for insurance services, all options corresponding to the demand question can be string encoded, and a prefix tree corresponding to the option can be constructed according to the string group corresponding to the option; according to the structure of the prefix tree, the target node is determined from the prefix tree, and the model reasoning steps of the text model are further determined according to the target node, which can reduce the model reasoning steps as much as possible and improve the reasoning and classification efficiency of the text model; when performing reasoning, the output of the text model is limited to the options corresponding to the prefix tree; when the reasoning steps reach the model reasoning steps, the target options for the demand question are matched and output by obtaining the strings corresponding to the multiple target sub-nodes, thereby controlling the results generated by the text model to be within the provided options, thereby improving the accuracy of text model reasoning. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.
[0013] Figure 1 This is a schematic diagram of an application environment of a text reasoning method for insurance services provided by the first embodiment of the present invention; Figure 2 It is a flowchart of a text reasoning method for insurance services provided by Embodiment 2 of the present invention; Figure 3 It is a flowchart of a text reasoning method for insurance services provided by Embodiment 3 of the present invention; Figure 4 This is a prefix tree diagram of a text reasoning method for insurance services provided by Embodiment 3 of the present invention; Figure 5 It is a flowchart of a text reasoning method for insurance services provided by the fourth embodiment of the present invention; Figure 6 It is a flowchart of a text reasoning method for insurance services provided by Embodiment 5 of the present invention; Figure 7 It is a flowchart of a text reasoning method for insurance services provided by Embodiment 6 of the present invention; Figure 8 is a structural schematic diagram of a text reasoning device for insurance services provided by an embodiment of the present invention; Fig. 9 is a structural schematic diagram of a computer device provided by an embodiment of the present invention; Fig.10It is another structural schematic diagram of a computer device provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0014] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0015] A text reasoning method for insurance services provided in the first embodiment of the present invention can be applied in the following aspects: Figure 1 In the application environment, the client communicates with the server through the network. The client can be operated by the user to extract all options set for the demand problem from the server, and the options are extracted from the insurance service product library by the user operation client. After receiving the options, the server executes the text reasoning method of the present invention. Among them, the client can be but not limited to various personal computers, laptops, smart phones, tablet computers and portable wearable devices. The server can be implemented with an independent server or a server cluster composed of multiple servers.
[0016] In the present invention, a text reasoning method for the insurance service industry is provided. By characterizing all options corresponding to demand questions, a prefix tree corresponding to the options is constructed according to the string group corresponding to the options; according to the structure of the prefix tree, a target node is determined from the prefix tree, and the model reasoning steps of the text model are further determined according to the target node, which can reduce the model reasoning steps as much as possible and improve the reasoning and classification efficiency of the text model; when reasoning, the output of the text model is limited to the options corresponding to the prefix tree; when the reasoning steps reach the model reasoning steps, the target options for the demand questions are matched and output by obtaining the strings corresponding to the multiple target sub-nodes, thereby controlling the results generated by the text model to be within the provided options, thereby improving the accuracy of text model reasoning.
[0017] like Figure 2 As shown, Figure 2 A flowchart of a text reasoning method for insurance services provided in the second embodiment of the present invention is provided. The text reasoning method is applied to the server of the first embodiment above. The text reasoning method may include the following steps: Step S201: Obtain all options extracted from the insurance service product library and set for the demand problem, perform string encoding on all options respectively, and obtain a string group corresponding to each option.
[0018] The text reasoning method for insurance services provided by the present invention can be applied to a server in various application scenarios, and the server can receive insurance demand questions from customers or insurance brokers. For example, in the insurance application field, customers can raise insurance needs by phone or online chat. At this time, it is necessary to use the server to call the text model to answer some insurance questions of customers or insurance brokers, so as to improve the efficiency of insurance promotion and user experience.
[0019] In the field of NLP, text models are an important tool that can be used to implement text classification and reasoning. In one embodiment, based on the insurance demand question of a customer or insurance broker, possible answer options for the demand question are determined from the insurance service product library, all answer options and demand questions are input into the text model as prompts of the text model, and the text model is used to perform text analysis and reasoning on the demand question and options, thereby outputting the optimal answer option for the demand question.
[0020] For example, a customer may ask a question about insurance needs, such as "Which insurance product should I choose to insure my 11-year-old child for an unexpected accident?" After receiving the customer's question, the intelligent answer engine initially extracts multiple corresponding options from the product library based on the question, and then uses the text model to perform text analysis and text reasoning classification, selects the most suitable option from multiple options, and recommends it to the customer. For example, in response to the customer's question, there are the following three products in the product library for selection: 1. Million-dollar home insurance: The coverage is…; 2. Million Youth Student Insurance: The coverage is…; 3. Million-dollar medical insurance: The coverage is...
[0021] The above three product options and demand questions are used as the input prompt of the text model. The text model can perform reasoning and output the answer options for the demand questions.
[0022] In one embodiment, after obtaining the answer options for the requirement question, the options need to be string encoded to obtain a string group corresponding to each option, so that the options can be converted into a format that can be recognized by the text model for text reasoning.
[0023] Optionally, all options are string-encoded separately to obtain a string group corresponding to each option, including: For any option, the option is string-encoded by a preset encoding tool to obtain at least one string corresponding to the option, thereby forming a string group of the option; Traverse all options and get the string group corresponding to each option.
[0024] After obtaining all options for the requirement question, the options need to be encoded. In one embodiment, for the above options, the present invention uses the tokenizer encoding tool of qwen2-7B for encoding. In other embodiments, other encoding tools can be used, which are not limited here.
[0025] After encoding the above options through the tokenizer encoding tool of qwen2-7B, the string corresponding to each option can be obtained, and multiple strings constitute the string group of options.
[0026] Continuing with the above example, after the above three options are encoded using the qwen2-7B tokenizer encoding tool, the string groups obtained for each option are: Million-dollar property insurance: [105574, 45629, 99421, 32463]; Millions of young students insurance: [105574, 104846, 99720, 100404]; Million medical insurance: [105574, 100182, 99567].
[0027] So far, the encoding operation for all options of the requirement question has been completed, and the string groups corresponding to all options have been obtained.
[0028] Step S202: Get the initialized root node, match the corresponding string as a child node for the root node according to all the string groups, form a prefix tree for all options, and determine the number of model reasoning steps based on the prefix tree.
[0029] After obtaining the string group corresponding to each option, you can start building the prefix tree of the option. In one embodiment, when building the prefix tree, you first need to create an empty node as the root node of the prefix tree, which is usually marked with an empty character or a special value (such as null, '', etc.), indicating that there are no characters. Then, based on the encoding results of all options, that is, the string group, the corresponding string is matched for the root node as a child node, and a prefix tree for all options is built, thereby constraining the string group corresponding to the option in the prefix tree, which is convenient for the reasoning of the subsequent text model.
[0030] After constructing the prefix tree, the maximum number of inference steps of the text model, that is, the model inference steps, can be determined based on the prefix tree structure. The prefix tree can be used to determine the target node that distinguishes each prefix tree path from other prefix tree paths in the prefix tree structure. By determining the level at which the target node is located, the model inference steps of the text model can be correspondingly determined, thereby quickly performing text inference and determining output options.
[0031] Step S203: Obtain the option constraint function in the text model, and for any node in the prefix tree, read the child node corresponding to the node according to the option constraint function.
[0032] After building the prefix tree and determining the number of model inference steps, it is necessary to obtain the option constraint function defined in the text model so that, according to the option constraint function, the child nodes that the node is allowed to output can be read at one of the nodes of the prefix tree, thereby limiting the output results of the text model to the nodes of the prefix tree, that is, limited to the provided options, thereby improving the accuracy of the text model output.
[0033] In the Transformers library of the text model, the generate function is a very powerful tool that allows users to generate text using a pre-trained model. The generate function has many parameters, among which prefix_allowed_tokens_fn is an optional function parameter.
[0034] In one embodiment, the present invention defines prefix_allowed_tokens_fn as an option constraint function, so that it can query the prefix tree according to the string currently generated by the text model, find the strings corresponding to all child nodes matching the string, and return these strings as a list of strings allowed to be output.
[0035] Continuing with the above example, when using the text model for reasoning, the text model is first initialized and starts to generate text. The currently generated sequence is empty or a specific starting string, corresponding to the root node in the prefix tree; then the text model performs the first step of reasoning decoding. At this time, the generate function calls the prefix_allowed_tokens_fn parameter to traverse the prefix tree structure, reads the string corresponding to the child node allowed to be output by the root node, and returns the string "105574". It can be understood that at this time, the prefix_allowed_tokens_fn parameter only allows the text model to output "105574", that is, "million", and cannot output other strings. The text model cannot select or output strings corresponding to options other than the above three options.
[0036] Therefore, by defining the prefix_allowed_tokens_fn parameter, the result of each step of reasoning of the text model can only be within the range limited by the prefix tree, that is, it can only be selected and output from the options corresponding to the prefix tree. The output of the text model is constrained to ensure that the generated text meets the constraints, which greatly improves the accuracy of text reasoning.
[0037] Step S204: Based on the text model and the option constraint function, a target child node is inferred from the child nodes under the root node, and the number of steps is increased by 1.
[0038] After defining the option constraint function for the prefix_allowed_tokens_fn parameter, you can start text reasoning and classification, which is also explained according to the above example. First, the text model is initialized according to the requirement question and the corresponding option string group. At this time, the model reasoning step is 0, and text generation begins. The currently generated sequence is empty or a specific starting string, corresponding to the root node in the prefix tree; then the text model performs the first step of reasoning decoding. At this time, the generate function in the text model calls the prefix_allowed_tokens_fn parameter to traverse the prefix tree structure and read the string list corresponding to the child nodes allowed to be output by the root node. Since there is only one child node corresponding to the root node, the prefix_allowed_tokens_fn parameter returns the string "105574", indicating that only the node "105574" can be selected as the target child node after reasoning from the root node. At this time, the model reasoning step is increased by 1.
[0039] Step S205: Take the target child node as the root node, return to execute inference of a target child node from the child nodes under the root node, until the number of steps reaches the number of model inference steps, and obtain the target child node corresponding to the number of model inference steps.
[0040] Continuing with the above example, after the model inference step is increased by 1, the node "105574" is used as the root node, and the execution is returned to infer a target child node from the child nodes under the root node. At this time, the generate function in the text model calls the prefix_allowed_tokens_fn parameter to continue traversing the prefix tree structure, reads the string list corresponding to the child nodes allowed to be output by the node "105574", and returns the string lists of "45629", "104846", and "100182", which correspond to the nodes "45629", "104846", and "100182", respectively. Point "104846" and node "100182" indicate that the result of the second step of reasoning can only select the corresponding string from node "45629", node "104846" and node "100182", that is, it is necessary to select one node from the three nodes as the target child node of node "105574", thereby limiting the result of text model reasoning to the range of options corresponding to the prefix tree. According to the preset target child node reasoning rules in the text model, a target child node is inferred from the above three nodes, for example, node "45629" is inferred as the second target child node.
[0041] At this time, since the number of inference steps has reached the acquired model inference step number, the text model can stop inference and obtain two target child nodes, namely node "105574" and node "45629".
[0042] Step S206: Determine the target option output by the text model for the requirement question based on the character strings corresponding to all the target sub-nodes.
[0043] After obtaining all target child nodes, the target path can be constructed according to the target child nodes, and the target path can be matched with the above prefix tree path to correspond to the target option.
[0044] The embodiment of the present invention can string encode all options corresponding to the demand question, and construct a prefix tree corresponding to the option according to the string group corresponding to the option; according to the structure of the prefix tree, determine the target node from the prefix tree, and further determine the model reasoning steps of the text model according to the target node, which can reduce the model reasoning steps as much as possible and improve the reasoning and classification efficiency of the text model; when performing reasoning, limit the output of the text model to the options corresponding to the prefix tree; when the reasoning steps reach the model reasoning steps, match and output the target options for the demand question through the strings corresponding to the multiple target sub-nodes obtained, thereby controlling the results generated by the text model to be within the provided options, thereby improving the accuracy of text model reasoning.
[0045] like Figure 3 As shown, it is a flowchart of a text reasoning method for insurance services provided by Embodiment 3 of the present invention. In step S202, according to all the string groups, the corresponding string is matched as a child node for the root node to form a prefix tree for all options, including: Step S301: according to the string groups of all options, the first string in one of the string groups is selected as a child node of the root node, and an initial path corresponding to the string group is constructed based on the root node and the child nodes.
[0046] After initializing the root node of the prefix tree, the first string is selected from the encoding result corresponding to one of the options, that is, the string group, as the first child node of the root node, thereby establishing the first initial path through the root node and the child node. This initial path corresponds to the string group and is used to represent the corresponding option.
[0047] Step S302: Determine whether there are any remaining character strings in the character string group.
[0048] Step S303: If it exists, continue to add the remaining strings in sequence along the initial path to construct a prefix tree path corresponding to one of the options, and return to execute the selection of the first string in one of the string groups as the child node of the root node until the prefix tree paths corresponding to all options are constructed.
[0049] For steps S302-S303, after constructing the initial path of one of the options, it is necessary to determine whether there are any remaining strings in the string group corresponding to the option except the first string that has been used as a child node. If there are any remaining strings, the remaining strings need to be added to the initial path in sequence according to the order in the string group. Specifically, the second string in the string group is used as the child node of the child node corresponding to the first string, and so on, until all the strings in the string group are added, thereby constructing a prefix tree path corresponding to one of the options.
[0050] If all the strings in the string group corresponding to one of the options have been added to the initial path, it is considered that the prefix tree path corresponding to the option has been built. At this time, the process returns to re-execute the selection of the first string in one of the string groups as the child node of the root node until the prefix tree paths corresponding to all options are built.
[0051] Step S304: If it does not exist, determine that the initial path is the prefix tree path corresponding to the option, and return to execute to select the first string in one of the string groups as the child node of the root node until the prefix tree paths corresponding to all options are constructed.
[0052] If there is only one string in the string group of one of the options, after the initial path is established, the initial path is used as the prefix tree path of the string group. At the same time, the string group corresponding to the next option is switched and selected, and the first string in one of the string groups is selected as the child node of the root node until the prefix tree paths corresponding to all options are built.
[0053] Step S305: Determine prefix trees for all options according to all prefix tree paths.
[0054] After obtaining the prefix tree paths of all options, a prefix tree for all options can be formed according to the prefix tree paths. Specifically, Figure 4As shown, it is a prefix tree schematic diagram of a text reasoning method for insurance services provided by the fourth embodiment of the present invention. In the prefix tree, the node marked with the word "initialization" is the root node, the node "105574" is the only child node of the root node, and the node "45629", the node "104846" and the node "100182" are all child nodes of the "105574" node. Among them, the node "105574", the node "45629", the node "99421" and the node "32463" constitute a prefix tree path, corresponding to the option "Million Home Insurance".
[0055] After constructing the prefix tree, the node structure of the prefix tree is parsed to determine the number of inference steps required for the text model.
[0056] like Figure 5 FIG. 2 is a flow chart of a text reasoning method for insurance services provided by Embodiment 4 of the present invention. The step S202 of determining the number of model reasoning steps based on the prefix tree includes: Step S401: Obtain a target node from the prefix tree, the in-degree and out-degree of the target node are both 1, and the in-degree and out-degree of the child nodes of the target node are also 1; Step S402: Obtain the level of the target node in the prefix tree, and determine the number of model reasoning steps based on the level.
[0057] For steps S401-S402, the target node is obtained from the prefix tree, and the selection condition of the target node is: the in-degree and out-degree of the target node are both 1, and the in-degree and out-degree of the child node of the target node are also 1. Specifically, in the present invention, the in-degree of any node is 1, which means that the parent node of the node has one and only one, and the out-degree is 1, which means that the child node of the node has one and only one.
[0058] Continue to refer to Figure 4 , from the above target node selection rules, we can know that node "45629", node "104846" and node "100182" are all target nodes. For example, when the text model is performing text reasoning, it only needs to reason to the target node "45629" and does not need to continue reasoning downward, because the corresponding prefix tree path can be directly determined through node "45629" and the parent node "105574" of node "45629", and the option corresponding to the prefix tree path is "Million Family Property Insurance".
[0059] It can be further seen that the text model starts reasoning from the initialized root node. After one step of reasoning, only node "105574" can be selected. Since there are 3 child nodes after node "105574", it is not yet certain which node to select. Therefore, it is necessary to continue with the second step of reasoning. If in the second step of reasoning, the text model infers that node "45629" is more in line with the reasoning logic, there is no need to continue with the third step of reasoning, because the corresponding prefix tree path can be directly determined through nodes "105574" and "45629", and the option corresponding to the prefix tree path is "Millions of Home Insurance".
[0060] Since the level of the node "45629" is exactly at the second level in the prefix tree calculated from the first child node after the root node, it can be seen that we only need to select the target node from the prefix tree and determine the number of model inference steps of the text model based on the value corresponding to the level of the target node.
[0061] Prior to the present invention, for the above three options, the text model needed at most 4 steps of reasoning to determine the output option. However, by selecting the target node from the prefix tree set by the present invention and determining the number of model reasoning steps based on the target node, successful reasoning can be achieved in 2 steps, which can reduce the number of steps of text model reasoning, thereby saving computing resources and improving the reasoning efficiency of the text model.
[0062] In the above example, since the three target nodes in the prefix tree are all at the second level, the model inference step number of the text model can be directly determined to be 2. In other cases, if multiple target nodes are at different levels, it is necessary to select the value corresponding to the maximum level as the model inference step number based on the levels of all target nodes in the prefix tree. In this way, the text model can perform inference according to the model inference step number and output accurate inference options.
[0063] like Figure 6 As shown, it is a flowchart of a text reasoning method for insurance services provided by an embodiment of the present invention for the fifth embodiment of the present application. Among them, in step S205, inferring a target child node from the child nodes under the root node also includes: S501: Obtain a string list of all child nodes under the root node, and calculate the logits scores of all strings in the string list.
[0064] S502: Obtain the string with the highest logits score from the string list, and determine that the child node corresponding to the string with the highest logits score is the target child node inferred by the text model.
[0065] Wherein, when obtaining a string list including multiple strings, the text model needs to infer a target string that conforms to the reasoning logic. For multiple child nodes under the root node, it is necessary to select a target child node from the multiple child nodes, that is, select a target string from the string list, and the child node corresponding to the target string is the target child node. In one embodiment, the text model is used to score the string corresponding to each child node, obtain the logits score of each string, and select the string with the highest logits score as the target string. Wherein, the calculation method of the logits score for different strings in the text model is a prior art and will not be repeated here.
[0066] Specifically, continuing with the above example, the text model scores all the strings in the string lists of "45629", "104846" and "100182" to obtain the logits score of each string. If the logits score of the string "45629" is the highest, it means that the text model will use the string "45629" as the output result of the second step of reasoning, and determine that the string "45629" is the target string, so the corresponding node "45629" is the target child node.
[0067] At the same time, since the number of reasoning steps of the text model has reached the model reasoning step number 2 calculated above, the text model reasoning ends. At this time, the target option of the text model for the requirement problem can be determined based on all target sub-nodes.
[0068] like Figure 7 FIG. 2 is a flow chart of a text reasoning method for insurance services provided by Embodiment 6 of the present invention. Step S206 determines the target option output by the text model for the demand question according to the character strings corresponding to all target sub-nodes, including: S601: Acquire the character strings corresponding to all target sub-nodes, and concatenate the character strings corresponding to the target sub-nodes in the acquisition order to obtain the target path.
[0069] The target path can be obtained by concatenating the strings corresponding to all target subnodes in order. For example, the target subnode "105574" and the target subnode "45629" are concatenated to obtain the target path [105574, 45629].
[0070] S602: According to the target path, determine the corresponding target prefix tree path from all prefix tree paths, and according to the target prefix tree path, determine the option corresponding to the target prefix tree path as the target option output by the text model for the requirement question.
[0071] After the target path is obtained, a target prefix tree path that matches the target path is matched from all prefix tree paths according to the target path, and the corresponding target option can be determined according to the target prefix tree path.
[0072] For example, the target path [105574, 45629] is matched with the above prefix tree path to obtain the matching target prefix tree path [105574, 45629, 99421, 32463], and the option corresponding to the target prefix tree path is "Millions of Family Property Insurance". At this time, it can be determined that the target option after text reasoning by the text model is "Millions of Family Property Insurance".
[0073] It should be understood that the order of execution of the steps in the above embodiment does not necessarily mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present invention.
[0074] like Figure 8 As shown, a text reasoning device for insurance services provided by an embodiment of the present invention corresponds one-to-one to a text reasoning method for insurance services in the above embodiment. The text reasoning device for insurance services includes an option encoding module 71, a prefix tree construction module 71, an option constraint module 73, a model reasoning module 74 and an option determination module 75. The functional modules are described in detail as follows: The option encoding module 71 is used to obtain all options set for the demand problem extracted from the insurance service product library, and perform string encoding on all options to obtain a string group corresponding to each option. A prefix tree building module 72 is used to obtain an initialized root node, match corresponding strings as child nodes for the root node according to all string groups, form a prefix tree for all options, and determine the number of model reasoning steps based on the prefix tree; The option constraint module 73 is used to obtain the option constraint function in the text model, and for any node in the prefix tree, read the child node corresponding to the node according to the option constraint function; The model inference module 74 is used to infer a target subnode from the subnodes under the root node based on the text model, and increase the number of steps by 1; take the target subnode as the root node, return to execute the inference of a target subnode from the subnodes under the root node, until the number of steps reaches the model inference step number, and obtain the target subnode corresponding to the number of model inference steps; The option determination module 75 is used to determine the target option output by the text model for the requirement question based on the character strings corresponding to all the target sub-nodes.
[0075] In one embodiment, the option encoding module 71 includes: A first encoding unit is used for encoding the string of any option by a preset encoding tool to obtain at least one string corresponding to the option to form a string group of the option; The second encoding unit is used to traverse all options and obtain a string group corresponding to each option.
[0076] In one embodiment, the prefix tree construction module 72 includes: An initial path building unit, used for selecting the first string in one of the string groups as a child node of the root node according to the string groups of all options, and building an initial path corresponding to the string group based on the root node and the child nodes; A judging unit, used for judging whether there are any remaining strings in the string group; If it exists, continue to add the remaining strings along the initial path in sequence to build a prefix tree path corresponding to one of the options, return to select the first string in one of the string groups as the child node of the root node, until the prefix tree paths corresponding to all options are built; If it does not exist, the initial path is determined to be the prefix tree path corresponding to the option, and the execution is returned to select the first string in one of the string groups as the child node of the root node until the prefix tree paths corresponding to all options are constructed; A prefix tree building unit is used to determine prefix trees for all options according to all prefix tree paths.
[0077] In one embodiment, the prefix tree construction module 72 further includes: A target node acquisition unit is used to acquire a target node from the prefix tree. The in-degree and out-degree of the target node are both 1, and the in-degree and out-degree of the child nodes of the target node are also 1. An inference step determination unit, used to obtain the level of the target node in the prefix tree and determine the model inference step based on the level; Among them, the in-degree of any node is 1, which means that the node has only one parent node, and the out-degree of any node is 1, which means that the node has only one child node.
[0078] In one embodiment, the reasoning step number determination unit further includes: The inference step determination subunit is used to determine the level value corresponding to the maximum level as the model inference step according to the levels of all target nodes in the prefix tree.
[0079] In one embodiment, the model reasoning module 74 includes: The score calculation unit is used to obtain the string list of all child nodes under the root node and calculate the logits scores of all strings in the string list; The target sub-node determination unit is used to obtain the string with the highest logits score from the string list, and determine that the sub-node corresponding to the string with the highest logits score is the target sub-node inferred by the text model.
[0080] In one embodiment, the option determination module 75 includes: A target path acquisition unit is used to acquire the character strings corresponding to all target sub-nodes, and sequentially concatenate the character strings corresponding to the target sub-nodes in the acquisition order to obtain the target path; The option acquisition unit is used to determine the corresponding target prefix tree path from all prefix tree paths according to the target path, and determine the option corresponding to the target prefix tree path as the target option output by the text model for the demand problem according to the target prefix tree path.
[0081] For the specific definition of a text reasoning device for insurance services, please refer to the definition of a text reasoning method for insurance services mentioned above, which will not be repeated here. Each module in the above-mentioned text reasoning device for insurance services can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0082] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Fig. 9 As shown. The computer device includes a processor, a memory, a network interface and a database connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile and / or volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external client via a network connection. When the computer program is executed by the processor, it implements the functions or steps on the service side of a text reasoning method for insurance services.
[0083] In one embodiment, a computer device is provided. The computer device may be a client, and its internal structure diagram may be as follows: Fig.10As shown. The computer device includes a processor, a memory, a network interface, a display screen and an input device connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external server via a network connection. When the computer program is executed by the processor, it implements the functions or steps of a client side of a text reasoning method for insurance services.
[0084] It should be noted that the above functions or steps that can be implemented by the computer-readable storage medium or computer device can refer to the relevant descriptions on the server side and the client side in the aforementioned method embodiment. To avoid repetition, they will not be described one by one here.
[0085] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0086] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
[0087] The embodiments described above are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included in the protection scope of the present invention.
[0088] The non-Company software tools or components appearing in the embodiments of this application are merely examples and do not represent actual use.
Claims
1. A text reasoning method for insurance services, characterized in that: include: Obtain all options set for the demand problem extracted from the insurance service product library, perform string encoding on all options respectively, and obtain a string group corresponding to each option; Obtain an initialized root node, match corresponding strings as child nodes for the root node according to all string groups, form a prefix tree for all options, and determine the number of model reasoning steps based on the prefix tree; Obtaining an option constraint function in the text model, and for any node in the prefix tree, reading a child node corresponding to the node according to the option constraint function; Based on the text model and the selection constraint function, infer a target child node from the child nodes under the root node, and increase the number of steps by 1; Taking the target child node as the root node, returning to execute inference of a target child node from the child nodes under the root node until the number of steps reaches the number of model inference steps, and obtaining the target child node corresponding to the number of model inference steps; According to the character strings corresponding to all the target sub-nodes, the target options output by the text model for the requirement question are determined.
2. The text reasoning method for insurance services according to claim 1, characterized in that: The string encoding is performed on all options respectively to obtain a string group corresponding to each option, including: For any option, the option is string-encoded by a preset encoding tool to obtain at least one string corresponding to the option, thereby forming a string group of the option; Traverse all options and get the string group corresponding to each option.
3. The text reasoning method for insurance services according to claim 1, characterized in that: According to all the string groups, the corresponding string is matched for the root node as a child node to form a prefix tree for all options, including: According to the string groups of all options, the first string in one of the string groups is selected as a child node of the root node, and an initial path corresponding to the string group is constructed based on the root node and the child nodes; Determine whether there are any remaining strings in the string group; If it exists, continue to add the remaining strings in sequence along the initial path to construct a prefix tree path corresponding to one of the options, return to execute and select the first string in one of the string groups as the child node of the root node, until the prefix tree paths corresponding to all the options are constructed; If it does not exist, the initial path is determined to be the prefix tree path corresponding to the option, and the process returns to select the first string in one of the string groups as the child node of the root node until the prefix tree paths corresponding to all the options are constructed; The prefix trees for all options are determined according to all the prefix tree paths.
4. The text reasoning method for insurance services according to claim 3, characterized in that: The determining the number of model reasoning steps based on the prefix tree includes: Obtain a target node from the prefix tree, wherein the in-degree and out-degree of the target node are both 1, and the in-degree and out-degree of the child nodes of the target node are also 1; Obtaining the level of the target node in the prefix tree, and determining the number of model reasoning steps based on the level; Among them, the in-degree of any node is 1, which means that the node has only one parent node, and the out-degree of any node is 1, which means that the node has only one child node.
5. The text reasoning method for insurance services according to claim 4, characterized in that: The determining the number of model reasoning steps based on the hierarchy includes: According to the levels of all the target nodes in the prefix tree, the level value corresponding to the maximum level is determined as the number of model reasoning steps.
6. The text reasoning method for insurance services according to claim 1, characterized in that: The step of inferring a target child node from the child nodes under the root node includes: Obtain a list of strings corresponding to all child nodes under the root node, and calculate the logits scores of all strings in the string list; The string with the highest logits score is obtained from the string list, and the child node corresponding to the string with the highest logits score is determined to be the target child node inferred by the text model.
7. The text reasoning method for insurance services according to any one of claims 1 to 6, characterized in that: Determining the target options output by the text model for the requirement question according to the character strings corresponding to all the target sub-nodes includes: Obtain the strings corresponding to all target subnodes, and concatenate the strings corresponding to the target subnodes in the order in which they are obtained to obtain the target path; According to the target path, a corresponding target prefix tree path is determined from all prefix tree paths, and according to the target prefix tree path, an option corresponding to the target prefix tree path is determined as a target option output by the text model for the demand question.
8. A text reasoning device for insurance services, characterized in that: include: The option encoding module is used to obtain all options set for the demand problem extracted from the insurance service product library, and perform string encoding on all options respectively to obtain a string group corresponding to each option; A prefix tree construction module is used to obtain an initialized root node, match corresponding strings as child nodes for the root node according to all string groups, form a prefix tree for all options, and determine the number of model reasoning steps based on the prefix tree; An option constraint module is used to obtain an option constraint function in a text model, and for any node in the prefix tree, read a child node corresponding to the node according to the option constraint function; A model reasoning module, used for inferring a target child node from the child nodes under the root node based on the text model and the selection constraint function, and adding 1 to the number of steps; Taking the target child node as the root node, returning to execute inference of a target child node from the child nodes under the root node until the number of steps reaches the number of model inference steps, and obtaining the target child node corresponding to the number of model inference steps; The option determination module is used to determine the target option output by the text model for the requirement question based on the character strings corresponding to all the target sub-nodes.
9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the text reasoning method for insurance services as described in any one of claims 1 to 7 are implemented.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the text reasoning method for insurance services as claimed in any one of claims 1 to 7 are implemented.