Graph generation method, and question analysis model training method and device
By inputting target questions and target prompt information into the pre-trained question analysis model, graphics corresponding to the geometry questions are generated, which solves the problems of slow graphics generation and poor accuracy in the existing technology, achieves fast and accurate graphics generation, and improves efficiency. Question-setting efficiency and accuracy.
Patent Information
- Application Number
- CN202411245289.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-06
- Publication Date
- 2024-10-11
- Estimated Expiration
- 2044-09-06
AI Technical Summary
In the existing technology, the generation of geometric problem graphics is slow and error-prone, and there is a lack of fast and accurate generation methods.
Using the graph generation method, by obtaining the target topic and target prompt information, inputting the pre-trained topic analysis model, the analysis results of categories, components, component attributes and component positions are generated, and these results are used to call the graph generation tool to generate graphics.
It realizes the rapid and accurate generation of geometry question graphics and improves the efficiency and accuracy of question setting.
Smart Images

Figure CN118762104A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer application technology, and in particular to a graph generation method, a training method and a device for a question analysis model. Background Art
[0002] In the field of education, geometry problems usually have corresponding geometric figures. For example, when a math or geometry teacher gives a geometry problem, he or she needs to give the figure corresponding to the problem. In the related art, the teacher gives the figure corresponding to the problem by hand-drawing. However, this method of giving problems is not only slow but also prone to errors. Therefore, how to quickly and accurately generate the corresponding geometric figures for the problem has become a technical problem that needs to be solved urgently. Summary of the invention
[0003] The purpose of the embodiments of the present invention is to provide a graph generation method, a training method and a device for a question analysis model, so as to realize fast and accurate generation of graphs. The specific technical solution is as follows: In a first aspect, an embodiment of the present invention provides a method for generating a graph, the method comprising: Obtaining a target title and target prompt information; the target prompt information includes: category prompt information, component prompt information, component attribute prompt information, and component location prompt information; Input the target topic and the target prompt information into a pre-trained topic analysis model to obtain a category analysis result corresponding to the category prompt information, a component analysis result corresponding to the component prompt information, a component attribute analysis result corresponding to the component attribute prompt information, and a component position analysis result corresponding to the component position prompt information; A graphic corresponding to the target topic is generated using the category analysis result, the component analysis result, the component attribute analysis result, and the component position analysis result.
[0004] Optionally, the topic analysis model includes: an encoder and a decoder; the step of inputting the target topic and the target prompt information into a pre-trained topic analysis model to obtain a category analysis result corresponding to the category prompt information, a component analysis result corresponding to the component prompt information, a component attribute analysis result corresponding to the component attribute prompt information, and a component position analysis result corresponding to the component position prompt information includes: Inputting the target topic and the category prompt information into a pre-trained topic analysis model, using the encoder to encode the target topic and the category prompt information to obtain a first feature vector and a second feature vector, and using the decoder to decode the first feature vector and the second feature vector to obtain a category analysis result corresponding to the category prompt information; Inputting the target topic and the component prompt information into a pre-trained topic analysis model, using the encoder to encode the target topic and the component prompt information to obtain a first feature vector and a third feature vector, and using the decoder to decode the first feature vector and the third feature vector to obtain a component analysis result corresponding to the component prompt information; Inputting the target topic and the component attribute prompt information into a pre-trained topic analysis model, using the encoder to encode the target topic and the component attribute prompt information to obtain a first feature vector and a fourth feature vector, and using the decoder to decode the first feature vector and the fourth feature vector to obtain a component attribute analysis result corresponding to the component attribute prompt information; The target title and the component position prompt information are input into a pre-trained title analysis model, the encoder is used to encode the target title and the component position prompt information to obtain a first feature vector and a fifth feature vector, and the decoder is used to decode the first feature vector and the fifth feature vector to obtain a component position analysis result corresponding to the component position prompt information.
[0005] Optionally, the topic analysis model includes: an encoder and four decoders; the target topic and the target prompt information are input into a pre-trained topic analysis model to obtain a category analysis result corresponding to the category prompt information, a component analysis result corresponding to the component prompt information, a component attribute analysis result corresponding to the component attribute prompt information, and a component position analysis result corresponding to the component position prompt information, including: Input the target topic and the category prompt information, the component prompt information, the component attribute prompt information, and the component position prompt information into a pre-trained topic analysis model, and use the encoder to encode the target topic and the category prompt information, the component prompt information, the component attribute prompt information, and the component position prompt information, respectively, to obtain a first eigenvector, a second eigenvector, a third eigenvector, a fourth eigenvector, and a fifth eigenvector; Decoding the first feature vector and the second feature vector using a first decoder to obtain a category analysis result corresponding to the category prompt information; Decoding the first feature vector and the third feature vector using a second decoder to obtain a component analysis result corresponding to the component prompt information; Decoding the first feature vector and the fourth feature vector using a third decoder to obtain a component attribute analysis result corresponding to the component attribute prompt information; The first feature vector and the fifth feature vector are decoded by using a fourth decoder to obtain a component position analysis result corresponding to the component position prompt information.
[0006] Optionally, the category analysis result includes: one-dimensional graphics, two-dimensional graphics, three-dimensional graphics or other graphics; the component analysis result includes: at least one of arrow, shape, position, style, style, matrix, table, graph, tree, mind map, background and adaptation; the component attribute analysis result includes: at least one of basic shape attribute, style attribute, text attribute, node attribute, rectangle, circle, star, arrow attribute, line type, color, layer, coordinate and loop; the component position analysis result includes: at least one of coordinate representation, node representation and path representation; The step of generating a graph corresponding to the target topic by using the category analysis result, the component analysis result, the component attribute analysis result, and the component position analysis result includes: Based on the category analysis result, the component analysis result, the component property analysis result and the component position analysis result, a preset graphic generation tool is called to generate a graphic corresponding to the target topic.
[0007] In a second aspect, an embodiment of the present invention provides a method for training a question analysis model, the method comprising: Obtaining a pre-trained topic analysis model and preset prompt information; the preset prompt information includes: category prompt information, component prompt information, component attribute prompt information, and component location prompt information; Obtaining sample titles and annotation attributes corresponding to the sample titles; the annotation attributes include: category, component, component attribute and component position; Input the sample topic and the preset prompt information into the pre-trained topic analysis model to obtain the attribute prediction result corresponding to the sample topic, the attribute prediction result including: the category prediction result corresponding to the category prompt information, the component prediction result corresponding to the component prompt information, the component attribute prediction result corresponding to the component attribute prompt information, and the component position prediction result corresponding to the component position prompt information; The loss between the attribute prediction result and the labeled attribute is calculated, and the parameters of the pre-trained question analysis model are adjusted according to the loss to obtain a trained question analysis model.
[0008] Optionally, the method further comprises: Adding a weight matrix to the pre-trained question analysis model and initializing the weight matrix; The calculating the loss between the attribute prediction result and the labeled attribute, and adjusting the parameters of the pre-trained question analysis model according to the loss to obtain a trained question analysis model, includes: The loss between the attribute prediction result and the labeled attribute is calculated, and the parameters of the weight matrix are adjusted according to the loss to obtain a trained question analysis model.
[0009] Optionally, adding a weight matrix to the pre-trained question analysis model and initializing the weight matrix includes: Adding a weight matrix to a designated part of the pre-trained question analysis model and initializing the weight matrix; The calculating the loss between the attribute prediction result and the labeled attribute, and adjusting the parameters of the weight matrix according to the loss to obtain a trained question analysis model, includes: Keeping the parameters of the pre-trained question analysis model unchanged, calculating the loss between the attribute prediction result and the labeled attribute, and adjusting the parameters of the weight matrix according to the loss until the learning rate of the weight matrix meets the convergence condition; The parameters of the pre-trained question analysis model are updated using the parameters of the weight matrix to obtain a trained question analysis model.
[0010] Optionally, the weight matrix includes a dimension reduction matrix and a dimension increase matrix; adding the weight matrix to a specified position of the pre-trained question analysis model and initializing the weight matrix includes: According to the output dimension of the designated part of the pre-trained question analysis model, a dimension reduction and then dimension increase operation is performed to obtain the dimension reduction matrix and the dimension increase matrix; Adding a bypass including the dimension reduction matrix and the dimension increase matrix at a designated position of the pre-trained question analysis model; The reduced-dimensional matrix is initialized using a random Gaussian distribution, and the increased-dimensional matrix is initialized using a zero matrix.
[0011] In a third aspect, an embodiment of the present invention provides a graphics generation device, the device comprising: The first acquisition module is used to acquire a target topic and target prompt information; the target prompt information includes: category prompt information, component prompt information, component attribute prompt information and component location prompt information; A first topic analysis module is used to input the target topic and the target prompt information into a pre-trained topic analysis model to obtain a category analysis result corresponding to the category prompt information, a component analysis result corresponding to the component prompt information, a component attribute analysis result corresponding to the component attribute prompt information, and a component position analysis result corresponding to the component position prompt information; A graphics generation module is used to generate a graphics corresponding to the target topic by using the category analysis result, the component analysis result, the component attribute analysis result and the component position analysis result.
[0012] In a fourth aspect, an embodiment of the present invention provides a training device for a question analysis model, the device comprising: The second acquisition module is used to acquire a pre-trained topic analysis model and preset prompt information; the preset prompt information includes: category prompt information, component prompt information, component attribute prompt information and component location prompt information; A third acquisition module is used to acquire sample titles and the annotated attributes corresponding to the sample titles; the annotated attributes include: category, component, component attribute and component position; A second topic analysis module is used to input the sample topic and the preset prompt information into the pre-trained topic analysis model to obtain an attribute prediction result corresponding to the sample topic, wherein the attribute prediction result includes: a category prediction result corresponding to the category prompt information, a component prediction result corresponding to the component prompt information, a component attribute prediction result corresponding to the component attribute prompt information, and a component position prediction result corresponding to the component position prompt information; The model training module is used to calculate the loss between the attribute prediction result and the labeled attribute, and adjust the parameters of the pre-trained question analysis model according to the loss to obtain a trained question analysis model.
[0013] In a fifth aspect, an embodiment of the present invention further provides an electronic device, comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus; Memory, used to store computer programs; The processor is used to implement any of the above methods when executing the program stored in the memory.
[0014] In a sixth aspect, an embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, any of the above-mentioned methods is implemented.
[0015] In a seventh aspect, an embodiment of the present invention further provides a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute any of the above-described methods.
[0016] Beneficial effects of the embodiments of the present invention: The embodiments of the present invention provide a method for generating graphics, a method for training a question analysis model, and a device, which use a pre-trained question analysis model in combination with target prompt information to analyze a target question, and obtain category analysis results, component analysis results, component attribute analysis results, and component position analysis results corresponding to the target question, so as to accurately generate graphics corresponding to the target question using the category analysis results, component analysis results, component attribute analysis results, and component position analysis results obtained by analysis. Compared with manual drawing, the method achieves rapid and accurate generation of graphics corresponding to the question, and improves the efficiency and accuracy of question setting.
[0017] Of course, it is not necessary to achieve all of the advantages described above at the same time to implement any product or method of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other embodiments can also be obtained based on these drawings.
[0019] Figure 1 A schematic diagram of a flow chart of a method for generating graphics provided by an embodiment of the present invention; Figure 2 A schematic diagram of a flow chart of a method for analyzing a question provided by an embodiment of the present invention; Figure 3 Another flowchart of the question parsing method provided by the embodiment of the present invention; Figure 4 A flowchart of a method for training a question analysis model provided by an embodiment of the present invention; Figure 5 Another flowchart of a method for training a question analysis model provided by an embodiment of the present invention; Figure 6 A schematic diagram of fine-tuning training of a question analysis model provided in an embodiment of the present invention; Figure 7 A schematic diagram of the structure of a graphics generating device provided by an embodiment of the present invention; Figure 8 A schematic diagram of the structure of a training device for a question analysis model provided by an embodiment of the present invention; Fig. 9A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0020] 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 only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field based on this application belong to the scope of protection of the present invention.
[0021] In order to achieve fast and accurate generation of graphics, an embodiment of the present invention provides a graphics generation method, a training method and a device for a question analysis model. The graphics generation method and the training method for a question analysis model provided by the embodiment of the present invention are applied to a scenario where a corresponding graphics is generated according to a question, and can be implemented by an electronic device, such as a client device or a server device.
[0022] like Figure 1 As shown, the graphics generation method provided by the embodiment of the present invention includes: S101, obtaining a target topic and target prompt information; The target prompt information includes: category prompt information, component prompt information, component attribute prompt information and component location prompt information; S102, inputting the target topic and the target prompt information into a pre-trained topic analysis model, obtaining a category analysis result corresponding to the category prompt information, a component analysis result corresponding to the component prompt information, a component attribute analysis result corresponding to the component attribute prompt information, and a component position analysis result corresponding to the component position prompt information; S103, generating a graph corresponding to the target topic using the category analysis results, component analysis results, component attribute analysis results, and component position analysis results.
[0023] In an embodiment of the present invention, a pre-trained question analysis model is used in combination with target prompt information to analyze the target question, and category analysis results, component analysis results, component attribute analysis results and component position analysis results corresponding to the target question are obtained, so that the category analysis results, component analysis results, component attribute analysis results and component position analysis results obtained by analysis can be used to accurately generate graphics corresponding to the target question. Compared with manual drawing, fast and accurate generation of graphics corresponding to the question is achieved, thereby improving the efficiency and accuracy of question setting.
[0024] In an embodiment of the present invention, a question analysis model is pre-trained and deployed in an electronic device, so as to use the pre-trained question analysis model to parse a question for which a graphic needs to be generated, and obtain relevant attributes corresponding to the question, such as category, component, component attribute, and component position information, so as to generate a graphic corresponding to the question. Specifically, the training process of the question analysis model is described in detail below.
[0025] In S101, the target question is any question that needs to generate a graphic. The target prompt information can be task-related information and context, specifically used to indicate the relationship between the input and output of the question analysis model to help the question analysis model better understand the task and generate the correct output. In one example, the target prompt information is a prompt word or instruction, which is input into a pre-trained question analysis model together with the target question to guide the question analysis model to output a response corresponding to the target prompt information.
[0026] In one implementation, the target prompt information may include: category prompt information, component prompt information, component attribute prompt information, and component position prompt information. The category prompt information is used to indicate that the input of the topic analysis model is the target topic, and the output is the category analysis result; the component prompt information is used to indicate that the input of the topic analysis model is the target topic, and the output is the component analysis result; the component attribute prompt information is used to indicate that the input of the topic analysis model is the target topic, and the output is the component attribute analysis result; the component position prompt information is used to indicate that the input of the topic analysis model is the target topic, and the output is the component position analysis result. Exemplarily, the category prompt information may be "generating the category of the topic according to the topic", or "what is the category of the topic", etc., the component prompt information may be "generating the component of the topic according to the topic", or "what are the components contained in the topic", etc., the component is used to represent the elements contained in the graph, the component attribute prompt information may be "generating the component attribute of the topic according to the topic", or "what is the attribute of the component in the topic", etc., the component position prompt information may be "generating the component position of the topic according to the topic", or "where is the position of the component in the topic", etc.
[0027] Furthermore, in S102, the target question and target prompt information are input into a pre-trained question analysis model, so that the question analysis model analyzes the target question under the guidance of the target prompt information, and obtains a category analysis result corresponding to the category prompt information of the target question, a component analysis result corresponding to the component prompt information, a component attribute analysis result corresponding to the component attribute prompt information, and a component position analysis result corresponding to the component position prompt information.
[0028] In a possible implementation, the category analysis results may include: one-dimensional graphics, two-dimensional graphics, three-dimensional graphics or other graphics; here, other graphics represent graphics other than one-dimensional graphics, two-dimensional graphics and three-dimensional graphics. The component analysis results may include: at least one of arrows, shapes, positioning, patterns, decorations, matrices, tables, graphs, trees, mind maps, backgrounds and fits. The component attribute analysis results may include: at least one of basic shape attributes, style attributes, text attributes, node attributes, rectangles, circles, stars, arrow attributes, line types, colors, layers, coordinates and loops. The component position analysis results may include: at least one of coordinate representation, node representation and path representation.
[0029] The category analysis results, component analysis results, component attribute analysis results, and component location analysis results contain rich content, making the graphics generated based on the category analysis results, component analysis results, component attribute analysis results, and component location analysis results more accurate.
[0030] In the embodiment of the present invention, the target prompt information can also specify the format of the output content of the question analysis model. For example, the format of the category analysis result, component analysis result, component attribute analysis result and component position analysis result output by the question analysis model is specified as a text in the tikz (a drawing tool) format. In the tikz format text, a circle is represented by \coordinate, a straight line is represented by \path, and special graphics are drawn by \filldraw, etc.
[0031] In a possible implementation, S103 may be to call a preset graphic generation tool to generate a graphic corresponding to the target topic based on the category analysis result, the component analysis result, the component property analysis result, and the component position analysis result.
[0032] Exemplarily, when a pre-trained question analysis model is used in combination with target prompt information to analyze the category analysis results, component analysis results, component property analysis results and component position analysis results corresponding to the target question, a tikz component or plug-in can be called to directly generate graphics corresponding to the target question.
[0033] In an embodiment of the present invention, a pre-trained question analysis model is used in combination with target prompt information to analyze the target question, and category analysis results, component analysis results, component attribute analysis results, and component position analysis results corresponding to the target question are obtained. Then, the category analysis results, component analysis results, component attribute analysis results, and component position analysis results obtained by analysis are used to call a preset graphics generation tool to accurately generate graphics corresponding to the target question. Compared with manual drawing, fast and accurate generation of graphics corresponding to the question is achieved, thereby improving the efficiency and accuracy of question setting.
[0034] In a possible implementation, the pre-trained topic analysis model may include an encoder and a decoder, such as Figure 2 As shown, the implementation method of the above S102 using the pre-trained question analysis model combined with the target prompt information to analyze the target question may include: S201, inputting the target question and the category prompt information into a pre-trained question analysis model, using an encoder to encode the target question and the category prompt information to obtain a first feature vector and a second feature vector, and using a decoder to decode the first feature vector and the second feature vector to obtain a category analysis result corresponding to the category prompt information; S202, inputting the target topic and the component prompt information into a pre-trained topic analysis model, using an encoder to encode the target topic and the component prompt information to obtain a first feature vector and a third feature vector, and using a decoder to decode the first feature vector and the third feature vector to obtain a component analysis result corresponding to the component prompt information; S203, inputting the target topic and the component attribute prompt information into a pre-trained topic analysis model, using an encoder to encode the target topic and the component attribute prompt information to obtain a first feature vector and a fourth feature vector, and using a decoder to decode the first feature vector and the fourth feature vector to obtain a component attribute analysis result corresponding to the component attribute prompt information; S204, input the target title and component position prompt information into a pre-trained title analysis model, use an encoder to encode the target title and component position prompt information to obtain a first eigenvector and a fifth eigenvector, use a decoder to decode the first eigenvector and the fifth eigenvector, and obtain a component position analysis result corresponding to the component position prompt information.
[0035] In an embodiment of the present invention, a question analysis model is trained by inputting questions and prompt words one by one. Accordingly, the question analysis model includes an encoder and a decoder, so that the question analysis model has a simple structure, low training complexity, and a more accurate model, thereby being able to more accurately parse the target question.
[0036] Among them, the encoder and decoder contained in the question analysis model can be implemented using a recurrent neural network, etc. The encoder encodes the question and prompt information input into the question analysis model, and converts the question and prompt information into context vectors of fixed length respectively. The decoder decodes the encoded context vector and generates a corresponding output based on the context vector.
[0037] The above steps S201 to S204 may be executed in parallel or one by one, which is not specifically limited in the embodiment of the present invention.
[0038] In a possible implementation, the pre-trained topic analysis model may include an encoder and four decoders, such as Figure 3 As shown, the implementation method of the above S102 using the pre-trained question analysis model combined with the target prompt information to analyze the target question may include: S301, inputting the target topic and category prompt information, component prompt information, component attribute prompt information, and component position prompt information into a pre-trained topic analysis model, and using an encoder to encode the target topic and category prompt information, component prompt information, component attribute prompt information, and component position prompt information, respectively, to obtain a first eigenvector, a second eigenvector, a third eigenvector, a fourth eigenvector, and a fifth eigenvector; S302, using a first decoder to decode the first feature vector and the second feature vector to obtain a category analysis result corresponding to the category prompt information; S303, using a second decoder to decode the first feature vector and the third feature vector to obtain a component analysis result corresponding to the component prompt information; S304, using a third decoder to decode the first feature vector and the fourth feature vector to obtain a component attribute analysis result corresponding to the component attribute prompt information; S305 , using a fourth decoder to decode the first feature vector and the fifth feature vector to obtain a component position analysis result corresponding to the component position prompt information.
[0039] In the embodiment of the present invention, the question analysis model is trained by inputting the question and multiple prompt words at one time. Accordingly, the question analysis model includes an encoder and four decoders. The four decoders can be understood as four branch networks of the question analysis model, which are respectively used to parse the category, component, component attribute and component position of the target question, so as to achieve faster parsing of the target question. The structures of the four decoders can be the same or different.
[0040] In one embodiment, if Figure 4 As shown, the training method of the question analysis model provided by the embodiment of the present invention includes: S401, obtaining a pre-trained question analysis model and preset prompt information.
[0041] The preset prompt information may include: category prompt information, component prompt information, component attribute prompt information and component location prompt information. Specifically, the preset prompt information may be the same as the target prompt information mentioned above, which are prompt words or instructions preset for the question analysis model.
[0042] The pre-trained question analysis model can be a pre-trained large model, such as the Tongyi Qianwen series model Qwen LLM (Large Language Models).
[0043] S402, obtaining sample questions and annotation attributes corresponding to the sample questions.
[0044] The annotation attributes corresponding to the sample questions may include: category, component, component attribute and component position. Among them, the category may include: one-dimensional graphics, two-dimensional graphics, three-dimensional graphics or other graphics; the component may include: arrows, shapes, positions, patterns, decorations, matrices, tables, graphs, trees, mind maps, backgrounds and fits; the component attributes may include: basic shape attributes, style attributes, text attributes, node attributes, rectangles, circles, stars, arrow attributes, line types, colors, layers, coordinates and loops; the component position may include: coordinate representation, node representation and path representation.
[0045] S403, inputting the sample question and preset prompt information into the pre-trained question analysis model to obtain the attribute prediction result corresponding to the sample question.
[0046] The property prediction results may include: the category prediction results corresponding to the category prompt information, the component prediction results corresponding to the component prompt information, the component property prediction results corresponding to the component property prompt information, and the component position prediction results corresponding to the component position prompt information. Among them, the category prediction results may include: one-dimensional graphics, two-dimensional graphics, three-dimensional graphics or other graphics; the component prediction results may include: at least one of arrows, shapes, positions, patterns, decorations, matrices, tables, graphs, trees, mind maps, backgrounds and fits; the component property prediction results may include: at least one of basic shape properties, style properties, text properties, node properties, rectangles, circles, stars, arrow properties, line types, colors, layers, coordinates and loops; the component position prediction results may include: at least one of coordinate representation, node representation and path representation.
[0047] In an embodiment of the present invention, the above-mentioned step S402 can directly obtain the pre-labeled sample questions and the labeled attributes corresponding to the sample questions, or can first obtain the sample questions, and then input the sample questions and preset prompt information into a pre-trained question analysis model to obtain the attribute prediction results corresponding to the sample questions, and then correct the attribute prediction results to obtain the labeled attributes corresponding to the sample questions, thereby saving the time and cost of manual labeling.
[0048] In a possible implementation, the pre-trained topic analysis model may include an encoder and a decoder. Accordingly, this step may be implemented in the following manner: Inputting the sample question and the category prompt information into the pre-trained question analysis model, using an encoder to encode the sample question and the category prompt information to obtain a sixth eigenvector and a second eigenvector, and using a decoder to decode the sixth eigenvector and the second eigenvector to obtain a category prediction result corresponding to the category prompt information; Input the sample question and component prompt information into the pre-trained question analysis model, use the encoder to encode the sample question and component prompt information to obtain the sixth eigenvector and the third eigenvector respectively, use the decoder to decode the sixth eigenvector and the third eigenvector to obtain the component prediction result corresponding to the component prompt information; Inputting the sample question and the component attribute prompt information into the pre-trained question analysis model, using an encoder to encode the sample question and the component attribute prompt information to obtain a sixth eigenvector and a fourth eigenvector, and using a decoder to decode the sixth eigenvector and the fourth eigenvector to obtain a component attribute prediction result corresponding to the component attribute prompt information; The sample question and component position prompt information are input into the pre-trained question analysis model, the sample question and the component position prompt information are respectively encoded by the encoder to obtain the sixth eigenvector and the fifth eigenvector, and the sixth eigenvector and the fifth eigenvector are decoded by the decoder to obtain the component position prediction result corresponding to the component position prompt information.
[0049] In another possible implementation, the pre-trained topic analysis model may include an encoder and four decoders. Accordingly, this step may be implemented in the following manner: Input the sample title and category prompt information, component prompt information, component attribute prompt information, and component position prompt information into the pre-trained title analysis model, and use an encoder to encode the sample title and category prompt information, component prompt information, component attribute prompt information, and component position prompt information, respectively, to obtain a sixth eigenvector, a second eigenvector, a third eigenvector, a fourth eigenvector, and a fifth eigenvector; Decoding the sixth eigenvector and the second eigenvector using the first decoder to obtain a category prediction result corresponding to the category prompt information; Decoding the sixth eigenvector and the third eigenvector using the second decoder to obtain a component prediction result corresponding to the component prompt information; Decoding the sixth eigenvector and the fourth eigenvector using the third decoder to obtain a component attribute prediction result corresponding to the component attribute prompt information; The sixth eigenvector and the fifth eigenvector are decoded by using the fourth decoder to obtain a component position prediction result corresponding to the component position prompt information.
[0050] S404, calculating the loss between the attribute prediction result and the labeled attribute, and adjusting the parameters of the pre-trained question analysis model according to the loss to obtain a trained question analysis model.
[0051] Exemplarily, sample questions and the annotation attributes corresponding to the sample questions are shown in Table 1 below, where two sample questions are used as examples for illustration: Table 1 Sample questions and their corresponding annotation attributes
[0052] The sample questions and the attribute prediction results corresponding to the sample questions are shown in Table 2 below: Table 2 Sample questions and corresponding attribute prediction results
[0053] The loss function used to calculate the loss between the attribute prediction result and the labeled attribute may be, for example, a cross entropy loss function, and then, the parameters of the pre-trained question analysis model are adjusted according to the loss until a preset end condition is met to obtain a trained question analysis model. The preset end condition may be a preset number of iterations, or the loss reaches a preset loss threshold, etc.
[0054] In an embodiment of the present invention, a pre-trained question analysis model is combined with preset prompt information to train the question analysis model, and the preset prompt information is used to effectively guide the pre-trained question analysis model to analyze sample questions, so that the trained question analysis model has question parsing capabilities, which expands the usage scenarios of large models, and facilitates the use of the question parsing capabilities of the trained question analysis model to analyze questions, so as to accurately generate graphics corresponding to the questions based on the category analysis results, component analysis results, component attribute analysis results, and component position analysis results obtained by the analysis, thereby achieving fast and accurate generation of graphics corresponding to the questions and improving the efficiency and accuracy of question setting.
[0055] In another embodiment, if Figure 5 As shown, the training method of the question analysis model provided by the embodiment of the present invention includes: S501, obtaining a pre-trained question analysis model and preset prompt information.
[0056] The preset prompt information may include: category prompt information, component prompt information, component attribute prompt information and component location prompt information.
[0057] S502, obtaining sample titles and annotation attributes corresponding to the sample titles.
[0058] The annotation attributes corresponding to the sample title may include: category, component, component attribute and component position.
[0059] The implementation process of step S501 to step 502 may refer to the implementation process of step S401 to step S402 described above.
[0060] S503, adding a weight matrix to the pre-trained question analysis model and initializing the weight matrix.
[0061] In the embodiment of the present invention, the obtained sample questions and the annotation attributes corresponding to the sample questions can be used to adopt the LORA method to fine-tune the pre-trained question analysis model to obtain a trained question analysis model.
[0062] like Figure 6As shown, a bypass can be added next to the parameters of the pre-trained question analysis model. The bypass is represented by a weight matrix, and the dimension of the weight matrix is the same as the dimension of the parameters of the pre-trained question analysis model. Among them, the input of the pre-trained question analysis model is represented as x, the output is represented as h, and the initial weight matrix is a 0 matrix.
[0063] In a possible implementation, a weight matrix may be added to a specified portion of a pre-trained question analysis model, and the weight matrix may be initialized.
[0064] In practical applications, the parameters of the pre-trained question analysis model can be taken as a whole, and a weight matrix can be added next to the parameters of the pre-trained question analysis model. The weight matrix can also be added next to the specified parts of the pre-trained question analysis model, such as the encoding layer of the encoder, the fully connected layer of the decoder, or each linear layer.
[0065] Take adding a weight matrix to a specified part as an example. The weight matrix includes a dimension reduction matrix A and a dimension increase matrix B. Accordingly, a dimension reduction and dimension increase operation can be performed according to the output dimension of the specified part of the pre-trained question analysis model to obtain the dimension reduction matrix and the dimension increase matrix. A bypass including the dimension reduction matrix and the dimension increase matrix is added to the specified part of the pre-trained question analysis model, and the dimension reduction matrix is initialized using a random Gaussian distribution, and the dimension increase matrix is initialized using a zero matrix.
[0066] Exemplarily, the output dimension of the designated part of the pre-trained question analysis model is d×d. An operation of reducing the dimension from d to r and then increasing the dimension from r to d is performed to simulate the intrinsic rank of the pre-trained question analysis model, and a dimension reduction matrix A of r×d and a dimension increase matrix B of d×r are obtained, that is, the parameter quantity is reduced from d×d to d×r+d×r, where r is generally 2, 4, 8 or 16, which is much smaller than d, which greatly reduces the parameter quantity. A bypass containing the dimension reduction matrix A and the dimension increase matrix B is added to the designated part of the pre-trained question analysis model. Figure 6 In , the bypass weight matrix can be expressed as BA, where BA represents the dot product of B and A. The dimension reduction matrix A is initialized using a random Gaussian distribution, and the dimension increase matrix B is initialized using a zero matrix to ensure that the bypass weight matrix BA is a zero matrix at the beginning of fine-tuning training.
[0067] S504, input the sample question and preset prompt information into the pre-trained question analysis model to obtain the attribute prediction result corresponding to the sample question.
[0068] The attribute prediction results may include: category prediction results corresponding to the category prompt information, component prediction results corresponding to the component prompt information, component attribute prediction results corresponding to the component attribute prompt information, and component position prediction results corresponding to the component position prompt information. The implementation process of this step may refer to the implementation process of the above step S403.
[0069] S505, calculating the loss between the attribute prediction result and the labeled attribute, and adjusting the parameters of the weight matrix according to the loss to obtain a trained question analysis model.
[0070] In one possible implementation, the parameters of the pre-trained question analysis model are kept unchanged, the loss between the attribute prediction result and the labeled attribute is calculated, and the parameters of the weight matrix are adjusted according to the loss until the learning rate of the weight matrix meets the convergence condition, and then the parameters of the pre-trained question analysis model are updated using the parameters of the weight matrix to obtain a trained question analysis model.
[0071] When fine-tuning the pre-trained question analysis model using the LORA method, keep the parameters of the pre-trained question analysis model unchanged, calculate the loss between the attribute prediction result output by the pre-trained question analysis model and the labeled attribute, adjust the parameters of the dimension reduction matrix A and the dimension increase matrix B according to the loss, until the difference between the learning rate of the dimension reduction matrix A and the dimension increase matrix B and the preset learning rate meets the set threshold, and then update the parameters of the pre-trained question analysis model to the superposition of the parameters of the pre-trained question analysis model and the value BA of the weight matrix, and obtain the trained question analysis model. Among them, the preset learning rate can be set to 1, and the set threshold can be set according to needs.
[0072] Exemplarily, the parameters of the pre-trained question analysis model are represented as W0, the input is represented as x, and the output is represented as h, then h= W0x+BAx. When fine-tuning the pre-trained question analysis model, W0 is kept unchanged, and the dimensionality reduction matrix A and the dimensionality increase matrix B are adjusted according to the loss between the attribute prediction results output by the pre-trained question analysis model and the labeled attributes, that is, BA is the parameter that needs to be updated and is the object to be fine-tuned.
[0073] After obtaining the trained question analysis model, the trained question analysis model is deployed in the electronic device through the container Docker, so as to use the trained question analysis model to parse the questions that need to generate graphics, and further generate corresponding graphics.
[0074] In the embodiment of the present invention, the pre-trained question analysis model is combined with the preset prompt information to train the question analysis model, and the LORA method is used to fine-tune the pre-trained question analysis model. During the training process, only the parameters in the dimension reduction matrix A and the dimension increase matrix B need to be fine-tuned, which greatly reduces the time and data processing amount of model training. The preset prompt information is used to effectively guide the pre-trained question analysis model to analyze the sample questions, so that the trained question analysis model has the question parsing ability, expands the use scenario of the large model, and is convenient to use the question parsing ability of the trained question analysis model to analyze the questions, so as to accurately generate the graphics corresponding to the questions according to the category analysis results, component analysis results, component attribute analysis results and component position analysis results obtained by the analysis, so as to achieve the rapid and accurate generation of the graphics corresponding to the questions, and improve the efficiency and accuracy of the questions. In addition, the LORA method is used to fine-tune the pre-trained question analysis model. Because only the parameters in the dimension reduction matrix A and the dimension increase matrix B need to be fine-tuned during the training process, the task switching can be achieved by fine-tuning BA when the model task changes.
[0075] Corresponding to the above method embodiments, the embodiments of the present invention also provide corresponding device embodiments.
[0076] See also Figure 7 The embodiment of the present invention further provides a graphics generation device, the device comprising: The first acquisition module 701 is used to acquire a target topic and target prompt information; the target prompt information includes: category prompt information, component prompt information, component attribute prompt information and component location prompt information; The first topic analysis module 702 is used to input the target topic and the target prompt information into a pre-trained topic analysis model to obtain a category analysis result corresponding to the category prompt information, a component analysis result corresponding to the component prompt information, a component attribute analysis result corresponding to the component attribute prompt information, and a component position analysis result corresponding to the component position prompt information; The graphic generation module 703 is used to generate a graphic corresponding to the target topic by using the category analysis results, component analysis results, component attribute analysis results and component position analysis results.
[0077] Optionally, the above-mentioned topic analysis model includes: an encoder and a decoder; a first topic analysis module 702, which is specifically used to: Input the target question and the category prompt information into a pre-trained question analysis model, use an encoder to encode the target question and the category prompt information to obtain a first feature vector and a second feature vector, and use a decoder to decode the first feature vector and the second feature vector to obtain a category analysis result corresponding to the category prompt information; Input the target question and component prompt information into a pre-trained question analysis model, use an encoder to encode the target question and component prompt information to obtain a first feature vector and a third feature vector, use a decoder to decode the first feature vector and the third feature vector, and obtain a component analysis result corresponding to the component prompt information; Input the target topic and the component attribute prompt information into a pre-trained topic analysis model, use an encoder to encode the target topic and the component attribute prompt information to obtain a first feature vector and a fourth feature vector, use a decoder to decode the first feature vector and the fourth feature vector, and obtain a component attribute analysis result corresponding to the component attribute prompt information; The target question and component position prompt information are input into a pre-trained question analysis model, and the target question and component position prompt information are respectively encoded by an encoder to obtain a first eigenvector and a fifth eigenvector. The first eigenvector and the fifth eigenvector are decoded by a decoder to obtain a component position analysis result corresponding to the component position prompt information.
[0078] Optionally, the above-mentioned topic analysis model includes: an encoder and four decoders; a first topic analysis module 702, specifically used for: Input the target topic and category prompt information, component prompt information, component attribute prompt information, and component position prompt information into a pre-trained topic analysis model, and use an encoder to encode the target topic and category prompt information, component prompt information, component attribute prompt information, and component position prompt information, respectively, to obtain a first eigenvector, a second eigenvector, a third eigenvector, a fourth eigenvector, and a fifth eigenvector; Decoding the first feature vector and the second feature vector using the first decoder to obtain a category analysis result corresponding to the category prompt information; Decoding the first feature vector and the third feature vector using the second decoder to obtain a component analysis result corresponding to the component prompt information; Decoding the first feature vector and the fourth feature vector using a third decoder to obtain a component attribute analysis result corresponding to the component attribute prompt information; The first feature vector and the fifth feature vector are decoded by using the fourth decoder to obtain a component position analysis result corresponding to the component position prompt information.
[0079] Optionally, the above-mentioned category analysis results include: one-dimensional graphics, two-dimensional graphics, three-dimensional graphics or other graphics; the component analysis results include: at least one of arrows, shapes, positions, styles, styles, matrices, tables, graphics, trees, mind maps, backgrounds and adaptations; the component attribute analysis results include: at least one of basic shape attributes, style attributes, text attributes, node attributes, rectangles, circles, stars, arrow attributes, line types, colors, layers, coordinates and loops; the component position analysis results include: at least one of coordinate representation, node representation and path representation.
[0080] Optionally, the graphic generation module 703 is specifically used to call a preset graphic generation tool to generate a graphic corresponding to the target topic based on the category analysis result, the component analysis result, the component property analysis result and the component position analysis result.
[0081] See also Figure 8 The embodiment of the present invention also provides a training device for a question analysis model, the device comprising: The second acquisition module 801 is used to acquire a pre-trained topic analysis model and preset prompt information; the preset prompt information includes: category prompt information, component prompt information, component attribute prompt information and component location prompt information; The third acquisition module 802 is used to obtain sample titles and the annotated attributes corresponding to the sample titles; the annotated attributes include: category, component, component attribute and component position; The second topic analysis module 803 is used to input the sample topic and the preset prompt information into the pre-trained topic analysis model to obtain the attribute prediction result corresponding to the sample topic, and the attribute prediction result includes: the category prediction result corresponding to the category prompt information, the component prediction result corresponding to the component prompt information, the component attribute prediction result corresponding to the component attribute prompt information, and the component position prediction result corresponding to the component position prompt information; The model training module 804 is used to calculate the loss between the attribute prediction result and the labeled attribute, and adjust the parameters of the pre-trained question analysis model according to the loss to obtain a trained question analysis model.
[0082] Optionally, the above device further includes: The initialization module is used to add a weight matrix to the pre-trained question analysis model and initialize the weight matrix; The model training module 804 is specifically used to calculate the loss between the attribute prediction result and the labeled attribute, and adjust the parameters of the weight matrix according to the loss to obtain a trained question analysis model.
[0083] Optionally, the initialization module is specifically used to add a weight matrix to a specified part of the pre-trained question analysis model and initialize the weight matrix; The model training module 804 is specifically used to keep the parameters of the pre-trained question analysis model unchanged, calculate the loss between the attribute prediction result and the labeled attribute, and adjust the parameters of the weight matrix according to the loss until the learning rate of the weight matrix meets the convergence condition; use the parameters of the weight matrix to update the parameters of the pre-trained question analysis model to obtain a trained question analysis model.
[0084] Optionally, the weight matrix includes a dimension reduction matrix and a dimension increase matrix; the initialization module is specifically used for: According to the output dimension of the specified part of the pre-trained question analysis model, a dimension reduction and then dimension increase operation is performed to obtain a reduced dimension matrix and an increased dimension matrix; Add a bypass containing a dimensionality reduction matrix and a dimensionality increase matrix to the specified part of the pre-trained question analysis model; The reduced-dimensional matrix is initialized with a random Gaussian distribution, and the increased-dimensional matrix is initialized with a zero matrix.
[0085] The embodiment of the present invention further provides an electronic device, such as Fig. 9 As shown, it includes a processor 901 , a communication interface 902 , a memory 903 and a communication bus 904 , wherein the processor 901 , the communication interface 902 , and the memory 903 communicate with each other via the communication bus 904 .
[0086] Memory 903, used for storing computer programs; The processor 901 is used to implement the steps of any of the above-mentioned graphics generation methods or question analysis model training methods when executing the program stored in the memory 903 to achieve the same technical effect.
[0087] The communication bus mentioned in the above electronic device can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0088] The communication interface is used for communication between the above electronic device and other devices.
[0089] The memory may include a random access memory (RAM) or a non-volatile memory (NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.
[0090] 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 gate or transistor logic devices, discrete hardware components.
[0091] In another embodiment provided by the present invention, a computer-readable storage medium is also provided, which stores a computer program. When the computer program is executed by a processor, it implements the steps of any of the above-mentioned graphics generation methods or question analysis model training methods to achieve the same technical effect.
[0092] In another embodiment provided by the present invention, a computer program product comprising instructions is also provided. When the computer is run on a computer, the computer executes the steps of any of the graphics generation methods or question analysis model training methods in the above embodiments to achieve the same technical effect.
[0093] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented by software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from one website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state drive Solid State Disk (SSD)), etc.
[0094] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0095] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device / electronic device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0096] The above description is only a preferred embodiment of the present invention and is not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.
Claims
1. A method for generating a graph, characterized in that: The method comprises: Obtaining a target title and target prompt information; the target prompt information includes: category prompt information, component prompt information, component attribute prompt information, and component location prompt information; Input the target topic and the target prompt information into a pre-trained topic analysis model to obtain a category analysis result corresponding to the category prompt information, a component analysis result corresponding to the component prompt information, a component attribute analysis result corresponding to the component attribute prompt information, and a component position analysis result corresponding to the component position prompt information; A graphic corresponding to the target topic is generated using the category analysis result, the component analysis result, the component attribute analysis result, and the component position analysis result.
2. The method according to claim 1, characterized in that The topic analysis model includes: an encoder and a decoder; the target topic and the target prompt information are input into a pre-trained topic analysis model to obtain a category analysis result corresponding to the category prompt information, a component analysis result corresponding to the component prompt information, a component attribute analysis result corresponding to the component attribute prompt information, and a component position analysis result corresponding to the component position prompt information, including: Inputting the target topic and the category prompt information into a pre-trained topic analysis model, using the encoder to encode the target topic and the category prompt information to obtain a first feature vector and a second feature vector, and using the decoder to decode the first feature vector and the second feature vector to obtain a category analysis result corresponding to the category prompt information; Inputting the target topic and the component prompt information into a pre-trained topic analysis model, using the encoder to encode the target topic and the component prompt information to obtain a first feature vector and a third feature vector, and using the decoder to decode the first feature vector and the third feature vector to obtain a component analysis result corresponding to the component prompt information; Inputting the target topic and the component attribute prompt information into a pre-trained topic analysis model, using the encoder to encode the target topic and the component attribute prompt information to obtain a first feature vector and a fourth feature vector, and using the decoder to decode the first feature vector and the fourth feature vector to obtain a component attribute analysis result corresponding to the component attribute prompt information; The target title and the component position prompt information are input into a pre-trained title analysis model, the encoder is used to encode the target title and the component position prompt information to obtain a first feature vector and a fifth feature vector, and the decoder is used to decode the first feature vector and the fifth feature vector to obtain a component position analysis result corresponding to the component position prompt information.
3. The method according to claim 1, characterized in that The topic analysis model includes: an encoder and four decoders; the target topic and the target prompt information are input into a pre-trained topic analysis model to obtain a category analysis result corresponding to the category prompt information, a component analysis result corresponding to the component prompt information, a component attribute analysis result corresponding to the component attribute prompt information, and a component position analysis result corresponding to the component position prompt information, including: Input the target topic and the category prompt information, the component prompt information, the component attribute prompt information, and the component position prompt information into a pre-trained topic analysis model, and use the encoder to encode the target topic and the category prompt information, the component prompt information, the component attribute prompt information, and the component position prompt information, respectively, to obtain a first eigenvector, a second eigenvector, a third eigenvector, a fourth eigenvector, and a fifth eigenvector; Decoding the first feature vector and the second feature vector using a first decoder to obtain a category analysis result corresponding to the category prompt information; Decoding the first feature vector and the third feature vector using a second decoder to obtain a component analysis result corresponding to the component prompt information; Decoding the first feature vector and the fourth feature vector using a third decoder to obtain a component attribute analysis result corresponding to the component attribute prompt information; The first feature vector and the fifth feature vector are decoded by using a fourth decoder to obtain a component position analysis result corresponding to the component position prompt information.
4. The method according to any one of claims 1 to 3, characterized in that: The category analysis results include: one-dimensional graphics, two-dimensional graphics, three-dimensional graphics or other graphics; the component analysis results include: at least one of arrows, shapes, positions, styles, styles, matrices, tables, graphics, trees, mind maps, backgrounds and adaptations; the component attribute analysis results include: at least one of basic shape attributes, style attributes, text attributes, node attributes, rectangles, circles, stars, arrow attributes, line types, colors, layers, coordinates and loops; the component position analysis results include: at least one of coordinate representation, node representation and path representation; The step of generating a graph corresponding to the target topic by using the category analysis result, the component analysis result, the component attribute analysis result, and the component position analysis result includes: Based on the category analysis result, the component analysis result, the component property analysis result and the component position analysis result, a preset graphic generation tool is called to generate a graphic corresponding to the target topic.
5. A training method for a question analysis model, characterized in that: The method comprises: Obtaining a pre-trained topic analysis model and preset prompt information; the preset prompt information includes: category prompt information, component prompt information, component attribute prompt information, and component location prompt information; Obtaining sample titles and annotation attributes corresponding to the sample titles; the annotation attributes include: category, component, component attribute and component position; Input the sample topic and the preset prompt information into the pre-trained topic analysis model to obtain the attribute prediction result corresponding to the sample topic, the attribute prediction result including: the category prediction result corresponding to the category prompt information, the component prediction result corresponding to the component prompt information, the component attribute prediction result corresponding to the component attribute prompt information, and the component position prediction result corresponding to the component position prompt information; The loss between the attribute prediction result and the labeled attribute is calculated, and the parameters of the pre-trained question analysis model are adjusted according to the loss to obtain a trained question analysis model.
6. The method according to claim 5, characterized in that The method further comprises: Adding a weight matrix to the pre-trained question analysis model and initializing the weight matrix; The calculating the loss between the attribute prediction result and the labeled attribute, and adjusting the parameters of the pre-trained question analysis model according to the loss to obtain a trained question analysis model, includes: The loss between the attribute prediction result and the labeled attribute is calculated, and the parameters of the weight matrix are adjusted according to the loss to obtain a trained question analysis model.
7. The method according to claim 6, characterized in that The step of adding a weight matrix to the pre-trained question analysis model and initializing the weight matrix includes: Adding a weight matrix to a designated part of the pre-trained question analysis model and initializing the weight matrix; The calculating the loss between the attribute prediction result and the labeled attribute, and adjusting the parameters of the weight matrix according to the loss to obtain a trained question analysis model, includes: Keeping the parameters of the pre-trained question analysis model unchanged, calculating the loss between the attribute prediction result and the labeled attribute, and adjusting the parameters of the weight matrix according to the loss until the learning rate of the weight matrix meets the convergence condition; The parameters of the pre-trained question analysis model are updated using the parameters of the weight matrix to obtain a trained question analysis model.
8. The method according to claim 7, characterized in that The weight matrix includes a dimension reduction matrix and a dimension increase matrix; The step of adding a weight matrix to a designated part of the pre-trained question analysis model and initializing the weight matrix includes: According to the output dimension of the designated part of the pre-trained question analysis model, a dimension reduction and then dimension increase operation is performed to obtain the dimension reduction matrix and the dimension increase matrix; Adding a bypass including the dimension reduction matrix and the dimension increase matrix at a designated position of the pre-trained question analysis model; The reduced-dimensional matrix is initialized using a random Gaussian distribution, and the increased-dimensional matrix is initialized using a zero matrix.
9. A graphics generating device, characterized in that: The device comprises: The first acquisition module is used to acquire a target topic and target prompt information; the target prompt information includes: category prompt information, component prompt information, component attribute prompt information and component location prompt information; A first topic analysis module is used to input the target topic and the target prompt information into a pre-trained topic analysis model to obtain a category analysis result corresponding to the category prompt information, a component analysis result corresponding to the component prompt information, a component attribute analysis result corresponding to the component attribute prompt information, and a component position analysis result corresponding to the component position prompt information; A graphics generation module is used to generate a graphics corresponding to the target topic by using the category analysis result, the component analysis result, the component attribute analysis result and the component position analysis result.
10. A training device for a question analysis model, characterized in that: The device comprises: The second acquisition module is used to acquire a pre-trained topic analysis model and preset prompt information; the preset prompt information includes: category prompt information, component prompt information, component attribute prompt information and component location prompt information; A third acquisition module is used to acquire sample titles and the annotation attributes corresponding to the sample titles; the annotation attributes include: category, component, component attribute and component position; A second topic analysis module is used to input the sample topic and the preset prompt information into the pre-trained topic analysis model to obtain an attribute prediction result corresponding to the sample topic, wherein the attribute prediction result includes: a category prediction result corresponding to the category prompt information, a component prediction result corresponding to the component prompt information, a component attribute prediction result corresponding to the component attribute prompt information, and a component position prediction result corresponding to the component position prompt information; The model training module is used to calculate the loss between the attribute prediction result and the labeled attribute, and adjust the parameters of the pre-trained question analysis model according to the loss to obtain a trained question analysis model.
Citation Information
Patent Citations
Data processing method, computer storage medium and related equipment
CN111260516A
System and method for analyzing market research data based on AI model
CN116579806A
Text data intelligent analysis method, device and equipment
CN117236315A
Image generation method, device and equipment
CN117635772A
Text data analysis processing method and system and electronic equipment
CN117764056A
