Psychological consultation dialogue generation method, device, equipment and storage medium
Through spatiotemporal knowledge graph and retrieval enhanced generation technology, combined with user historical dialogue information, it predicts the type of dialogue activities and matches text fragments from the psychological knowledge base, and uses large language models to generate responses, which solves the problem of lack of systematicness and professionalism in online psychological consultation. problems, achieving more precise and personalized consulting support.
Patent Information
- Application Number
- CN202411028276.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-30
- Publication Date
- 2024-10-29
- Estimated Expiration
- 2044-07-30
AI Technical Summary
The existing online psychological counseling system lacks systematicity and professionalism, making it difficult to provide in-depth psychological counseling knowledge and personalized treatment plans, resulting in poor counseling results.
Through enhanced generation technology based on spatiotemporal knowledge graph and retrieval, combined with the user's historical dialogue information and current dialogue status, it predicts the type of dialogue activities, matches target text fragments from the psychological knowledge base, and uses large language models to generate professional responses.
It improves the systematicness and professionalism of online psychological consultation responses, provides more precise and personalized consultation support, and ensures continuous and stable help effects.
Smart Images

Figure CN118553412B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of artificial intelligence technology, and in particular to a method, device, equipment and storage medium for generating a psychological consultation dialogue. Background Art
[0002] Although the current online psychological counseling system provides a convenient consultation channel for those seeking help, and the conversation ability has been significantly improved after combining with big model technology, it still has many drawbacks, which limit the professionalism and effectiveness of online counseling services.
[0003] Most of the existing online psychological counseling systems focus on providing emotional support and simple conversations, lacking in-depth psychological counseling knowledge, consultation strategies, and integration of helping techniques. Psychological counseling is not just about listening and comforting, but also a helping job that requires professional knowledge and skills. However, the current online systems rarely combine the professional theories, techniques, and methods of psychological counseling to provide scientific and systematic guidance to help seekers. This lack makes online counseling often stay at the surface level, difficult to get to the core of the problem, and unable to provide personalized solutions. Online psychological counseling systems are usually unable to implement systematic and coherent treatment plans for multiple treatments of users. Psychological counseling is often a continuous process that requires multiple exchanges and treatments to achieve the desired effect. However, the current online systems can only provide fragmented counseling services and lack overall planning and follow-up. This makes it difficult for help seekers to obtain continuous and stable help when using online counseling, and the treatment effect is greatly reduced.
[0004] Therefore, there is an urgent need for a psychological counseling dialogue generation method that can effectively ensure the systematicity and professionalism of online psychological counseling responses. Summary of the invention
[0005] The main purpose of the present invention is to provide a method, device, equipment and storage medium for generating psychological consultation dialogues, aiming to solve the technical problem that online psychological consultation responses in the prior art lack systematicity and professionalism.
[0006] To achieve the above object, the present invention provides a method for generating a psychological consultation dialogue, the method comprising the following steps:
[0007] Upon receiving a dialogue input instruction from a user, determining the current dialogue state of the user based on the spatiotemporal knowledge graph and according to the historical dialogue information and historical dialogue state of the user;
[0008] Predicting a conversation activity type according to a conversation context corresponding to a current conversation of the user and a current conversation activity sequence;
[0009] Using retrieval-enhanced generation technology, matching a target text segment from a psychological knowledge base according to the current dialogue state and the dialogue activity type;
[0010] The current dialogue state, the dialogue activity type and the target text segment are input into a preset large language model to generate a target response sentence.
[0011] Optionally, before the step of determining the current conversation state of the user according to the historical conversation information and the historical conversation state of the user when receiving the conversation input instruction of the user, the method further comprises:
[0012] Acquire historical conversation information of the user, and determine a conversation information triplet according to the historical conversation information;
[0013] Determining time information or space information corresponding to the dialogue information triplet;
[0014] The time information or the space information is added to the corresponding dialogue information triplet to obtain a dialogue information quadruple, and a spatiotemporal knowledge graph corresponding to the user is constructed based on the dialogue information quadruple.
[0015] Optionally, when receiving a dialogue input instruction from a user, the step of determining the current dialogue state of the user based on the spatiotemporal knowledge graph and according to the historical dialogue information and historical dialogue state of the user includes:
[0016] Upon receiving a dialogue input instruction from a user, determining time information or space information corresponding to the historical dialogue information of the user based on the spatiotemporal knowledge graph;
[0017] Analyze the user's psychological state based on the time information or the spatial information, the historical conversation information and the historical conversation state to obtain an analysis result;
[0018] The change of the user's psychological state is determined based on the analysis result, and the current conversation state of the user is determined based on the change of the psychological state.
[0019] Optionally, the step of predicting the type of dialogue activity according to the dialogue context corresponding to the current dialogue of the user and the current dialogue activity sequence includes:
[0020] Obtaining a conversation context corresponding to the current conversation of the user, and determining the information content of the conversation context;
[0021] When the information content of the conversation context exceeds a preset information threshold, dividing the conversation context into a plurality of current conversation activity sequences according to a preset format;
[0022] Each of the current dialogue activity sequences is input into a preset classification model to generate the next dialogue activity type for psychological consultation.
[0023] Optionally, after the step of obtaining the conversation context corresponding to the current conversation of the user and determining the information content of the conversation context, the method further includes:
[0024] When the information content of the dialogue context does not exceed a preset information threshold, the dialogue context is input into the preset classification model to generate the next dialogue activity type of the psychological consultation.
[0025] Optionally, the step of matching the target text segment from the psychological knowledge base by using the retrieval enhancement generation technology according to the current dialogue state and the dialogue activity type includes:
[0026] Converting the psychological knowledge in the psychological knowledge base into psychological knowledge documents, and segmenting the psychological knowledge documents to obtain text fragments;
[0027] Converting the text segment into a text segment vector and storing the text segment vector in a vector database;
[0028] Converting the current dialogue state and the dialogue activity type into a corresponding current dialogue state vector and dialogue activity type vector;
[0029] The current dialog state vector and the dialog activity type vector are matched with the text segment vector in the vector database to obtain a target text segment.
[0030] Optionally, the step of inputting the current dialogue state, the dialogue activity type and the target text segment into a preset large language model to generate a target reply sentence includes:
[0031] Converting the dialog activity type into a dialog topic in natural language according to a predefined template;
[0032] generating prompt information based on the current dialog state and the dialog activity type;
[0033] The prompt information and the target text segment are input into a preset large language model to generate reply content, and a target reply sentence is generated according to the conversation topic and the reply content.
[0034] In addition, to achieve the above-mentioned purpose, the present invention also proposes a psychological consultation dialogue generation device, the device comprising:
[0035] A dialogue state determination module, configured to determine the current dialogue state of the user based on the spatiotemporal knowledge graph and the historical dialogue information and historical dialogue state of the user when receiving a dialogue input instruction from the user;
[0036] An activity type prediction module, configured to predict a conversation activity type based on a conversation context corresponding to a current conversation of the user and a current conversation activity sequence;
[0037] A text information matching module, used to match a target text segment from a psychological knowledge base according to the current dialogue state and the dialogue activity type by using a retrieval enhancement generation technique;
[0038] The target response generation module is used to input the current dialogue state, the dialogue activity type and the target text segment into a preset large language model to generate a target response sentence.
[0039] In addition, to achieve the above-mentioned purpose, the present invention also proposes a psychological counseling dialogue generation device, which includes: a memory, a processor, and a psychological counseling dialogue generation program stored on the memory and executable on the processor, and the psychological counseling dialogue generation program is configured to implement the steps of the psychological counseling dialogue generation method described above.
[0040] In addition, to achieve the above-mentioned purpose, the present invention also proposes a storage medium, on which a psychological counseling dialogue generation program is stored, and when the psychological counseling dialogue generation program is executed by a processor, the steps of the psychological counseling dialogue generation method described above are implemented.
[0041] The present invention discloses that upon receiving a user's dialogue input instruction, the current dialogue state of the user is determined based on a spatiotemporal knowledge graph and according to the user's historical dialogue information and historical dialogue state; the dialogue activity type is predicted according to the dialogue context corresponding to the user's current dialogue and the current dialogue activity sequence; the target text segment is matched from a psychological knowledge base through the current dialogue state and the dialogue activity type using a retrieval enhancement generation technology; the current dialogue state, the dialogue activity type and the target text segment are input into a preset large language model to generate a target reply sentence. Since the present invention determines the user's current dialogue state based on the user's historical dialogue information and historical dialogue state, matches the target text segment from the psychological knowledge base using a retrieval enhancement generation technology, and finally generates the target reply sentence through a preset large language model, compared with the prior art, the present invention ensures the systematic nature of online psychological consultation replies and improves the professionalism of online psychological consultation replies. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] Figure 1 It is a flowchart of the first embodiment of the method for generating a psychological consultation dialogue of the present invention;
[0043] Figure 2 It is a flowchart of the second embodiment of the method for generating a psychological consultation dialogue of the present invention;
[0044] Figure 3 A schematic diagram of a flow chart of a third embodiment of a method for generating a psychological consultation dialogue according to the present invention;
[0045] Figure 4 It is a structural block diagram of the first embodiment of the psychological consultation dialogue generating device of the present invention;
[0046] Figure 5 It is a structural schematic diagram of a psychological consultation dialogue generating device in a hardware operating environment involved in an embodiment of the present invention.
[0047] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION
[0048] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.
[0049] The embodiment of the present invention provides a method for generating a psychological consultation dialogue, referring to Figure 1 , Figure 1 This is a flow chart of the first embodiment of the psychological consultation dialogue generation method of the present invention.
[0050] In this embodiment, the psychological consultation dialogue generation method includes the following steps:
[0051] Step S10: upon receiving a dialogue input instruction from the user, determining the current dialogue state of the user based on the spatiotemporal knowledge graph and according to the historical dialogue information and historical dialogue state of the user.
[0052] It should be noted that the execution subject of this embodiment can be a computer server device with data processing, network communication and program running functions used in the psychological counseling scenario, such as a personal computer, a laptop computer, a mobile phone, a smart watch, etc., or an electronic device capable of realizing the above functions, a psychological counseling dialogue generation device, etc. The following takes a psychological counseling system (hereinafter referred to as the system) including a psychological counseling dialogue generation device as an example to illustrate this embodiment and the following embodiments.
[0053] It should be understood that the above-mentioned user input instruction may be an instruction generated when the user inputs information in the system dialog box.
[0054] It should be explained that the above-mentioned spatiotemporal knowledge graph may be a knowledge graph containing time information or spatial information that is pre-constructed based on the historical conversation information in the user's personal knowledge base. The personal knowledge base is a database for storing the user's historical conversation information. By storing the historical conversation information and planning and following up the user's psychological consultation based on the historical conversation information, the systematic nature of the subsequent system response can be effectively guaranteed.
[0055] It should be noted that the current conversation state of the user mentioned above may be the user's current emotion and demand information.
[0056] In a specific implementation, when a dialogue input instruction from a user is received, the time information or space information corresponding to the historical dialogue information of the user can be determined based on the spatiotemporal knowledge graph; the psychological state of the user is analyzed based on the time information or the space information, the historical dialogue information and the historical dialogue state to obtain an analysis result; the change in the psychological state of the user is determined based on the analysis result, and the current dialogue state of the user is determined based on the change in the psychological state.
[0057] Step S20: predicting a conversation activity type according to a conversation context corresponding to the user's current conversation and a current conversation activity sequence.
[0058] It should be noted that the above-mentioned dialogue activity types may indicate what type of dialogue activities the system should conduct, and the dialogue activity types include: asking questions, listening, and making suggestions.
[0059] It should be explained that in order to improve the accuracy of dialogue activity type prediction and data processing efficiency, in a specific implementation, different prediction methods can be selected according to the richness of the information content of the dialogue context.
[0060] For example, the conversation context corresponding to the current conversation of the user is obtained, and the information content of the conversation context is determined; when the information content of the conversation context exceeds a preset information threshold, the conversation context is divided into a plurality of current conversation activity sequences according to a preset format; each of the current conversation activity sequences is input into a preset classification model to generate the next conversation activity type for psychological counseling.
[0061] Furthermore, when the information content of the dialogue context does not exceed a preset information threshold, the dialogue context is input into the preset classification model to generate the next dialogue activity type of the psychological consultation.
[0062] In a specific implementation, when the information content of the dialogue context exceeds a preset information threshold, the dialogue context (a plurality of consecutive sentences ( , , , ...)) into multiple current dialog activity sequences (e.g. [ ][CLS] [SEP][CLS] ...); then input each of the current dialogue activity sequences into a preset classification model (such as a BERT model), and then calculate each sentence head The average loss of the tag; finally, according to the preset classification model and each sentence head The average loss of marks predicts the type of conversational activity that occurs next in a psychological consultation.
[0063] It should be noted that the prediction process (or classification process) of the above-mentioned preset classification model can be classified using the BERT model (an advanced natural language processing model) to map the conversation context and / or conversation activity sequence to a probability distribution ( ). If the dialog activity type ( ) corresponds to the dimension in ( ) has the highest probability value, then the dialog activity type ( ) is selected as the predicted dialog activity type.
[0064] Step S30: using the retrieval enhancement generation technology, matching the target text segment from the psychological knowledge base according to the current dialogue state and the dialogue activity type.
[0065] It should be understood that Retrieval-Augmented Generation (RAG) is a cutting-edge technology that combines information retrieval with generative artificial intelligence (especially large language models). This technology retrieves relevant information from external data sources and uses the retrieved information to guide the generation of text or answers, thereby improving the quality and accuracy of predictions.
[0066] It should be noted that the above-mentioned psychological knowledge base includes the collection and organization of a large amount of professional psychological counseling knowledge, including but not limited to psychological counseling theory, treatment strategies, case analysis, etc., to form a comprehensive and private local knowledge base, which will provide strong professional support for the dialogue system.
[0067] It is understandable that when using the retrieval enhancement generation technology to match the target text fragment from the psychological knowledge base through the current dialogue state and dialogue activity type, the psychological knowledge base can be indexed first, and after the indexing, the user's demand response type is determined according to the current dialogue state and dialogue activity type, and then a retrieval operation is performed in the psychological knowledge base to obtain the most relevant text fragment, that is, the target text fragment.
[0068] Step S40: inputting the current dialogue state, the dialogue activity type and the target text segment into a preset large language model to generate a target response sentence.
[0069] It is understandable that a large language model refers to a deep learning model with a large number of parameters. These models learn language patterns, grammar and semantics by processing a large amount of text data, so as to understand and generate human language. The above-mentioned preset large language model can be a Chinese large language model such as LLM, ChatGLM, BLOOM, etc., which is not limited in this embodiment.
[0070] In a specific implementation, the dialogue activity type can be converted into a dialogue topic in natural language form according to a predefined template; prompt information can be generated based on the current dialogue state and the dialogue activity type; the prompt information and the target text fragment can be input into a preset large language model to generate reply content, and a target reply sentence can be generated according to the dialogue topic and the reply content.
[0071] It should be noted that after completing the prediction of the dialogue activity type, in order to improve the effectiveness, the dialogue activity type ( ) is converted into natural language form and expressed as ( ). For example, if the predicted conversation activity type is "recommend therapy", the converted conversation topic may be "In the next speech, the therapist will design a therapy." This conversion makes the activities output by the system closer to the actual consultation scenario, which is easier for users to understand and execute.
[0072] This embodiment discloses that when receiving a user's dialogue input instruction, the current dialogue state of the user is determined based on the spatiotemporal knowledge graph and according to the user's historical dialogue information and historical dialogue state; the dialogue activity type is predicted according to the dialogue context corresponding to the user's current dialogue and the current dialogue activity sequence; the target text segment is matched from the psychological knowledge base through the current dialogue state and the dialogue activity type using the retrieval enhancement generation technology; the current dialogue state, the dialogue activity type and the target text segment are input into the preset large language model to generate the target reply sentence. Since this embodiment determines the user's current dialogue state based on the user's historical dialogue information and historical dialogue state, matches the target text segment from the psychological knowledge base using the retrieval enhancement generation technology, and finally generates the target reply sentence through the preset large language model, compared with the existing technology, this embodiment ensures the systematic nature of the online psychological consultation reply and improves the professionalism of the online psychological consultation reply.
[0073] refer to Figure 2 , Figure 2 This is a flow chart of the second embodiment of the psychological consultation dialogue generation method of the present invention.
[0074] Based on the first embodiment above, in this embodiment, before step S10, the following steps are further included:
[0075] Step S01: Acquire historical conversation information of a user, and determine a conversation information triplet according to the historical conversation information.
[0076] Step S02: Determine the time information or space information corresponding to the dialogue information triplet.
[0077] Step S03: Add the time information or the space information to the corresponding dialogue information triplet to obtain a dialogue information quadruple, and construct a spatiotemporal knowledge graph corresponding to the user based on the dialogue information quadruple.
[0078] It should be noted that in the dialogue information triple (s, p, o), s, p, and o represent the subject, predicate as the relationship type, and object, respectively.
[0079] This embodiment adds the time information or the space information to the corresponding dialogue information triple to obtain a dialogue information quadruple, that is, the dialogue information triple (s, p, o) is expanded into a quadruple with a timestamp t or an environment stamp e, that is, (s, p, o, t) or (s, p, o, e). This structure can more comprehensively capture the spatiotemporal attributes of events or facts.
[0080] It should be explained that the timestamp t or the environment stamp e represents "time information or space (environment) information". In this embodiment, in addition to the traditional triple relationship, an additional dimension is introduced to describe the time or environmental background of the event or fact, and the corresponding spatiotemporal knowledge graph of the user is constructed through the dialogue information quadruple. Then, when the user's dialogue input instruction is received, the current dialogue state of the user is determined based on the spatiotemporal knowledge graph and according to the user's historical dialogue information and historical dialogue state, so that the system can continuously track the progress of the dialogue, understand the user's emotions and needs, and generate appropriate responses based on the previous dialogue content and the current dialogue state. By integrating time or environmental information, the dynamic changes of the user's psychological state can be more accurately grasped, thereby providing more accurate and personalized consulting support.
[0081] This embodiment discloses obtaining the historical conversation information of the user, and determining the conversation information triplet according to the historical conversation information; determining the time information or space information corresponding to the conversation information triplet; adding the time information or the space information to the corresponding conversation information triplet to obtain the conversation information quadruple, and constructing the spatiotemporal knowledge graph corresponding to the user based on the conversation information quadruple; then upon receiving the conversation input instruction from the user, determining the current conversation state of the user based on the spatiotemporal knowledge graph and according to the historical conversation information and the historical conversation state of the user; predicting the conversation activity type according to the conversation context corresponding to the current conversation of the user and the current conversation activity sequence; matching the target text segment from the psychological knowledge base according to the current conversation state and the conversation activity type by using the retrieval enhancement generation technology; inputting the current conversation state, the conversation activity type and the target text segment into the preset large language model to generate the target reply sentence. Compared with the prior art, this embodiment more accurately grasps the dynamic changes of the user's psychological state by integrating time or environmental information, thereby providing more accurate and personalized consulting support.
[0082] refer to Figure 3 , Figure 3 This is a flow chart of the third embodiment of the method for generating a psychological consultation dialogue according to the present invention.
[0083] Based on the above embodiments, in this embodiment, step S30 includes:
[0084] Step S301: converting the psychological knowledge in the psychological knowledge base into psychological knowledge documents, and segmenting the psychological knowledge documents to obtain text segments.
[0085] Step S302: converting the text segment into a text segment vector, and storing the text segment vector in a vector database.
[0086] Step S303: converting the current dialog state and the dialog activity type into corresponding current dialog state vectors and dialog activity type vectors.
[0087] Step S304: Match the current dialog state vector and the dialog activity type vector with the text segment vector in the vector database to obtain a target text segment.
[0088] It should be noted that the psychological knowledge in the psychological knowledge base can be converted into independent psychological knowledge documents through a loader. Then, a splitter is used to split the psychological knowledge document into small text fragments or document summaries. These text fragments are easier to process and facilitate subsequent semantic searches. After the segmentation is completed, these text fragments are passed to an embedding machine to convert the text fragments into text fragment vectors that can be used for semantic search. The text fragment vectors and the text fragments corresponding to the text fragment vectors are then stored in a vector database for subsequent retrieval.
[0089] In a specific implementation, the current dialogue state and the dialogue activity type can be passed to the same embedding machine as above to be converted into the corresponding current dialogue state vector and dialogue activity type vector. Then, in the vector database, the system will determine the text segment closest to the current dialogue state vector and dialogue activity type vector, i.e., the target text segment. These target text segments will be used to generate the target reply sentence. The retrieval-enhanced generation technology can ensure that the generated reply sentence is closely centered around the current dialogue state and dialogue activity type, thereby improving the accuracy and relevance of the reply.
[0090] This embodiment discloses converting the psychological knowledge in the psychological knowledge base into psychological knowledge documents, and segmenting the psychological knowledge documents to obtain text segments; converting the text segments into text segment vectors, and storing the text segment vectors into a vector database; converting the current dialogue state and the dialogue activity type into corresponding current dialogue state vectors and dialogue activity type vectors; matching the current dialogue state vector and the dialogue activity type vector with the text segment vectors in the vector database to obtain target text segments. Compared with the prior art, this embodiment can ensure that the reply sentences generated by the subsequent system are closely centered around the current dialogue state and dialogue activity type, thereby improving the accuracy and relevance of the reply.
[0091] In addition, an embodiment of the present invention further proposes a storage medium, on which a psychological counseling dialogue generation program is stored. When the psychological counseling dialogue generation program is executed by a processor, the steps of the psychological counseling dialogue generation method described above are implemented.
[0092] Reference Figure 4 , Figure 4 This is a structural block diagram of the first embodiment of the psychological consultation dialogue generation device of the present invention.
[0093] like Figure 4As shown, the psychological consultation dialogue generation device proposed in the embodiment of the present invention includes: a dialogue state determination module 401, an activity type prediction module 402, a text information matching module 403 and a target answer generation module 404.
[0094] The dialogue state determination module 401 is used to determine the current dialogue state of the user based on the spatiotemporal knowledge graph and according to the historical dialogue information and historical dialogue state of the user when receiving the dialogue input instruction of the user.
[0095] The activity type prediction module 402 is used to predict the conversation activity type according to the conversation context corresponding to the current conversation of the user and the current conversation activity sequence.
[0096] The text information matching module 403 is used to match the target text segment from the psychological knowledge base according to the current dialogue state and the dialogue activity type by using the retrieval enhancement generation technology.
[0097] The target response generation module 404 is used to input the current dialogue state, the dialogue activity type and the target text segment into a preset large language model to generate a target response sentence.
[0098] The dialogue state determination module 401 is further used to determine the time information or space information corresponding to the user's historical dialogue information based on the spatiotemporal knowledge graph when receiving the user's dialogue input instruction; analyze the user's psychological state based on the time information or the space information, the historical dialogue information and the historical dialogue state to obtain an analysis result; determine the user's psychological state change based on the analysis result, and determine the user's current dialogue state based on the psychological state change.
[0099] The activity type prediction module 402 is also used to obtain the conversation context corresponding to the user's current conversation and determine the information content of the conversation context; when the information content of the conversation context exceeds a preset information threshold, the conversation context is divided into multiple current conversation activity sequences according to a preset format; each of the current conversation activity sequences is input into a preset classification model to generate the next conversation activity type for psychological counseling.
[0100] The activity type prediction module 402 is further configured to input the conversation context into the preset classification model to generate the next conversation activity type for psychological consultation when the information content of the conversation context does not exceed a preset information threshold.
[0101] The target reply generation module 404 is further used to convert the dialogue activity type into a dialogue topic in natural language form according to a predefined template; generate prompt information based on the current dialogue state and the dialogue activity type; input the prompt information and the target text segment into a preset large language model to generate reply content, and generate a target reply sentence according to the dialogue topic and the reply content.
[0102] The embodiment of the device discloses that upon receiving a user's dialogue input instruction, the current dialogue state of the user is determined based on the spatiotemporal knowledge graph and according to the user's historical dialogue information and historical dialogue state; the dialogue activity type is predicted according to the dialogue context corresponding to the user's current dialogue and the current dialogue activity sequence; the target text segment is matched from the psychological knowledge base through the current dialogue state and the dialogue activity type using the retrieval enhancement generation technology; the current dialogue state, the dialogue activity type and the target text segment are input into a preset large language model to generate a target reply sentence. Since the embodiment of the device determines the current dialogue state of the user based on the user's historical dialogue information and historical dialogue state, matches the target text segment from the psychological knowledge base using the retrieval enhancement generation technology, and finally generates the target reply sentence through the preset large language model, compared with the prior art, the embodiment of the device ensures the systematic nature of the online psychological consultation reply and improves the professionalism of the online psychological consultation reply.
[0103] Based on the above-mentioned first embodiment of the psychological counseling dialogue generating device of the present invention, a second embodiment of the psychological counseling dialogue generating device of the present invention is proposed.
[0104] In this embodiment, the dialogue state determination module 401 is also used to obtain the user's historical dialogue information, and determine the dialogue information triplet based on the historical dialogue information; determine the time information or space information corresponding to the dialogue information triplet; add the time information or the space information to the corresponding dialogue information triplet to obtain the dialogue information quadruple, and construct the spatiotemporal knowledge graph corresponding to the user based on the dialogue information quadruple.
[0105] Other embodiments or specific implementations of the psychological counseling dialogue generation device of the present invention can refer to the above-mentioned method embodiments, which will not be repeated here.
[0106] The present application provides a psychological counseling dialogue generation device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the psychological counseling dialogue generation method in the above-mentioned embodiment one.
[0107] Reference below Figure 5, which shows a schematic diagram of the structure of a psychological counseling dialogue generation device suitable for implementing the embodiment of the present application. The psychological counseling dialogue generation device in the embodiment of the present application may include but is not limited to mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Descriptions), PMPs (Portable Media Players), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 5 The psychological counseling dialogue generation device shown is merely an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.
[0108] like Figure 5 As shown, the psychological counseling dialogue generating device may include a processing device 1001 (such as a central processing unit, a graphics processor, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM: Read Only Memory) 1002 or a program loaded from a storage device 1003 to a random access memory (RAM: Random Access Memory) 1004. In RAM1004, various programs and data required for the operation of the psychological counseling dialogue generating device are also stored. The processing device 1001, ROM1002 and RAM1004 are connected to each other through a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Generally, the following systems can be connected to the I / O interface 1006: an input device 1007 including, for example, a touch screen, a touchpad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; an output device 1008 including, for example, a liquid crystal display (LCD: Liquid Crystal Display), a speaker, a vibrator, etc.; a storage device 1003 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 can allow the psychological counseling dialogue generation device to communicate wirelessly or wired with other devices to exchange data. Although the figure shows a psychological counseling dialogue generation device with various systems, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems can be implemented or provided alternatively.
[0109] In particular, according to the embodiments disclosed in the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, the embodiments disclosed in the present application include a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by the processing device 1001, the above-mentioned functions defined in the method of the embodiment disclosed in the present application are executed.
[0110] The psychological counseling dialogue generation device provided by the present application adopts the psychological counseling dialogue generation method in the above embodiment, which can solve the technical problem that the online psychological counseling responses in the prior art lack systematization and professionalism. Compared with the prior art, the beneficial effects of the psychological counseling dialogue generation device provided by the present application are the same as the beneficial effects of the psychological counseling dialogue generation method provided by the above embodiment, and the other technical features in the psychological counseling dialogue generation device are the same as the features disclosed in the method of the previous embodiment, which will not be repeated here.
[0111] It should be understood that the various parts disclosed in this application can be implemented by hardware, software, firmware or a combination thereof. In the description of the above embodiments, specific features, structures, materials or characteristics can be combined in any one or more embodiments or examples in a suitable manner.
[0112] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
[0113] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system 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 system. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or system including the element.
[0114] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0115] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as a read-only memory / random access memory, a magnetic disk, or an optical disk), and includes a number of instructions for enabling a terminal device (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present invention.
[0116] The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. A method for generating psychological consultation dialogues. It is characterized in that The method includes: Upon receiving a dialogue input instruction from a user, determining the current dialogue state of the user based on the spatiotemporal knowledge graph and according to the historical dialogue information and historical dialogue state of the user; Predicting a conversation activity type according to a conversation context corresponding to a current conversation of the user and a current conversation activity sequence; Using retrieval-enhanced generation technology, matching a target text segment from a psychological knowledge base according to the current dialogue state and the dialogue activity type; Inputting the current dialogue state, the dialogue activity type and the target text segment into a preset large language model to generate a target reply sentence; Wherein, before the step of determining the current conversation state of the user according to the historical conversation information and the historical conversation state of the user when receiving the conversation input instruction of the user, the method further includes: Acquire historical conversation information of the user, and determine a conversation information triplet according to the historical conversation information; Determining time information or space information corresponding to the dialogue information triplet; Adding the time information or the space information to the corresponding dialogue information triplet to obtain a dialogue information quadruple, and constructing a spatiotemporal knowledge graph corresponding to the user based on the dialogue information quadruple; Wherein, when receiving the user's dialogue input instruction, the step of determining the user's current dialogue state based on the spatiotemporal knowledge graph and according to the user's historical dialogue information and historical dialogue state includes: Upon receiving a dialogue input instruction from a user, determining time information or space information corresponding to the historical dialogue information of the user based on the spatiotemporal knowledge graph; Analyze the user's psychological state based on the time information or the spatial information, the historical conversation information and the historical conversation state to obtain an analysis result; The change of the user's psychological state is determined based on the analysis result, and the current conversation state of the user is determined based on the change of the psychological state.
2. The method according to claim 1, It is characterized in that The step of predicting the type of dialogue activity according to the dialogue context corresponding to the current dialogue of the user and the current dialogue activity sequence comprises: Obtaining a conversation context corresponding to the current conversation of the user, and determining the information content of the conversation context; When the information content of the conversation context exceeds a preset information threshold, dividing the conversation context into a plurality of current conversation activity sequences according to a preset format; Each of the current dialogue activity sequences is input into a preset classification model to generate the next dialogue activity type for psychological consultation.
3. The method according to claim 2, It is characterized in that After the step of obtaining the conversation context corresponding to the current conversation of the user and determining the information content of the conversation context, the method further includes: When the information content of the dialogue context does not exceed a preset information threshold, the dialogue context is input into the preset classification model to generate the next dialogue activity type of the psychological consultation.
4. The method according to claim 1, It is characterized in that The step of matching the target text segment from the psychological knowledge base by using the retrieval enhancement generation technology according to the current dialogue state and the dialogue activity type comprises: Converting the psychological knowledge in the psychological knowledge base into psychological knowledge documents, and segmenting the psychological knowledge documents to obtain text fragments; Converting the text segment into a text segment vector and storing the text segment vector in a vector database; Converting the current dialogue state and the dialogue activity type into a corresponding current dialogue state vector and dialogue activity type vector; The current dialog state vector and the dialog activity type vector are matched with the text segment vector in the vector database to obtain a target text segment.
5. The method according to claim 1, It is characterized in that The step of inputting the current dialogue state, the dialogue activity type and the target text segment into a preset large language model to generate a target reply sentence includes: Converting the dialog activity type into a dialog topic in natural language according to a predefined template; generating prompt information based on the current dialog state and the dialog activity type; The prompt information and the target text segment are input into a preset large language model to generate reply content, and a target reply sentence is generated according to the conversation topic and the reply content.
6. A psychological consultation dialogue generation device, It is characterized in that The device comprises: A dialogue state determination module, configured to determine the current dialogue state of the user based on the spatiotemporal knowledge graph and the historical dialogue information and historical dialogue state of the user when receiving a dialogue input instruction from the user; An activity type prediction module, configured to predict a conversation activity type based on a conversation context corresponding to a current conversation of the user and a current conversation activity sequence; A text information matching module, used to match a target text segment from a psychological knowledge base according to the current dialogue state and the dialogue activity type by using a retrieval enhancement generation technique; A target response generation module, used for inputting the current dialogue state, the dialogue activity type and the target text segment into a preset large language model to generate a target response sentence; The dialogue state determination module is further used to obtain historical dialogue information of the user, and determine a dialogue information triplet according to the historical dialogue information; determine the time information or space information corresponding to the dialogue information triplet; add the time information or the space information to the corresponding dialogue information triplet to obtain a dialogue information quadruple, and construct a spatiotemporal knowledge graph corresponding to the user based on the dialogue information quadruple; The dialogue state determination module is also used to determine the time information or space information corresponding to the user's historical dialogue information based on the spatiotemporal knowledge graph when receiving the user's dialogue input instruction; analyze the user's psychological state based on the time information or the space information, the historical dialogue information and the historical dialogue state to obtain an analysis result; determine the user's psychological state change based on the analysis result, and determine the user's current dialogue state based on the psychological state change.
7. A psychological consultation dialogue generation device, It is characterized in that The device includes: a memory, a processor, and a psychological counseling dialogue generation program stored in the memory and executable on the processor, wherein the psychological counseling dialogue generation program is configured to implement the steps of the psychological counseling dialogue generation method as described in any one of claims 1 to 5.
8. A storage medium, It is characterized in that The storage medium stores a psychological counseling dialogue generation program, and when the psychological counseling dialogue generation program is executed by the processor, the steps of the psychological counseling dialogue generation method according to any one of claims 1 to 5 are implemented.
Citation Information
Patent Citations
Emotion perception and support dialogue system construction method based on deep learning
CN114999610A
Emotion-guided dialogue content generation method based on crowd intelligence strategy
CN117668208A
