Knowledge base question and answer platform construction method based on large language model
By using a knowledge base question-answering platform based on a large language model, we have achieved efficient processing of multi-source heterogeneous data and support for multi-turn dialogues. This solves the problems of high semantic understanding and maintenance costs in existing systems and improves the accuracy and security of question answering.
Patent Information
- Application Number
- CN202511470313.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-15
- Publication Date
- 2025-11-18
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing knowledge base question answering systems lack the ability to understand user query intent and deep semantic relationships between words, cannot cope with the diversity of expressions and the complexity of language, lack the ability to integrate and recreate information, cannot support multi-turn dialogues, have high maintenance costs, and lack quality assessment and security control of output content.
It adopts a knowledge base question answering platform based on a large language model, which generates answers by collecting heterogeneous data from multiple sources, semantic segmentation and vectorization processing, combined with hybrid retrieval technology, and performs confidence assessment and security filtering, supporting multi-turn dialogue and real-time optimization.
It improves the accuracy and security of question answering, enables a flexible multi-turn dialogue experience, reduces maintenance costs, and optimizes the timeliness of the knowledge base through real-time updates.
Smart Images

Figure CN120973958A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of natural language processing, more particularly to a knowledge base question answering platform construction method based on a large language model. BACKGROUND
[0002] With the explosive growth of enterprise-level knowledge management needs and the popularization of artificial intelligence technology, efficient and accurate knowledge base question answering platforms have become key tools for improving information acquisition efficiency and empowering decision support.
[0003] Early knowledge base question answering systems rely heavily on rule templates and semantic parsing. Such systems usually require experts to manually write a large number of syntax and semantic rules to parse natural language questions into standardized query statements for knowledge bases. With the development of machine learning, researchers began to use feature engineering and statistical models to automatically learn the mapping of questions to query statements. The rise of deep learning, especially the application of recurrent neural networks and attention mechanisms, has driven the development of end-to-end models that can automatically learn vector representations of natural language and knowledge base semantics and directly predict answers or generate intermediate logical forms. The following defects exist: Heavy reliance on keyword-based literal matching, lack of understanding of user query intent and deep semantic relationships between words, unable to cope with the challenges of expression diversity and language complexity; Lack of information integration and re-creation capabilities, unable to extract core elements from multiple heterogeneous sources of information and generate coherent, concise, and direct answers, only returning original text fragments or preset fixed answers; Lack of active quality evaluation and risk control mechanisms for output content, the system cannot judge the accuracy and reliability of its answers, and has no content filtering capabilities, posing reliability and security risks; Usually designed as a standalone single-round question answering mode, without the ability to understand and remember the context of the conversation, unable to support coherent multi-round, context-related natural interactions, and the user experience is fragmented; Performance is highly dependent on pre-prepared rules, templates, or knowledge systems, and knowledge updates and system expansion require a lot of manual intervention, making it difficult to adapt to a dynamic knowledge environment, with high maintenance costs and complexity.
[0004] Therefore, a method with high flexibility, high accuracy, high reliability, efficient interaction, and real-time updating and optimization is needed to solve the above problems. SUMMARY
[0005] In order to overcome the above-mentioned defects of the prior art, the present application provides a knowledge base question answering platform construction method based on a large language model to solve the problems existing in the background art.
[0006] To achieve the above object, the application provides the following technical scheme: a knowledge base question and answer platform construction method based on a large language model, comprising: S1, collecting multi-source heterogeneous original knowledge data in real time through a knowledge collection module, and preprocessing and cleaning the data through a data preprocessing module to obtain standardized text; S2, dividing long text into short text fragments with complete semantics based on a semantic segmentation algorithm through a text processing module, and converting the text fragments into high-dimensional vector representations using a pre-trained model through a vectorization module; S3, processing the original inquiry content input by the user through a question understanding module, and starting keyword retrieval and semantic retrieval through a hybrid retrieval module and calculating scores to obtain a retrieval comprehensive index; S4, sorting the results obtained according to the retrieval comprehensive index, fusing the retrieved result fragments, the user inquiry content and the predefined system instructions to construct a final prompt through a prompt generation module, and inputting the final prompt into the selected large language model through an answer generation module to generate a preliminary answer; S5, evaluating the confidence of the generated answer through an answer quality analysis module, and performing safety and compliance filtering to output the answer; S6, receiving a secondary inquiry from the user, judging the relevance of the two dialogues through a secondary inquiry processing module, if there is relevance, performing a completion process and repeating steps S3-S5, if there is no relevance, directly repeating steps S3-S5; S7, collecting hot issues, failed queries and dialogue round optimization knowledge base and retrieval through a feedback learning module.
[0007] The application collects, cleans, semantically segments and vectorizes multi-source knowledge through automatic modules; uses hybrid retrieval technology to accurately match user queries, and fuses retrieval results and system instructions to construct prompt words, which are input into a large language model to generate answers; finally, after confidence evaluation and safety filtering, the answers are output, and multiple rounds of dialogues and feedback learning are supported; end-to-end intelligent processing from knowledge to answer is realized, the accuracy, safety and user experience of question and answer are significantly improved, and the system has self-evolution ability, effectively overcoming the core defects of traditional technology such as poor semantic understanding, high maintenance cost and lack of security mechanism.
[0008] The technical effects and advantages of the application are as follows:
[0009] 1, the semantic segmentation algorithm is used to cut the text in the application, which ensures the integrity of the text fragments, and the hybrid retrieval method is used by combining the intent matching ability of semantic retrieval and the accurate matching ability of keyword retrieval, which is suitable for various and complex inquiries and has high flexibility; 2、 The application constructs standardized prompts through system instructions, context splicing and repeated user questions, and sorts the results according to relevance to input a large language model, thereby improving the accuracy of answers; 3、 The application introduces multi-dimensional confidence evaluation, sets strict multi-layer security and compliance filtering, ensures that the output content meets the specifications, avoids legal and reputation risks, provides a clear degradation scheme, and still provides good user experience when the model is uncertain or cannot answer, thereby ensuring the reliability of the system; 4、 The secondary inquiry processing module can judge the relevance of multiple rounds of dialogue and complete them, realizing a real context dialogue experience and making the interaction more natural and efficient; 5、 The application realizes real-time knowledge collection and update, ensures the timeliness of the knowledge base, runs through metadata management throughout the whole process, and continuously optimizes the knowledge base and retrieval strategy, so that the platform becomes more intelligent with time, the value increases with time, and a closed loop of 'data-application-feedback-tracing-optimization' is formed. BRIEF DESCRIPTION OF DRAWINGS
[0010] Figure 1 The structural diagram of the application.
[0011] Figure 2 The flowchart of the application.
[0012] Figure 3 The logic diagram of the application. DETAILED DESCRIPTION
[0013] The technical solutions in the application will be described clearly and completely below with reference to the drawings in the application, and additionally, the forms of each structure described in the following embodiments are only examples, and the automatic unloading device of the rotary furnace with the self-cooling function is not limited to each structure described in the following embodiments. All other embodiments obtained by those skilled in the art without creative labor belong to the scope of protection of the application.
[0014] Referring to Figure 1 The application provides a knowledge base question and answer platform construction method based on a large language model.
[0015] Referring to Figure 2 The specific implementation steps of the application include the following steps: S1, real-time collection of multi-source heterogeneous original knowledge data through a knowledge collection module, and pre-processing and cleaning of the data through a data pre-processing module to obtain standardized text.
[0016] It needs to be specified that the multi-source data sources include but are not limited to internal documents, public network resources, databases and APIs; heterogeneous data, that is, data formats and structures are different, non-structured data including continuous paragraphs in PDF, Word and web pages are the main objects; semi-structured data includes Excel tables, data with labels and # topics; structured data is data in the database.
[0017] It needs to be specified that the specific steps of the knowledge collection module are: A1, create a unified data access interface, provide corresponding parsers for each file type, and parse files of different formats into pure text; A2, design a listening mechanism to scan the specified directory and database in real time, and automatically trigger collection when new files are found; A3, store the parsed raw knowledge data and its corresponding metadata in the database, where the metadata includes data source, file name, last modification time and publisher.
[0018] It needs to be noted that general texts can be read directly, Office documents and text-type PDFs are parsed using corresponding libraries, scanned PDFs need to extract text first and then parse, web pages use corresponding libraries to remove tags and only keep the text, databases and APIs use corresponding database connection libraries or request libraries to get data and define mapping rules to convert to text data.
[0019] It needs to be specified that the data preprocessing and cleaning of the parsed raw knowledge data are text cleaning, text normalization and text enhancement.
[0020] The text cleaning specifically removes irrelevant characters including garbled characters and special symbols, and retains key punctuation including periods and question marks; converts full-width characters to half-width characters, unifies the formats of dates and currencies, and compresses multiple consecutive spaces or line breaks into a single one; eliminates headers, footers, page numbers, email addresses and link content; removes duplicate content.
[0021] The text normalization specifically uses a unified character encoding for all text; for English text, convert to lowercase, and for individual English in Chinese text, no conversion is needed; use a spelling check library to handle errors in the text and correct obvious errors.
[0022] The text enhancement specifically unifies different expressions of a unified concept into one, for example, "LLM", "large language model" and "Large Language Model" are unified into "large language model"; if the knowledge base contains multiple languages, translate all text into Chinese text for unified processing.
[0023] It should be noted that the normalized text obtained after preprocessing and cleaning of the original knowledge data is stored, stored according to the source unit, and the association between the text and the metadata is retained.
[0024] S2, the text processing module is segmented into a semantic complete short text fragment based on a semantic segmentation algorithm, and a pre-trained model is used to convert the text fragment into a high-dimensional vector representation by a vectorization module.
[0025] It should be noted that the text processing module needs to be segmented into short text fragments suitable for model processing and semantic coherence in order to avoid information loss caused by directly embedding long text into the knowledge base, ensuring that the segmented fragment is a logically self-consistent semantic unit, rather than a sentence or paragraph cut off in the middle. Too long will introduce noise, and too short will lose context; the target length is between 100-500, and when segmenting, the first part of the next fragment and the last part of the previous fragment are kept 100-200 characters overlap to ensure the coherence of the context. The specific segmentation strategy is as follows:
[0026] For simple text, use strong semantic separators to segment the document into chapter blocks; if a chapter block is still too large, use a secondary priority separator to further segment; until the size of all fragments is within the preset range.
[0027] For high-level semantics, the document is divided into sentences; calculate the embedding vectors of each pair of adjacent sentences and their cosine similarity; when the similarity is lower than a certain threshold, the place with low similarity is the boundary of theme conversion, and segmentation is performed at that place.
[0028] For specific types of documents, segment according to the inherent structure, Markdown / HTML documents are segmented according to the title tags, and the content under each title naturally forms a semantic fragment; code documents are segmented according to the function, class, module, etc. Code structure; academic papers are segmented according to the chapters such as abstract, introduction, related work, method, experiment, conclusion; presentation slides are segmented according to the title and content of each page of the slide.
[0029] It should be noted that each independent and complete information containing semantic fragment is obtained, and a text fragment list with a unique ID is generated, and each ID is bound to metadata, which includes source file path, collection time, document type, chapter title, keywords and author, which can trace back to the original document and its position in the original document.
[0030] It should be noted that the vectorization module converts the text fragment into an embedding vector in a high-dimensional space, which can make semantically similar text closer in vector space.
[0031] Need to be specific, the specific process of vectorization is to load the pre-trained embedding model, write a batch function, input the text segment list obtained in the last step into the model, and output a corresponding vector list. The text segment and its corresponding vector and metadata are stored in a vector database specially designed for high-dimensional vector search, supporting approximate nearest neighbor search, which can quickly find the most similar fragments to the problem vector in a large number of vectors.
[0032] Referring to Figure 3 , S3, the original inquiry content input by the user is processed by the question understanding module, and the keyword retrieval and semantic retrieval are started by the mixed retrieval module, and the comprehensive index of retrieval is obtained by calculating the scores respectively.
[0033] Need to be specific, the question understanding module is to process the original inquiry content input by the user in spoken language, short or ambiguous, so as to make it more suitable for retrieval. The processing process is as follows: Use the open source library to recognize the user input content, correct the spelling errors or wrong characters in it; expand the core query vocabulary, add synonyms, near synonyms and upper and lower words, so that the retrieval is not limited to literal matching, and more relevant results can be retrieved; use the model in S2 to convert the processed user query content to obtain the query vector.
[0034] Need to be specific, the mixed retrieval module includes keyword retrieval and semantic retrieval, wherein the keyword retrieval is good at accurate matching, and the semantic retrieval is good at semantic similarity. The specific process is as follows: The semantic retrieval uses the query vector to perform approximate retrieval in the vector database, and obtains a group of fragments and their semantic similarity scores with the query, wherein the similarity score is a cosine similarity score; The keyword retrieval directly uses the processed query keywords to retrieve in the traditional inverted index, and obtains another group of fragments and their matching scores with the keywords, wherein the matching score is a BM25 score; Need to be explained, the range and distribution of cosine similarity score and BM25 score are completely different, and direct weighted average has no meaning, so the cosine similarity score and BM25 score are normalized respectively, and the specific process is as follows: ; Wherein X' is the normalized score of a certain result fragment of single retrieval, X is the original score of a certain result fragment of single retrieval, Xmax and Xmin are the maximum and minimum values of the original scores of all result fragments in this retrieval result, and the cosine similarity normalized score is denoted as Y, and the BM25 similarity score is denoted as S.
[0035] It needs to be specified that the retrieval comprehensive index is specifically: Z = a * Y + (1 - a) * S; Wherein Z is the retrieval comprehensive index, the value range is in [0, 1], indicating the comprehensive score of semantic retrieval and keyword retrieval of each result fragment, the higher the retrieval comprehensive index, the stronger the relevance to the inquiry content; Y is the normalized score of semantic retrieval, S is the normalized score of keyword retrieval; a is the weight of semantic retrieval, the value range is in [0, 1], supporting dynamic adjustment.
[0036] It needs to be explained that a = 1 means completely relying on semantic retrieval, a = 0 means completely relying on keyword retrieval, and a = 0.5 means that semantic retrieval and keyword retrieval are equally important. In the initial stage, a test set containing multiple typical problems is constructed, and the correct answer fragments corresponding to each problem are manually labeled. Try different a values, for each value, run all test questions, and calculate the accuracy and recall rate of the retrieval results. Select the a value with the highest index as the initial value; use a lightweight classifier to determine the query type, and use different weight combinations for different types to improve retrieval accuracy.
[0037] S4, according to the result of the retrieval comprehensive index, the retrieved result fragments, the user inquiry content and the pre-defined system instructions are fused to construct the final prompt through the prompt generation module, and the final prompt is input into the selected large language model through the answer generation module to generate the preliminary answer.
[0038] It needs to be specified that the result fragments and their metadata obtained by Top-K sorting algorithm from high to low according to the result of comprehensive retrieval index are used as the answer fragments to reply to the user's inquiry content. The value of K is in the range of 5-10, which can be dynamically adjusted according to the requirements of the Q&A platform.
[0039] It needs to be specified that the prompt generation module is specifically: Construct a clear instruction to define the role and behavior specification of the platform, the instruction is specifically: "You are the assistant of the knowledge base Q&A platform, please answer the user's inquiry only according to the following provided
result fragments
result fragments
[0040] Need to be specific, the answer generation module is specifically for the final prompt input to the large language model and get its returned answer, the returned answer is simply formatted, cleaned and additional information; for the same query, the answer is stored, the next time directly return the answer; record the log of each question and answer, including user inquiry content, retrieved context, generated prompt and model answer.
[0041] S5, through the answer quality analysis module to evaluate the confidence of the generated answer, and safety and compliance filtering, output answer.
[0042] Need to be specific, the confidence evaluation judges the accuracy of the answer based on the user inquiry content in the fact level, the confidence score is the weighted sum of the consistency score of the answer and the context, the relevance score of the question and the answer and the specific score of the answer.
[0043] The consistency of the answer and the context, that is, whether the core fact in the answer is supported by the provided knowledge fragment, inputs the answer and the retrieved context into the natural language inference model to get a probability that the answer is supported by the context. When the probability is >0.9, it means that all key claims are explicitly supported by the context, and the consistency score of the answer and the context is 100 points. When the probability is between 0.7 and 0.9, it means that the answer is mostly supported, but contains inferences and summaries that are not explicitly opposed, and the consistency score of the answer and the context is 70 points. When the probability is between 0.4 and 0.7, it means that the answer contains 1 obvious, unsupported claim or illusion, and the consistency score of the answer and the context is 40 points. When the probability is <0.4, it means that the answer is completely detached from the context or is anchored with the context, and the consistency score of the answer and the context is 0 points.
[0044] The relevance of the question and the answer, that is, whether the answer responds to the user's inquiry, uses the same embedding model to vectorize the generated answer and the user inquiry content to calculate the cosine similarity. When the cosine similarity is >0.8, it is highly relevant, and the relevance score of the question and the answer is 100 points. When the cosine similarity is between 0.6 and 0.8, it means that it is related but not complete, and the relevance score of the question and the answer is 70 points. When the cosine similarity is between 0.4 and 0.6, it means that it is partially related, but deviates from the topic, and the relevance score of the question and the answer is 40 points. When the cosine similarity is <0.4, it means that it is not related, and the relevance score of the question and the answer is 0 points.
[0045] The answer specificity is determined by the proportion and length of named entities in the answer, including time, place, number, and specific terms. If the answer contains two or more specific numbers, dates, or name entities, the answer specificity score is 100 points. If the answer contains at least one specific entity, the answer specificity score is 70 points. If the answer is vague, general, and lacks specific data, the answer specificity score is 40 points. If the answer is completely empty, such as "maybe" or "unclear" words, the answer specificity score is 0 points. The weights of the answer and context consistency, the relevance of the question and the answer, and the answer specificity are in the ranges of 0.45-0.55, 0.25-0.35, and 0.15-0.25, respectively. When the confidence score exceeds the threshold value, indicating that the confidence evaluation is passed, the threshold value is in the range of 0.9-0.95, which is not specifically limited in this embodiment.
[0046] It should be specifically noted that the safety and compliance use a deduction system. Since both safety and compliance need to be met, the starting score shares 100 points. The keyword blacklist and safety classifier model are run, and when the rules are triggered, the score is deducted according to the severity to obtain the final score.
[0047] The safety deduction items specifically include: Hate speech, such as offensive or discriminatory language against race, gender, or religion, violent or illegal content, such as encouragement or incitement, or descriptions of violence, crime, or self-harm, political errors, and sexual content, such as explicit sexual descriptions or pornography, are all serious level speech, directly -100 points; unprofessional, insulting language, such as profanity, personal attacks, and impolite language, is a moderate level of speech -50 points; biased expressions are a mild level of speech -20 points.
[0048] The compliance deduction items specifically include: Medical advice, such as unauthorized diagnosis, treatment recommendations, or guaranteed efficacy, financial advice, such as specific investment advice, guaranteed returns, or market predictions, legal advice, such as specific legal opinions or alternative legal services, privacy leaks, such as personal identification numbers, phone numbers, and addresses, and confidential information leaks, such as internal codes, unpublished strategies, and customer data, are all serious level speech, directly -100 points; absolute statements, such as "absolute," "definitely," and "never," are mild level speech -20 points.
[0049] It should be explained that when the final score exceeds the threshold value, it means that the safety and compliance filtering is passed, and the threshold value is in the range of 80-90, which is not specifically limited in this embodiment.
[0050] It should be specifically noted that if the safety and compliance filtering is not passed, the answer is not output, and a preset safety reply template is triggered.
[0051] If the security and compliance filters pass, but the confidence assessment fails, a de-escalation plan is enabled, informing the user of the limitations of the answer and guiding the user to provide more information, rather than outputting a low-confidence answer directly. If the security and compliance filters pass and the confidence assessment passes, the answer is output.
[0052] S6, upon receiving the user's second inquiry, the secondary inquiry processing module determines the relevance of the two conversations. If there is a correlation, the completion process is performed and the steps S3-S5 are repeated. If there is no correlation, the steps S3-S5 are directly repeated.
[0053] It should be specifically noted that when receiving the user's second inquiry, the context needs to be recognized to determine the relevance of the user's second inquiry and the previous conversation, so as to perform more accurate retrieval, which is specifically: Determine whether the second inquiry is a modification, supplement or refinement of the first inquiry, including explicit reference and implicit continuation. The explicit reference means whether the inquiry contains pronouns or referential words, such as it, this, the above, and just mentioned. The implicit continuation means that the second inquiry is a natural extension, refinement or correction of the first inquiry, such as explaining in detail and where to buy. At this time, direct retrieval is performed, such as "it" in "how much is it" has no semantic meaning, and the context of the first query needs to be completed in the current query. If the inquiry has nothing to do with the historical conversation, ignore the context and process it as a new problem.
[0054] S7, collect hot issues, failed queries and dialogue round optimization knowledge base and retrieval through the feedback learning module.
[0055] It should be specifically noted that the feedback learning module comprehensively and structurally records each user interaction, including session content, original inquiry content, processing process data, and output and user feedback data.
[0056] The hot issues include synonymous query content and common topic fields, which are used to guide the priority of knowledge base construction, so that the knowledge content corresponding to the hot issues is complete and accurate.
[0057] For high-frequency but poor retrieval effect problems, automatically prompt the administrator that "problem 'X' is frequently asked, but the relevant content in the knowledge base is missing or insufficient"; the large language model automatically searches for related problems in the network or internal data sources, and recommends the found high-quality answers to the administrator for review and addition to the knowledge base; if the answer is divided into different fragments, resulting in incomplete information, automatically adjust the document segmentation strategy.
[0058] The failure query includes a dialogue in which the user feeds back an incorrect answer, a dialogue in which confidence evaluation fails, and a dialogue in which the user repeatedly asks questions or rewrites questions in the same dialogue. Failure reason analysis is performed on the failure query. It is found that the correct answer is in the knowledge base but is not retrieved, and the query keywords do not match, semantic understanding is biased, and fragment segmentation is unreasonable. A failure explanation is generated that the correct answer has been retrieved but an incorrect answer is generated, and the answer summary is incorrect or the answer generation prompt is incorrect.
[0059] For retrieval failure dialogues, a large language model is used to generate synthetic data for the correct answer fragment and irrelevant fragment of the query, and the embedding model is fine-tuned for domain-specificity. The weight alpha of keyword retrieval and semantic retrieval in hybrid retrieval is recalibrated to make the comprehensive score more reasonable.
[0060] For generation failure dialogues, hallucinations and incorrect answer dialogues are collected to build a failure case library for analysis. The S4 prompt template is improved by adding stricter restrictions in the instructions, and the large language model is adjusted to make the answer generation more fluent and complete.
[0061] The effective dialogue turn is a multi-turn dialogue in which the user gives positive feedback or successfully ends the dialogue. Excellent query completion and rewriting recommendations are collected. Successful query rewriting dialogues, i.e., the user's original question to the system's optimized question, are used as training data to fine-tune a small model that is specifically used for query rewriting, making it more effective.
[0062] From the above description of the embodiments, those skilled in the art can clearly understand that the embodiments of the present application can be implemented by means of software or software combined with necessary general hardware platforms, and of course, can also be implemented by hardware functions; based on such understanding, the technical solutions of the present application can be embodied in the form of a software product, which is stored in a storage medium, including a plurality of instructions for causing a computer device, such as but not limited to a personal computer, a server, or a network device, to execute all or part of the steps of the method described in any embodiment of the present application.
[0063] The above describes exemplary embodiments of the present application. It should be understood that the above exemplary embodiments are not limiting but illustrative, and the protection scope of the present application is not limited thereto; it should be understood that those skilled in the art can modify and vary the embodiments of the present application without departing from the spirit and scope of the present application, and these modifications and variations should be within the protection scope of the present application.
Claims
1. A method for constructing a knowledge base question-answering platform based on a large language model, characterized in that: Specifically, the following steps are included: S1. Collect multi-source heterogeneous raw knowledge data in real time through the knowledge acquisition module, and obtain standardized text through data preprocessing and cleaning through the data preprocessing module; S2. The text processing module segments the long text into semantically complete short text fragments based on the semantic segmentation algorithm, and the vectorization module uses a pre-trained model to convert the text fragments into high-dimensional vector representations. S3. The original query content input by the user is processed through the question understanding module, and keyword search and semantic search are initiated through the hybrid search module, and scores are calculated separately to obtain the comprehensive search index; S4. Sort the results obtained from the comprehensive retrieval index, and use the prompt generation module to integrate the retrieved result fragments, user queries and predefined system instructions to construct the final prompt. Then, use the answer generation module to input the final prompt into the selected large language model to generate a preliminary answer. S5. The confidence level of the generated answers is evaluated through the answer quality analysis module, and security and compliance filtering is performed before outputting the answers. S6. Upon receiving a second inquiry from the user, the second inquiry processing module determines the correlation between the two conversations. If there is a correlation, the completion process is performed and steps S3-S5 are repeated. If there is no correlation, steps S3-S5 are repeated directly. S7. Collect hot topics through the feedback learning module, and optimize the knowledge base and retrieval through failed queries and dialogue rounds.
2. The method for constructing a knowledge base question-answering platform based on a large language model according to claim 1, characterized in that: The specific steps of the knowledge acquisition module are as follows: A1. Create a unified data access interface, equip each file type with a corresponding parser, and parse files of different formats into plain text; A2. Design a monitoring mechanism to scan a specified directory and database in real time, and automatically trigger collection when new files are found. A3. Associate the parsed raw knowledge data with its corresponding metadata and store it in the database. The metadata includes the data source, file name, last modification time and publisher.
3. The method for constructing a knowledge base question-answering platform based on a large language model according to claim 1, characterized in that: The text processing module segments the text into short, semantically coherent text fragments suitable for model processing; each fragment generates a list of text fragments with a unique ID, and each ID is bound to metadata, which includes the source file path, collection time, document type, chapter title, keywords and author, and can trace its original document and its position in the original document; The vectorization module converts text fragments into embedding vectors in a high-dimensional space, loads a pre-trained embedding model, writes a batch processing function, inputs the list of text fragments obtained in the previous step into the model, the model outputs a corresponding list of vectors, and stores the text fragments, their corresponding vectors, and metadata together in a vector database specifically for high-dimensional vector search.
4. The method for constructing a knowledge base question-answering platform based on a large language model according to claim 1, characterized in that: The specific processing procedure of the question understanding module is as follows: The system uses an open-source library to recognize user input and correct spelling errors or typos; it expands the core query vocabulary by adding synonyms, near-synonyms, and hyponyms to enable searches that go beyond literal matching and retrieve more results relevant to the question; and it uses a model from S2 to transform the processed user query content into a query vector. The hybrid retrieval module includes keyword retrieval and semantic retrieval. Keyword retrieval excels at exact matching, while semantic retrieval excels at semantic similarity. The specific process is as follows: Semantic retrieval uses query vectors to perform approximate retrieval in a vector database, obtaining a set of fragments and their semantic similarity scores with the query, wherein the similarity scores are cosine similarity scores; Keyword retrieval directly uses the processed query keywords to perform a search in the traditional inverted index, obtaining another set of fragments and keywords with matching scores, which are BM25 scores; The cosine similarity score and BM25 score are normalized separately, specifically as follows: ; Where X′ is the normalized score of a single result segment in a single search, X is the original score of a single result segment in a single search, Xmax and Xmin are the maximum and minimum original scores of all result segments in this search result, and the cosine similarity normalized score is denoted as Y, and the BM25 similarity score is denoted as S. The comprehensive search index is specifically: Z = α * Y + (1 - α) * S; Where Z is the comprehensive retrieval index, with a value range of [0,1], representing the comprehensive score of semantic retrieval and keyword retrieval for each result fragment. The higher the comprehensive retrieval index, the stronger the relevance to the query content; Y is the normalized score of semantic retrieval, and S is the normalized score of keyword retrieval; α is the weight of semantic retrieval, with a value range of [0,1], and supports dynamic adjustment.
5. The method for constructing a knowledge base question-answering platform based on a large language model according to claim 1, characterized in that: The results of the comprehensive retrieval index are sorted from high to low using the Top-K sorting algorithm. The resulting result fragments and their metadata are used as answer fragments to respond to user queries. The prompt generation module specifically includes: Construct a clear instruction definition for the platform's roles and behavioral norms; concatenate the Top-K result fragments retrieved in step S3 in order of relevance, and indicate the source and origin of each fragment; repeat the user's question, i.e., the user query after processing the user's original content in step S3; and explain the answer requirements. The answer generation module specifically inputs the constructed final prompts into the large language model and obtains the returned answers. It performs simple formatting, cleaning, and additional information on the returned answers. For identical queries, it stores the answers and returns them directly next time. It records a log of each question and answer session, including the user's question content, the retrieved context, the generated prompts, and the model's answer.
6. The method for constructing a knowledge base question-answering platform based on a large language model according to claim 1, characterized in that: The confidence assessment judges the accuracy of the answer at the factual level based on the content of the user's query. The confidence score is a weighted sum of the answer and context consistency score, the question and answer relevance score, and the answer specificity score. The consistency between the answer and the context refers to whether the core facts in the answer are supported by the provided knowledge fragment. The answer and the retrieved context are input into the natural language reasoning model to obtain the probability that the answer is supported by the context. The relevance of the question and answer refers to whether the answer responds to the user's query. The generated answer is vectorized using the same embedding model as the retrieval to generate an answer vector, and the cosine similarity between the answer vector and the user's query content vector is calculated. The specificity of the answer is judged by the proportion and length of named entities including time, location, numbers, and proper nouns in the answer. The security and compliance assessment uses a point deduction system, with a shared starting score of 100. The system runs a keyword blacklist and security classifier model, and when a rule is triggered, points are deducted according to the severity to obtain the final score. If the security and compliance filters fail, no answer will be output, and the preset security recovery template will be triggered. If the security and compliance filtering passes, but the confidence assessment fails, a low-confidence answer will not be output directly. Instead, a downgrade scheme will be activated, informing the user of the limitations of the answer and guiding the user to provide more information. If both the security and compliance filtering and the confidence assessment pass, the answer will be output.
Citation Information
Patent Citations
Complementation retrieval method and device based on artificial intelligence
CN105808688A
Open domain question and answer method and device, equipment and storage medium
CN119066183A
Knowledge base generation and retrieval method based on RAG technology and intelligent question answering system
CN120045653A
Structured document knowledge base construction method, system and equipment based on tree structure and semantic perception and medium
CN120179676A
Dynamic knowledge retrieval enhancement method based on large language model
CN120407570A
Cited By
Product defect detection and knowledge question and answer method, system and equipment
CN121707926A
Intelligent question and answer method and system for artificial intelligence large model
CN121808007A
An intelligent question and answer method and system for an artificial intelligence large model
CN121808007B
Irrigation area water volume scheduling scheme autonomous generation system and method based on multi-agent architecture
CN121809921A
Large model optimization method and system based on context engineering in futures field
CN121937227A
