Atlas-based prompt recommendation method and device, equipment and medium
By constructing a graph-based prompt recommendation method, the problems of low quality and efficiency in prompt generation and optimization in medical consultation platforms are solved, achieving higher quality and more efficient prompt recommendations, and improving the accuracy and efficiency of online consultations.
Patent Information
- Application Number
- CN202310834806.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-07
- Publication Date
- 2025-11-28
- Estimated Expiration
- 2043-07-07
AI Technical Summary
Existing prompt generation and optimization methods have low quality and efficiency in medical consultation platforms, and cannot effectively utilize the potential of pre-trained language models.
We construct a graph-based prompt recommendation method. By acquiring a pre-defined prompt library and a pre-trained language model set, we perform graph construction, knowledge enhancement, and learning to match user input information to obtain the optimal prompt.
It improves the quality and generation efficiency of prompts, enhances the accuracy and efficiency of online consultation functions, and provides more suitable prompts and attribute recommendations.
Smart Images

Figure CN116821373B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of artificial intelligence and digital medical technology, and in particular to a prompt recommendation method and device based on a graph, an electronic device and a computer readable storage medium. BACKGROUND
[0002] Prompt learning is a method of using a pre-trained language model (PLM) to complete different tasks without retraining or fine-tuning the PLM. The core of prompt learning is to design a suitable prompt, which is a specific input format used to guide the PLM to produce the desired output. For example, in the online consultation function of a medical consultation platform, due to the limited resources of professional doctors, most medical problems are concentrated on common problems such as colds and fever. These common medical problems have already been answered and are very meaningful for reference. By analyzing existing medical question and answer data, a prompt learning method can be used to quickly provide feedback answers to patients' questions for reference. A pre-trained language model (PLM) can be used to complete this task, and a prompt learning method can reduce the training cost and data requirements of the model.
[0003] Currently, there are some open-source frameworks and tools that provide implementation and support for prompt learning, such as OpenPrompt. These frameworks and tools usually provide some pre-defined or hand-crafted prompts for users to choose or modify, and also provide some methods or interfaces to automatically or semi-automatically generate or optimize prompts, such as gradient descent, reinforcement learning, and meta-learning. However, the current methods of generating and optimizing prompts are not intelligent and flexible enough, resulting in low quality and efficiency of prompt generation. SUMMARY
[0004] The present application provides a prompt recommendation method and device based on a graph and a computer readable storage medium, which mainly aims to solve the problem of low quality and efficiency of prompt generation and optimization for medical question and answer models in medical consultation platforms.
[0005] To achieve the above purpose, the present application provides a prompt recommendation method based on a graph, which comprises:
[0006] Obtaining a preset prompt library and a corresponding set of pre-trained language models, and constructing a graph set according to the preset prompt library and the set of pre-trained language models;
[0007] Obtaining external knowledge data, converting the external knowledge data into preset format knowledge information, using the preset format knowledge information to enhance the knowledge of the graph set, and obtaining an enhanced graph set;
[0008] Performing graph learning on the enhanced graph set to obtain an optimized graph set;
[0009] Obtaining user input information, and matching the optimal prompt corresponding to the user input information from the optimized graph set according to the user input information.
[0010] Optionally, the constructing a graph set according to the preset prompt prompt library and the pre-trained language model set comprises:
[0011] Taking a prompt in the preset prompt prompt library as a prompt node;
[0012] Taking a pre-trained language model in the language model set as a PLM node;
[0013] Extracting a prompt corresponding to the prompt node and a PLM corresponding to the PLM node, and taking the prompt and the PLM as a prompt-PLM edge;
[0014] Extracting the relationship between each prompt node, and taking the relationship between each prompt node as a prompt-prompt edge;
[0015] According to the prompt node, the PLM node, the prompt-PLM edge and the prompt-prompt edge, using a preset graph drawing tool to construct a graph set.
[0016] Optionally, the converting the external knowledge data into preset format knowledge information comprises:
[0017] Extracting text information related to a prompt in the preset prompt prompt library from the knowledge data;
[0018] Extracting entity words, entity word attributes, relationship words and relationship word attributes in the text information;
[0019] Constructing the entity words, the entity word attributes, the relationship words and the relationship word attributes into knowledge information in a preset format of a triple.
[0020] Optionally, the using the preset format knowledge information to enhance the knowledge of the graph set to obtain an enhanced graph set comprises:
[0021] match the entity vocabulary and the entity vocabulary attribute in the preset format knowledge information with nodes in the graph set and attributes corresponding to the nodes, to obtain an entity matching degree and an attribute matching degree;
[0022] align the entity vocabulary and the entity vocabulary attribute with the entity matching degree and the attribute matching degree greater than or equal to a preset matching threshold to the nodes in the graph set;
[0023] add the entity vocabulary and the entity vocabulary attribute with the entity matching degree and the attribute matching degree less than the preset matching threshold as new nodes of a corresponding graph in the graph set, and add the relationship vocabulary and the relationship vocabulary attribute corresponding to the entity vocabulary as new edges to the corresponding graph, to obtain an enhanced graph set.
[0024] Optionally, the graph learning on the enhanced graph set to obtain an optimized graph set comprises:
[0025] encoding each graph corresponding edge and node in the enhanced graph set to obtain a node feature vector set and an edge feature vector set;
[0026] randomly selecting a node feature vector in the node feature vector set as a first starting node feature vector, and performing information transmission on the first starting node feature vector according to an edge feature vector corresponding to the first starting node feature vector to obtain a dynamic vector feature;
[0027] updating a next node feature vector corresponding to the edge feature vector by using the dynamic vector feature, until all node feature vectors in the corresponding graph are updated, to obtain an updated graph;
[0028] randomly selecting a node feature vector in the updated graph as a second starting feature vector, and predicting attributes of a next node and attributes of a corresponding edge according to the second starting feature vector, corresponding node attributes and a corresponding edge feature vector, until attributes of all nodes and edges in the corresponding graph are predicted, to obtain an optimized graph.
[0029] Optionally, the matching of the optimal prompt corresponding to the user input information from the optimized graph set according to the user input information comprises:
[0030] calculating semantic similarity of the user input information and nodes and edges of the optimized graph set to obtain a node similarity score and an edge similarity score;
[0031] constructing a graph query statement according to attributes of the user input information and nodes and edges in the optimized graph set, and querying the optimized graph set according to the graph query statement to obtain a prompt candidate set;
[0032] identify the needs and preferences of the user input information;
[0033] According to the needs, the preferences, the node similarity score and the edge similarity score, the prompt candidate set is sorted to obtain a prompt ranking set;
[0034] The user input information is subjected to intent recognition to obtain the target of the user, and the optimal prompt is matched from the prompt ranking set according to the target.
[0035] Optionally, the calculation of the node semantic similarity between the user input information and the optimized graph set obtains a node similarity score, comprising:
[0036] The user input information is subjected to word segmentation to obtain an input word sequence;
[0037] The input word sequence is subjected to vector conversion to obtain a user feature vector sequence;
[0038] The node feature vectors of each node in the optimized graph set are extracted;
[0039] The semantic similarity between each user feature vector in the user feature vector sequence and the node feature vector is calculated to obtain a node similarity score.
[0040] To solve the above problems, the present application also provides a prompt recommendation device based on a graph, the device comprising:
[0041] A graph construction module is configured to obtain a preset prompt library and a corresponding pre-trained language model set, and construct a graph set according to the preset prompt library and the pre-trained language model set;
[0042] A graph enhancement module is configured to obtain external knowledge data, convert the external knowledge data into preset format knowledge information, and use the preset format knowledge information to enhance the graph set to obtain an enhanced graph set;
[0043] A graph optimization module is configured to perform graph learning on the enhanced graph set to obtain an optimized graph set;
[0044] A graph recommendation module is configured to obtain user input information, and match the optimal prompt corresponding to the user input information from the optimized graph set according to the user input information.
[0045] To solve the above problems, the present application also provides an electronic device, comprising:
[0046] At least one processor; and,
[0047] A memory in communication connection with the at least one processor; wherein
[0048] The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor to enable the at least one processor to perform the above-mentioned atlas-based prompt recommendation method.
[0049] To solve the above problems, the present application also provides a computer readable storage medium, the computer readable storage medium stores at least one computer program, and the at least one computer program is executed by a processor in an electronic device to implement the above-mentioned atlas-based prompt recommendation method.
[0050] The embodiment of the present application constructs an atlas set according to the preset prompt library and the pre-trained language model set, represents prompts and pre-trained language models (PLMs) as nodes, and represents the relationship between prompts and the relationship between prompts and PLMs as edges, so that the recommended prompts have higher quality; further, the external knowledge data is converted into preset format knowledge information, the atlas set is knowledge enhanced by using the preset format knowledge information, an enhanced atlas set is obtained, the atlas set is expanded, the content and expression of prompts and related attributes of the atlas set are enriched, the prompts are more perfect and have higher quality; further, the enhanced atlas set is atlas learned to obtain an optimized atlas set, so that the atlas is more accurate, and the quality and efficiency of the pre-trained language model corresponding to the prompt of the online consultation function are improved; finally, the optimal prompt corresponding to the user input information is matched from the optimized atlas set according to the user input information, the appropriate prompt and corresponding attribute are quickly provided for the user, and the efficiency of prompt acquisition is improved. Therefore, the atlas-based prompt recommendation method, device, electronic device and computer readable storage medium provided by the present application can solve the problems of low generation and optimization quality and efficiency of the prompt corresponding to the medical question and answer model in the medical field. BRIEF DESCRIPTION OF DRAWINGS
[0051] Figure 1 The flowchart of the atlas-based prompt recommendation method provided by an embodiment of the present application is shown in the figure;
[0052] Figure 2 For Figure 1 The detailed implementation flowchart of one of the steps in the atlas-based prompt recommendation method shown in the figure is shown in the figure;
[0053] Figure 3 ForFigure 1 A detailed implementation process schematic diagram of another step in the atlas-based prompt recommendation method shown;
[0054] Figure 4 A functional module diagram of the atlas-based prompt recommendation device provided for an embodiment of the present application;
[0055] Figure 5 A structural schematic diagram of an electronic device for implementing the atlas-based prompt recommendation method provided for an embodiment of the present application.
[0056] The implementation, functional features and advantages of the present application will be further described with reference to the embodiments and the accompanying drawings. DETAILED DESCRIPTION
[0057] It should be understood that the specific embodiments described herein are merely intended to explain the present application, and are not intended to limit the present application.
[0058] The embodiment of the present application provides an atlas-based prompt recommendation method. An execution subject of the atlas-based prompt recommendation method includes but is not limited to at least one of electronic devices such as a server and a terminal, which can be configured to execute the method provided by the embodiment of the present application. In other words, the atlas-based prompt recommendation method can be executed by software or hardware installed in a terminal device or a server device, and the software can be a blockchain platform. The server includes but is not limited to a single server, a server cluster, a cloud server or a cloud server cluster, etc. The server can be a stand-alone server, or a cloud server providing cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content distribution networks (CDN), and big data and artificial intelligence platforms, etc. basic cloud computing services.
[0059] Referring to Figure 1 As shown in the figure, a flowchart of the atlas-based prompt recommendation method provided for an embodiment of the present application. In this embodiment, the atlas-based prompt recommendation method includes:
[0060] S1, obtain a preset prompt library and a corresponding pre-training language model set, and construct an atlas set according to the preset prompt library and the pre-training language model set.
[0061] In the embodiment of the present application, the preset prompt library is a prompt corresponding to natural language processing tasks such as text classification, text generation, and text summary.
[0062] In the embodiment of the present application, the pre-trained language model is trained in a self-supervised manner on a large corpus. The pre-trained language model can be used for text classification, text generation, text summarization, question and answer systems, etc. The prompt learning method can reduce the training cost and data requirement of the model.
[0063] In detail, in S1, the graph set is constructed according to the preset prompt prompt library and the pre-trained language model set, including:
[0064] The prompt in the preset prompt prompt library is taken as a prompt node;
[0065] The pre-trained language model in the language model set is taken as a PLM node;
[0066] The prompt corresponding to the prompt node and the PLM corresponding to the PLM node are extracted, and the prompt and the PLM relationship are taken as a prompt-PLM edge;
[0067] The relationship between each prompt node is extracted, and the relationship between each prompt node is taken as a prompt-prompt edge;
[0068] According to the prompt node, the PLM node, the prompt-PLM edge and the prompt-prompt edge, a preset graph drawing tool is used to construct a graph set.
[0069] In the embodiment of the present application, the graph in the graph set is composed of nodes and edges, including prompt nodes, PLM nodes, prompt-PLM edges and prompt-prompt edges.
[0070] In one embodiment of the present application, the prompt node represents a specific prompt and includes, but is not limited to, the following attributes: (1) id, which represents the unique identifier of the prompt node in the graph; (2) task_type, which represents the task type corresponding to the prompt, such as the question and answer task type of analyzing existing medical question and answer data in a medical consultation platform to provide a quick feedback answer to the patient's question for the patient's reference; (3) domain, which represents the field or topic corresponding to the prompt, such as natural language processing, computer vision, medical health, etc.; (4) template, which represents the input format or pattern adopted by the prompt, which can be fixed or dynamic. For example, "What is the capital of [MASK]?" is a fixed template, and "[MASK] is a type of [MASK]." is a dynamic template; (5) initialization, which represents the initialization strategy or method adopted by the prompt, which can be random or supervised. For example, "[CLS] [MASK] [SEP]" is a random initialization, and "[CLS] The answer is [MASK]. [SEP]" is a supervised initialization; (6) verbalization, which represents the semanticization strategy or method adopted by the prompt, which can be explicit or implicit. For example, "[CLS] The answer is [MASK]. [SEP]" is an explicit semanticization, and "[CLS] [MASK] [SEP]" is an implicit semanticization.
[0071] In one embodiment of the present application, the PLM node represents a specific pre-trained language model, including but not limited to the following attributes: (1) id, which represents the unique identifier of the PLM node in the graph. (2) name, which represents the name or code of the PLM corresponding to the PLM node, such as BERT, GPT-3, XLNet, etc. (3) size, which represents the size or parameter amount of the PLM corresponding to the PLM node, such as base, large, xlarge, etc. (4) architecture, which represents the architecture or model type of the PLM corresponding to the PLM node, such as Transformer, RNN, CNN, etc. (5) pretraining_data, which represents the source or type of pre-training data of the PLM corresponding to the PLM node, such as Wikipedia, Common Crawl, BooksCorpus, etc. (6) pretraining_objective, which represents the pre-training objective or loss function of the PLM corresponding to the PLM node, such as Masked Language Modeling, Next Sentence Prediction, Causal Language Modeling, etc.
[0072] In one embodiment of the present application, the prompt-PLM edge represents the relationship between a specific prompt and a specific PLM, including but not limited to the following attributes: (1) id, which represents the unique identifier of the prompt-PLM edge in the graph. (2) source, which represents the source node of the prompt-PLM edge, i.e. the prompt node. (3) target, which represents the target node of the prompt-PLM edge, i.e. the PLM node. (4) compatibility, which represents the compatibility or adaptability between the prompt and the PLM, which can be binary or continuous. For example, "1" represents complete compatibility, "0" represents complete incompatibility, and "0.8" represents higher compatibility. (5) performance, which represents the performance or performance of the prompt on the PLM, which can be multiple indicators or evaluation methods. For example, "0.9" represents accuracy, "0.8" represents F1 score, "0.7" represents BLEU score, etc.
[0073] In one embodiment of the present application, the prompt-prompt edge represents the relationship between two specific prompts, including but not limited to the following attributes: (1) id, which represents the unique identifier of the prompt-prompt edge in the graph. (2) source, which represents the source node of the prompt-prompt edge, i.e., the prompt node. (3) target, which represents the target node of the prompt-prompt edge, i.e., the prompt node. (4) similarity, which represents the similarity or distance between two prompts, which can be various metrics or calculation methods. For example, "0.9" represents cosine similarity, "0.8" represents Euclidean distance, and "0.7" represents edit distance. (5) transformability, which represents the transformability or variability between two prompts, which can be various rules or algorithms. For example, "[MASK] is a type of [MASK]". can be converted to "[MASK] are a type of [MASK]." by replacing "is" with "are".
[0074] In an embodiment of the present application, a graph set is constructed according to the preset prompt library and the set of pre-trained language models, and the prompt and the pre-trained language model (PLM) are represented as nodes, and the relationship between prompts and the relationship between prompts and PLMs are represented as edges. The association between the prompt and the pre-trained language model (PLM) is strong, so that the quality of the recommended prompt is higher.
[0075] S2, obtain external knowledge data, convert the external knowledge data into preset format knowledge information, use the preset format knowledge information to enhance the knowledge of the graph set, and obtain an enhanced graph set.
[0076] In an embodiment of the present application, the external knowledge data can be data related to medical question and answer in encyclopedias and literature.
[0077] In an embodiment of the present application, the preset format knowledge information can be knowledge information in the format of triplets or key-value pairs.
[0078] In detail, in S2, the external knowledge data is converted into preset format knowledge information, including:
[0079] extracting text information related to prompts in the preset prompt library from the knowledge data;
[0080] extracting entity words, entity word attributes, relationship words, and relationship word attributes from the text information;
[0081] The entity vocabulary, the entity vocabulary attribute, the relation vocabulary and the relation vocabulary attribute are constructed as knowledge information in a preset format of a triple.
[0082] Further, referring to Figure 2 As shown in the figure, the knowledge enhancement of the graph set by using the preset format knowledge information in S2 includes:
[0083] S21, the entity vocabulary and the entity vocabulary attribute in the preset format knowledge information are matched with the nodes in the graph set and the attributes corresponding to the nodes, to obtain an entity matching degree and an attribute matching degree;
[0084] S22, the entity vocabulary and the entity vocabulary attribute with the entity matching degree and the attribute matching degree greater than or equal to a preset matching threshold are aligned with the nodes in the graph set;
[0085] S23, the entity vocabulary and the entity vocabulary attribute with the entity matching degree and the attribute matching degree less than the preset matching threshold are taken as new nodes of the corresponding graph in the graph set, and the relation vocabulary corresponding to the entity vocabulary and the relation vocabulary attribute are added to the corresponding graph as new edges, to obtain an enhanced graph set.
[0086] In one embodiment of the application, the entity vocabulary is "cough" and "white radish", the entity vocabulary attribute is "sputum", the relation vocabulary is "suggested food" and the relation vocabulary attribute is "beneficial". The entity vocabulary "cough" can be added to the "cold" corresponding graph as a new node, and the edge between "cough" and "white radish" is "suggested food", and the edge attribute is "beneficial".
[0087] In the embodiment of the application, the graph set is knowledge enhanced by using external knowledge data, the expansion of the graph set is realized, the content and expression of the prompt and related attributes of the graph set are enriched, and the prompt is more perfect and the quality is higher.
[0088] S3, graph learning is performed on the enhanced graph set to obtain an optimized graph set.
[0089] In detail, referring to Figure 3 As shown in the figure, S3 includes:
[0090] S31, the edges and nodes corresponding to each graph in the enhanced graph set are encoded to obtain a node feature vector set and an edge feature vector set;
[0091] S32, randomly select one node feature vector in the node feature vector set as a first starting node feature vector, perform information transmission on the first starting node feature vector according to the edge feature vector corresponding to the first starting node feature vector, and obtain a dynamic vector feature;
[0092] S33, update the next node feature vector corresponding to the edge feature vector by using the dynamic vector feature, until all node feature vectors in the corresponding graph are updated, and obtain an updated graph;
[0093] S34, randomly select one node feature vector in the updated graph as a second starting feature vector, predict the attributes of the next node and the attributes of the corresponding edge according to the second starting feature vector, the corresponding node attributes and the corresponding edge feature vector, until the attributes of all nodes and edges in the corresponding graph are predicted, and obtain an optimized graph.
[0094] In the embodiment of the application, machine learning methods such as deep neural network (deep neural network), such as graph convolutional network (graph convolutional network), graph attention network (graph attention network), graph variational autoencoder (graph variational autoencoder) can be used to encode the edges and nodes corresponding to each graph in the enhanced graph set, to obtain the node feature vector set and the edge feature vector set.
[0095] In the embodiment of the application, machine learning methods such as deep neural network (deep neural network), such as recurrent neural network (recurrent neural network), long short-term memory network (long short-term memory network), gated recurrent unit network (gated recurrent unit network) can be used to perform information transmission and state update on the nodes (node) and edges (edge) in the graph (graph), to obtain a dynamic vector feature, and further the dynamic vector feature can be spliced with the next node feature vector corresponding to the edge feature vector to update the next node feature vector.
[0096] In the embodiment of the application, a machine learning method such as a deep neural network, for example, a multilayer perceptron, a fully connected network, a residual network, etc., can be used to predict the attributes of the next node and the corresponding edge according to the second initial feature vector, the corresponding node attributes and the corresponding edge feature vector.
[0097] In the embodiment of the application, for a PLM node, the name, size, architecture, pre-training data, pre-training target and other attributes of the PLM node can be predicted; for a prompt-PLM edge, its compatibility and performance relationship can be predicted; for a prompt-prompt edge, its similarity and conversion property can be predicted.
[0098] In the embodiment of the application, the graph atlas learning of encoding, updating and predicting nodes and edges of the enhanced atlas set is performed to obtain an optimized atlas set, thereby improving the quality and efficiency of the prompt and related attributes of the pre-trained language model corresponding to the online consultation function.
[0099] S4, obtaining user input information, and matching the optimal prompt corresponding to the user input information from the optimized atlas set according to the user input information.
[0100] In the embodiment of the application, the user input information is information input by the user according to his own needs, including but not limited to task description, data sample, etc.
[0101] In detail, the matching of the optimal prompt corresponding to the user input information from the optimized atlas set according to the user input information in S4 includes:
[0102] calculating the semantic similarity between the user input information and the nodes and edges of the optimized atlas set to obtain node similarity scores and edge similarity scores;
[0103] constructing a graph query statement according to the user input information and the attributes of the nodes and edges in the optimized atlas set, querying the optimized atlas set according to the graph query statement to obtain a prompt candidate set;
[0104] identifying the needs and preferences of the user input information;
[0105] sorting the prompt candidate set according to the needs, the preferences, the node similarity scores and the edge similarity scores to obtain a prompt sorted set;
[0106] Performing intent recognition on the user input information obtains a target of the user, and an optimal prompt is matched from the prompt ranking set according to the target.
[0107] In the embodiment of the application, the requirement and preference of the user input information can be recognized by using an intent recognition model, and the intent recognition model can be constructed based on a rule template or a deep learning method.
[0108] Further, the node semantic similarity between the user input information and the optimized graph set is calculated to obtain a node similarity score, including:
[0109] The user input information is segmented to obtain an input segmentation sequence;
[0110] The input segmentation sequence is converted into a vector to obtain a user feature vector sequence;
[0111] The node feature vectors of each node in the optimized graph set are extracted;
[0112] The semantic similarity between each user feature vector in the user feature vector sequence and the node feature vector is calculated to obtain a node similarity score.
[0113] In the embodiment of the application, the semantic similarity between each user feature vector in the user feature vector sequence and the node feature vector can be calculated by using cosine similarity to obtain a node similarity score.
[0114] In the embodiment of the application, the user input information is matched with the optimized graph set, and the nodes and edges in the graph are queried or ranked, and the optimal prompt is recommended from the ranking result, so as to quickly provide a suitable prompt and corresponding attribute for a medical question and answer model in a medical field inquiry platform.
[0115] The embodiment of the present application constructs a graph set according to the preset prompt prompt library and the pre-training language model set, represents prompts and pre-training language models (PLMs) as nodes, and represents the relationship between prompts and the relationship between prompts and PLMs as edges, so that the recommended prompt has higher quality; further, the external knowledge data is converted into preset format knowledge information, the graph set is knowledge enhanced by using the preset format knowledge information, and an enhanced graph set is obtained, the graph set is expanded, the content and expression of the prompt and related attributes of the graph set are enriched, the prompt is more perfect and has higher quality; further, the enhanced graph set is graph learned to obtain an optimized graph set, the graph is more accurate, and the quality and efficiency of the prompt and related attributes of the pre-training language model corresponding to the online consultation function are improved; finally, the optimal prompt corresponding to the user input information is matched from the optimized graph set according to the user input information, the appropriate prompt and corresponding attributes are quickly provided for the model, and the efficiency of prompt acquisition is improved. Therefore, the prompt recommendation method based on the graph provided by the present application can solve the generation and optimization quality and efficiency of the prompt corresponding to the medical question and answer model in the medical field consultation platform.
[0116] As Figure 4 shown, it is a functional module diagram of the prompt recommendation device based on the graph provided by an embodiment of the present application.
[0117] The prompt recommendation device based on the graph 100 can be installed in an electronic device. According to the functions to be realized, the prompt recommendation device based on the graph 100 can include a graph construction module 101, a graph enhancement module 102, a graph optimization module 103 and a graph recommendation module 104. The modules of the present application can also be referred to as units, which refer to a series of computer program segments that can be executed by an electronic device processor and can complete fixed functions, and are stored in the memory of the electronic device.
[0118] In the present embodiment, the functions of each module / unit are as follows:
[0119] The graph construction module 101 is configured to obtain a preset prompt prompt library and a corresponding pre-training language model set, and construct a graph set according to the preset prompt prompt library and the pre-training language model set;
[0120] The graph enhancement module 102 is configured to obtain external knowledge data, convert the external knowledge data into preset format knowledge information, and knowledge enhance the graph set by using the preset format knowledge information to obtain an enhanced graph set.
[0121] The atlas optimization module 103 is configured to perform atlas learning on the enhanced atlas set to obtain an optimized atlas set.
[0122] The atlas recommendation module 104 is configured to obtain user input information and match an optimal prompt corresponding to the user input information from the optimized atlas set according to the user input information.
[0123] In detail, each module in the atlas-based prompt recommendation device 100 in the embodiment of the present application adopts the same technical means as the atlas-based prompt recommendation method described in the above Figures 1 to 3 and can produce the same technical effects, which will not be described here.
[0124] As shown in Figure 5 , it is a structural schematic diagram of an electronic device for implementing the atlas-based prompt recommendation method according to an embodiment of the present application.
[0125] The electronic device 1 can include a processor 10, a memory 11, a communication bus 12, and a communication interface 13, and can further include a computer program stored in the memory 11 and executable on the processor 10, such as an atlas-based prompt recommendation program.
[0126] In some embodiments, the processor 10 can be composed of integrated circuits, for example, can be composed of a single packaged integrated circuit, or can be composed of multiple packaged integrated circuits with the same function or different functions, including one or more combinations of central processing units (CPUs), microprocessors, digital processing chips, graphics processors, and various control chips. The processor 10 is the control core of the electronic device, which connects all components of the electronic device through various interfaces and lines, executes programs or modules stored in the memory 11 (such as executing the atlas-based prompt recommendation program), and calls data stored in the memory 11 to perform various functions of the electronic device and process data.
[0127] The memory 11 includes at least one type of readable storage medium, such as a flash memory, a mobile hard disk, a multimedia card, a card-type memory (e.g., an SD or DX memory, etc.), a magnetic memory, a disk, an optical disk, etc. In some embodiments, the memory 11 can be an internal storage unit of an electronic device, such as a mobile hard disk of the electronic device. In other embodiments, the memory 11 can also be an external storage device of the electronic device, such as a plug-in mobile hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. Further, the memory 11 can include both an internal storage unit and an external storage device of the electronic device. The memory 11 can be used not only to store application software and various data installed in the electronic device, such as the code of the prompt recommendation program based on the atlas, but also to temporarily store data that has been output or will be output.
[0128] The communication bus 12 can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. The bus is configured to enable connection and communication between the memory 11 and at least one processor 10, etc.
[0129] The communication interface 13 is used for communication between the electronic device and other devices, including a network interface and a user interface. Optionally, the network interface can include a wired interface and / or a wireless interface (e.g., a WI-FI interface, a Bluetooth interface, etc.), which is usually used to establish a communication connection between the electronic device and other electronic devices. The user interface can be a display (Display), an input unit (such as a keyboard (Keyboard)), and optionally, the user interface can also be a standard wired interface, a wireless interface. Optionally, in some embodiments, the display can be an LED display, a liquid crystal display, a touch liquid crystal display, an OLED (Organic Light-Emitting Diode) touch, etc. The display can also be appropriately referred to as a display screen or a display unit, which is used to display information processed in the electronic device and to display a visualized user interface.
[0130] Figure 5 Only the electronic device with components is shown, and those skilled in the art can understand that, Figure 5The structure shown does not constitute a limitation on the electronic device 1, and can include fewer or more components than shown, or combine certain components, or arrange different components.
[0131] For example, although not shown, the electronic device can also include a power supply (such as a battery) to power the various components. Preferably, the power supply can be logically connected to the at least one processor 10 through a power management device, so that the power management device can implement functions such as charge management, discharge management, and power consumption management. The power supply can also include one or more direct current or alternating current power supplies, recharging devices, power supply fault detection circuits, power supply converters or inverters, power supply status indicators, and any other components. The electronic device can also include various sensors, Bluetooth modules, Wi-Fi modules, and the like, which are not described here.
[0132] It should be understood that the embodiments are only for illustration and are not limited in the scope of the patent application by this structure.
[0133] The atlas-based prompt recommendation program stored in the memory 11 in the electronic device 1 is a combination of multiple instructions, which, when executed in the processor 10, can achieve:
[0134] Obtain a preset prompt library and a corresponding set of pre-trained language models, and construct a graph set according to the preset prompt library and the set of pre-trained language models;
[0135] Obtain external knowledge data, convert the external knowledge data into pre-set format knowledge information, use the pre-set format knowledge information to enhance the graph set with knowledge, and obtain an enhanced graph set;
[0136] Perform graph learning on the enhanced graph set to obtain an optimized graph set;
[0137] Obtain user input information, and match the optimal prompt corresponding to the user input information from the optimized graph set according to the user input information.
[0138] Specifically, the specific implementation method of the processor 10 for the above instructions can refer to the description of the related steps in the corresponding embodiments of the accompanying drawings, which is not described here.
[0139] Further, the modules / units integrated in the electronic device 1 are stored in a computer readable storage medium if they are realized in the form of software function units and sold or used as independent products. The computer readable storage medium can be volatile or non-volatile. For example, the computer readable medium can include any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM).
[0140] The application further provides a computer readable storage medium, which stores a computer program, and the computer program can realize the following when executed by a processor of an electronic device:
[0141] obtaining a preset prompt library and a corresponding pre-training language model set, and constructing a graph set according to the preset prompt library and the pre-training language model set;
[0142] obtaining external knowledge data, converting the external knowledge data into preset format knowledge information, performing knowledge enhancement on the graph set by using the preset format knowledge information, and obtaining an enhanced graph set;
[0143] performing graph learning on the enhanced graph set, and obtaining an optimized graph set;
[0144] obtaining user input information, and matching an optimal prompt corresponding to the user input information from the optimized graph set according to the user input information.
[0145] In several embodiments provided in the application, it should be understood that the disclosed devices, apparatuses and methods can be implemented in other manners. For example, the above-described apparatus embodiments are merely illustrative, and the division of the modules is merely a logical function division, and there can be another division manner in actual implementation.
[0146] The modules illustrated as separate components can or can not be physically separated, and the components illustrated as modules can or can not be physical units, i.e., can be located in one place, or can be distributed on multiple network units. Part or all of the modules can be selected according to actual needs to achieve the purpose of the embodiment scheme.
[0147] In addition, each functional module in each embodiment of the application can be integrated in one processing unit, or each unit can exist physically independently, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware or in the form of hardware plus software function modules.
[0148] It will be obvious to a person skilled in the art that the application is not limited to the details of the above-described exemplary embodiments but can be implemented in other embodiments without departing from the scope of the application.
[0149] The embodiments are therefore to be considered in all respects as illustrative and not restrictive, the scope of the application being indicated by the appended claims rather than by the above description, all changes which come within the meaning and range of equivalency of the claims are therefore intended to be embraced therein. No single feature or combination of features should be considered essential unless expressly stated as such in the claims.
[0150] The blockchain referred to in the present application is a new application mode of distributed data storage, peer-to-peer transmission, consensus mechanism, encryption algorithm and other computer technologies. Blockchain, in essence, is a decentralized database, which is a series of data blocks associated using cryptographic methods, each data block containing a batch of network transaction information for verifying the validity (anti-fake) of the information and generating the next block. The blockchain can include a blockchain underlying platform, a platform product service layer, and an application service layer.
[0151] The embodiments of the present application can acquire and process related data based on artificial intelligence technology. Artificial intelligence (AI) is the use of digital computers or computer-controlled machines to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.
[0152] In addition, it is clear that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. The plurality of units or devices stated in the system claims can also be implemented by one unit or device through software or hardware. The words first, second, etc. are used to indicate names and not to indicate any particular order.
[0153] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application and are not limiting. Although the present application has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solutions of the present application can be modified or replaced by equivalents without departing from the spirit and scope of the present application.
Claims
1. A method for atlas-based prompt recommendation, characterized in that, The method comprises: acquiring a preset prompt library and a corresponding pre-training language model set, and constructing a graph set according to the preset prompt library and the pre-training language model set; acquiring external knowledge data, converting the external knowledge data into preset format knowledge information, using the preset format knowledge information to enhance the knowledge of the graph set, and obtaining an enhanced graph set; performing graph learning on the enhanced graph set to obtain an optimized graph set; acquiring user input information, and matching an optimal prompt corresponding to the user input information from the optimized graph set according to the user input information, comprising: calculating the semantic similarity of the user input information and the nodes and edges of the optimized graph set to obtain node similarity scores and edge similarity scores; constructing a graph query statement according to the user input information and the attributes of the nodes and edges in the optimized graph set, querying the optimized graph set according to the graph query statement, and obtaining a prompt candidate set; identifying the needs and preferences of the user input information; sorting the prompt candidate set according to the needs, the preferences, the node similarity scores and the edge similarity scores to obtain a prompt sorting set; performing intent recognition on the user input information to obtain the target of the user, and matching an optimal prompt from the prompt sorting set according to the target. 2.The atlas-based prompt recommendation method of claim 1, wherein, The construction of the graph set according to the preset prompt library and the pre-training language model set comprises: taking the prompts in the preset prompt library as prompt nodes; taking the pre-training language models in the language model set as PLM nodes; extracting the prompts corresponding to the prompt nodes and the PLM relationships corresponding to the PLM nodes, taking the prompts and the PLM relationships as prompt-PLM edges; extracting the relationships between each prompt node and taking the relationships between each prompt node as prompt-prompt edges; constructing a graph set by using a preset graph drawing tool according to the prompt nodes, the PLM nodes, the prompt-PLM edges and the prompt-prompt edges. 3.The atlas-based prompt recommendation method of claim 1, wherein, The conversion of the external knowledge data into preset format knowledge information comprises: extracting text information related to prompts in the preset prompt library from the knowledge data; extracting entity words, entity word attributes, relationship words and relationship word attributes from the text information; constructing the entity words, the entity word attributes, the relationship words and the relationship word attributes into knowledge information in the form of triplets. 4.The atlas-based prompt recommendation method of claim 3, wherein, The use of the preset format knowledge information to enhance the knowledge of the graph set to obtain an enhanced graph set comprises: matching the entity words, the entity word attributes in the preset format knowledge information with the nodes and the attributes corresponding to the nodes in the graph set to obtain entity matching degrees and attribute matching degrees; align the entity words and the entity word attributes with the nodes in the graph set when the entity matching degree and the attribute matching degree are greater than or equal to a preset matching threshold; add the entity words and the entity word attributes with the entity matching degree and the attribute matching degree less than the preset matching threshold as new nodes of a corresponding graph in the graph set, and add the relationship words corresponding to the entity words and the relationship word attributes as new edges to the corresponding graph to obtain an enhanced graph set. 5.The atlas-based prompt recommendation method of claim 1, wherein, The graph learning on the enhanced graph set to obtain an optimized graph set comprises: encoding each graph corresponding edge and node in the enhanced graph set to obtain a node feature vector set and an edge feature vector set; randomly selecting a node feature vector in the node feature vector set as a first starting node feature vector, performing information transmission on the first starting node feature vector according to the edge feature vector corresponding to the first starting node feature vector to obtain a dynamic vector feature; updating a next node feature vector corresponding to the edge feature vector by using the dynamic vector feature until all node feature vectors in the corresponding graph are updated to obtain an updated graph; randomly selecting a node feature vector in the updated graph as a second starting feature vector, predicting the attributes of a next node and the attributes of a corresponding edge according to the second starting feature vector, corresponding node attributes and corresponding edge feature vectors until the attributes of all nodes and edges in the corresponding graph are predicted to obtain an optimized graph. 6.The atlas-based prompt recommendation method of claim 1, wherein, The calculation of the semantic similarity of the user input information and the nodes of the optimized graph set to obtain a node similarity score comprises: segmenting the user input information to obtain an input segmentation sequence; performing vector conversion on the input segmentation sequence to obtain a user feature vector sequence; extracting node feature vectors of each node in the optimized graph set; calculating the semantic similarity of each user feature vector in the user feature vector sequence and the node feature vectors to obtain a node similarity score.
7. An atlas-based prompt recommendation apparatus for implementing the atlas-based prompt recommendation method according to any one of claims 1 to 6, characterized in that, The apparatus comprises: a graph construction module configured to obtain a preset prompt library and a corresponding pre-trained language model set, and construct a graph set according to the preset prompt library and the pre-trained language model set; a graph enhancement module configured to obtain external knowledge data, convert the external knowledge data into preset format knowledge information, and perform knowledge enhancement on the graph set by using the preset format knowledge information to obtain an enhanced graph set; a graph optimization module configured to perform graph learning on the enhanced graph set to obtain an optimized graph set; a graph recommendation module configured to obtain user input information, and match an optimal prompt corresponding to the user input information from the optimized graph set according to the user input information.
8. An electronic device, comprising: The electronic device comprises: at least one processor; and a memory connected in communication with the at least one processor; wherein The memory stores a computer program executable by the at least one processor, and the computer program is executed by the at least one processor to enable the at least one processor to perform the atlas-based prompt recommendation method according to any one of claims 1 to 6.
9. A computer readable storage medium storing a computer program, characterized in that, The computer program is executed by the processor to implement the atlas-based prompt recommendation method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Medical automatic question-answering system construction method based on knowledge graph
CN112071429A