Large model knowledge enhancement method and device integrating multi-strategy sentence segmentation and semantic clustering

Through the big model knowledge enhancement method that integrates multi-strategic clauses and semantic clustering, the problem of errors easily arise when generating content of big models is solved, and the accuracy and credibility of knowledge enhancement is improved. It is suitable for applications in multiple vertical fields.

CN118069837BActive Publication Date: 2025-04-04BEIJING FOREIGN STUDIES UNIVERSITY
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410113900.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-01-27
Publication Date
2025-04-04
Estimated Expiration
2044-01-27

AI Technical Summary

Technical Problem

Existing large-scale model technologies are prone to knowledge-based errors or untrusted text content when generating content, which affects its application and credibility, especially in vertical fields and user private customization applications.

Method used

A large-scale knowledge enhancement method that combines multi-strategy clauses and semantic clustering is adopted to improve the accuracy of knowledge enhancement by obtaining user local documents and input problems, performing content reading, harmful information judgment, preprocessing, multi-strategy clauses, word embedding vectorization and semantic clustering search enhancement.

Benefits of technology

It improves the accuracy of user local document information recalls that enhance knowledge on big models, enhances the accuracy and credibility of document vector recalls, and is suitable for knowledge Q&A applications in the fields of education, law, medicine, etc.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118069837B_ABST
    Figure CN118069837B_ABST
Patent Text Reader

Abstract

The present invention discloses a large model knowledge enhancement method and device integrating multi-strategy sentence segmentation and semantic clustering, the method comprising: obtaining user local documents and user input questions, and performing harmful information judgment respectively; when the read content of the user local document is harmless, preprocessing is performed, and multi-strategy segmentation is performed by multi-strategy sentence segmentation; when the user input question is harmless, word embedding vectorization operation is performed on the user input question and the user local document content after multi-strategy segmentation respectively; vector similarity calculation is performed on the vectorized user input question and the user local document content; the search enhancement method based on semantic clustering selects part of the most similar vectors, and the corresponding document sentence is correspondingly expanded and output as the final result. The method can improve the accuracy of user local document information recall for knowledge enhancement of the large model, and is suitable for the education field, legal field and medical field with high accuracy of large model knowledge question and answer.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer application technology, and in particular to a method and device for large model knowledge enhancement that integrates multi-strategy sentence segmentation technology and semantic clustering search enhancement algorithm. Background Art

[0002] With the release of OpenAI's new generation intelligent product ChatGPT in November 2022, it marked that general artificial intelligence technology has entered a new era. Domestic and foreign technology companies, universities, research institutions, etc. have joined in the research and development of large model technology, and large model technology has gradually progressed and matured.

[0003] The existing big model technologies represented by ChatGPT and GPT-4 can complete artificial intelligence tasks such as copywriting, knowledge dialogue question and answer, and automatic programming. However, their effects in many actual application scenarios are still unsatisfactory. There are "hallucination" problems such as "serious nonsense". Big models are prone to generate knowledge errors or unreliable text content when generating content, which seriously affects the application and credibility of big models.

[0004] In addition, there are also some problems and difficulties in the application of large models in vertical fields and user-customized applications. For application problems in vertical fields, the domain knowledge can be increased by fine-tuning the large model; however, fine-tuning the large model will inevitably lead to the loss of the original capabilities of the large model and "catastrophic forgetting" and other problems. Enhancing the knowledge of the large model through external knowledge bases and other methods is undoubtedly a direction worthy of research.

[0005] In terms of user-customized applications, open source frameworks such as langchain can easily access user local documents to enhance the knowledge of large models, but user local documents are mostly unstructured data, and there are problems such as low recall rate of accurate document information and low accuracy of information recognition. Summary of the invention

[0006] In view of the above problems, the present invention provides a large model knowledge enhancement method and device integrating multi-strategy sentence segmentation and semantic clustering, aiming to improve the accuracy of user local document information recall used for knowledge enhancement of the large model.

[0007] In a first aspect, the present invention provides a large model knowledge enhancement method integrating multi-strategy sentence segmentation and semantic clustering, comprising the following steps:

[0008] Step 1: Obtain the user's local document and user input questions;

[0009] Step 2: Read the content of the user's local document;

[0010] Step 3: Determine harmful information based on the read content of the user's local document and the user input question;

[0011] Step 4: When it is determined that the read content of the user's local document is harmless, preprocessing is performed;

[0012] Step 5: The pre-processed read content of the user's local document is segmented using a multi-strategy sentence segmentation method;

[0013] Step 6: When it is determined that the user input question is harmless, a word embedding vectorization operation is performed on the user input question and the user local document content segmented by multiple strategies respectively;

[0014] Step 7: Calculate the vector similarity between the vectorized user input question and the user's local document content;

[0015] Step 8: The search enhancement method based on semantic clustering selects some of the most similar vectors, expands the corresponding document sentences accordingly and outputs them as the final result.

[0016] Preferably, the step 2 comprises:

[0017] When the user's local document is in excel, csv, word, or txt format, the corresponding third-party library function in python is used to read the text file;

[0018] When the user's local document is in pdf, jpg, or png format, OCR scanning is performed to read the document information content.

[0019] Preferably, step 3 comprises:

[0020] A neural network is used to perform multi-classification harmful information judgment on the read content of the user's local document and the user input question.

[0021] Preferably, step 4 comprises:

[0022] When it is determined that the read content of the user's local document is harmless, invalid document information is filtered, content is deduplicated, and the format of the document content is adjusted.

[0023] Preferably, step 5 comprises:

[0024] The preprocessed read content of the user's local document is segmented by multiple strategies using a sentence segmentation method based on sentence punctuation marks, a sentence segmentation method based on sentence semantic structure, and a sentence segmentation method based on entity extension; wherein the sentence segmentation method based on entity extension is segmented by multiple strategies, including:

[0025] S41: Obtain the pre-processed read content of the user's local document;

[0026] S42: splitting the document based on punctuation marks in the document;

[0027] S43: performing named entity recognition on the segmented sentences respectively;

[0028] S44: Determine whether the current sentence is the first sentence of the document. If the current sentence is the first sentence of the document, the sentence will be directly segmented; if the current sentence is not the first sentence of the document, the sentence will be processed separately according to the entity conditions contained in the segmented sentence:

[0029] S45: Segment and merge the sentences in the document respectively until the segmentation and processing of all the sentences in the document are completed.

[0030] Preferably, the processing of the sentences respectively in step S44 includes:

[0031] S441: When a sentence contains one entity: compare it with the entity contained in the previous sentence to see if they are exactly the same; if they are exactly the same, merge the current sentence into the previous sentence; if they are not exactly the same, split the current sentence into independent sentences;

[0032] S442: When the sentence contains 0 entities: merge the current sentence into the previous sentence;

[0033] S443: When a sentence contains two or more entities: compare with the entities contained in the previous sentence to see if they are exactly the same; if they are exactly the same, merge the current sentence into the previous sentence; if they are not exactly the same, split the current sentence into independent sentences.

[0034] Preferably, in step 6, a word embedding vectorization operation is performed by adopting a word embedding vectorization model; the word embedding vectorization model is moka-ai's m3e series pre-trained model, sensenova's piccolo series pre-trained model, OpenAI's text-embedding series model, or text2vec-base-chinese series model.

[0035] Preferably, the vector similarity calculation in step 7 adopts the cosine similarity between the calculated vectors, the Euclidean distance algorithm, or the integrated similarity retrieval framework Faiss model.

[0036] Preferably, the step S8 comprises:

[0037] 1): The sequence obtained after calculating the vector similarity:

[0038] f(n)=[f1,f2,f3,...,f n ]

[0039] Among them, the length of the sequence f(n) is N, f1, f2, ..., f n The similarity values ​​obtained after semantic similarity calculation between the vectorized user input question and the vectorized user local document content;

[0040] 2): Suppose there is a function sequence g(m) for data enhancement operation:

[0041]

[0042] Among them, the sequence length of g(m) is M, and M is an odd number. Indicates adjacent sentences and central sentences The weight value of the semantic association degree, Represents the next adjacent sentence and the central sentence The weight value of the degree of semantic relevance;

[0043] 3): Perform a convolution-like operation on the similarity calculation result sequence f(n) and g(m) to obtain the sequence s(n):

[0044]

[0045] Among them, the range of n is n∈[0,N-1], and the range of m is N is the length of the similarity calculation result sequence f(n), and M is the length of the sequence function g(m);

[0046] 4): Complete the calculation of the algorithm for each sentence in the document, and obtain the similarity calculation result of the final sentence after the search enhancement algorithm; according to the similarity calculation result, expand the corresponding document sentence accordingly and output it as the final result.

[0047] In a second aspect, the present invention further provides a large model knowledge enhancement device integrating multi-strategy sentence segmentation and semantic clustering, comprising:

[0048] The acquisition module is used to obtain the user's local documents and user input questions;

[0049] A document reading module, used to read the content of the user's local document;

[0050] A harmful information judgment module, used for judging harmful information based on the read content of the user's local document and the user input question;

[0051] A document preprocessing module, used for performing preprocessing when it is determined that the read content of the user's local document is harmless;

[0052] A multi-strategy document content segmentation module is used to perform multi-strategy segmentation on the pre-processed read content of the user's local document using a multi-strategy sentence segmentation method;

[0053] A word embedding module, used for performing word embedding vectorization operations on the user input question and the user local document content segmented by multiple strategies respectively when it is determined that the user input question is harmless;

[0054] A similarity calculation module, used to perform vector similarity calculation on the vectorized user input question and the user's local document content;

[0055] The search enhancement and output module based on semantic clustering selects part of the most similar vectors, expands the corresponding document sentences and outputs them as the final result.

[0056] Compared with the prior art, the present invention has the following beneficial effects:

[0057] The present invention provides a large-model knowledge enhancement method that integrates multi-strategy sentence segmentation and semantic clustering, including: obtaining user local documents and user input questions; reading the content of the user local documents; judging harmful information on the read content of the user local documents and the user input questions; when it is judged that the read content of the user local documents is harmless, preprocessing is performed; multi-strategy segmentation is performed on the read content of the user local documents after preprocessing using a multi-strategy sentence segmentation method; when it is judged that the user input question is harmless, word embedding vectorization operations are performed on the user input question and the user local document content that has been segmented by multiple strategies respectively; vector similarity calculation is performed on the vectorized user input question and the user local document content; based on the search enhancement method of semantic clustering, part of the most similar vectors is selected, and the corresponding document sentences are correspondingly expanded and output as the final result. This method can improve the accuracy of user local document information recall when performing knowledge enhancement on large models. It is suitable for scenarios where knowledge enhancement, summarization or other task requirements are achieved based on local documents during knowledge enhancement on large models. It is particularly suitable for application scenarios with high accuracy in knowledge question and answering of large models, such as education, law, medicine, etc.

[0058] The sentence segmentation method based on entity extension proposed in the present invention can complete the sentence segmentation of the document from the perspective of complete entity information, and is particularly suitable for scenarios of knowledge dialogue-type human-computer interaction.

[0059] Furthermore, by performing multi-strategy sentence segmentation on the local documents input by users for knowledge enhancement of the large model, namely, sentence segmentation based on sentence punctuation structure, sentence segmentation based on sentence semantic structure, and sentence segmentation based on entity extension, we can achieve multi-angle and different fine-grained sentence segmentation of user input documents, thereby increasing the accuracy of vector recall.

[0060] In addition, the present invention also proposes a search enhancement algorithm based on semantic clustering, which further improves the accuracy of document vector recall based on the principle in linguistics that adjacent sentences usually have certain correlation and clustering. BRIEF DESCRIPTION OF THE DRAWINGS

[0061] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the prior art descriptions are briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention, and for ordinary technicians in this field, other drawings can be obtained based on the provided drawings without creative work.

[0062] Figure 1 A flow chart of a large model knowledge enhancement method integrating multi-strategy sentence segmentation and semantic clustering provided in an embodiment of the present invention.

[0063] Figure 2 A schematic diagram of a method for entity expansion clauses provided in an embodiment of the present invention.

[0064] Figure 3 This is an example diagram of the specific execution process of the semantic clustering search enhancement algorithm provided in an embodiment of the present invention.

[0065] Figure 4 A schematic diagram of a multi-document processing mode provided by an embodiment of the present invention.

[0066] Figure 5 A schematic diagram of program modules of a large model knowledge enhancement device integrating multi-strategy sentence segmentation and semantic clustering provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0067] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0068] The embodiments of the present invention are described in detail below with reference to the accompanying drawings.

[0069] Embodiment 1:

[0070] like Figure 1 As shown, the embodiment of the present invention provides a large model knowledge enhancement method integrating multi-strategy sentence segmentation and semantic clustering, which is described from two perspectives, namely, obtaining user documents and user input questions, and includes the following steps:

[0071] S1: Get the user's local document. The local document preprocessing part includes S11-S16 as follows:

[0072] The specific implementation process is as follows:

[0073] S11, firstly process the document material input by the user to obtain a local document;

[0074] First, the document materials input by the user are processed to obtain local documents. The local documents input by the user include documents or pictures in formats such as excel, csv, pdf, word, jpg, png, and txt.

[0075] S12: Read the local document input by the user;

[0076] Read the local document input by the user. When the document input by the user is in excel, csv, word, or txt format, the corresponding third-party library function in python will be used to read the text file. When the document input by the user is in pdf, jpg, or png format, OCR scanning will be performed first to extract the text information and save it as a document in word or txt format, and then the document information content will be read;

[0077] As an exemplary implementation, in S12, the local document input by the user is read. When the document input by the user is in pdf, jpg, or png format, OCR scanning is performed first. The method adopted may include utilizing the corresponding library function in pyPDF2 in python, or utilizing PaddleOCR, draw_ocr, and other methods in the Ali paddlepaddle module that can realize OCR scanning.

[0078] S13: Determine whether the document content contains harmful information. If the local document is determined to contain harmful information, the model will terminate and reply with relevant prompt text; if the document information is determined to be harmless, proceed to the next step;

[0079] As an exemplary implementation, in S13, harmful information in the document content is judged, and the neural network used mainly adopts traditional neural networks such as vector multi-classification models based on machine learning, BILSTM-CRF, etc. to perform multi-classification harmful information judgment on the input information.

[0080] S14: For the local document determined as harmless information in step S13, local document preprocessing is performed;

[0081] As an exemplary implementation, in S14, the local document judged as harmless information in the previous step S13 will be subjected to local document preprocessing, wherein the preprocessing of the document mainly includes filtering invalid information in the document, such as removing some special symbols (such as ※, *, -, etc.); standardizing the format of the document content, such as replacing two line breaks with one line break and deduplicating the document content.

[0082] S15: Use multi-strategy sentence segmentation technology to segment the preprocessed documents;

[0083] In S15, the preprocessed document is segmented using a multi-strategy sentence segmentation technique. The adopted document segmentation techniques mainly include a sentence segmentation method based on sentence punctuation marks, a sentence segmentation method based on sentence semantic structure, and a sentence segmentation method based on entity extension.

[0084] As an exemplary implementation, in S15, in the sentence segmentation method based on sentence punctuation marks, the punctuation marks used for sentence segmentation can be the punctuation marks commonly used at the end of a complete sentence in the traditional sense, such as ".。\n??!!", or the sentence can be segmented in a more fine-grained manner, such as using full punctuation marks ",,.。\n??!!;;" etc.;

[0085] As an exemplary implementation, in S15, based on the sentence semantic structure segmentation method, a third-party library function in Python is mainly used, such as RecursiveCharacterTextSplitter, MarkdownHeaderSplitText and other library functions in the open source framework langchain.

[0086] As an exemplary implementation, in S15, based on the entity extension sentence method, refer to Figure 2 As shown, the specific implementation methods mainly include:

[0087] S41: Obtain the pre-processed read content of the user's local document;

[0088] S42: Split the document based on the punctuation marks in the document. To perform more fine-grained segmentation on the document, the punctuation marks used in the document segmentation are all punctuation marks, including “,,.。\n??!!;;”, etc.;

[0089] S43: performing named entity recognition on the segmented sentences respectively;

[0090] As an exemplary implementation, in S43, named entity recognition is performed on the segmented sentences respectively, and the neural network used is a variant of the Transformer model, RoBERTa_wwm_ext neural network;

[0091] S44: If the current sentence is the first sentence of the document, it will be directly separated into an independent sentence. If the current sentence is not the first sentence of the document, the sentence will be processed as follows according to the entity conditions contained in the segmented sentence:

[0092] S441: When a sentence contains one entity: compare with the entity contained in the previous sentence to see if they are exactly the same; if they are exactly the same, merge the current sentence into the previous sentence; if they are not exactly the same, split the current sentence into independent sentences;

[0093] S442: When the sentence contains 0 entities: merge the current sentence into the previous sentence;

[0094] S443: When a sentence contains two or more entities: compare with the entities contained in the previous sentence to see if they are exactly the same; if they are exactly the same, merge the current sentence into the previous sentence; if they are not exactly the same, split the current sentence into independent sentences.

[0095] S45: Segment and merge the sentences of the document respectively until the segmentation and processing of all the sentences of the document are completed.

[0096] In this embodiment, a sentence segmentation method based on entity expansion is used to segment the document content based on entities. The method of first segmenting the text using all punctuation marks and then performing entity combination greatly improves the accuracy and operability of entity recognition compared to a method of directly performing full-text entity recognition and then segmenting the text. It achieves the segmentation of document sentences from the perspective of complete entity information. Segmenting document sentences from different angles and at different granularities is beneficial to the accuracy of subsequent document vector recall.

[0097] S16: Perform word embedding vectorization processing on the segmented document sentences, and store the vectors for subsequent similarity calculation;

[0098] As an exemplary implementation, in S16, word embedding vectorization processing is performed on the segmented document sentences, and the models used may include moka-ai's m3e series pre-trained models, sensenova's piccolo series pre-trained models, OpenAI's text-embedding series models, text2vec-base-chinese series models, etc.

[0099] S2: User input question processing part: The specific execution process includes S21-S23 as follows:

[0100] S21: First, obtain the user input question;

[0101] S22: Determine harmful information on the question. If the question input by the user is diagnosed as containing harmful information, the model will terminate and reply with relevant prompt text; if the question input by the user is diagnosed as harmless, proceed to the next step;

[0102] As an exemplary implementation, in S22, harmful information in the question is judged, and the neural network used mainly adopts traditional neural networks such as vector multi-classification model based on machine learning, BILSTM-CRF, etc. to perform multi-classification harmful information judgment on the input information.

[0103] S23: word embedding vectorization is performed on the harmless user question diagnosed by the diagnosis module to complete the user input question processing part;

[0104] As an exemplary implementation, in step S23, word embedding vectorization is performed on the harmless user question diagnosed by the diagnosis module, and the word embedding vectorization model adopted can be moka-ai's m3e series pre-trained model, sensenova's piccolo series pre-trained model, OpenAI's text-embedding series model, text2vec-base-chinese series model, etc.

[0105] S3: Final answer generation part: The specific execution process includes S31-S33 as follows:

[0106] S31: Calculate similarity between the vectorized question sentences and the vectorized document sentences in S1 and S2 respectively;

[0107] In step S31, similarity is calculated for the vectorized question and the vectorized document clauses in S1 and S2, respectively. The method used to calculate the vector similarity may include the traditional method of calculating the cosine similarity and Euclidean distance between vectors, or the similarity retrieval Faiss model.

[0108] S32: further, using a search enhancement processing algorithm based on semantic clustering to improve the accuracy of vector recall;

[0109] S33: Select the top k most similar vectors processed by the algorithm, and output the corresponding document sentences as the final result;

[0110] In step S33, the top k most similar vectors processed by the algorithm are selected, and the corresponding document sentences are output as the final result. The specific implementation method is to locate the top k sentence positions processed by the algorithm in step S32, and adopt the forward expansion and backward expansion methods. For example, you can choose to expand 100 words in the forward and backward directions of the current positioning sentence, or choose to expand 1 sentence in the forward and backward directions of the current positioning sentence. By appropriately expanding the positioning sentence, the integrity of the document sentence content and the accuracy of vector recall are further enhanced.

[0111] In linguistics, sentences in a paragraph usually do not exist in isolation. Adjacent sentences usually have causal relationships, parallel relationships, and general-specific relationships to better describe things or explain principles. Therefore, the semantics of sentences in a document have the characteristics of clustering. Figure 3 As shown, the implementation process of the semantic clustering-based search enhancement processing algorithm in the above step S32 is:

[0112] S51: Assume that the sequence obtained after the semantic similarity between the question and the document vector is calculated through the above steps S1 and S2 and step S31 of step S3 is:

[0113] f(n)=[f1,f2,f3,...,f n ]

[0114] Among them, the length of the sequence f(n) is N, f1, f2, ..., f n The similarity value obtained by calculating the semantic similarity between the vectorized user input question and the vectorized user local document sentence;

[0115] S52: Suppose there is a function sequence g(m) for performing data enhancement operation:

[0116]

[0117] Among them, the sequence length of g(m) is M, and M is usually an odd number. Represents adjacent sentences and central sentences The weight value of the semantic association degree, g m Represents the next adjacent sentence and the central sentence The weight value of the semantic relevance degree. Usually, the weight values ​​in the g(m) sequence are symmetrically distributed, that is, g1 = g m , g2=g m-1 , …;

[0118] As an exemplary implementation, in step S52, the specific parameters of the sequence g(m) may be: m=5, g(m)=[0.5, 0.7, 1, 0.7, 0.5]. In practical applications, the value of m and the specific weight value in the weight parameter g(m) may be flexibly selected as needed;

[0119] S53: Perform a convolution-like operation on the similarity calculation result sequence f(n) and g(m) to obtain a sequence s(n):

[0120]

[0121] Among them, the range of n is n∈[0,N-1], and the range of m is N is the length of the similarity calculation result sequence f(n), and M is the length of the sequence function g(m);

[0122] S54: Complete the calculation of the algorithm for each sentence in the document, and obtain the similarity calculation result of the final sentence after the search enhancement algorithm; according to the similarity calculation result, expand the corresponding document sentence accordingly and output it as the final result.

[0123] The algorithm is based on the principle in linguistics that paragraph sentences usually do not exist in isolation, and adjacent sentences usually have semantic similarity and semantic clustering. The algorithm can not only effectively filter out "noise" sentences in the document, but also further enhance the focus of the located vector and improve the accuracy of document vector sentence recall.

[0124] As an exemplary implementation, the present invention also provides an example diagram of a specific execution process of a semantic clustering search enhancement algorithm, such as Figure 3 As shown;

[0125] Suppose there is a sequence f(n) obtained after the semantic similarity between the question and document vectors is calculated after the above steps S1 and S2 and step S31 of step S3, where n=15;

[0126] like Figure 3 As shown in part a, f(15) = [1,1,0.2,0.2,0.2,0.2,0.2,1,1,1,1,1,0,1,1,1];

[0127] Among them, in the similarity value calculation result f(15), the smaller the value, the higher the similarity;

[0128] Suppose there is a function sequence g(m) for data enhancement operation, where m=5, g(5) is specifically:

[0129] g(5)=[f1,f2,f3,f4,f5]=[0.5,0.7,1,0.7,0.5]

[0130] Among them, f2=f4=0.7, which means that the semantic relevance between the nearest neighboring points and the center point f3 is relatively large; f1=f5=0.5, which means that the semantic relevance between the second nearest neighboring points and the center point f3 is average;

[0131] like Figure 3 Part b shows a schematic diagram of the function g(m)=g(5);

[0132] Substitute f(n) and g(m) into the formula Perform operations;

[0133] Where N = 16, M = 5, m∈[-2,2], n∈[0,15], in the sequence f(n), the operation points that exceed the given operation range are defaulted to 1;

[0134] When n = 0, we have

[0135]

[0136]

[0137] When specifically operating s(0), similar points in f(n) that exceed the operation range are supplemented with 1, that is, 1 is added to the first two digits and the last two digits of f(n) respectively;

[0138] When n = 1, we have

[0139]

[0140]

[0141] like Figure 3 Part c shows s(2), then the calculation result of s(2) according to the formula is

[0142]

[0143]

[0144] like Figure 3 Part c shows s(15), s(15) is

[0145]

[0146]

[0147] The actual meaning of the specific example is as follows. Assuming that the number of sentences in a document after sentence segmentation is 16, the semantic similarity calculation results are:

[0148] f(15)=[f0,f1,f2,...,f 15 ]=[1,1,0.2,0.2,0.2,0.2,0.2,1,1,1,1,1,0,1,1,1]

[0149] The actual meaning is, where the lower the score, the higher the similarity, and the higher the score, the lower the similarity. According to the semantic similarity calculation results and the characteristics of semantic clustering, in the f(15) related semantic cluster, there are 5 sentences with high similarity, namely [f2,f3,f4,f5,f6,]. It is easy to know that the document sentence vector to be recalled should be within the range of these 5 sentences; in addition, there is another sentence f 12 It has the highest semantic similarity calculation value, but the similarity values ​​of the sentences before and after it are both 1, that is, there are no clusters near this sentence to support f 12 Although this sentence has the highest semantic similarity calculation value, it is likely to be a noise sentence.

[0150] Substituting the above specific values ​​into the search enhancement algorithm based on semantic clustering, the final calculation result sequence is as follows: Figure 3 As shown in part d, s(15) is:

[0151] s(15)=[s0,s1,s2,...,s 15 ]

[0152] =[0.6,0.488,0.328,0.216,0.136,0.216,0.328,0.488,0.6,0.68,0.58,0.54,0.48,0.54,0.58,0.68]

[0153] It can be seen that after the algorithm processing, the minimum value of the semantic similarity calculation result is located at f4 = 0.136, while f 12 The minimum value of the nearby points is 0.48; after being processed by the algorithm, the noise sentence f is successfully filtered out 12 , it is located in the semantic cluster near f4, which improves the accuracy of vector recall.

[0154] As an exemplary implementation, the present invention also provides a schematic diagram of a multi-document processing mode, such as Figure 4 As shown, when the user continues to input a new document based on the document that has already been input, the following processes or processing steps are included:

[0155] (1) Obtaining and reading the user input document. The process of obtaining and reading the user input document is the same as the method in step S1 and will not be repeated here.

[0156] (2) Determine whether the newly input document contains harmful information;

[0157] (3) If the document information is judged to be harmless information, proceed to the next processing step to select whether to add a new document based on the original document;

[0158] (4) If you choose to add a new document based on the original document, then perform document preprocessing, document sentence segmentation, word embedding vectorization and other steps on the newly added document, and add the newly added document vector to the end of the original document and store it;

[0159] (5) Subsequently, the question word embedding vectorization, semantic similarity calculation, search enhancement algorithm, sentence integration and other steps in steps S2 and S3 will be executed to output the final answer sentence.

[0160] If you choose not to add new documents based on the original documents, each newly added document will be preprocessed, segmented, and vectorized, and each processed document will be stored as a vector separately.

[0161] When performing subsequent steps such as semantic similarity calculation, the BM25 algorithm is first used to perform a rough recall of each document, and then semantic similarity calculation, sorting, search enhancement algorithm, answer integration and other steps are performed on the vector sentences in the recalled documents to output the final answer sentence.

[0162] In summary, the large model knowledge enhancement method that integrates multi-strategy sentence segmentation and semantic clustering provided in the embodiment of the present invention can be used to improve the accuracy of user local document information recall for knowledge enhancement of large models. First, three sentence segmentation techniques are adopted, namely, a sentence segmentation method based on traditional sentence punctuation structure and a sentence segmentation method based on sentence semantic structure. On this basis, a sentence segmentation method based on entity extension is proposed. By segmenting sentences from different angles and at different granularities, sentence similarity can be calculated from multiple angles, thereby improving the accuracy of subsequent document vector recall. Secondly, the present invention proposes a search enhancement method based on semantic clustering. Based on the principle of semantic clustering of linguistic document paragraphs, it can filter out noise sentences and enhance the accuracy of related sentence positioning.

[0163] Finally, the method of the embodiment of the present invention is particularly suitable for scenarios in which knowledge enhancement, summarization and conclusion based on local documents are performed in large-model knowledge enhancement, or other task requirements are achieved based on local documents. It is particularly suitable for application scenarios with high accuracy in large-model knowledge question and answering, such as education, law, medicine, etc.

[0164] Embodiment 2:

[0165] like Figure 5As shown, the present invention also provides a large model knowledge enhancement device integrating multi-strategy sentence segmentation and semantic clustering, comprising:

[0166] The acquisition module is used to obtain the user's local documents and user input questions;

[0167] A document reading module, used to read the content of the user's local document;

[0168] A harmful information judgment module, used for judging harmful information based on the read content of the user's local document and the user input question;

[0169] A document preprocessing module, used for performing preprocessing when it is determined that the read content of the user's local document is harmless;

[0170] A multi-strategy document content segmentation module is used to perform multi-strategy segmentation on the pre-processed read content of the user's local document using a multi-strategy sentence segmentation method;

[0171] A word embedding module, used for performing word embedding vectorization operations on the user input question and the user local document content segmented by multiple strategies respectively when it is determined that the user input question is harmless;

[0172] A similarity calculation module, used to perform vector similarity calculation on the vectorized user input question and the user's local document content;

[0173] The search enhancement and output module based on semantic clustering selects part of the most similar vectors, expands the corresponding document sentences accordingly and outputs them as the final result.

[0174] The above-mentioned functional modules disclosed in this embodiment are used to execute the large-model knowledge enhancement method integrating multi-strategy sentence segmentation and semantic clustering disclosed in Example 1 of the present invention.

[0175] Embodiment 3:

[0176] The third aspect of an embodiment of the present invention discloses a computer device, including a memory and a processor, wherein the memory stores computer-readable instructions, and when the computer-readable instructions are executed by the processor, the processor executes a large-model knowledge enhancement method that integrates multi-strategy sentence segmentation and semantic clustering as described in embodiment 1 of the present invention.

[0177] Embodiment 4:

[0178] An embodiment of the present invention further provides a computer storage medium storing a computer program. When the computer execution instructions are executed by a processor, the computer storage medium is used to implement the technical solution described in the above embodiment 1. The specific functions and technical effects that can be achieved are not repeated here.

[0179] The above is a detailed introduction to the large-model knowledge enhancement method and device that integrates multi-strategy sentence segmentation and semantic clustering provided by the present invention. This article uses specific examples to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea; at the same time, for general technical personnel in this field, according to the ideas of the present invention, there will be changes in the specific implementation methods and application scopes. In summary, the content of this specification should not be understood as a limitation on the present invention.

[0180] In this article, relational terms such as first and second, etc. are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "comprise", "include" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the statement "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.

Claims

1. A large model knowledge enhancement method integrating multi-strategy sentence segmentation and semantic clustering, characterized in that: The following steps are involved: Step 1: Obtain the user's local document and user input questions; Step 2: Read the content of the user's local document; Step 3: Determine harmful information based on the read content of the user's local document and the user input question; Step 4: When it is determined that the read content of the user's local document is harmless, preprocessing is performed; Step 5: The pre-processed read content of the user's local document is segmented using a multi-strategy sentence segmentation method; Step 6: When it is determined that the user input question is harmless, a word embedding vectorization operation is performed on the user input question and the user local document content segmented by multiple strategies respectively; Step 7: Calculate the vector similarity between the vectorized user input question and the user's local document content; Step 8: Select some of the most similar vectors based on the search enhancement method of semantic clustering, expand the corresponding document sentences accordingly and output them as the final result; Wherein, the step 5 comprises: The preprocessed read content of the user's local document is segmented by multiple strategies using a sentence segmentation method based on sentence punctuation marks, a sentence segmentation method based on sentence semantic structure, and a sentence segmentation method based on entity extension; wherein the sentence segmentation method based on entity extension is segmented by multiple strategies, including: S41: Obtain the pre-processed read content of the user's local document; S42: splitting the document based on punctuation marks in the document; S43: performing named entity recognition on the segmented sentences respectively; S44: Determine whether the current sentence is the first sentence of the document. If the current sentence is the first sentence of the document, the sentence will be directly segmented; if the current sentence is not the first sentence of the document, the sentence will be processed separately according to the entity conditions contained in the segmented sentence: S45: Segment and merge the sentences in the document respectively until segmentation and processing of all the sentences in the document are completed; The step 8 comprises: 1): The sequence obtained after calculating the vector similarity: <h2 style=";text-align:left;direction:ltr">f(n) = [f1,f2,f3,...,f<h2 style=";text-align:left;direction:ltr"> n <h2 style=";text-align:left;direction:ltr"> ] Among them, the length of the sequence f(n) is N, f1, f2, ..., f n The similarity values ​​obtained after semantic similarity calculation between the vectorized user input question and the vectorized user local document content; 2): Suppose there is a function sequence g(m) for data enhancement operation: Among them, the sequence length of g(m) is M, and M is an odd number. Indicates adjacent sentences and central sentences The weight values ​​of semantic association degree, g1, g2, ... …,g m Represents the secondary adjacent sentence and the central sentence The weight value of the degree of semantic relevance; 3): Perform a convolution-like operation on the similarity calculation result sequence f(n) and g(m) to obtain the sequence s(n): Among them, the range of n is n∈[0,N-1], and the range of m is N is the length of the similarity calculation result sequence f(n), and M is the length of the sequence function g(m); 4): Complete the calculation of the algorithm for each sentence in the document, and obtain the similarity calculation result of the final sentence after the search enhancement algorithm; according to the similarity calculation result, expand the corresponding document sentence accordingly and output it as the final result.

2. According to claim 1, a large model knowledge enhancement method integrating multi-strategy sentence segmentation and semantic clustering is characterized in that: The step 2 comprises: When the user's local document is in excel, csv, word, or txt format, the corresponding third-party library function in python is used to read the text file; When the user's local document is in pdf, jpg, or png format, OCR scanning is performed to read the document information content.

3. According to claim 1, a large model knowledge enhancement method integrating multi-strategy sentence segmentation and semantic clustering is characterized in that: The step 3 comprises: A neural network is used to perform multi-classification harmful information judgment on the read content of the user's local document and the user input question.

4. According to claim 1, a large model knowledge enhancement method integrating multi-strategy sentence segmentation and semantic clustering is characterized in that: The step 4 comprises: When it is determined that the read content of the user's local document is harmless, invalid document information is filtered, content is deduplicated, and the format of the document content is adjusted.

5. According to claim 1, a large model knowledge enhancement method integrating multi-strategy sentence segmentation and semantic clustering is characterized in that: The processing of the sentences in step S44 includes: S441: When a sentence contains one entity: compare it with the entity contained in the previous sentence to see if they are exactly the same; if they are exactly the same, merge the current sentence into the previous sentence; if they are not exactly the same, split the current sentence into independent sentences; S442: When the sentence contains 0 entities: merge the current sentence into the previous sentence; S443: When a sentence contains two or more entities: compare with the entities contained in the previous sentence to see if they are exactly the same; if they are exactly the same, merge the current sentence into the previous sentence; if they are not exactly the same, split the current sentence into independent sentences.

6. According to claim 1, a large model knowledge enhancement method integrating multi-strategy sentence segmentation and semantic clustering is characterized in that: In the step 6, a word embedding vectorization operation is performed by adopting a word embedding vectorization model; the word embedding vectorization model is moka-ai's m3e series pre-trained model, sensenova's piccolo series pre-trained model, OpenAI's text-embedding series model or text2vec-base-chinese series model.

7. According to claim 1, a large model knowledge enhancement method integrating multi-strategy sentence segmentation and semantic clustering is characterized in that: The vector similarity calculation in step 7 adopts the cosine similarity between the vectors, the Euclidean distance algorithm or the integrated similarity retrieval framework Faiss model.

8. A large model knowledge enhancement device integrating multi-strategy sentence segmentation and semantic clustering, characterized in that: Using the large model knowledge enhancement method integrating multi-strategy sentence segmentation and semantic clustering as claimed in any one of claims 1 to 7, the device comprises: The acquisition module is used to obtain the user's local documents and user input questions; A document reading module, used to read the content of the user's local document; A harmful information judgment module, used for judging harmful information based on the read content of the user's local document and the user input question; A document preprocessing module, used for performing preprocessing when it is determined that the read content of the user's local document is harmless; A multi-strategy document content segmentation module is used to perform multi-strategy segmentation on the pre-processed read content of the user's local document using a multi-strategy sentence segmentation method; A word embedding module, used for performing word embedding vectorization operations on the user input question and the user local document content segmented by multiple strategies respectively when it is determined that the user input question is harmless; A similarity calculation module, used to perform vector similarity calculation on the vectorized user input question and the user's local document content; The search enhancement and output module based on semantic clustering selects part of the most similar vectors, expands the corresponding document sentences and outputs them as the final result.

Citation Information

Patent Citations

  • Comprehensive pipe gallery industry knowledge question-answering system construction method based on knowledge graph

    CN111831794A

  • Multi-modal implication enhanced image text retrieval method and system

    CN115712740A