Online communication processing method and system based on unstructured text retrieval model
By using knowledge graphs and multi-vector representation of BERT models in text retrieval, the semantic ambiguity problem is solved, the search accuracy and efficiency are improved, and more accurate similarity calculation is achieved.
Patent Information
- Application Number
- CN202411366567.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-29
- Publication Date
- 2025-03-07
- Estimated Expiration
- 2044-09-29
AI Technical Summary
The prior art is difficult to effectively solve the semantic ambiguity problem in text retrieval, resulting in insufficient retrieval accuracy and efficiency.
Using knowledge graph combined with multivector representation of BERT model, BERT semantic representation is fused to improve the semantic representation and similarity calculation accuracy of text by constructing internal and external knowledge graphs and using graph embedding methods.
It improves the accuracy and efficiency of text retrieval, and can more accurately calculate the similarity between query and text, meeting the needs of complex information retrieval scenarios.
Smart Images

Figure CN118885571B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of information retrieval, and in particular to the application of unstructured text in China Unicom's online privacy communication service system. Background Art
[0002] The 21st century is an era of technological innovation led by information technology. With the rapid increase in the amount of information, the amount of information generated every day is huge and mostly unstructured. Among them, text data accounts for more than 80% of network data, and it is very difficult to retrieve and filter information from it. Unstructured text retrieval refers to the text retrieval model returning the most relevant document set in the unstructured document library based on the query keywords entered by the user. The text retrieval model mainly includes text definition, text and query representation, and relevance calculation. Among them, how to calculate the relevance between the text and the query keywords entered by the user is the core issue in text retrieval.
[0003] Over the past few decades, people have proposed a variety of text retrieval models, from traditional vector space models, probabilistic models, clustering models, to deep learning models. Vector space models and probabilistic models achieve retrieval by calculating the similarity between text and query. Clustering models cluster text collections into different topics to provide more accurate retrieval results. Deep learning models improve the performance and stability of deep learning models in the field of text retrieval through methods such as data enhancement, negative sample sampling, and model fusion.
[0004] Knowledge Graph was proposed by Google in 2012 to improve the efficiency of search engines, and was subsequently expanded to other fields. It is a knowledge base that represents complex relationships between entities in a simple and intuitive graph structure, and can be used to support unstructured text retrieval technology. The application of knowledge graph in text retrieval mainly includes two aspects: (1) Entity linking: linking entities mentioned in the text with corresponding entities in the knowledge graph to improve the accuracy and richness of search results. (2) Semantic search: Based on the relationship and attribute information of the knowledge graph, contextual semantics can be considered during search to improve the accuracy and relevance of search results. There are two main types of text retrieval methods combined with knowledge graphs: one is to introduce background information and prior knowledge through knowledge graphs to optimize retrieval performance, and the other is to learn implicit representations of information from large-scale data through deep learning technology.
[0005] Although text retrieval is an important branch in the field of information retrieval, the accuracy and efficiency of traditional text retrieval methods can no longer meet actual needs as information increases and becomes more complex. Common traditional text retrieval methods include Boolean models, vector space models, probability models, and rule-based models. Boolean models strictly match strings and cannot be sorted. In the face of increasingly complex and large amounts of information, it is obviously not applicable; vector space models tend to ignore frequently occurring words and retain low-frequency words. However, it ignores word order and semantic information, and only represents text as a vector of a single word frequency, which cannot distinguish text semantics; rule-based text retrieval models are simple to implement and have good interpretability, and are suitable for some simple text retrieval scenarios. However, they may not be able to handle some complex scenarios well, making it difficult to meet the personalized needs of users.
[0006] At present, there are two main directions of text retrieval research based on deep learning: based on semantic representation and based on interactive information. Deep learning based on text semantic representation solves the dictionary explosion problem existing in traditional methods and reduces computational complexity and memory usage space. However, it also has many defects, such as word hashing may cause word conflicts and high noise and difficulty in convergence; text retrieval based on interactive information matching mainly includes DRMM, KNRM and ANCE models. The ANCE model uses an approximate nearest neighbor negative contrast learning strategy to achieve efficient and accurate retrieval in open domain question answering and other retrieval tasks. It mainly focuses on optimizing dense vector representation to improve retrieval results.
[0007] In recent years, the rapid development of deep learning methods has brought new opportunities for the improvement of text retrieval technology, and text retrieval methods based on deep learning have gradually become a hot topic of research. With the rise of knowledge graphs, more and more scholars have applied knowledge graphs to text retrieval and proposed a series of text retrieval methods based on knowledge graphs, aiming to improve the accuracy and efficiency of text retrieval through rich semantic information and structural information. Summary of the invention
[0008] In view of the above-mentioned defects of the prior art, the present invention uses knowledge graph to realize unstructured text retrieval, solves the semantic ambiguity problem in the field of text retrieval, and improves the retrieval accuracy; further, after extracting the segment keywords, they are input into the BERT model for multi-vector representation of keywords to ensure that different semantic representations of the same keyword have appropriate differences; the coverage mechanism is introduced in its local matching layer so that it can better calculate the similarity between the query and the SMS according to the different granularities of the SMS; in addition, the BERT semantic representation is integrated using a method based on knowledge graph embedding, and the semantic representation and similarity calculation accuracy of the text are improved by utilizing the close entities and relationships in the endogenous knowledge graph, the easy generation of global semantics, and the exogenous knowledge graph that can enhance the extensibility of text representation. The similarity matrix constructed by this method is more accurate and can further improve the retrieval performance. The applicability and limitations of different graph embedding methods under different data characteristics are analyzed to lay a good foundation for specific applications.
[0009] The present invention intends to provide an online communication processing method, system, computer-readable storage medium and computer device based on an unstructured text retrieval model to solve the deficiencies in the prior art. The technical problem to be solved by the present invention is achieved through the following technical solutions.
[0010] A first aspect of the present invention provides an online communication processing method based on an unstructured text retrieval model, the method comprising:
[0011] Step 1, input step;
[0012] Step 2: constructing a knowledge graph and storing the knowledge graph. The constructing a knowledge graph and storing the knowledge graph further includes:
[0013] Build a document library, use the SMS content dataset as the document library, save all texts in the project root directory, and rename the text files to different IDs;
[0014] Construct an endogenous knowledge graph, use an open source toolkit to call the SpERT model to generate triples to construct the endogenous knowledge graph; use the HanLP library to preprocess each text, including data cleaning, noise removal and encoding into UTF-8 format; extract and merge entity relationships for each preprocessed text through the SpERT model to generate triples; store the triples in the knowledge graph, perform addition operations on triples that do not exist at all, perform merging operations on triples that exist partially or completely, and save the text IDs for nodes and relationships;
[0015] Construct an exogenous knowledge graph and train an initial model, use OpenKG, obtain a partial knowledge graph of the text as the exogenous knowledge graph through a RESTful API, and use an entity to save the text ID;
[0016] Step 3: calling and regularly updating the text retrieval model;
[0017] Step 4, executing database operations to implement data management steps;
[0018] Step five, retrieval step.
[0019] In combination with the first aspect, it further includes step six, a visualization step, for displaying the results of user queries and presenting retrieval results.
[0020] In combination with the first aspect, further, the open source toolkit uses the HanLP library, which provides a variety of Chinese text processing functions, including word segmentation, part-of-speech tagging, named entity recognition, dependency syntax analysis, keyword extraction, text classification, sentiment analysis and question-answering system.
[0021] In combination with the first aspect, the step of performing database operations to implement data management further includes:
[0022] When adding text, the newly added text is saved in the text library, and after preprocessing, keywords are extracted and saved in a new file; the endogenous knowledge graph is completed using the knowledge graph construction method; OpenKG is accessed through the RESTful API according to the relationship entities involved in the new text, and the triples are obtained to complete the exogenous knowledge graph;
[0023] When deleting text, the endogenous knowledge graph and the exogenous knowledge graph delete related nodes and relationships according to the ID of the text, and update the newly created file at the same time;
[0024] Perform model iteration by setting a scheduled task to execute the train.py script for retraining the retrieval model every two weeks. The generated new model ir.model overwrites the old model.
[0025] In combination with the first aspect, the searching step further comprises:
[0026] User input,
[0027] Parameter verification, used to verify whether the user's input is legal;
[0028] Query keyword extraction, the keyword entered by the user is passed to the keyword input box on the front-end page, and then passed to the back-end service.
[0029] Document similarity calculation,In text retrieval, the similarity between the query statement entered by the user and the text in the document library can be converted into a many-to-many correlation match between multiple query keywords and multiple text keywords.,Using cosine similarity, we first vectorize the text data of the two articles and convert them into vectors respectively.,Then, by calculating the cosine values of the two vectors, we use the following formula (1) to determine the similarity between them,
[0030] (1)
[0031] In formula (1), Q i ,W j represents two entity vectors, , Represents vector Q i , W j The module length;
[0032] Generate a corresponding semantic vector for each entity, and then use cosine similarity to calculate the semantic distance between all entities; to ensure the consistency and accuracy of the knowledge graph, set the entity similarity threshold to 0.9;
[0033] Sorting of search results,
[0034] The keywords of each text are obtained from the newly created file, input into the text retrieval model together with the query keywords, and the retrieval results are output in reverse order of relevance.
[0035] A second aspect of the present invention provides an online communication processing system based on an unstructured text retrieval model, the system comprising:
[0036] Input module;
[0037] Constructing a knowledge graph and a storage module, the knowledge graph and storage module further includes:
[0038] The document library constructs a submodule, uses the SMS content dataset as the document library, stores all texts in the project root directory, and renames the text files to different IDs;
[0039] The endogenous knowledge graph construction submodule uses an open source toolkit to call the SpERT model to generate triples to construct the endogenous knowledge graph; each text is preprocessed using the HanLP library, including data cleaning, noise removal, and encoding into UTF-8 format; entity relationships are extracted and merged for each preprocessed text using the SpERT model to generate triples; the triples are stored in the knowledge graph, and new additions are performed on triples that do not exist at all, and merge operations are performed on triples that exist partially or completely, and nodes and relationships save text IDs;
[0040] The exogenous knowledge graph and the training initial model construction submodule use OpenKG to obtain a partial knowledge graph of the text as the exogenous knowledge graph through a RESTful API, and use entities to save text IDs;
[0041] Call and regularly update the text retrieval model module;
[0042] Perform database operations to implement data management modules;
[0043] Retrieval module.
[0044] A third aspect of the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of an online communication processing method based on an unstructured text retrieval model.
[0045] A fourth aspect of the present invention provides a computer device, comprising: a memory for storing a computer program; a processor for executing the computer program to implement the steps of an online communication processing method based on an unstructured text retrieval model.
[0046] The innovation of the present invention lies in:
[0047] 1. In order to solve the problem of semantic ambiguity in the field of text retrieval, the input word vector is improved, BERT word embedding and knowledge enhancement technology based on knowledge graph embedding are introduced to enhance the algorithm's ability to understand text and queries, thereby improving retrieval accuracy.
[0048] 2. A model based on unstructured text retrieval is designed to solve the problem of text ambiguity. The model first extracts keywords from each natural segment of the document to reduce the complexity of task processing and the amount of calculation; then the BERT multi-vector representation combined with the coverage mechanism is used to improve the local matching layer, so that the model can calculate the relevance based on the local segment level granularity of the document and the global document level granularity to improve the semantic matching accuracy; finally, the global decision layer improved by Bi-GRU is used to reduce the risk of overfitting and improve the calculation efficiency.
[0049] 3. In order to solve the problem that the BERT model focuses too much on the local context and ignores the global semantic information of the document library, we use the knowledge graph embedding combined with the BERT semantic representation method to balance the local semantics of keywords in a single text and the global semantics of multiple related texts.
[0050] The present invention aims to improve the retrieval accuracy and efficiency of short message content, better serve the people, and maintain network information security. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] Figure 1is a flow chart of an online communication processing method based on an unstructured text retrieval model of the present invention;
[0052] Figure 2 It is a system architecture diagram of the online communication processing method based on the unstructured text retrieval model of the present invention;
[0053] Figure 3 It is a flowchart of an embodiment of the data retrieval in the online communication processing method based on the unstructured text retrieval model of the present invention;
[0054] Figure 4 It is an internal structure diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0055] It should be noted that, in the absence of conflict, the embodiments and features in the embodiments of the present application can be combined with each other. The present invention will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.
[0056] It should be noted that the above detailed descriptions are exemplary and are intended to provide further explanation of the present application. Unless otherwise specified, all technical and scientific terms used herein have the same meaning as commonly understood by those of ordinary skill in the art to which the present application belongs.
[0057] Aiming at the problem that the existing unstructured text retrieval model cannot solve text ambiguity and semantic search, the present invention designs an online communication processing method and system based on the unstructured text retrieval model, and realizes the text semantic retrieval function.
[0058] Aiming at the problem of semantic ambiguity that is difficult to solve in the field of text retrieval, the present invention improves the input word vector, introduces BERT word embedding and knowledge enhancement technology based on knowledge graph embedding, enhances the algorithm's ability to understand text and queries, and thus improves retrieval accuracy.
[0059] In addition, the present invention also designs a model based on unstructured text retrieval to solve the text ambiguity problem. The model first extracts keywords from each natural segment of the document to reduce the complexity of task processing and the amount of calculation; then the BERT multi-vector representation combined with the coverage mechanism is used to improve the local matching layer, so that the model can perform correlation calculations based on the local segment level granularity of the document and the global document level granularity to improve the semantic matching accuracy; finally, the Bi-GRU improved global decision layer is used to reduce the risk of overfitting and improve the calculation efficiency.
[0060] like Figure 1The present invention proposes a flowchart of an online communication processing method based on an unstructured text retrieval model, the method comprising: an input step; a knowledge graph construction and storage step; a text retrieval model call and regular update step; a database operation to implement a data management step; and a retrieval step. The specific implementation process of the retrieval step will be described in detail in the following embodiment.
[0061] Build knowledge graph and storage:
[0062] The preprocessing work includes document library construction, endogenous knowledge graph construction, exogenous knowledge graph construction and initial model training. This system uses the SMS content dataset as a document library, stores all texts in the project root directory, and renames the text files to different IDs.
[0063] This system uses the HanLP library, an open source toolkit for one-stop Chinese processing, to call the SpERT model to generate triples to construct the endogenous knowledge graph. HanLP is a Chinese natural language processing toolkit developed by the Natural Language Processing Group of the Institute of Computing Technology, Chinese Academy of Sciences. It is currently one of the most popular Chinese natural language processing toolkits in China. It provides a variety of Chinese text processing functions, including word segmentation, part-of-speech tagging, named entity recognition, dependency syntactic analysis, keyword extraction, text classification, sentiment analysis, question-answering system, etc. The specific steps are as follows:
[0064] (1) Use HanLP, Numpy and other libraries to preprocess each text, including data cleaning, noise removal and encoding into UTF-8 format;
[0065] (2) For each preprocessed text, entity relations are extracted and merged using the SpERT model to generate triples.
[0066] (3) These triples are stored in the knowledge graph. New operations are performed on triples that do not exist at all, and merge operations are performed on triples that exist partially or completely. The nodes and relationships save the ID numbers of the texts.
[0067] The exogenous knowledge graph uses OpenKG, which is an open knowledge graph community alliance project initiated and advocated by the Language and Knowledge Computing Professional Committee of the Chinese Information Society in 2015. It is suitable for Chinese applications. The system obtains part of the knowledge graph involving text as the exogenous knowledge graph through RESTfulAPI, and the text ID is saved for the relevant entities.
[0068] The system architecture diagram of the online communication processing method based on the unstructured text retrieval model of the present invention is as follows: Figure 2 As shown in the figure, it is a B / S-based Web system, which includes a visualization layer, a back-end service layer, and a data layer supporting the system implementation.
[0069] (1) Visualization layer, used to present the final search results. The present invention is written in HTML and CSS for user query input and search result presentation.
[0070] (2) The backend service layer is written using the Flask framework, which is a mainstream web framework under Python and is often used in small web project development. It can implement the functions of the retrieval module. The service layer can call and regularly update the text retrieval model, operate the database, and implement data management.
[0071] (3) Data layer: This layer implements the knowledge graph storage module, which is used to store knowledge graphs and graph convolution training. The database uses Neo4J, which is a mainstream graph database with fast speed and simple operation. Neo4J GDSL is a plug-in library for performing graph analysis and data science tasks. It provides some graph embedding algorithms and supports deep learning training, which greatly simplifies the development and training difficulties. The backend service uses py2neo to interact with the database. Py2neo allows developers to interact directly with the Neo4J database in the Python environment to execute queries, manage transactions, and operate graph data.
[0072] System implementation:
[0073] The environment deployment of the present invention is shown in Table 1. The CPU used in the system is Intel(R) Core(TM) i7-10700, the GPU used is NVIDIA GeForce RTX 3070Ti / 16G, the operating system used is Ubuntu 16.04, and the software used is Python 3.6, PyTorch, TextNet, and Neo4J 4.2.5.
[0074]
[0075] Table 1 Environment deployment of online communication processing system for unstructured text retrieval model
[0076] Data Management and Model Management
[0077] This system takes into account that the text library is not static and that daily use involves the addition and deletion of text. The data management module of this system implements this function. When text is added, first, the newly added text is saved in the text library (under the project root directory), and after preprocessing, the keywords are extracted and saved in the kw.kv file; then, the knowledge graph construction method is used to complete the endogenous knowledge graph of this system; finally, the RESTful API is used to access OpenKG based on the relational entities involved in the new text to obtain relevant triples to complete the exogenous knowledge graph. When text is deleted, the endogenous and exogenous knowledge graphs delete the relevant nodes and relationships based on the text ID, and update the kw.kv file at the same time.
[0078] Since the model is trained based on the old text library, the text library changes greatly over time, and the old model is difficult to generalize to the new text library, so it needs to be updated as the text library changes. This system uses the model management module to implement the model iteration function. By setting a scheduled task, the train.py script for retraining the retrieval model is executed every two weeks, and the generated new model ir.model overwrites the old model.
[0079] Search steps
[0080] The retrieval step is the most important and core step of this system. The query keyword is passed to the keyword input box on the front-end page, and then passed to the back-end service. The keywords of each text are obtained from the kw.kv file, and input into the text retrieval model together with the query keyword, and the retrieval results are output in reverse order of relevance. The process is as follows Figure 3 shown.
[0081] Step 1: User input, the query keyword is passed into the keyword input box of the front-end page, and then passed to the back-end service.
[0082] Step 2: Parameter verification, used to verify whether the user's input is legal.
[0083] Step 3: Document similarity calculation,
[0084] A similarity matrix is a matrix used to represent the similarity or dissimilarity between a set of objects, where each row and column represents an object, and each element of the matrix represents the similarity or dissimilarity between two objects. It is usually a symmetric matrix. The similarity matrix can help us understand the relationship between data, so as to make more effective data analysis and decision-making. In machine learning and data mining, similarity matrices are often used in tasks such as clustering, dimensionality reduction, anomaly detection, text retrieval, recommendation systems, and clustering.
[0085] The similarity matrix can be represented in the form of a matrix or a graph. In the matrix form, the similarity matrix is an n*m matrix, where n and m represent the number of query and text keywords respectively.
[0086] In text retrieval, the similarity between the query statement entered by the user and the text in the document library can be converted into a many-to-many correlation match between multiple query keywords and multiple text keywords, that is, the similarity between a single query keyword and a single text keyword is calculated and the final similarity score of the query and text is generated on this basis using appropriate methods.
[0087] There are many ways to calculate similarity, the commonly used ones are:
[0088] (1) Euclidean distance: vector distance is regarded as a derivative representation of the distance between two points in Euclidean space. Although this method is simple, it is not very suitable for representing semantic similarity because it only considers the distance between vectors but not the directional relationship between them.
[0089] (1) (1)
[0090] (2) Cosine similarity: This method interprets similarity as the cosine value of two points in a multidimensional space. It is the most widely used due to its simplicity and efficiency. First, the text data of the two articles are vectorized and converted into a vector respectively. Then, the cosine value of the two vectors is calculated to determine the similarity between them.
[0091] (2)
[0092] In formula (2), Q i , W j represents two entity vectors, , Represents vector Q i , W j The module length;
[0093] (3) Tanimoto coefficient: an indicator used to measure the similarity between two samples, also known as the Jaccard coefficient. It is a metric calculated based on the intersection and union of two sets to measure the similarity between two sets. The Tanimoto coefficient ranges from 0 to 1, and the larger the value, the higher the similarity between the two samples. The advantage of the Tanimoto coefficient is that it is simple and easy to implement, and it also has good performance for large-scale data sets. However, when the feature sets of two samples show a strong overlap, the Tanimoto coefficient may overestimate their similarity.
[0094] The present invention adopts the cosine similarity method to merge entities. First, a corresponding semantic vector is generated for each entity, and then the semantic distance between all entities is calculated using cosine similarity. In the construction of the knowledge graph, in order to ensure the consistency and accuracy of the knowledge graph, a higher entity similarity threshold is usually set, such as between 0.8 and 0.9. Considering that the processing of the similarity matrix will fuse the associations between different entities, strong consistency is adopted, that is, the threshold is set to 0.9.
[0095] Step 4: Get the keywords of each text from the kw.kv file, input them into the text retrieval model together with the query keywords, and output the retrieval results in reverse order of relevance.
[0096] Figure 4 An example of a physical structure diagram of an electronic device is shown. The electronic device may be a smart terminal, and its internal structure diagram may be as follows: Figure 4 As shown. The electronic device includes a processor, an internal memory and a network interface connected via a system bus. The processor of the electronic device is used to provide computing and control capabilities. The memory of the electronic device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the electronic device is used to communicate with an external terminal via a network connection.
[0097] Those skilled in the art will understand that Figure 4 The structure shown in the figure is only a block diagram of a part of the structure related to the scheme of the present invention, and does not constitute a limitation on the electronic device to which the scheme of the present invention is applied. The specific electronic device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0098] It should be noted that the terms used herein are only for describing specific embodiments and are not intended to limit the exemplary embodiments according to the present application.
[0099] In the above detailed description, reference is made to the accompanying drawings, which form a part of this document. In the accompanying drawings, similar symbols typically identify similar components unless the context indicates otherwise. The illustrated embodiments described in the detailed description, drawings, and claims are not meant to be limiting. Other embodiments may be used, and other changes may be made, without departing from the spirit or scope of the subject matter presented herein.
[0100] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. An online communication processing method based on an unstructured text retrieval model, characterized in that: The method comprises: Step 1, input step; Step 2: constructing a knowledge graph and storing the knowledge graph. The constructing a knowledge graph and storing the knowledge graph further includes: Build a document library, use the SMS content dataset as the document library, save all texts in the project root directory, and rename the text files to different IDs; Construct an endogenous knowledge graph, use an open source toolkit to call the SpERT model to generate triples to construct the endogenous knowledge graph; use the HanLP library to preprocess each text, including data cleaning, noise removal and encoding into UTF-8 format; extract and merge entity relationships for each preprocessed text through the SpERT model to generate triples; store the triples in the knowledge graph, perform addition operations on triples that do not exist at all, perform merging operations on triples that exist partially or completely, and save the text IDs for nodes and relationships; Construct an exogenous knowledge graph and train an initial model, use OpenKG, obtain a partial knowledge graph of the text as the exogenous knowledge graph through a RESTful API, and use an entity to save the text ID; Step 3: calling and regularly updating the text retrieval model; Step 4: Execute database operations to implement data management steps. When adding text, the newly added text is saved in the text library, and keywords are extracted after preprocessing and saved in a new file; the endogenous knowledge graph is completed using the knowledge graph construction method; OpenKG is accessed through the RESTful API according to the relationship entities involved in the new text, and the triples are obtained to complete the exogenous knowledge graph; When deleting text, the endogenous knowledge graph and the exogenous knowledge graph delete related nodes and relationships according to the ID of the text, and update the newly created file at the same time; Perform model iteration by setting a scheduled task to execute the train.py script for retraining the retrieval model every two weeks. The generated new model ir.model will overwrite the old model. Step 5, a retrieval step, the retrieval step further comprises: User input; Parameter verification, used to verify whether the user's input is legal; Query keyword extraction: the keywords entered by the user are passed to the keyword input box on the front-end page and then passed to the back-end service; Document similarity calculation,In text retrieval, the similarity between the query statement entered by the user and the text in the document library can be converted into a many-to-many correlation match between multiple query keywords and multiple text keywords.,Using cosine similarity, we first vectorize the text data of the two articles and convert them into vectors respectively.,Then, by calculating the cosine values of the two vectors, we use the following formula (1) to determine the similarity between them, (1) In formula (1), , represents two entity vectors, Representation vector , The modulus length is used to generate a corresponding semantic vector for each entity, and then the cosine similarity is used to calculate the semantic distance between all entities. To ensure the consistency and accuracy of the knowledge graph, the entity similarity threshold is set to 0.9; The search results are sorted by obtaining keywords of each text from the newly created file, inputting them into the text search model together with the query keywords, and outputting the search results sorted in reverse order of relevance.
2. The online communication processing method based on the unstructured text retrieval model according to claim 1, characterized in that: It further includes step six, a visualization step, for displaying the results of the user's query and presenting the retrieval results.
3. The online communication processing method based on the unstructured text retrieval model according to claim 1, characterized in that: The open source toolkit uses the HanLP library, which provides a variety of Chinese text processing functions, including word segmentation, part-of-speech tagging, named entity recognition, dependency syntax analysis, keyword extraction, text classification, sentiment analysis, and question-answering systems.
4. An online communication processing system based on an unstructured text retrieval model, used to implement the method according to any one of claims 1 to 3, characterized in that: The system comprises: Input module; Constructing a knowledge graph and a storage module, the knowledge graph and storage module further includes: The document library constructs a submodule, uses the SMS content dataset as the document library, stores all texts in the project root directory, and renames the text files to different IDs; The endogenous knowledge graph construction submodule uses an open source toolkit to call the SpERT model to generate triples to construct the endogenous knowledge graph; each text is preprocessed using the HanLP library, including data cleaning, noise removal, and encoding into UTF-8 format; entity relationships are extracted and merged for each preprocessed text using the SpERT model to generate triples; the triples are stored in the knowledge graph, and new additions are performed on triples that do not exist at all, and merge operations are performed on triples that exist partially or completely, and nodes and relationships save text IDs; The exogenous knowledge graph and the training initial model construction submodule use OpenKG to obtain a partial knowledge graph of the text as the exogenous knowledge graph through a RESTful API, and use entities to save text IDs; Call and regularly update the text retrieval model module; Execute database operations to implement the data management module. When adding text, the newly added text is saved in the text library, and keywords are extracted after preprocessing and saved in a new file; use the knowledge graph construction method to complete the endogenous knowledge graph; access OpenKG through the RESTful API according to the relationship entities involved in the new text, and obtain the triples to complete the exogenous knowledge graph; When deleting text, the endogenous knowledge graph and the exogenous knowledge graph delete related nodes and relationships according to the ID of the text, and update the newly created file at the same time; Perform model iteration by setting a scheduled task to execute the train.py script for retraining the retrieval model every two weeks. The generated new model ir.model will overwrite the old model. A search module, the search module further comprising: User input submodule, The parameter verification submodule is used to verify whether the user's input is legal. In the query keyword extraction submodule, the keywords entered by the user are passed to the keyword input box on the front-end page and then to the back-end service. Document similarity calculation submodule,In text retrieval, the similarity between the query statement entered by the user and the text in the document library can be converted into a many-to-many correlation match between multiple query keywords and multiple text keywords.,Using cosine similarity, the text data of the two articles are first vectorized and converted into vectors respectively.,Then, by calculating the cosine value of the two vectors, the similarity between them is determined using the following formula (1), (1) In formula (1), , represents two entity vectors, Representation vector , The modulus length is used to generate a corresponding semantic vector for each entity, and then the cosine similarity is used to calculate the semantic distance between all entities. To ensure the consistency and accuracy of the knowledge graph, the entity similarity threshold is set to 0.9; The search result sorting submodule obtains the keywords of each text from the newly created file, inputs them into the text search model together with the query keywords, and outputs the search results sorted in reverse order of relevance.
5. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the online communication processing method based on the unstructured text retrieval model described in any one of claims 1 to 3 are implemented.
6. A computer device, characterized in that: include: Memory for storing computer programs; A processor is used to execute the computer program to implement the steps of the online communication processing method based on the unstructured text retrieval model as described in any one of claims 1 to 3.
Citation Information
Patent Citations
Intelligent dialogue method and device based on large language model, medium and equipment
CN117076650A
Text retrieval method and device, electronic equipment and storage medium
CN118312587A