Chat method and system for character science popularization education based on large language model, and chat robot

Through chat methods and systems based on large language model, vertical application and multi-module structure are constructed, and the problem of lack of targeted and coverage of popular science education information of characters in the existing technology is solved, and the semantic accuracy of large language model in the field of popular science education of characters is realized. and personalized response to personalization, improving information quality and user satisfaction.

CN119202208AInactive Publication Date: 2024-12-27EAST CHINA NORMAL UNIV

Patent Information

Application Number
CN202411712052.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-27
Publication Date
2024-12-27
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

The existing technology lacks popular science education information for people with strong targeted and wide coverage, and it is difficult to provide detailed and personalized popular science education services for people with low user satisfaction and information consultation efficiency.

Method used

Chat methods and systems based on large language models, through the construction of vertical application fine-tuning models, multi-module structures and high-dimensional vector retrieval, the semantic understanding and personalization generation of popular science education information of characters is realized, including fine-tuning modules and message list maintenance modules , intention recognition module, knowledge base system module and knowledge output module, dynamically convert user query into an input format that can be understood by large language models, and generate popular science education information for people that conform to user intentions and tone.

Benefits of technology

The semantic accuracy and response personalization of the large language model in the field of popular science education of characters is realized, providing users with detailed, accurate and in line with the needs background, improving information quality and user satisfaction.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119202208A_ABST
    Figure CN119202208A_ABST
Patent Text Reader

Abstract

The invention discloses a chatting method and system for character science popularization education based on a large language model, and a chatting robot. The chatting method comprises the steps of character popular science education targeted vertical training, message list construction, user query input and intention recognition, character popular science education knowledge base retrieval and matching, user query recording, input format adjustment and content enhancement, preliminary character popular science education response generation and large language model response recording. Outputting people science popularization education knowledge; the system comprises a fine tuning module, a message list maintenance module, an intention recognition module, a knowledge base system module, a format adaptive conversion module and a knowledge output module. In a word, compared with the prior art, the method has the advantages that a new solution is provided for self-adaptive and dynamic intelligent generation of the chatting robot for people science popularization education, and technical advancement and high efficiency are brought to vertical application of people science popularization education of a large language model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to a new generation of information technology and products, specifically a chat method, system and chat robot for character science education based on a large language model. Background Art

[0002] In the development of artificial intelligence, the construction and application of large language models have achieved remarkable results in general fields. In character popular science education, large language models can help understand and process character information and related queries, and provide automated consulting and analysis services.

[0003] However, there is no vertical application of large language models that focuses on popular science education of characters. Traditional methods are unable to provide highly targeted and wide-coverage popular science education information of characters due to the lack of highly targeted services and in-depth analysis of complex queries. For example, the lack of a general summary of the character's life and a cutting-edge method for calculating the similarity of the character information knowledge base makes it difficult to provide users with detailed and personalized popular science education information of characters, which not only reduces user satisfaction, but also affects the individual targeting and efficiency of character information consulting services.

[0004] Among them, the chat method of character science education aims to provide effective communication and science education for character information issues. Through this method, users can use natural language to query the big language model about the character's life, works or achievements, and the big language model can understand the query and provide relevant and accurate information. Improve the efficiency and quality of character information consultation and management, so that users can obtain character science education information in a more intuitive and convenient way.

[0005] Therefore, there is an urgent need for chat methods, systems and chat robots for character science education based on large language models to achieve personalized and accurate services for character information issues. Summary of the invention

[0006] The purpose of the present invention is to realize a chat method, system and chat robot for character science education based on a large language model. By constructing a chat method, a multi-module structure system and a chat robot based on a large language model, the vertical application of the large language model for character science education is realized, and the semantic understanding and information generation capabilities of the large language model for character science education are optimized.

[0007] The specific technical solution for achieving the purpose of the present invention is:

[0008] A chat method for popular science education of characters based on a large language model, specifically comprising:

[0009] Targeted vertical training for character science education: Build a character science education knowledge base based on public social data, reorganize the format, and form a character science education fine-tuning instruction data set; use the character science education instruction data to fine-tune the pre-trained large language model through instruction supervision, so that the large language model can learn character science education knowledge, thereby building a large vertical model for character science education;

[0010] Constructing a message list: constructing a message list for the user, which is used to dynamically store and maintain the conversation history; the method of constructing a message list specifically includes: using Python to create a list data structure, the elements of which are the dialogue roles and their conversation contents; the method of dynamically storing the conversation history specifically includes recording the roles and their conversation contents in each round of conversation, and filling them into the list elements through the append() function; the method of maintaining the conversation history specifically includes setting a maximum history length tag, and timely cleaning up the conversation history that exceeds the maximum history length;

[0011] User query input and intent recognition: Query intent analysis is performed based on user input to determine the user's demand background. Specifically, the user inputs a character consultation question, and based on the user input information, the sentence structure is analyzed using natural language processing technology to extract key information including names and achievements to identify the user's demand background.

[0012] Retrieval and matching of the character science education knowledge base: Use the FAISS library to perform high-dimensional vectorization on the constructed character science education knowledge base, project the character science education knowledge base into a high-dimensional vector space to form a vector database, perform text embedding operations on the user query content, and project it into a high-dimensional vector space with the same dimension as the vector database; use the FAISS library to filter out highly relevant text segments and set priority tags for them as reference text segments; the FAISS library is a library designed for large-scale vector similarity search disclosed by Facebook AI;

[0013] Record user queries: store user query content in the message list; specifically, fill the user into the role element through the append() function, and fill the user query content into the conversation content element content;

[0014] Input format adjustment and content enhancement: Dynamically convert user query content and reference text into an input format that can be understood by the large language model; specifically, formulate a PROMPT format for the large language model, and fill the user query and reference text with priority tags into the PROMPT format in a hierarchical manner;

[0015] Preliminary character science education response generation: Based on the adjusted input format and message list, the large language model generates a preliminary response to form a preliminary character science education response to the user's character consultation;

[0016] Record the large language model response: store the response content generated by the large language model into the message list; specifically, fill the large language model into the role element through the append() function, and fill the response content generated by the large language model into the conversation content element content;

[0017] Output of character science popularization education information: Based on the preliminary character science popularization education response and the user's demand background, the large language model is adaptively optimized internally to generate and display character science popularization education information that meets the user's intentions and tone; specifically, the preliminary character science popularization education response and the user's demand background are re-infused into the large language model, and the large language model is adaptively optimized internally to generate and display character science popularization education information that meets the user's intentions and tone; the generated answer content is visualized to highlight the character's key information and educational information on the visualization interface.

[0018] A chat system for popular science education of characters based on a large language model, the chat system for popular science education of characters based on a large language model is used to execute the chat method for popular science education of characters based on a large language model, the system comprising:

[0019] Fine-tuning module, message list maintenance module, intention recognition module, knowledge base system module, format adaptive conversion module and knowledge output module;

[0020] The fine-tuning module realizes vertical training of the large language model and constructs a vertical large model of character popular science education; the message list maintenance module stores and maintains the dialogue history between the user and the large language model in real time, realizes the multi-round dialogue function for the large language model, and enhances the context understanding ability; the intention recognition module realizes the recognition of the user's demand background, and instills the demand background into the large language model to enhance the personalized generation of responses; the knowledge base system module realizes the storage and matching of character information, and provides support for the semantic precision of the character popular science education information generated by the large language model; the format adaptive conversion module realizes the dynamic conversion of the PROMPT format, and realizes the large language model's precise understanding of user queries, contextual relationships and reference paragraphs; the knowledge output module realizes the generation and visualization of character popular science education information based on the large language model.

[0021] Furthermore, the fine-tuning module specifically includes a data collection and preprocessing stage and an instruction fine-tuning stage;

[0022] The data collection and preprocessing stage specifically includes obtaining a large amount of character information from public data and performing data cleaning on the information, including removing duplicate and invalid information, correcting erroneous text, manual annotation and format standardization, so as to build a high-quality character science education knowledge base; the public data comes from authoritative publications, academic papers, official records and public online character biographical databases to ensure the credibility and authority of the data; the high-quality character science education knowledge base specifically refers to a knowledge base that stores character information after data processing, which is used to improve the accuracy of the large language model's response to character science education;

[0023] The instruction fine-tuning stage specifically includes organizing and reorganizing the constructed high-quality character popular science education knowledge base according to the popular science education instruction format to form an instruction data set for fine-tuning the character popular science education data field; based on the instruction data set, the LoRA method is used to fine-tune the large language model in the vertical field of character popular science education; the LoRA method specifically refers to a method for adjusting the internal weights of a pre-trained large language model by introducing a low-rank matrix while ensuring that the overall parameter quantity of the model remains unchanged; the popular science education instruction format specifically refers to an instruction format that includes a task description, a target character query input, and a target character popular science education information output.

[0024] Furthermore, the message list maintenance module specifically includes a message list construction phase and a message list dynamic maintenance phase;

[0025] The message list building phase specifically includes building a message list for the user, which records the user's conversation history and saves the user's query content and the response generated by the large language model in each round of conversation;

[0026] The dynamic maintenance of the message list stage specifically includes streamlining the update content of the message list in each round of updates, only recording the original query content of the user and the response content of the large language model in each round of conversation, and the latest user query is dynamically converted into the PROMPT format during actual use; setting a maximum history length label to promptly clean up the conversation history that exceeds the maximum history length.

[0027] Furthermore, the intention recognition module specifically includes using natural language processing technology based on user input to perform sentence structure analysis on user input content, extract key information including names and achievements, so as to identify the user's demand background.

[0028] Furthermore, the knowledge base system module specifically includes a vector database construction phase and a vector search engine establishment phase;

[0029] The vector database construction phase specifically includes segmenting the text in the character science education knowledge base, and the text segmentation is completed by the recursive character text segmenter RCTS, using a variety of characters to ensure the coherence of the text during segmentation; converting the segmented text fragments into vector format, generating embedding vectors of the same dimension through the MistralAI Embeddings embedding model, and using the FAISS library to centrally store the embedding vectors to form a vector database; the vector database is stored in the local memory to support fast loading and response to user queries;

[0030] The vector search engine establishment phase specifically includes using the FAISS library to build a similarity calculation function to implement the vector similarity calculation task, calculating the similarity between the user query vector and the vectors of each paragraph in the vector database through the cosine similarity calculation method, selecting the top_k most similar paragraphs and setting priority tags according to the similarity, as a reference corpus when the large language model generates a response.

[0031] Furthermore, the format adaptive conversion module specifically includes a PROMPT format for popular science education of characters and a PROMPT dynamic filling;

[0032] The PROMPT is a Chain-of-Thought PROMPT in the advanced prompt word engineering, which combines the user's query content, relevant context content and character science education rules in a thought chain manner, and converts the user input and reference paragraphs into an input format that can be understood by the large language model;

[0033] The dynamic filling of PROMPT specifically includes calculating the vector similarity between the user query and the Chinese paragraph in the vector database through the vector search engine in the knowledge base system module, selecting the reference paragraph, and dynamically filling the user query and the reference document into the corresponding position in the PROMPT format.

[0034] Furthermore, the knowledge output module specifically includes a preliminary response generation stage, an adaptive optimization response stage and a visual interface display stage;

[0035] The preliminary response generation stage specifically includes taking the message list and the adjusted input format as input content, inputting them into the large language model to generate a preliminary character science education response;

[0036] The adaptive optimization response stage specifically includes instilling the user's demand background obtained by the intention recognition module and the preliminary character science education response into the large language model, and the large language model adjusts and optimizes the preliminary character science education response according to the user's demand background and the reference text to generate character science education information that meets the user's intention and tone;

[0037] The visualization interface display stage specifically includes using HTML to build a web page, which visualizes the generated popular science education information of the character, and uses CSS to highlight the key information and educational information of the character on the page.

[0038] A chat robot for character science education based on a large language model comprises a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps of the above-mentioned chat method when executing the computer program.

[0039] Compared with the prior art, the present invention provides a new solution for adaptive, dynamic and intelligent generation of popular science education information of characters based on a large language model; wherein, the chat method streamlines the generation of popular science education information of characters queried by users, realizes the semantic precision and personalized response of the large language model, and provides users with accurate, detailed and popular science education information of characters that meets the background of user needs; the multi-modular system architecture has extremely high scalability, each module provides technical support for the chat method, and the modules use efficient and advanced technical solutions to realize the functions of each module, which greatly improves the quality of popular science education information of characters. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] FIG1 is a flow chart of the chat method of the present invention;

[0041] FIG2 is a diagram showing the chat system architecture of the present invention;

[0042] FIG3 is a schematic diagram of a fine-tuning module of the present invention;

[0043] FIG4 is a schematic diagram of a message list maintenance module of the present invention;

[0044] FIG5 is a schematic diagram of an intention recognition module of the present invention;

[0045] FIG6 is a schematic diagram of a knowledge base system module of the present invention;

[0046] FIG7 is a schematic diagram of a format adaptive conversion module of the present invention;

[0047] FIG8 is a schematic diagram of a knowledge output module of the present invention;

[0048] FIG9 is a schematic diagram of the PROMPT format of the present invention;

[0049] FIG. 10 is a diagram illustrating the dialogue flow of the present invention. DETAILED DESCRIPTION

[0050] The specific implementation modes of the present invention are described in detail below in conjunction with the accompanying drawings, but it should be understood that the protection scope of the present invention is not limited by the specific implementation modes.

[0051] Example

[0052] See also Figure 1 The present invention provides a technical solution: a chat method for character science education based on a large language model, comprising the following steps:

[0053] S1. Targeted vertical training of popular science education for people: Build a knowledge base of popular science education for people based on public social data, reorganize the format, and form a fine-tuned instruction data set for popular science education for people; use the popular science education instruction data for people to supervise and fine-tune the pre-trained large language model, so that the large language model can learn the knowledge of popular science education for people, thereby building a large vertical model of popular science education for people; the purpose of this step is to build an optimized large vertical model of popular science education for people as a base model, providing high coverage and high accuracy of basic knowledge and understanding ability of popular science education for people, which is the core foundation for subsequent steps;

[0054] S2, build message list: build a message list for the user, which is used to dynamically store and maintain the conversation history; in this embodiment, it specifically includes: using Python to create a list data structure, the elements of which are the dialogue roles and their conversation content; recording the roles and their conversation content in each round of conversation, and filling them into the list elements through the append() function; setting a maximum history length tag, and timely cleaning up the conversation history that exceeds the maximum history length; the role of this step is to support the context understanding and coherence of the large language model in multiple rounds of conversations, allowing users to conduct deeper queries based on the conversation history, and timely clean up redundant storage space to ensure stability and efficiency in complex conversation scenarios;

[0055] S3, user query input and intent recognition: query intent analysis is performed based on user input to determine the user's demand background; specifically, the user inputs a character consultation question, and based on the user input information, the sentence structure is analyzed using natural language processing technology to extract key information including names and achievements to identify the user's demand background; the purpose of this step is to provide a clear direction for the subsequent generation of character science education information by identifying the user's demand background, and ensure that the large language model generates personalized character science education information that is highly relevant to the user's query;

[0056] S4. Retrieval and matching of the character science education knowledge base: Use the FAISS library to perform high-dimensional vectorization on the constructed character science education knowledge base, project the character science education knowledge base into a high-dimensional vector space to form a vector database, perform text embedding operation on the user query content, and project it into a high-dimensional vector space with the same dimension as the vector database; use the FAISS library to screen out highly relevant text segments and set priority tags for them as reference text segments; wherein, the FAISS library is a library designed for large-scale vector similarity search disclosed by Facebook AI; the purpose of this step is to achieve accurate matching of user query content with relevant information in the knowledge base through efficient vectorization retrieval technology, and ensure the semantic accuracy of the character science education information generated by the large language model;

[0057] S5. Record user query: store the user query content in the message list; specifically, fill the user into the role element through the append() function, and fill the user query content into the conversation content element content; the purpose of this step is to record the user's query history, ensure that context information is retained in multiple rounds of conversations, and provide data support for user conversations for continuous understanding and dynamic response;

[0058] S6. Input format adjustment and content enhancement: Dynamically convert user query content and reference text into an input format that can be understood by the large language model; specifically, formulate a PROMPT format for the large language model, and fill the user query and reference text with priority tags into the PROMPT format in a hierarchical manner; the purpose of this step is to further improve the large language model's ability to understand user query content by optimizing the input format and integrating reference text, accurately understand the user's intention and demand background, and help the large language model generate more accurate and user-friendly popular science education information;

[0059] S7, generating preliminary character popular science education response: Based on the adjusted input format and message list, the large language model generates a preliminary response to form a preliminary character popular science education response for the user's character consultation; the purpose of this step is to use the large language model to comprehensively analyze and process the user's query content and related context, quickly generate a preliminary response that matches the user's needs, and lay the foundation for subsequent response optimization and personalized enhancement;

[0060] S8. Record the response of the large language model: store the response content generated by the large language model into the message list; specifically, fill the large language model into the role element through the append() function, and fill the response content generated by the large language model into the content element of the conversation content; the purpose of this step is to record the response history of the large language model, ensure that the context information is retained in multiple rounds of conversations, and provide data support for the large language model conversation for continuous understanding and dynamic response;

[0061] S9, output of character science education information: Based on the preliminary character science education response and the user demand background, the large language model is adaptively optimized internally to generate and display character science education information that meets the user's intention and tone; specifically, the preliminary character science education response and the user's demand background are re-instilled into the large language model, and the large language model is adaptively optimized internally to generate and display character science education information that meets the user's intention and tone; the generated answer content is visualized, and the key information and educational information of the character are highlighted on the visualization interface. The purpose of this step is to further enhance the personalization and accuracy of the character science education information by deeply integrating the preliminary character science education response with the user demand background identified in step S3, and present it through a visualization interface to improve the educational value and user participation of the character science education information.

[0062] See also Figure 2 The present invention provides a technical solution: a chat system for popular science education of characters based on a large language model, comprising the following modules:

[0063] Fine-tuning module, message list maintenance module, intention recognition module, knowledge base system module, format adaptive conversion module and knowledge output module.

[0064] The fine-tuning module realizes vertical training of the large language model and constructs a vertical large model of character popular science education; the message list maintenance module stores and maintains the dialogue history between the user and the large language model in real time, realizes the multi-round dialogue function for the large language model, and enhances the context understanding ability; the intention recognition module realizes the recognition of the user's demand background, and instills the demand background into the large language model to enhance the personalized generation of responses; the knowledge base system module realizes the storage and matching of character information, and provides support for the semantic precision of the character popular science education information generated by the large language model; the format adaptive conversion module realizes the dynamic conversion of the PROMPT format, and realizes the large language model's precise understanding of user queries, contextual relationships and reference paragraphs; the knowledge output module realizes the generation and visualization of character popular science education information based on the large language model.

[0065] The specific implementation process of each module in this embodiment is as follows.

[0066] Referring to FIG3 , the fine-tuning module specifically includes a data collection and preprocessing stage and an instruction fine-tuning stage;

[0067] The data collection and preprocessing stage specifically includes obtaining a large amount of character information from public data and performing data cleaning on the information, including removing duplicate and invalid information, correcting erroneous text, manual annotation and format standardization, so as to build a high-quality character science popularization education knowledge base; the public data used in this embodiment comes from the public database of East China Normal University, which contains public science popularization education materials covering a wide range of scientific topics: a compilation of literature on relevant social science famous teachers recorded in the famous teacher database of East China Normal University, and information on social science famous teachers who have made significant contributions to society, to ensure the credibility and authority of the data; the high-quality character science popularization education knowledge base specifically refers to a knowledge base that stores character information after data processing, which is used to improve the response accuracy of the large language model to character science popularization education; wherein, the main idea in the deduplication cleaning work is to determine whether it is a duplicate document by comparing the Jaccard similarity of two documents, the similarity threshold is set to 0.5, and the documents with Jaccard similarity lower than the similarity threshold are regarded as duplicate documents and deleted; wherein, Jaccard similarity is defined as the ratio of the size of the intersection of A and B to the size of the union of A and B, in this embodiment, A and B They are two documents to be compared;

[0068] The instruction fine-tuning stage specifically includes organizing and reorganizing the constructed high-quality character science education knowledge base according to the science education instruction format to form an instruction data set for fine-tuning the character science education data field; in this embodiment, the science education instruction format is as follows:

[0069] Input: Please introduce [name of person]

[0070] Output:

[0071] 1. [Name of person] ([year of birth] - [year of death]) is a distinguished [professional / identity] in [professional field], widely known for his [major achievements or contributions] in [specific field].

[0072] 2. He / she was born on [specific date] in [place of birth] and his / her early life experiences include [brief description of early life experiences, such as family background, education or early career, etc.].

[0073] 3. He / she has made significant contributions in [a certain field], such as [Specific example 1, describing the importance of the contribution and how it has changed the relevant field], [Specific example 2, further elaborating on another important achievement], etc.

[0074] 4. His thoughts or works not only had a profound impact during his lifetime, but also continued to play an important role in later generations, especially in terms of [specific impacts, such as scientific discoveries, technological innovations, or changes in social concepts].

[0075] 5. For more biographies, please see: 1. [Excerpt 1 (Excerpt source 1)]; 2. [Excerpt 2 (Excerpt source 2)].

[0076] Based on the instruction dataset, the LoRA method is used to fine-tune the instructions in the vertical field of popular science education for the large language model; the LoRA method specifically refers to a method for adjusting the internal weights of a pre-trained large language model by introducing a low-rank matrix while ensuring that the overall parameter quantity of the model remains unchanged.

[0077] Referring to FIG4 , the message list maintenance module specifically includes a message list construction phase and a message list dynamic maintenance phase;

[0078] The message list building phase specifically includes using Python to build a message list for the user (messages=[]), which records the user's conversation history, and uses the messages.append() function to save the user's query content and the response generated by the large language model in each round of conversation;

[0079] The dynamic maintenance of the message list stage specifically includes streamlining the updated content of the message list at each update round, recording only the original user query content and the response content of the large language model in each round of conversation, and dynamically converting the latest user query to the PROMPT format when actually used; setting the maximum history length tag (max_history_length), and using the messages.pop(0) function to remove the earliest historical message when the conversation history exceeds the limit; traditional message lists usually directly maintain the complete PROMPT format, which contains a large amount of information that is highly repeated with the response content generated by the large language model, resulting in information redundancy. By streamlining and dynamically managing the conversation history at this stage, the redundancy problem in the traditional message list is effectively solved, while ensuring that the large language model can efficiently use relevant context information when generating responses, improving system performance and response quality.

[0080] Referring to FIG5 , the intention recognition module specifically includes, based on user input, using natural language processing technology to perform sentence structure analysis on the user input content, extract key information including names and achievements, and identify the user's demand background. The user demand background identified by this module provides a clear direction for the subsequent generation of character science popularization education information, ensuring that the large language model generates personalized character science popularization education information that is highly relevant to the user query.

[0081] Referring to FIG6 , the knowledge base system module specifically includes a vector database construction phase and a vector search engine establishment phase;

[0082] The vector database construction phase specifically includes an efficient and structured method for processing a large amount of character science education knowledge base text data, and the sub-steps of the method are as follows:

[0083] 1. Text segmentation: First, the long text in the character science education knowledge base is reasonably segmented. This step uses a technology called Recursive Character Text Splitter (RCTS). RCTS technology recursively segments the text by detecting a preset character list. The preset character list in this stage is ["\n\n", "\n", " ", "。", ", ", "\u200b", "\uff0c", "\u3001", "\uff0e", "\u3002", ""]; the zero-width spaces and various full-width symbols in the character list are used to maintain the integrity of the words, and the original text is recursively divided into a series of smaller, easy-to-manage paragraphs or "chunks" according to the preset character list, chunk_size and chunk_overlap parameters. Among them, the chunk_size specifies the target length of each chunk (in characters), and chunk_overlap specifies the number of characters shared between adjacent chunks to maintain the coherence and integrity of the context between paragraphs. In this embodiment, chunk_size is set to 512 characters, and chunk_overlap is set to 50 characters, that is, each paragraph contains at least 462 new characters, and 50 characters overlap with the previous paragraph, and so on;

[0084] 2. Build a vector database: Convert the segmented text fragments into vector form through the pre-trained open source embedding model MistralAI Embeddings, which maps the segmented text fragments into a fixed-dimensional space preset by the model to form embedded vectors in the same high-dimensional space. With the help of the Facebook AI Research (FAISS) library, these embedded vectors are centrally stored in the local file system to form a vector database. The FAISS library is a library designed for large-scale vector similarity search disclosed by Facebook AI;

[0085] The vector search engine establishment phase specifically includes using the FAISS library to build a similarity calculation function, implementing the vector similarity calculation task, calculating the similarity between the user query vector and each text segment vector in the vector database through the cosine similarity calculation method, selecting the top_k text segments with the highest similarity and setting priority tags according to the similarity level, as the reference corpus when the large language model generates a response. Among them, the cosine similarity calculation method is as follows: , when the cosine value of the two vectors is closer to 1, it means that the angle between the two vectors is closer to 0 degrees, that is, the two vectors are more similar, indicating that the paragraph in the vector database has a higher similarity with the user query. Among them, is the cosine of the angle between the two vectors, is the midpoint of the n-dimensional vector space The i-th component of is the midpoint of the n-dimensional vector space The i-th component of , a and b are two vectors. The top_k most similar passages are selected as the reference corpus when the large language model generates responses.

[0086] Refer to FIG. 7 , the format adaptive conversion module specifically includes the PROMPT format for character science education and PROMPT dynamic filling;

[0087] The PROMPT is a Chain-of-Thought PROMPT in the advanced prompt word engineering. It combines the user's query content, relevant context content and character science education rules in a thought chain manner, and converts the user input and reference paragraphs into an input format that can be understood by the large language model. The design of the Chain-of-Thought PROMPT guides the large language model to gradually deduce the generation process of character science education information, and significantly improves the ability of the large language model in processing the user's multi-level query logical relationship, making the generated character science education information more intelligent and more in line with the user's actual needs. See Figure 9 for the specific PROMPT format design.

[0088] The dynamic filling of PROMPT specifically includes calculating the vector similarity between the user query and the Chinese paragraphs in the vector database through the vector search engine in the knowledge base system module, selecting the top_k paragraphs with the highest similarity as reference paragraphs, and dynamically filling the user query and the reference document into the corresponding positions in the PROMPT format.

[0089] Referring to FIG8 , the knowledge output module specifically includes a preliminary response generation stage, an adaptive optimization response stage, and a visualization interface display stage;

[0090] The preliminary response generation stage specifically includes taking the message list and the adjusted input format as input content, inputting them into the large language model to generate a preliminary character science education response;

[0091] The adaptive optimization response stage specifically includes instilling the user's demand background obtained by the intent recognition module and the preliminary character science education response into the large language model, and adjusting and optimizing the preliminary character science education response according to the user's demand background and reference text in the large language model to generate character science education information that meets the user's intention and tone; this stage deeply integrates the preliminary character science education response with the user's demand background identified by the intent recognition module to further enhance the personalization and accuracy of the character science education information; and presents it through a visual interface.

[0092] The visualization interface display stage specifically includes using HTML to build a web page, which visualizes the generated character science education information, and uses CSS to highlight the character's key information and educational information on the page to improve the educational value of the character science education information and user participation.

[0093] Please refer to FIG. 10 , which is a diagram showing a demonstration of the dialogue flow of this embodiment, illustrating a user's chat history about famous thinkers and teachers.

[0094] The above is only a specific implementation of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can make equivalent replacements or changes according to the technical solution and inventive concept of the present invention within the scope disclosed by the present invention, which are all included in the protection scope of the present invention.

Claims

1. A chat method for character science education based on a large language model, characterized in that: The method comprises: Targeted vertical training for character science education: Build a character science education knowledge base based on public social data, reorganize the format, and form a character science education fine-tuning instruction data set; use the character science education instruction data to fine-tune the pre-trained large language model through instruction supervision, so that the large language model can learn character science education knowledge, thereby building a large vertical model for character science education; Build message list: Build message list for users to dynamically store and maintain conversation history; specifically, create a list data structure using Python, where the elements of the list are the roles and their content; record the roles and their content in each round of conversation, and fill them into the list elements through the append() function; set the maximum history length tag, and clean up the conversation history that exceeds the maximum history length in time; User query input and intent recognition: Query intent analysis is performed based on user input to determine the user's demand background. Specifically, the user inputs a character consultation question, and based on the user input information, the sentence structure is analyzed using natural language processing technology to extract key information including names and achievements to identify the user's demand background. Retrieval and matching of the character science education knowledge base: Use the FAISS library to perform high-dimensional vectorization on the constructed character science education knowledge base, project the character science education knowledge base into a high-dimensional vector space to form a vector database, perform text embedding operations on the user query content, and project it into a high-dimensional vector space with the same dimension as the vector database; use the FAISS library to filter out highly relevant text segments and set priority tags for them as reference text segments; wherein, the FAISS library is a library designed for large-scale vector similarity search disclosed by Facebook AI; Record user queries: store user query content in the message list; specifically, fill the user into the role element through the append() function, and fill the user query content into the conversation content element content; Input format adjustment and content enhancement: Dynamically convert user query content and reference text into an input format that can be understood by the large language model; specifically, formulate a PROMPT format for the large language model, and fill the user query and reference text with priority tags into the PROMPT format in a hierarchical manner; Preliminary character science education response generation: Based on the adjusted input format and message list, the large language model generates a preliminary response to form a preliminary character science education response to the user's character consultation; Record the large language model response: store the response content generated by the large language model into the message list; specifically, fill the large language model into the role element through the append() function, and fill the response content generated by the large language model into the conversation content element content; Output of character science popularization education information: Based on the preliminary character science popularization education response and the user's demand background, the large language model is adaptively optimized internally to generate and display character science popularization education information that meets the user's intentions and tone; specifically, the preliminary character science popularization education response and the user's demand background are re-infused into the large language model, and the large language model is adaptively optimized internally to generate and display character science popularization education information that meets the user's intentions and tone; the generated answer content is visualized to highlight the character's key information and educational information on the visualization interface.

2. A chat system for character science education based on a large language model, characterized in that: The chat system for character science popularization education based on a large language model is used to execute the chat method for character science popularization education based on a large language model as claimed in claim 1, and the system comprises: Fine-tuning module, message list maintenance module, intention recognition module, knowledge base system module, format adaptive conversion module and knowledge output module; The fine-tuning module realizes vertical training of the large language model and constructs a vertical large model of character popular science education; the message list maintenance module stores and maintains the dialogue history between the user and the large language model in real time, realizes the multi-round dialogue function for the large language model, and enhances the context understanding ability; the intention recognition module realizes the recognition of the user's demand background, and instills the demand background into the large language model to enhance the personalized generation of responses; the knowledge base system module realizes the storage and matching of character information, and provides support for the semantic precision of the character popular science education information generated by the large language model; the format adaptive conversion module realizes the dynamic conversion of the PROMPT format, and realizes the large language model's precise understanding of user queries, contextual relationships and reference paragraphs; the knowledge output module realizes the generation and visualization of character popular science education information based on the large language model.

3. The chat system according to claim 2, characterized in that: The fine-tuning module specifically includes a data collection and preprocessing stage and an instruction fine-tuning stage; The data collection and preprocessing stage specifically includes obtaining a large amount of character information from public data and performing data cleaning on the information, including removing duplicate and invalid information, correcting erroneous text, manual annotation and format standardization, so as to build a high-quality character science education knowledge base; the public data comes from authoritative publications, academic papers, official records and public online character biographical databases to ensure the credibility and authority of the data; the high-quality character science education knowledge base specifically refers to a knowledge base that stores character information after data processing, which is used to improve the accuracy of the large language model's response to character science education; The instruction fine-tuning stage specifically includes organizing and reorganizing the constructed high-quality character popular science education knowledge base according to the popular science education instruction format to form an instruction data set for fine-tuning the character popular science education data field; based on the instruction data set, the LoRA method is used to fine-tune the large language model in the vertical field of character popular science education; the LoRA method specifically refers to a method for adjusting the internal weights of a pre-trained large language model by introducing a low-rank matrix while ensuring that the overall parameter quantity of the model remains unchanged; the popular science education instruction format specifically refers to an instruction format that includes a task description, a target character query input, and a target character popular science education information output.

4. The chat system according to claim 2, characterized in that: The message list maintenance module specifically includes a message list construction phase and a message list dynamic maintenance phase; The message list building phase specifically includes building a message list for the user, which records the user's conversation history and saves the user's query content and the response generated by the large language model in each round of conversation; The dynamic maintenance of the message list stage specifically includes streamlining the update content of the message list in each round of updates, only recording the original query content of the user and the response content of the large language model in each round of conversation, and the latest user query is dynamically converted into the PROMPT format during actual use; setting a maximum history length label to promptly clean up the conversation history that exceeds the maximum history length.

5. The chat system according to claim 2, characterized in that: The intention recognition module specifically includes, based on user input, using natural language processing technology to perform sentence structure analysis on the user input content, extract key information including names and achievements, so as to identify the user's demand background.

6. The chat system according to claim 2, characterized in that: The knowledge base system module specifically includes a vector database construction phase and a vector search engine establishment phase; The vector database construction phase specifically includes segmenting the text in the character science education knowledge base, and the text segmentation is completed by the recursive character text segmenter RCTS, using a variety of characters to ensure the coherence of the text during segmentation; converting the segmented text fragments into vector format, generating embedding vectors of the same dimension through the MistralAI Embeddings embedding model, and using the FAISS library to centrally store the embedding vectors to form a vector database; the vector database is stored in the local memory to support fast loading and response to user queries; The vector search engine establishment phase specifically includes using the FAISS library to build a similarity calculation function to implement the vector similarity calculation task, calculating the similarity between the user query vector and the vectors of each paragraph in the vector database through the cosine similarity calculation method, selecting the top_k most similar paragraphs and setting priority tags according to the similarity, as a reference corpus when the large language model generates a response.

7. The chat system according to claim 2, characterized in that: The format adaptive conversion module specifically includes the PROMPT format for character science education and PROMPT dynamic filling; The PROMPT is a Chain-of-Thought PROMPT in the advanced prompt word engineering, which combines the user's query content, relevant context content and character science education rules in a thought chain manner, and converts the user input and reference paragraphs into an input format that can be understood by the large language model; The dynamic filling of PROMPT specifically includes calculating the vector similarity between the user query and the Chinese paragraph in the vector database through the vector search engine in the knowledge base system module, selecting the reference paragraph, and dynamically filling the user query and the reference document into the corresponding position in the PROMPT format.

8. The chat system according to claim 2, characterized in that: The knowledge output module specifically includes a preliminary response generation stage, an adaptive optimization response stage and a visual interface display stage; The preliminary response generation stage specifically includes taking the message list and the adjusted input format as input content, inputting them into the large language model to generate a preliminary character science education response; The adaptive optimization response stage specifically includes instilling the user's demand background obtained by the intention recognition module and the preliminary character science education response into the large language model, and the large language model adjusts and optimizes the preliminary character science education response according to the user's demand background and the reference text to generate character science education information that meets the user's intention and tone; The visualization interface display stage specifically includes using HTML to build a web page, which visualizes the generated popular science education information of the character, and uses CSS to highlight the key information and educational information of the character on the page.

9. A chat robot for character science education based on a large language model, comprising a memory and a processor, characterized in that: The memory stores a computer program, and the processor implements the steps of the chatting method described in claim 1 when executing the computer program.

Citation Information

Patent Citations

  • Data retrieval method and system based on large language model

    CN116701431A

  • Method for improving response speed of large-scale language model based on similarity retrieval

    CN116910221A

  • Intelligent education chat robot training method based on large language model

    CN117171322A

  • AI-based medical science popularization digital human software and method

    CN118861256A

  • System and method for a cognitive conversation service

    US20220358295A1

Cited By

  • Multi-object picking and placing method for autonomous mobile mechanical arm robot

    CN120735030A

  • Intelligent dialogue method, system and device based on private data and storage medium

    CN120893561A

  • Learner emotion intelligent identification method based on multi-mode adaptive fusion network

    CN121117737A