Chinese multi-turn dialogue medical system, device and storage medium based on prompt language model
By using a Chinese multi-turn dialogue system based on the Prompt language model, combined with the Transformer self-attention mechanism and prompt-tuning technology, the system addresses the efficiency and quality issues in diagnosis and treatment within the medical system, providing personalized medical consultation services while achieving information security and system fluency.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- BEIJING UNIV OF TECH
- Filing Date
- 2023-11-22
- Publication Date
- 2026-07-14
Smart Images

Figure CN117577305B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to a Chinese multi-turn dialogue medical system based on the Prompt language model, belonging to the field of artificial intelligence and medical interaction technology. Background Technology
[0002] Currently, the healthcare system has an increasing demand for patient diagnosis, treatment, and consultation, requiring an intelligent system that can improve the efficiency and quality of healthcare services. Summary of the Invention
[0003] This invention proposes a Chinese multi-turn dialogue medical system based on the Prompt language model. Through dialogue interaction, it can more accurately understand patients' needs and provide personalized medical advice.
[0004] The technical solution of this invention is a Chinese multi-turn dialogue medical system based on the Prompt language model, mainly comprising the following modules: a patient information module, a dialogue engine module, and a Prompt language model module. The patient information module is interactively connected to the dialogue engine module, and the dialogue engine module is interactively connected to the Prompt language model module. Through collaborative work with the patient information module and the Prompt language model module, the dialogue engine module achieves dynamic updates of patient information and real-time invocation of the Prompt language model, and returns responses from the Prompt language model. The three modules are encrypted and connected via SSL / TLS protocol to ensure the privacy of patient information, and seamless integration with the Prompt language model is achieved through API calls.
[0005] Furthermore, the dialogue engine module is responsible for handling the dialogue flow between user input and system output. The dialogue engine module is built using the Python Flask framework and includes capturing patient input, returning output, text cleaning, saving historical conversations, managing basic patient information, and authenticating patient permissions.
[0006] Furthermore, the patient information module is used to collect, store, and manage basic patient information; this patient information module utilizes database technology to establish a patient information database, ensuring information security and privacy protection.
[0007] Furthermore, the Prompt language model module is implemented based on a deep learning model to answer relevant questions raised by patients. This module employs the Transformer self-attention mechanism, using a large amount of unsupervised medical data to train a pre-trained model, and then performs Prompt-tuning on the pre-trained model based on a small amount of data to obtain the Prompt language model.
[0008] Furthermore, the dialogue engine module adopts the Transformer architecture to improve dialogue understanding. It utilizes a pre-trained Chinese Prompt language model with prompt-tuning, fine-tuning it to achieve customization for the medical field, while introducing a context-aware autonomy mechanism to better understand the context of multi-turn dialogues.
[0009] Furthermore, the patient information module employs a distributed database to ensure the real-time nature and reliability of information. SSL / TLS encryption technology is introduced to guarantee the secure transmission and storage of patient information.
[0010] Furthermore, the Prompt language model module employs the Transformer self-attention mechanism to handle long-distance dependencies and understand the context of the input text. It utilizes large-scale medical text data for pre-training to obtain context-sensitive representations of medical knowledge and terminology. Prompt-tuning is used to dynamically expand and update the Prompt language model; the Prompt-tuning process is as follows: Prompt tokens are tokens that are not meaningful in reality. After being input into the Transformer pre-trained model, they are mapped to IDs from 0 to N and initialized using Gaussian to an N*Model_dim parameter matrix, denoted as Prompt_weight. The other parameters of the Prompt language model are denoted as Pretrain_weight. Pretrain_weight is fixed; that is, as pre-training progresses, the value of Prompt_weight is continuously updated, while Pretrain_weight remains unchanged.
[0011] Furthermore, the apparatus for a Chinese multi-turn dialogue medical system based on the Prompt language model includes a memory, a processor, and a computer program stored in the memory and running on the processor. When the processor executes the program, it implements the steps of the method for a Chinese multi-turn dialogue medical system based on the Prompt language model.
[0012] Furthermore, the storage medium of the Chinese multi-turn dialogue medical system based on the Prompt language model is a non-transitory computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, it implements the steps of the method of the Chinese multi-turn dialogue medical system based on the Prompt language model.
[0013] Compared with existing technologies, the system of this invention realizes the diverse processing of questions raised by patients in medical care based on artificial intelligence, including but not limited to common symptoms, disease diagnosis, treatment suggestions, etc., in order to provide comprehensive medical consultation services. Attached Figure Description
[0014] Figure 1 This is a diagram of a Chinese multi-turn dialogue medical system based on the Prompt language model.
[0015] Figure 2 This is a schematic diagram of the Prompt-tuning process.
[0016] Figure 3 This is a schematic diagram of the system of the present invention. Detailed Implementation
[0017] The present invention will now be described in detail with reference to the accompanying drawings and embodiments.
[0018] like Figure 1 The diagram shows a Chinese multi-turn dialogue medical system based on the Prompt language model. It includes the following modules: a patient information module, a dialogue engine module, and a Prompt language model module. The patient information module interacts with the dialogue engine module, and the dialogue engine module interacts with the Prompt language model module. Through collaboration with the patient information module and the Prompt language model module, the dialogue engine module dynamically updates patient information, calls the Prompt language model in real time, and returns responses from the Prompt language model. The three modules are encrypted using SSL / TLS to ensure patient information privacy and seamlessly integrate with the Prompt language model via API calls.
[0019] Step (1) When a user starts a conversation, they need to log in through the dialogue engine model. Only after the model verification is successful can the conversation begin.
[0020] Step (2): After the dialogue begins, the dialogue engine module first receives user input, cleans the input data, and removes special characters, whitespace, etc. The processed text is denoted as Input. History is initialized to an empty string.
[0021] Step (3) The dialogue engine model transmits the user ID to the patient information module and calls the patient's historical diagnosis information, which is recorded as Message.
[0022] Step (4): After the dialogue engine model obtains the Message, it concatenates the Message, History, and Input in sequence using \n. After concatenation, due to machine performance limitations, the module will trim the text length to 1024 (prioritizing the trimming of the preceding text; 1024 is a set value that depends on machine performance. Theoretically, if machine performance is unlimited, this length can also be unlimited). Then it is transmitted to the Prompt language model module.
[0023] Step (5) After the Prompt language model module obtains Message, History, and Input, it performs a series of encoding, calculation, and decoding operations and returns the result, which is denoted as Response.
[0024] Step (6) The dialogue engine model obtains the Response and returns it to the user. At the same time, it uses \n to concatenate the History, Input, and Response in order and updates it to a new History.
[0025] Step (7) Repeat steps (2)-(6) to achieve multi-turn dialogue.
[0026] The system acquires the dialogue context through a context-aware mechanism and performs semantic analysis on the input. Then, module A calls module B to update or retrieve patient information. Simultaneously, module A calls module C to query the medical knowledge base and generate a system response. The entire process ensures the security of information transmission through encrypted connections.
[0027] The Prompt language model module employs a Transformer self-attention mechanism to handle long-distance dependencies and understand the context of the input text. It is pre-trained using large-scale medical text data to acquire context-sensitive representations of medical knowledge and terminology. Prompt-tuning is used to dynamically expand and update the model, allowing for the timely incorporation of new medical information and research findings, ensuring timely and accurate responses to patient inquiries.
[0028] Figure 2 This is a schematic diagram of the Prompt-tuning process. The Prompt-tuning process is as follows: Prompt tokens are tokens that are not meaningful in reality, such as [unused0], [unused1], [unused2], ..., [unusedN]. After being input into the Transformer pre-trained model, they are mapped to IDs from 0 to N and initialized using Gaussian to an N*Model_dim parameter matrix, denoted as Prompt_weight. The other parameters of the model are denoted as Pretrain_weight. Pretrain_weight is fixed; that is, as training progresses, the value of Prompt_weight is continuously updated, while Pretrain_weight remains unchanged. The advantage of this is that it saves training time and has low performance requirements on the machine. Therefore, it can be used as a technique for dynamically updating the prompt model.
[0029] In terms of module selection, different pre-trained prompt language models with prompt-tuning, such as GPT, BERT, and Transformer-XL, can be selected according to actual needs to adapt to specific medical scenarios and improve system performance.
[0030] Furthermore, the apparatus for a Chinese multi-turn dialogue medical system based on the Prompt language model includes a memory, a processor, and a computer program stored in the memory and running on the processor. When the processor executes the program, it implements the steps of the method for a Chinese multi-turn dialogue medical system based on the Prompt language model.
[0031] Furthermore, a non-transitory computer-readable storage medium for a Chinese multi-turn dialogue medical system based on the Prompt language model is provided, on which a computer program is stored, which, when executed by a processor, implements the steps of the method for a Chinese multi-turn dialogue medical system based on the Prompt language model.
[0032]
[0033]
[0034] Glossary
[0035] In summary, this invention, by employing a Chinese multi-turn dialogue medical system based on the promptPrompt language model, achieves more precise and efficient medical services. The collaborative work between modules ensures smooth dialogue and personalized service delivery, providing patients with a better medical experience.
Claims
1. A Chinese multi-turn dialogue medical system based on the Prompt language model, characterized in that, include: The system comprises a patient information module, a dialogue engine module, and a Prompt language model module. The patient information module interacts with the dialogue engine module, and the dialogue engine module interacts with the Prompt language model module. The dialogue engine module, through collaboration with the patient information module and the Prompt language model module, dynamically updates patient information and calls the Prompt language model in real time, returning a response from the Prompt language model. The three modules are encrypted using SSL / TLS to ensure patient information privacy and seamlessly integrate with the Prompt language model via API calls. The Prompt language model module employs the Transformer self-attention mechanism to handle long-distance dependencies and understand the context of the input text; Large-scale medical text data is used for pre-training to obtain context-sensitive representations of medical knowledge and professional terminology. Prompt-tuning is employed to dynamically expand and update the Prompt language model. The Prompt-tuning process is as follows: Prompt tokens are tokens that are not meaningful in reality. After being input into the Transformer pre-trained model, they are mapped to IDs from 0 to N and initialized using Gaussian to an N * Model_dim parameter matrix, denoted as Prompt_weight. Other parameters of the Prompt language model are denoted as Pretrain_weight. Pretrain_weight is fixed; that is, as pre-training progresses, the value of Prompt_weight is continuously updated, while Pretrain_weight remains unchanged. Step (1) When a user starts a conversation, they need to log in through the dialogue engine model. The conversation can only begin after the model verification is successful. After the dialogue is started in step (2), the dialogue engine module first receives the user input, cleans the user input, and records the processed text as Input; and initializes History to an empty string. Step (3) The dialogue engine model transmits the user ID to the patient information module and calls the patient's historical diagnosis information, which is recorded as Message; Step (4) After the dialogue engine model obtains the Message, it concatenates the Message, History, and Input in order using \n, and then trims the text length to 1024; then it transmits it to the Prompt language model module. Step (5) After the Prompt language model module obtains Message, History, and Input, it returns the result after a series of encoding, calculation, and decoding operations, which is recorded as Response; Step (6) The dialogue engine model obtains the Response and returns it to the user. At the same time, it uses \n to concatenate the History, Input, and Response in order and updates it to a new History. Step (7) Repeat steps (2) - (6) to achieve multi-turn dialogue; obtain the dialogue context through the context-aware mechanism and perform semantic analysis on the input; then update or obtain patient information, query the medical knowledge base, and generate system response; Encrypted connections ensure the security of information transmission.
2. The Chinese multi-turn dialogue medical system based on the Prompt language model according to claim 1, characterized in that, The dialogue engine module is responsible for handling the dialogue flow between user input and system output. The dialogue engine module is built using the Python Flask framework and includes capturing patient input, returning output, text cleaning, saving historical sessions, managing basic patient information, and authenticating patient permissions.
3. The Chinese multi-turn dialogue medical system based on the Prompt language model according to claim 1, characterized in that, The patient information module is used to collect, store, and manage basic patient information. This module utilizes database technology to establish a patient information database, ensuring information security and privacy protection.
4. The Chinese multi-turn dialogue medical system based on the Prompt language model according to claim 1, characterized in that, The Prompt language model module is implemented based on a deep learning model and is used to answer relevant questions raised by patients. The Prompt language model module adopts the Transformer self-attention mechanism technology, uses a large amount of unsupervised medical data to train a pre-trained model, and then performs Prompt-tuning on the pre-trained model based on a small amount of data to obtain the Prompt language model.
5. The Chinese multi-turn dialogue medical system based on the Prompt language model according to claim 1, characterized in that, The dialogue engine module adopts the Transformer architecture to improve the dialogue understanding effect; it utilizes the prompt-tuning pre-trained Chinese Prompt language model and achieves customization in the medical field through fine-tuning, while introducing a context-aware autonomy mechanism to better understand the context of multi-turn dialogues.
6. The Chinese multi-turn dialogue medical system based on the Prompt language model according to claim 1, characterized in that, The patient information module uses a distributed database to ensure the real-time nature and reliability of information; it also incorporates SSL / TLS encryption technology to guarantee the secure transmission and storage of patient information.
7. The Chinese multi-turn dialogue medical system based on the Prompt language model according to claim 1, characterized in that, An apparatus for a Chinese multi-turn dialogue medical system based on the Prompt language model includes a memory, a processor, and a computer program stored in the memory and running on the processor. When the processor executes the program, it implements the steps of a method for a Chinese multi-turn dialogue medical system based on the Prompt language model.
8. The Chinese multi-turn dialogue medical system based on the Prompt language model according to claim 1, characterized in that, The storage medium of the Chinese multi-turn dialogue medical system based on the Prompt language model is a non-transitory computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, it implements the steps of the Chinese multi-turn dialogue medical system method based on the Prompt language model.