CN117473034A - Interactive text processing method and device, electronic equipment and storage medium - Google Patents

Interactive text processing method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN117473034A
CN117473034A CN202311163655.6A CN202311163655A CN117473034A CN 117473034 A CN117473034 A CN 117473034A CN 202311163655 A CN202311163655 A CN 202311163655A CN 117473034 A CN117473034 A CN 117473034A
Authority
CN
China
Prior art keywords
vector
text
segment
fragment
paragraph
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311163655.6A
Other languages
Chinese (zh)
Inventor
刘刚
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN202311163655.6A priority Critical patent/CN117473034A/en
Publication of CN117473034A publication Critical patent/CN117473034A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/31Indexing; Data structures therefor; Storage structures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying
    • G06F16/332Query formulation
    • G06F16/3329Natural language query formulation or dialogue systems
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying
    • G06F16/3331Query processing
    • G06F16/334Query execution
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Computational Linguistics (AREA)
  • Mathematical Physics (AREA)
  • Software Systems (AREA)
  • Artificial Intelligence (AREA)
  • Human Computer Interaction (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application provides an interactive text processing method, an interactive text processing device, electronic equipment and a storage medium, which are applied to various scenes such as cloud technology, artificial intelligence, intelligent traffic, auxiliary driving and the like, wherein the method comprises the following steps: acquiring an interactive text; analyzing the interactive text to obtain at least one of chapter fragments, paragraph fragments and sentence fragments; establishing at least one of chapter fragment index information, paragraph fragment index information and sentence fragment index information; acquiring target index information, of which the similarity of the query text corresponding to the interactive text meets a preset condition, from the index information; acquiring a corresponding target text segment from the text segment; generating context information according to the target text segment; and inputting the context information and the query text into the large language model to obtain a query result of the query text. According to the scheme, the deep understanding and analysis of the interactive text can be completed together with the large language model, so that the user can answer the question of the interactive text.

Description

Interactive text processing method and device, electronic equipment and storage medium
Technical Field
The application belongs to the technical field of computers, and particularly relates to an interactive text processing method, an interactive text processing device, electronic equipment and a storage medium.
Background
Social networks refer to internet applications that provide communication and interaction services for users aggregated online in various forms with certain social relationships or common interests as ties. With the rapid development of the internet, social networks have emerged into massive users, and with the increase of users joining the social networks, the content of files uploaded by users in the social networks has also increased. In addition, a large amount of file content uploaded by the user is also saved in the network-based online storage service (e.g., a network disk, etc.).
In the related art, the retrieval and processing of the text content in the social network or the online storage service are generally realized based on the name of the file content, the classification result of classifying the file content when the user uploads the file content, or the description information obtained by describing the file content when the user uploads the file content, etc., however, the related art cannot deeply understand and process the file content in the social network or the online storage service, for example, cannot answer various questions based on the file content, and the processing efficiency of the text content in the social network or the online storage service is reduced, so that the interactive response efficiency and the interactive response precision of the user and the text content in the social network or the online storage service are reduced.
Disclosure of Invention
In order to solve the technical problems, the application provides an interactive text processing method, an interactive text processing device, electronic equipment and a storage medium.
In one aspect, the present application proposes an interactive text processing method, where the method includes:
acquiring an interactive text;
carrying out structural analysis processing on the interactive text to obtain a text fragment; the text segment comprises at least one of a chapter segment, a paragraph segment and a sentence segment;
establishing index information corresponding to the text fragments; the index information is used for representing the position information of the text segment in the interactive text, and comprises at least one of chapter segment index information corresponding to the chapter segment, paragraph segment index information corresponding to the paragraph segment and sentence segment index information corresponding to the sentence segment;
obtaining target index information, of which the similarity of the query text corresponding to the interactive text meets a preset condition, from at least one of the chapter fragment index information, the paragraph fragment index information and the sentence fragment index information;
acquiring a target text segment corresponding to the target index information from the text segment;
Generating context information of the query text according to the target text segment;
inputting the context information and the query text to a large language model for query result prediction processing to obtain a query result of the query text; the large-scale language model is obtained by performing instruction fine adjustment on an initial large-scale language model based on preset context information of a preset field, preset query text aiming at the preset context information and a preset query result corresponding to the preset query text.
In another aspect, the present application proposes an interactive text processing apparatus, the apparatus comprising:
the text acquisition module is used for acquiring the interactive text;
the analysis module is used for carrying out structural analysis processing on the interactive text to obtain a text fragment; the text segment comprises at least one of a chapter segment, a paragraph segment and a sentence segment;
the index establishing module is used for establishing index information corresponding to the text fragments; the index information is used for representing the position information of the text segment in the interactive text, and comprises at least one of chapter segment index information corresponding to the chapter segment, paragraph segment index information corresponding to the paragraph segment and sentence segment index information corresponding to the sentence segment;
The index acquisition module is used for acquiring target index information, of which the similarity of the query text corresponding to the interactive text meets a preset condition, from at least one of the chapter fragment index information, the paragraph fragment index information and the sentence fragment index information;
a target text segment obtaining module, configured to obtain a target text segment corresponding to the target index information from the text segment;
the context generation module is used for generating context information of the query text according to the target text segment;
the query result generation module is used for inputting the context information and the query text into a large language model to perform query result prediction processing so as to obtain a query result of the query text; the large-scale language model is obtained by performing instruction fine adjustment on an initial large-scale language model based on preset context information of a preset field, preset query text aiming at the preset context information and a preset query result corresponding to the preset query text.
In another aspect, the application proposes an electronic device for interactive text processing, the electronic device comprising a processor and a memory, the memory storing at least one instruction or at least one program, the at least one instruction or at least one program being loaded and executed by the processor to implement an interactive text processing method as described above.
In another aspect, the present application proposes a computer readable storage medium having stored therein at least one instruction or at least one program, the at least one instruction or the at least one program being loaded and executed by a processor to implement an interactive text processing method as described above.
In another aspect, the present application proposes a computer program product comprising a computer program which, when executed by a processor, implements an interactive text processing method as described above.
The embodiment of the application provides an interactive text processing method, an interactive text processing device, electronic equipment and a storage medium, wherein the method comprises the following steps: acquiring an interactive text and a query text aiming at the interactive text; carrying out structural analysis processing on the interactive text to obtain a text fragment; the text segment comprises at least one of a chapter segment, a paragraph segment and a sentence segment; establishing index information corresponding to the text fragments; the index information comprises at least one of chapter fragment index information corresponding to the chapter fragments, paragraph fragment index information corresponding to the paragraph fragments and sentence fragment index information corresponding to the sentence fragments; obtaining target index information of which the similarity of query texts corresponding to the interactive texts meets preset conditions from at least one of chapter fragment index information, paragraph fragment index information and sentence fragment index information; acquiring a target text segment corresponding to the target index information from the text segment; generating context information of the query text according to the target text segment; and inputting the context information and the query text into the large language model to perform query result prediction processing, so as to obtain a query result of the query text. The method and the device can complete the deep understanding of the interactive text through at least one dimension of the chapter fragments, the paragraph fragments and the sentence fragments and complete the deep understanding of the interactive document together with a large language model, so that more accurate, comprehensive and readable interactive document theme summary and information extraction are generated based on user question and answer, the question of the user on the document is answered pertinently, the efficiency of processing the interactive text, the interactive response efficiency and the interactive response precision between the user and the interactive text are improved, and the processing cost of the interactive text is reduced.
Drawings
In order to more clearly illustrate the technical solutions and advantages of embodiments of the present application or of the prior art, the following description will briefly introduce the drawings that are required to be used in the embodiments or the prior art descriptions, it is obvious that the drawings in the following description are only some embodiments of the present application, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a schematic diagram illustrating an implementation environment of an interactive text processing method, according to an exemplary embodiment.
Fig. 2 is a flow diagram illustrating a method of interactive text processing according to an exemplary embodiment.
Fig. 3 is a flow chart diagram II of an interactive text processing method according to an exemplary embodiment.
FIG. 4 is a flowchart illustrating a method of training a chapter semantic similarity model according to an exemplary embodiment.
FIG. 5 is a flowchart illustrating a training method for a sentence semantic similarity model, according to one exemplary embodiment.
FIG. 6 is a flow chart diagram II illustrating a training method for a sentence semantic similarity model, according to an example embodiment.
Fig. 7 is a flow chart diagram III illustrating a method of interactive text processing according to an exemplary embodiment.
FIG. 8 is a system diagram illustrating an interactive text processing according to an exemplary embodiment.
Fig. 9 is a block diagram illustrating an interactive text processing device according to an exemplary embodiment.
Fig. 10 is a block diagram of a hardware structure of a server according to an exemplary embodiment.
Fig. 11 is a block diagram of a hardware structure of a server according to an exemplary embodiment.
Detailed Description
Artificial intelligence (Artificial Intelligence, AI) is the theory, method, technique and application system that uses a digital computer or a machine controlled by a digital computer to simulate, extend and extend human intelligence, sense the environment, acquire knowledge and use the knowledge to obtain optimal results. In other words, artificial intelligence is an integrated technology of computer science that attempts to understand the essence of intelligence and to produce a new intelligent machine that can react in a similar way to human intelligence. Artificial intelligence, i.e. research on design principles and implementation methods of various intelligent machines, enables the machines to have functions of sensing, reasoning and decision. The artificial intelligence software technology mainly comprises a computer vision technology, a voice processing technology, a natural language processing technology, machine learning/deep learning and other directions.
Natural language processing (Nature Language processing, NLP) is an important direction in the fields of computer science and artificial intelligence. It is studying various theories and methods that enable effective communication between a person and a computer in natural language. Natural language processing is a science that integrates linguistics, computer science, and mathematics. Thus, the research in this field will involve natural language, i.e. language that people use daily, so it has a close relationship with the research in linguistics. Natural language processing techniques typically include text processing, semantic understanding, machine translation, robotic questions and answers, knowledge graph techniques, and the like.
Specifically, the process of obtaining the query text in the present application involves a robot question and answer in the NLP.
Machine Learning (ML) is a multi-domain interdisciplinary, involving multiple disciplines such as probability theory, statistics, approximation theory, convex analysis, algorithm complexity theory, etc. It is specially studied how a computer simulates or implements learning behavior of a human to acquire new knowledge or skills, and reorganizes existing knowledge structures to continuously improve own performance. Machine learning is the core of artificial intelligence, a fundamental approach to letting computers have intelligence, which is applied throughout various areas of artificial intelligence. Machine learning and deep learning typically include techniques such as artificial neural networks, confidence networks, reinforcement learning, transfer learning, induction learning, teaching learning, and the like.
Specifically, the training process of chapter semantic similarity model, paragraph semantic similarity model and sentence semantic similarity model in the embodiment of the present application relates to deep learning technology in machine learning.
First, technical terms related to embodiments of the present application will be described:
faiss: the method is an open-source search library for clustering and similarity, provides efficient similarity search and clustering for dense vectors, supports the search of billions of vectors, and is the most mature approximate neighbor search library at present.
Elastic search: is a distributed, highly extended, high real-time search and data analysis engine. The method can conveniently enable a large amount of data to have the capabilities of searching, analyzing and exploring. The horizontal scalability of the elastomer search is fully utilized, enabling the data to become more valuable in a production environment.
The large language model (Large Language Model, LLM) refers to a computer model capable of processing and generating natural language; it represents a significant advancement in the field of artificial intelligence and is expected to change this field through learned knowledge. LLM can predict the next word or sentence through learning the statistical rule and semantic information of language data, and with the continuous expansion of input data set and parameter space, LLM's ability also can improve correspondingly. LLM is used in a variety of application fields such as robotics, machine learning, machine translation, speech recognition, image processing, etc., and so is called a multi-Modal Large Language Model (MLLM).
Instruction Tuning: instruction trimming is to generate an instruction (instruction) independently for each task by a pointer, perform trimming on a plurality of full-shot tasks, and then evaluate generalization capability (zero shot) on specific tasks. full-shot refers to fine tuning of all parameters in the pre-trained model.
Prompt tune: prompting learning, and a class of learning methods in machine learning: under the condition of not significantly changing the structure and parameters of the pre-training language model, the effect of the model is greatly improved by adding 'prompt information' to the input as an information enhancement, which can be an instruction to a task and also be multiplexing of a pre-training target, wherein the essence of the method is the enhancement of the parameter effectiveness training, and the prompt template (prompt template) is independently generated, and then the full-shot fine adjustment and evaluation are carried out on each task.
The following description of the embodiments of the present application will be made clearly and fully with reference to the accompanying drawings, in which it is evident that the embodiments described are only some, but not all, of the embodiments of the present application. All other embodiments, which can be made by one of ordinary skill in the art without undue burden from the present disclosure, are within the scope of the present application based on the embodiments herein.
It should be noted that the terms "first," "second," and the like in the description and the claims of the embodiments of the present application and the above figures are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged where appropriate such that embodiments of the present application described herein may be implemented in sequences other than those illustrated or otherwise described herein. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or server that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed or inherent to such process, method, article, or apparatus, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
FIG. 1 is a schematic diagram illustrating an implementation environment of an interactive text processing method, according to an exemplary embodiment. As shown in fig. 1, the implementation environment may at least include a terminal 01 and a server 02, where the terminal 01 and the server 02 may be directly or indirectly connected through a wired or wireless communication manner, and the embodiment of the present application is not limited herein.
Specifically, the server 02 may be configured to obtain an interaction text and a query text, and obtain a query result corresponding to the query text from the interaction text. Optionally, the server 02 may be an independent physical server, or may be a server cluster or a distributed system formed by a plurality of physical servers, or may be a cloud server that provides cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (Content Delivery Network, CDN), and basic cloud computing services such as big data and artificial intelligence platforms.
Specifically, the terminal 01 may be used to display the query result. The terminal 01 may include, but is not limited to, a mobile phone, a computer, an intelligent voice interaction device, an intelligent home appliance, a vehicle-mounted terminal, an aircraft, etc.
The embodiment of the invention can be applied to various scenes, including but not limited to cloud technology, artificial intelligence, intelligent transportation, auxiliary driving and the like.
It should be noted that fig. 1 is only an example. In other scenarios, other implementation environments may also be included.
It should be noted that, in the specific embodiments of the present application, related data such as interactive text, query text, etc. related data is related to user information, and when the embodiments of the present application are applied to specific products or technologies, permission or consent of the user needs to be obtained, and collection, use and processing of the related data need to comply with related laws and regulations and standards.
Fig. 2 is a flow diagram illustrating a method of interactive text processing according to an exemplary embodiment. The method may be used in the implementation environment of fig. 1. The present specification provides method operational steps as described above, for example, in the examples or flowcharts, but may include more or fewer operational steps based on conventional or non-inventive labor. The order of steps recited in the embodiments is merely one way of performing the order of steps and does not represent a unique order of execution. When implemented in a real system or server product, the methods illustrated in the embodiments or figures may be performed sequentially or in parallel (e.g., in a parallel processor or multithreaded environment). As shown in fig. 2, the method may include:
s101, acquiring an interactive text.
Alternatively, the interactive text may be various fields, various types of interactive text, and is not particularly limited.
As one example, the interaction text may be a text file uploaded by a user in a social network. In order to facilitate the convenient and fast communication of users, a plurality of users join the instant messaging group, the types and the discussion contents of the instant messaging group are very wide, and as the types of the users joining the instant messaging group are increased and the users participating in communication in the instant messaging group are increased, the content of the files uploaded by the users accumulated in the instant messaging group is also increased, so that a great amount of digital resources such as PDF, word, txt, web and other files are reserved in the instant messaging group, and very rich data such as various electronic books and the like are also included. In addition to text files accumulated in the instant messaging group, the interaction file may also be a link to a text file or a file web page transmitted during the point-to-point chat process.
As another example, the interactive text may also be a text file saved in an online storage service (e.g., a web disk, etc.). For example, a file in a format of PDF, word, web, txt, or the like, or various electronic books, or the like.
S103, carrying out structural analysis processing on the interactive text to obtain a text fragment; the text segment includes at least one of a chapter segment, a paragraph segment, and a sentence segment.
In this embodiment, the interactive text may be a tree structure in nature, and since some text chapters of the interactive text may be long, the interactive text cannot be directly input into the model. Based on the above, the server may perform structural analysis on the interactive text to segment the interactive text into small text segments, so as to obtain at least one of chapter segments, paragraph segments and sentence segments, i.e. which are chapters, which are paragraphs and which are sentences in the interactive text. At least one of the chapter section, the paragraph section, and the sentence section may form a hierarchical tree structure.
It should be noted that, the text segment includes what granularity segments are determined according to the type of the interactive text, and if the interactive text is an electronic book, and there is a chapter in the interactive text, the chapter segment, the paragraph segment and the sentence segment can be obtained by parsing the interactive text. If the interactive text is an article that does not typically include chapters, it may be parsed to obtain paragraph fragments and sentence fragments. If the interactive text is a paragraph, it can be parsed to obtain sentence fragments.
Therefore, the embodiment of the application can analyze the interactive text with at most three granularities, namely sentence level granularity, paragraph level granularity and chapter level granularity, so that text fragments with different granularities can be recalled according to the three levels of granularities, and further deep understanding and processing of the interactive text are realized.
S105, establishing index information corresponding to the text fragments; the index information is used for representing the position information of the text fragment in the interactive text, and comprises at least one of chapter fragment index information corresponding to the chapter fragment, paragraph fragment index information corresponding to the paragraph fragment and sentence fragment index information corresponding to the sentence fragment.
In this embodiment of the present invention, the server may establish, for each text segment, corresponding index information indicating position information of the text segment in the interactive text, that is, the index information is a position guide of the text segment in the interactive text, and by using the index information, the corresponding text segment may be quickly located and accessed, so that the relevant text segment may be recalled according to the query text input by the user.
Because the index information comprises at least one of chapter fragment index information corresponding to chapter fragments, paragraph fragment index information corresponding to paragraph fragments and sentence fragment index information corresponding to sentence fragments, recall of at least one of sentence level granularity, fragment level granularity and chapter level granularity can be realized, deep understanding and processing of the interactive text can be realized, and therefore, the positioning accuracy of the query result corresponding to the query text can be improved.
S107, obtaining target index information, of which the similarity of query texts corresponding to the interactive texts meets preset conditions, from at least one of chapter fragment index information, paragraph fragment index information and sentence fragment index information.
Optionally, the query text is a question posed for the text content of the interactive text.
In the embodiment of the present application, the target index information, for which the similarity with the query text satisfies the preset condition, may be searched for by searching for vector semantic similarity, such as Faiss or elastic search, from at least one of the chapter fragment index information, the paragraph fragment index information, and the sentence fragment index information.
For example, the similarity satisfying the preset condition may refer to a condition that the similarity is greater than a preset similarity threshold. Furthermore, the similarity meeting the preset condition can be represented by a distance, namely, the index information with the distance from the query text being smaller than a preset distance threshold value is taken as target index information.
S109, acquiring a target text segment corresponding to the target index information from the text segment.
In this embodiment of the present application, through vector semantic similarity search, for example, the search is that the target index information and the similarity with the query text are returned by the Faiss or the elastic search, and further, the target index information and the distance between the target index information and the query text are returned, and the server may obtain, through the target index information, the original data corresponding to the target index information from the text segments already obtained through division, so as to obtain the target text segments.
S1011, generating the context information of the query text according to the target text segment.
S1013, inputting context information and query text to a large language model to perform query result prediction processing to obtain a query result of the query text; the large-scale language model is obtained by performing instruction fine adjustment on the initial large-scale language model based on preset context information of a preset field, preset query text aiming at the preset context information and preset query results corresponding to the preset query text.
In the embodiment of the application, the server can process the retrieved target text segment as required and serve as the context information of the query text. Illustratively, the processing of the retrieved target text segment on demand may include, but is not limited to: at least one of copying, editing, summarizing, ordering, screening, translating, compressing, filtering, and recoding. The server takes the context information and the query text as the input of the large language model, and finally, fine adjustment of partial large language model and few parameters is realized, effective multiplexing of large model capacity is realized, and finally, a query result is generated through the large language model.
Therefore, the interactive text can be deeply understood, analyzed and recalled through three granularities of chapters, paragraphs and sentences, and the deep understanding of the interactive document is completed together with a large language model, so that more accurate, comprehensive and readable interactive document theme summary and information extraction are generated based on user question and answer, the question of the user on the document is pertinently answered, the efficiency of interactive text processing, the interactive response efficiency and the interactive response precision between the user and the interactive text are improved, and the processing cost of the interactive text is reduced.
It should be noted that, in the step S103, the above may be implemented in various manners, which is not particularly limited. In one embodiment, the server may parse the interactive text by a plug-in capability disclosed by a third party, such as a docparameter module, according to a format of the interactive text, to identify chapters, paragraphs, sentences, and the like in the text document. The docparameter refers to an end-to-end document structure analysis scheme, which can perform structure extraction on documents (scanning edition, picture edition and the like), and comprises entity identification (entity refers to all elements needing to be detected, including text, rows, columns, cells and the like) and relationship classification. In another embodiment, without a third party plug-in, the server may employ optical character recognition (Optical Character Recognition, OCR) techniques to identify documents, identify chapters, paragraphs, sentences, etc. of content. Specifically, the method can train an OCR model by using the organization segmentation information of chapters, paragraphs and sentences, such as paragraph title word sizes, blank and sentence end mark samples, so that the OCR model can determine the general result of each region, and the trained OCR model can be used for identifying interactive texts and at least one of the chapters, the paragraphs and the sentences of the content.
In an alternative embodiment, after the step S103, the method may further include:
vectorizing the text fragments to obtain text fragment vectors corresponding to the text fragments; the text segment vector comprises at least one of a chapter segment vector corresponding to a chapter segment, a paragraph segment vector corresponding to a paragraph segment and a sentence segment vector corresponding to a sentence segment.
In this embodiment, after the server divides the interactive text into at least one of a chapter segment, a paragraph segment, and a sentence segment, the server may vectorize at least one of the chapter segment, the paragraph segment, and the sentence segment to obtain at least one of a chapter segment vector corresponding to the chapter segment, a paragraph segment vector corresponding to the paragraph segment, and a sentence segment vector corresponding to the sentence segment.
Accordingly, in the step S105, the establishing the index information corresponding to the text segment includes: and establishing index information corresponding to at least one of the chapter fragment vector, the paragraph fragment vector and the sentence fragment vector to obtain the index information corresponding to the text fragment.
In this embodiment, when the text segment vector corresponding to the text segment includes a chapter segment vector, a paragraph segment vector, and a sentence segment vector, index information corresponding to each of the chapter segment vector, the paragraph segment vector, and the sentence segment vector may be established, so as to obtain chapter segment index information corresponding to the chapter segment, paragraph segment index information corresponding to the paragraph segment, and sentence segment index information corresponding to the sentence segment. When the text segment vector corresponding to the text segment includes a paragraph segment vector and a sentence segment vector, index information corresponding to each of the paragraph segment vector and the sentence segment vector may be established to obtain paragraph segment index information corresponding to the paragraph segment and sentence segment index information corresponding to the sentence segment. When the text segment vector corresponding to the text segment includes a sentence segment vector, index information corresponding to the sentence segment vector may be established, so as to obtain sentence segment index information corresponding to the sentence segment.
The method of creating the index information of the vector may be various, and is not particularly limited herein. In some embodiments, the vector may be an embedded vector (ebedding vector), and the server may store the ebedding vector in a Faiss distributed index library to obtain the corresponding index information. In addition, the parsed interactive text and various corresponding index information can be stored in the object storage (Cloud Object Storage, COS), the COS has the advantages of no format limitation, no storage capacity on line, high stability and the like, and the processing efficiency of the interactive text can be improved by storing the parsed interactive text and various corresponding index information in the COS. In other embodiments, the text segment vector may also be stored in a node object that will form a graph (index) with other nodes. The graph index may be a simple list structure, tree structure, or key table. Furthermore, one index may be combined from different indexes.
It should be noted that, a display index and a structure index of the text file may also be established, and the display index may be understood as an index of different levels of a complex book or book collection. The structure index is for structuring a book, such as which chapters a book has, which chapters are specific to which page, and so on, and is refined layer by layer. Both the display index and the structural index may be used to locate where the query results are located.
Fig. 3 is a second flowchart of an interactive text processing method according to an exemplary embodiment, as shown in fig. 3, in the step S107, obtaining target index information that satisfies a preset condition from similarity of query text corresponding to an interactive text from at least one of chapter segment index information, paragraph segment index information, and sentence segment index information may include:
s1071, retrieving a target vector with similarity with a semantic vector of the query text meeting a preset condition from at least one of a chapter fragment vector, a paragraph fragment vector and a sentence fragment vector.
S1073, determining target index information corresponding to the target vector from at least one of chapter fragment index information, paragraph fragment index information and sentence fragment index information.
In this embodiment, the server may find topk vectors closest to the semantic vector of the query text from at least one of the chapter fragment vector, the paragraph fragment vector, and the sentence fragment vector, to obtain the target vector. For example, in the Faiss distributed vector search, a Faiss framework can be utilized to realize a distributed high-dimensional neighbor search platform, and a K-nearest neighbor algorithm (such as HNSW algorithm) adopting large-scale vector search can efficiently recall, in millions of vectors, topk vectors with a distance between the semantic vector (with a cutoff threshold and a similarity score considered at the same time) being smaller than a preset distance threshold, namely topk vectors similar to the semantic vector, with an efficiency of tens of milliseconds, thereby realizing the accurate positioning and search of query text.
Because the index is established for each vector in advance, after the target vector is obtained, the server can search the index information of the text segment corresponding to the target vector from at least one of the chapter segment index information, the paragraph segment index information and the sentence segment index information to obtain the target index information. The target index information is obtained from at least one of chapter fragment index information, paragraph fragment index information and sentence fragment index information, so that recall with different granularity can be realized, the understanding depth for understanding the interactive file is improved, the generation precision of a query result is improved, and the interactive response precision between a user and an interactive text is further improved; in addition, through vectorizing text fragments, establishing vector indexes and searching vector semantic similarity, topk vectors with the distance between tens of milliseconds and semantic vectors smaller than a preset distance threshold can be efficiently recalled in tens of milliseconds, so that accurate and rapid positioning and searching of query results are realized.
In an alternative embodiment, continuing to fig. 3, in a case where the text segment includes a chapter segment, a paragraph segment, and a sentence segment, and the text segment vector includes one of a chapter segment vector, a paragraph segment vector, and a sentence segment vector, in the step S1071, retrieving the target vector having a similarity with the semantic vector of the query text satisfying the preset condition from at least one of the chapter segment vector, the paragraph segment vector, and the sentence segment vector may include:
S10711, obtaining a target chapter fragment vector with similarity meeting a first preset condition with the semantic vector from the chapter fragment vector.
S10713, obtaining the target paragraph fragment vector with the similarity meeting the second preset condition from the paragraph fragment vector corresponding to the target chapter fragment vector.
S10715, obtaining target sentence fragment vectors with similarity meeting a third preset condition with the semantic vectors from sentence fragment vectors corresponding to the target paragraph fragment vectors. And determining the target sentence fragment vector as a target vector.
In this embodiment, when the text segment includes a chapter segment, a paragraph segment, and a sentence segment, and the text segment vector includes a chapter segment vector, a paragraph segment vector, and a sentence segment vector, the server may first obtain a target chapter segment vector having a similarity with the semantic vector that satisfies a first preset condition from the chapter segment vector. For example, topk target chapter fragment vectors whose similarity with the semantic vector satisfies the first preset condition may be obtained from the chapter fragment vectors using a Faiss frame or an elastic search.
After determining that the target chapter fragment vector is obtained, the server may obtain, from the paragraph fragment vector corresponding to the target chapter fragment vector, a target paragraph fragment vector whose similarity with the semantic vector satisfies a second preset condition. The paragraph fragments corresponding to the interactive text may be multiple and may be derived from different chapters, and the paragraph fragment vector corresponding to the target chapter fragment vector may refer to: paragraph segment vectors of paragraph segments included in the chapter segments corresponding to the target chapter segment vector. For example, topk target paragraph segment vectors with similarity between semantic vectors satisfying the second preset condition may be obtained from paragraph segment vectors corresponding to the target chapter segment vectors by using a Faiss frame or an elastic search.
After determining that the target paragraph segment vector is obtained, the server may obtain, from sentence segment vectors corresponding to the target paragraph segment vector, a target sentence segment vector whose similarity with the semantic vector satisfies a third preset condition. The server takes the target sentence fragment vector as a target vector meeting preset conditions. The sentence fragments corresponding to the interactive text may be derived from different paragraphs and chapters, and the sentence fragment vector corresponding to the target paragraph fragment vector may refer to: sentence fragment vectors of sentence fragments included in the paragraph fragments corresponding to the target paragraph fragment vector. For example, topk target sentence fragment vectors with similarity with the semantic vector satisfying the third preset condition may be obtained from sentence fragment vectors corresponding to the target paragraph fragment vectors by using a Faiss framework or an elastic search.
The first preset condition, the second preset condition, and the third preset condition may be the same or different from each other. For example, the similarity satisfies the first preset condition, the second preset condition, and the third preset condition may be conditions that the similarity is smaller than a certain similarity threshold. Still further, the third preset condition may be a condition that a distance between the third preset condition and the semantic vector is smaller than a certain distance threshold.
According to the embodiment of the invention, the optimal sentence can be recalled through at least one of the three granularities of the chapter, the paragraph and the sentence by the target vector with the similarity of the semantic vector of the query text meeting the preset condition, so that the depth understanding and the analysis of the interactive text are realized, and the accurate matching and positioning of the query result are realized.
In other embodiments, the target chapter segment vector whose similarity satisfies the first preset condition, the target paragraph segment vector whose similarity satisfies the second preset condition, and the target sentence segment vector whose similarity satisfies the third preset condition may also be used as target vectors whose similarity satisfies the preset conditions.
In other embodiments, the retrieval of the target vector having the similarity with the semantic vector of the query text satisfying the preset condition from at least one of the chapter fragment vector, the paragraph fragment vector, and the sentence fragment vector in the step S1071 may further include:
the method comprises the steps of obtaining a target chapter fragment vector with similarity meeting a first preset condition from the chapter fragment vector, obtaining a target chapter fragment vector with similarity meeting a second preset condition from the paragraph fragment vector, and obtaining a target chapter fragment vector with similarity meeting a third preset condition from the sentence fragment vector. And determining the target chapter fragment vector, the target chapter fragment vector and the target chapter fragment vector as target vectors meeting preset conditions.
In this embodiment, topk target chapter fragment vectors with similarity to the semantic vector satisfying a first preset condition can be obtained from the chapter fragment vectors through the chapter granularity, topk target chapter fragment vectors with similarity to the semantic vector satisfying a second preset condition can be obtained from the paragraph fragment vectors through the paragraph granularity, and topk target chapter fragment vectors with similarity to the semantic vector satisfying a third preset condition can be obtained from the sentence fragment vectors through the sentence granularity. And fusing the topk target chapter fragment vectors, the topk target chapter fragment vectors and the topk target chapter fragment vectors recalled at the granularity to obtain the target vector with the similarity meeting the preset condition.
In an optional embodiment, in the step S10711, the obtaining, from the chapter fragment vectors, the target chapter fragment vector having a similarity with the semantic vector that satisfies the first preset condition may include:
inputting a chapter fragment vector and a semantic vector to a chapter semantic similarity model for similarity matching processing so as to acquire a target chapter fragment vector, the similarity of which with the semantic vector meets a first preset condition, from the chapter fragment vector;
The chapter semantic similarity model is obtained by training a first pre-training model based on anchored sample chapter data corresponding to a first sample query text, positive sample chapter fragments and negative sample chapter fragments in a sample chapter fragment set, the title content of the positive sample chapter fragment is matched with the content of the anchored sample chapter data, and the title content of the negative sample chapter fragment is not matched with the content of the anchored sample chapter data.
In this embodiment, the first pre-training model may be trained by the anchor sample chapter data corresponding to the first sample query text, the positive sample chapter segment whose content is matched with the anchor sample chapter data, and the negative sample chapter segment whose content is not matched with the anchor sample chapter data, to obtain a chapter semantic similarity model, and the chapter segment vector and the semantic vector are input to the chapter semantic similarity model to perform similarity matching processing, so as to obtain a topk target chapter segment vector. Because the chapter semantic similarity model is obtained by training a first pre-training model based on the anchored sample chapter data, the positive sample chapter fragments and the negative sample chapter fragments in the sample chapter fragment set, the chapter semantic similarity model obtained by training has the functions of pulling in the distance between the same category data and pulling out the distance between different category data, so that more accurate, comprehensive and readable file chapter topic summary and chapter information extraction can be recalled on the basis of chapter granularity through the pre-training model, the deep understanding of chapters of interactive texts is realized, and the positioning and matching precision of chapters where query results are located is improved.
FIG. 4 is a flow chart of a method of training a chapter semantic similarity model according to an exemplary embodiment, as shown in FIG. 4, in an exemplary embodiment, the method of training a chapter semantic similarity model includes:
s201, acquiring a sample chapter fragment set and a first sample query text.
S203, generating anchor sample chapter data according to the first sample query text.
S205, positive sample chapter fragments and negative sample chapter fragments are determined from the sample chapter fragment set.
S207, inputting the anchor sample chapter data, the positive sample chapter fragment and the negative sample chapter fragment into a first pre-training model for feature extraction, and obtaining an anchor sample chapter data vector corresponding to the anchor sample chapter data, a positive sample chapter data vector corresponding to the positive sample chapter fragment and a negative sample chapter data vector corresponding to the negative sample chapter fragment.
S209, calculating a first difference between the anchor sample chapter data vector and the negative sample chapter data vector and a second difference between the anchor sample chapter data vector and the positive sample chapter data vector.
And S2011, calculating first loss data according to the first difference and the second difference.
S2013, adjusting network parameters of the first pre-training model according to the first loss data until a preset training ending condition is met, and obtaining a chapter semantic similarity model.
In this embodiment, for the chapter semantic similarity model at the chapter level, the first pre-training model may employ a pre-training language model PTM that shares parameters, for example, a pre-training text model, and more specifically, may use the lishes to model the text. The LICHEES is a Bert model based on the expected training of information flow large-scale text corpus, and can better extract semantic features from the information flow text corpus. The data of the chapter semantic similarity model at the chapter level mainly comprises the titles and multi-level title contents of chapters, and a loss function of the model can adopt triple loss (triple loss), wherein the triple loss is a loss function of deep learning and is mainly used for training samples with small differences.
Specifically, the server may obtain a sample set of chapter fragments and a first sample query text for the sample set of chapter fragments. The server takes the first sample query text as Anchor sample chapter data (Anchor), or preprocesses the first sample query text to obtain Anchor sample chapter data. The server determines a Positive sample chapter section (Positive) in which the title content matches the content of the anchor sample chapter data, and a Negative sample chapter section (Negative) in which the title content does not match the content of the anchor sample chapter data, based on the titles and multi-level title contents of the chapters of the sample chapter section set. In other embodiments, in order to increase the distance between the Anchor and the Negative, the training accuracy of the chapter semantic similarity model and the understanding depth of the chapter semantic similarity model obtained by training on the chapter of the interactive text are improved, and the Negative-sample chapter fragment may be determined by the following method: the negative sample chapter segment may be a difficult negative sample chapter segment or a random negative sample chapter segment, for example, a chapter that is not related to the first sample query text in open field question answer (OpenQA) data may be used as the negative sample chapter segment.
The server inputs triples (Anchor, positive and Negative) to the first pre-training model to perform feature extraction, so as to obtain an anchor sample chapter data vector corresponding to the anchor sample chapter data, a positive sample chapter data vector corresponding to the positive sample chapter segment, and a Negative sample chapter data vector corresponding to the Negative sample chapter segment. Calculating the distance between the anchor sample chapter data vector and the negative sample chapter data vector to obtain a first difference, and obtaining the distance between the anchor sample chapter data vector and the positive sample chapter data vector to obtain a second difference; the first loss data is calculated based on the first difference and the second difference. The core idea of the first loss data calculation is to implement similarity calculation between samples by making the distance between Anchor and Positive smaller than the distance between Anchor and Negative. The optimization goal is to pull the distance between Anchor and Positive and the distance between Anchor and Negative. The calculation formula of the first loss data may be as follows:
L=max(d(a,p)-d(a,n)+margin,0):
where a refers to Anchor, p refers to Positive, n refers to Negative, the distance L may represent the first loss data, d (a, p) refers to the difference between the Anchor sample chapter data vector and the Positive sample chapter data vector, d (a, n) refers to the difference between the Anchor sample chapter data and the Negative sample chapter data vector, and margin refers to the edge parameter, that is, the first distance representing the Anchor sample chapter data vector and the Positive sample chapter data vector, and the second distance representing the Anchor sample chapter data vector and the Negative sample chapter data vector satisfy a preset condition, for example, the preset condition may be the minimum interval between the first distance and the second distance. As can be seen from the above disclosure, the first loss data may be a maximum between (d (a, p) -d (a, n) +margin) and 0.
After obtaining the lost data, the server judges whether the lost data meets a preset training ending condition or whether the number of times of model training meets the preset training ending condition, if any one of the above judgment is yes, model training is ended, and the model obtained through training is used as a chapter semantic similarity model. If the judgment is no, repeating the model training process until the loss data meets the preset training ending condition or the number of times of model training meets the preset training ending condition.
The input of the chapter semantic similarity model training process in the embodiment of the application is a triple of anchoring sample chapter data, positive sample chapter fragments and Negative sample chapter fragments, and loss data is calculated by using a triple loss, and the triple loss can realize similarity calculation between samples by enabling the distance between an Anchor and a Positive to be smaller than the distance between the Anchor and the Negative. Therefore, the triple loss is used for calculating the loss data, the determination accuracy of the loss data can be improved, and further the training accuracy of the chapter semantic similarity model is improved, so that the chapter semantic similarity model obtained through training has the function of recalling target chapter fragment vectors based on chapter granularity, and the function of deeply understanding chapters of interactive texts is achieved.
In an optional embodiment, in the step S10713, the obtaining, from the chapter fragment vectors, the target chapter fragment vector having a similarity with the semantic vector that satisfies the first preset condition may include:
inputting a target chapter fragment vector and a semantic vector into a paragraph semantic similarity model to perform similarity matching processing so as to obtain a target paragraph fragment vector, the similarity of which and the semantic vector meet a second preset condition, from paragraph fragment vectors corresponding to the target chapter fragment vector;
the paragraph semantic similarity model is obtained by training a second pre-training model based on the anchored paragraph data corresponding to the second sample query text, the positive sample paragraph fragments and the negative sample paragraph fragments in the sample paragraph fragment set, wherein the content of the positive sample paragraph fragments is matched with the content of the anchored paragraph data, and the content of the negative sample paragraph fragments is not matched with the content of the anchored paragraph data.
In this embodiment, the second pre-training model may be trained by the anchor sample paragraph data corresponding to the second sample query text, the positive sample paragraph segment whose content matches the anchor sample paragraph data, and the negative sample paragraph segment whose content does not match the anchor sample paragraph data, to obtain a paragraph semantic similarity model, and performing similarity matching processing on the target chapter segment vector and the semantic vector to the chapter semantic similarity model to obtain a topk target paragraph segment vector. Because the paragraph semantic similarity model is obtained by training the second pre-training model based on the anchoring sample paragraph data, the positive sample paragraph fragment, the content and the negative sample paragraph fragment, the paragraph semantic similarity model obtained by training has the functions of pulling in the distance between the same category data and pulling out the distance between different categories data, so that more accurate, more comprehensive and more readable file paragraph summary and paragraph information extraction can be recalled on the basis of paragraph granularity through the pre-trained model, the deep understanding of the paragraphs of the interactive text is realized, and the positioning and matching precision of the paragraphs where query results are located is improved.
In an exemplary embodiment, the training method of the paragraph semantic similarity model includes:
and acquiring a sample paragraph fragment set corresponding to the second sample query text and the sample chapter fragment.
Anchor sample paragraph data is generated from the sample second sample query text.
Positive and negative sample paragraph fragments are determined from the set of sample paragraph fragments.
And inputting the anchoring sample paragraph data, the positive sample paragraph and the negative sample paragraph into a second pre-training model for feature extraction to obtain an anchoring sample paragraph data vector corresponding to the anchoring sample paragraph data, a positive sample paragraph data vector corresponding to the positive sample paragraph and a negative sample paragraph data vector corresponding to the negative sample paragraph.
A third difference between the anchor and negative sample paragraph data vectors and a fourth difference between the anchor and positive sample paragraph data vectors are calculated.
And calculating second loss data according to the third difference and the fourth difference.
And adjusting network parameters of the second pre-training model according to the second loss data until a preset training ending condition is met, and obtaining the paragraph semantic similarity model.
It should be noted that, the chapter semantic similarity model and the paragraph semantic similarity model have similar model structures, but the data samples are different, and the training samples of the paragraph semantic similarity model are sample paragraph fragment sets corresponding to sample chapter fragments, that is, mainly paragraphs. The second pre-training model may also employ a pre-training language model PTM that shares parameters, for example employing a pre-trained text model, more specifically the LICH EES may be used to model the text.
Specifically, the server may obtain a sample paragraph fragment set corresponding to the sample chapter fragment and a second sample query text for the sample paragraph fragment set. The server takes the second sample query text as Anchor sample chapter data (Anchor), or preprocesses the second sample query text to obtain Anchor sample paragraph data. The server determines a Positive sample paragraph segment (Positive) whose paragraph content matches the content of the anchor sample chapter data, and a Negative sample paragraph segment (Negative) whose paragraph content does not match the content of the anchor sample paragraph data, based on the paragraph contents of the sample paragraph segments in the sample paragraph segment set.
The server inputs triples (Anchor, positive and Negative) to the second pre-training model for feature extraction to obtain an anchor sample section data vector corresponding to the anchor sample section data, a positive sample section data vector corresponding to the positive sample section segment, and a Negative sample section data vector corresponding to the Negative sample section segment. Calculating the distance between the anchor sample paragraph data vector and the negative sample paragraph data vector to obtain a third difference, and calculating the distance between the anchor sample paragraph data vector and the positive sample paragraph data vector to obtain a fourth difference; and calculating second loss data according to the third difference and the fourth difference. The calculation formula of the second loss data is the same as the calculation formula of the first loss data, and will not be described herein.
After obtaining the second loss data, the server judges whether the second loss data meets the preset training ending condition or not, or whether the number of times of model training meets the preset training ending condition, if any one of the judgment is yes, model training is ended, and the model obtained through training is used as a paragraph semantic similarity model. If the judgment is no, repeating the model training process until the loss data meets the preset training ending condition or the number of times of model training meets the preset training ending condition.
The input of the paragraph semantic similarity model training process in the embodiment of the application is a Triplet of anchoring sample paragraph data, positive sample paragraph fragments and Negative sample paragraph fragments, and loss data is calculated by using a triple loss, and the triple loss can realize similarity calculation between samples by enabling the distance between an Anchor and a Positive to be smaller than the distance between the Anchor and the Negative. Therefore, the triple loss is used for calculating the loss data, the determination accuracy of the loss data can be improved, and further the training accuracy of the paragraph semantic similarity model is improved, so that the paragraph semantic similarity model obtained through training has the function of recalling the target paragraph fragment vector based on paragraph granularity, and the function of deeply understanding paragraphs of interactive texts is achieved.
In an optional embodiment, in the step S10715, the obtaining, from the sentence fragment vectors corresponding to the target paragraph fragment vectors, the target sentence fragment vectors having the similarity with the semantic vector satisfying the third preset condition may include:
and combining each sentence fragment vector corresponding to the target paragraph fragment vector with the semantic vector to obtain a sentence combination result of each sentence fragment vector corresponding to the target paragraph fragment vector.
Inputting each sentence combination result to a sentence semantic similarity model for similarity matching processing so as to obtain a target sentence fragment vector with similarity meeting a third preset condition from at least two sentence fragment vectors corresponding to the target paragraph fragment vector; the sentence semantic similarity model is obtained by training a third pre-training model based on a sample paragraph segment and a sample query text marked with a sample query result label.
In this embodiment, the server may train the third pre-training model in advance through the sample paragraph fragments and the third sample query text labeled with the sample query result label to obtain the semantic similarity model, so that the semantic similarity model obtained by training has a sentence fragment vector that searches for a sentence fragment vector with similarity between semantic vectors of a certain query sample and satisfies a preset condition from the existing sentence fragment vectors. It should be noted that the third pre-training model may be various types of pre-training language models.
After the target paragraph segment vector is obtained, the server can obtain sentence segment vectors of sentence segments included in the target paragraph segment corresponding to the target paragraph segment vector, the number of the sentence segment vectors can be at least two, and the server can combine each sentence segment vector corresponding to the target paragraph segment vector with the semantic vector to obtain a sentence combination result of each sentence segment vector corresponding to the target paragraph segment vector. Illustratively, the combining may refer to: and splicing the sentence fragment vectors in front of or behind the semantic vectors to obtain sentence combination results of each sentence fragment vector.
The server may input each sentence combination result to the sentence semantic similarity model to perform similarity matching processing, so as to obtain, from at least two sentence fragment vectors corresponding to the target paragraph fragment vector, a target sentence fragment vector whose similarity with the semantic vector satisfies a third preset condition. The third preset condition may be a condition that the similarity is smaller than a certain similarity threshold, and further, the similarity satisfies the third preset condition may be a condition that a distance between the third preset condition and the semantic vector is smaller than a certain distance threshold.
Because the sentence fragment vector with the similarity meeting the third preset condition with the semantic vector is searched from the sentence fragment vector corresponding to the recalled target paragraph fragment vector, the recall precision of the sentence fragment vector can be improved; in addition, the target sentence fragment vector is recalled through the sentence semantic similarity model, the sentence semantic similarity model is obtained by training the third pre-training model based on the sample paragraph fragments and the sample query text marked with the sample query result label, so that the sentence semantic similarity model obtained by training has the function of searching the target fragment sentence vector similar to the semantic vector of the query text from the input sentence vector, the recall precision of the sentence fragment vector can be improved, and the recall efficiency of the sentence fragment vector can also be improved.
FIG. 5 is a flow chart diagram I of a training method for a sentence semantic similarity model according to an exemplary embodiment, as shown in FIG. 5, in an alternative embodiment, the training method for a sentence semantic similarity model includes:
s301, acquiring a sample paragraph fragment and a third sample query text.
S303, dividing the sample paragraph fragments to obtain at least two sample sentence fragments.
S305, combining sample sentence fragment vectors of each sample sentence fragment with sample semantic vectors of sample query texts to obtain sample sentence combination results corresponding to each sample sentence fragment vector.
S307, inputting each sample sentence combination result to a third pre-training model for query prediction processing, and obtaining a prediction matching result of each sample sentence combination result matched with the sample query result label.
S309, adjusting network parameters of the third pre-training model according to the difference between the predicted matching result and the actual matching result until the difference between the predicted matching result and the actual matching result meets a fourth preset condition, and obtaining a sentence semantic similarity model; the actual matching result is the actual similarity matching result between each sample sentence combination result and the sample query result label.
Optionally, in the step S301, the server may obtain a sample paragraph segment and a third sample query text for the sample paragraph segment, where the third sample query text carries a sample query result tag. The sample paragraph segment may be a paragraph segment of various fields, which is not particularly limited.
In the step S303, the server may segment the sample paragraph segments according to a preset manner to obtain at least two sample sentence segments. The preset manner may be punctuation marks, the number of words included in a sentence, the number of lines included in a sentence, and the like. In the case that the predetermined pattern is punctuation, the punctuation may be a period.
In the step S305, the server may combine the sample sentence fragment vector of each sample sentence fragment and the sample semantic vector of the sample query text to obtain a sample sentence combination result corresponding to each sample sentence fragment vector. Illustratively, the combining may refer to: and splicing the sample sentence fragment vectors in front of or behind the sample semantic vectors to obtain sample sentence combination results corresponding to each sample sentence fragment vector.
In the step S307, the server may input each sample sentence combination result to the third pre-training model to perform query prediction processing, so as to obtain a prediction matching result of each sample sentence combination result matched with the sample query result label. The predicted match result may be a "yes" or "no" match result, and may be a predicted match probability, for example.
In the above step S309, since the sample query result tag is known, the actual matching result of the matching between each sample sentence combination result and the sample query result tag may be predetermined according to the known sample query result tag. The actual matching result may be a "yes" or "no" matching result, or may be a predicted matching probability. And the server adjusts network parameters of the third pre-training model according to the difference between the actual matching results of the predicted matching results until the difference between the predicted matching results and the actual matching results meets a fourth preset condition, and a sentence semantic similarity model is obtained. The fourth preset condition may refer to a condition that a difference between the predicted matching result and the actual matching result is smaller than a preset difference threshold value.
FIG. 6 is a second flow chart of a training method for a sentence semantic similarity model according to an exemplary embodiment, where as shown in FIG. 6, sample paragraph fragments may be segmented to obtain three sample sentence fragments (sample sentence fragment 1, sample sentence fragment 2, and sample sentence fragment 3), and sample sentence fragment vectors of the sample sentence fragment 1 and sample semantic vectors of sample query text are combined to obtain a sample sentence combination result 1 corresponding to the sample sentence fragment 1; combining the sample sentence fragment vector of the sample sentence fragment 2 and the sample semantic vector of the sample query text to obtain a sample sentence combination result 2 corresponding to the sample sentence fragment 2; and combining the sample sentence fragment vector of the sample sentence fragment 3 with the sample semantic vector of the sample query text to obtain a sample sentence combination result 3 corresponding to the sample sentence fragment 3. And inputting a sample sentence combination result 1, a sample sentence combination result 2 and sample sentence combination results 3 to a third pre-training model for query prediction processing to obtain a prediction matching probability 1, a prediction matching probability 2 and a prediction matching probability 3, wherein the sample sentence combination result 1, the sample sentence combination result 2 and the sample sentence combination result 3 are respectively matched with a sample query result label.
Since the sample query result tag is known, according to the known sample query result tag, the actual matching probability 1, the actual matching probability 2, and the actual matching probability 3 of the sample sentence combination result 1, the sample sentence combination result 2, and the sample sentence combination result 3, respectively, matching the sample query result tag, may be predetermined.
And the server adjusts network parameters of the third pre-training model according to the difference between the predicted matching probability 1 and the actual matching probability 1, the difference between the predicted matching probability 2 and the actual matching probability 2 and the difference between the predicted matching probability 3 and the actual matching probability 3 until the predicted matching probability 1 is matched with the actual matching probability 1, the predicted matching probability 2 is matched with the actual matching probability 2 and the predicted matching probability 3 is matched with the actual matching probability 3, so that a sentence semantic similarity model is obtained.
Therefore, sentence fragments can be obtained by sentence segmentation of paragraphs, the sentence fragments are used as granularity training sentence semantic similarity models, the training efficiency and the accuracy of the semantic similarity models are improved, the semantic similarity models obtained by training can have the capability of searching sentence fragment vectors with similarity meeting preset conditions from sentence fragment vectors corresponding to recalled target paragraph fragment vectors, and therefore the recall accuracy and recall efficiency of the sentence fragment vectors are improved.
In other embodiments, the training method of the sentence semantic similarity model may further include:
acquiring RACE, QAngaroo, openQA, etc. Wherein RACE is a large-scale reading and understanding dataset derived from a middle school test question. QAngaroo is a reading understanding dataset that gathers multiple pieces of information through multiple inference steps.
Sentence correlation sample datasets are constructed from the reading understanding datasets.
And reversely inquiring the sentence position where the inquiring text is positioned according to the inquiring text and the answer label aiming at reading and understanding data, wherein the style of the training data set is < query, sense >. And adjusting model parameters according to the difference between the query result and the answer label until a preset training ending condition is met, and obtaining the sentence semantic similarity model.
In other embodiments, the obtaining, from the sentence fragment vectors corresponding to the target paragraph fragment vectors, the target sentence fragment vector having a similarity with the semantic vector satisfying the third preset condition may include: and inputting the sentence fragment vector corresponding to the target paragraph fragment vector to a language Encoder (Encoder) for similarity matching to obtain the target sentence fragment vector.
In an alternative embodiment, in the case that the text segment includes a paragraph segment and a sentence segment, and the text segment vector includes one of the paragraph segment vector and the sentence segment vector, in the step S1071, retrieving the target vector having a similarity with the semantic vector of the query text satisfying the preset condition from at least one of the chapter segment vector, the paragraph segment vector, and the sentence segment vector includes:
and obtaining the target paragraph fragment vector with the similarity meeting a fifth preset condition from the paragraph fragment vector.
And obtaining the target sentence fragment vector with the similarity between the target sentence fragment vector and the semantic vector meeting the sixth preset condition from the sentence fragment vectors corresponding to the target paragraph fragment vector meeting the fifth preset condition.
And determining the target sentence fragment vector meeting the sixth preset condition as a target vector.
In this embodiment, if the interactive text does not include chapters, only the paragraph segment and the sentence segment are included in the text segment obtained by the structural analysis, and the corresponding text segment vector only includes the paragraph segment vector and the sentence segment vector, then the server may obtain a target paragraph segment vector with similarity meeting a fifth preset condition from the paragraph segment vector, and obtain a target sentence segment vector with similarity meeting a sixth preset condition from the sentence segment vector corresponding to the target paragraph segment vector meeting the fifth preset condition, and finally determine at least one of the target paragraph segment vector meeting the fifth preset condition and the target sentence segment vector meeting the sixth preset condition as the target vector.
It should be noted that, the "obtaining the target paragraph segment vector with the similarity with the semantic vector satisfying the fifth preset condition from the paragraph segment vector" may include: and inputting the paragraph fragment vector and the semantic vector into a paragraph semantic similarity model to perform similarity matching processing so as to obtain a target paragraph fragment vector with similarity meeting a fifth preset condition from the paragraph fragment vector. The paragraph semantic similarity model is referred to the training process, and is not described herein.
It should be noted that, the "obtaining, from the sentence fragment vectors corresponding to the target paragraph fragment vectors satisfying the fifth preset condition, the target sentence fragment vector having the similarity with the semantic vector satisfying the sixth preset condition" may include: combining the sentence fragment vector corresponding to the target paragraph fragment vector meeting the fifth preset condition with the semantic vector to obtain a sentence combination result of each sentence fragment vector corresponding to the target paragraph fragment vector meeting the fifth preset condition; and inputting each sentence combination result into a sentence semantic similarity model to perform similarity matching processing so as to obtain a target sentence fragment vector with similarity meeting a sixth preset condition from at least two sentence fragment vectors corresponding to the target paragraph fragment vector. The sentence semantic similarity model is referred to the training process, and is not described herein.
After the target paragraph fragment vector satisfying the fifth preset condition and the target sentence fragment vector satisfying the sixth preset condition are obtained, at least one of the target paragraph fragment vector and the target sentence fragment vector may be taken as the target vector. It should be noted that, the fifth preset condition and the sixth preset condition may be conditions that the similarity is smaller than a certain similarity threshold, and further, may be conditions that the distance between the fifth preset condition and the semantic vector is smaller than a certain distance threshold, and the fifth preset condition and the sixth preset condition may be the same or different. Therefore, under the condition that the interactive text does not comprise chapters, the optimal sentence can be recalled through two dimensions of the paragraph and the sentence by the aid of the target vector, wherein the similarity of the semantic vector of the query text and the semantic vector of the paragraph and the sentence meets the preset condition, so that the deep understanding and analysis of the paragraph and the sentence of the interactive text are realized, and the accurate matching and positioning of the query result are realized.
In an alternative embodiment, in the case that the text segment includes a sentence segment and the text segment vector includes a sentence segment vector, in the step S1071, retrieving the target vector having a similarity with the semantic vector of the query text satisfying the preset condition from at least one of the chapter segment vector, the paragraph segment vector, and the sentence segment vector includes:
And obtaining the target paragraph sentence vector with the similarity meeting the seventh preset condition from the sentence fragment vector. And determining the target paragraph sentence vector with the similarity meeting the seventh preset condition as a target vector.
In this embodiment, if the interactive text does not include chapters and paragraphs, the text fragment obtained by structural analysis includes a sentence fragment, and the corresponding text fragment vector includes only a sentence fragment vector, then the server may obtain a target paragraph sentence vector whose similarity with the semantic vector satisfies a seventh preset condition from the sentence fragment vector, and determine the target paragraph sentence vector whose similarity satisfies the seventh preset condition as the target vector.
It should be noted that, the obtaining the target paragraph sentence vector with the similarity between the sentence fragment vector and the semantic vector satisfying the seventh preset condition may include: combining the sentence fragment vector and the semantic vector to obtain a sentence combination result of the sentence fragment vector; and inputting the sentence combination result to a sentence semantic similarity model for similarity matching processing to obtain a target paragraph sentence vector with similarity meeting a seventh preset condition. The sentence semantic similarity model is referred to the training process, and is not described herein. Therefore, under the condition that the interactive text does not comprise chapters and paragraphs, the optimal sentence can be recalled through one dimension of the sentence, namely the target vector with the similarity of the semantic vector of the query text meeting the preset condition, and the deep understanding and analysis of the sentence content of the interactive text are realized, so that the accurate matching and positioning of the query result are realized.
It should be noted that, in the step S107, the method may be implemented in a plurality of ways, and not limited to this, in an alternative embodiment, the index information includes chapter segment index information, paragraph segment index information, and sentence segment index information, and in the step S107, the obtaining, from at least one of the chapter segment index information, the paragraph segment index information, and the sentence segment index information, target index information that the similarity of the query text corresponding to the interactive text satisfies the preset condition may include:
and determining target index information corresponding to the target vector from the chapter fragment index information, the paragraph fragment index information and the sentence fragment index information.
In this embodiment, in the case that the interactive text includes a chapter, structural analysis is performed on the interactive text to obtain a text segment including a chapter segment, a paragraph segment, and a sentence segment, and the corresponding index information includes a chapter segment index information, a paragraph segment index information, and a sentence segment index information, then after obtaining the target vector, the target index information corresponding to the target vector may be determined from the chapter segment index information, the paragraph segment index information, and the sentence segment index information.
In another alternative embodiment, the index information includes paragraph fragment index information and sentence fragment index information, and determining target index information corresponding to the target vector from at least one of the chapter fragment index information, the paragraph fragment index information, and the sentence fragment index information includes:
from the paragraph fragment index information and the sentence fragment index information, target index information corresponding to the target vector is determined.
In this embodiment, in the case that the interactive text includes a paragraph, the text segment includes a paragraph segment and a sentence segment, and the corresponding index information includes paragraph segment index information and sentence segment index information, after the target vector is obtained, the target index information corresponding to the target vector may be determined from the paragraph segment index information and the sentence segment index information.
In another alternative embodiment, the index information includes sentence fragment index information, and determining target index information corresponding to the target vector from at least one of chapter fragment index information, paragraph fragment index information, and sentence fragment index information includes:
Target index information corresponding to the target vector is determined from the sentence fragment index information.
In some embodiments, continuing to fig. 3, in the step S1013, the inputting the context information and the query text into the large language model performs the query result prediction processing, to obtain the query result of the query text may include:
s10131, generating prompt information according to the context information and the query text.
S10133, inputting prompt information into the large language model to conduct query result prediction processing, and obtaining a query result of the query text.
Alternatively, in the above step S10131, the server may generate a prompt message (prompt) according to the context information and the query text. In one embodiment, the server obtains a pre-configured prompt template, wherein the prompt template comprises an information slot, and the server fills the context information and the query text into the prompt slot to obtain prompt information. In another embodiment, the server may directly splice the context information and the query text to obtain the prompt information, or encrypt the spliced context information and the query text to obtain the prompt information.
Optionally, in the step S10131, the server may input the prompt information into the large language model to perform prompt learning of the query result prediction process, so as to obtain the query result of the query text. The method and the device can complete the deep understanding of the interactive file by deep understanding and analyzing the interactive text and matching with a large language model, realize the generation of more accurate, comprehensive and readable topic summary and information extraction of the interactive file based on the question and answer of the user, and pertinently answer the question of the user on the file, thereby greatly improving the processing efficiency of the interactive file and the interactive response efficiency between the user and the interactive text and reducing the processing cost of the interactive file; in addition, the Prompt is essentially an instruction to a downstream task, and can be enhanced as information to tell the model what task to do and what content to output. The method has the advantages that the aim and the parameters used by the pre-training language model in the pre-training stage can be multiplexed in prompt learning, and as the basic large model freezes part of parameters and layers, the parameters of the part of models can be used in the actual business scene on the basis of the trained models because of the fact that the basic large model does not have many hardware computing resources and storage.
The following describes a large language model:
the large language model uses a Transform structure, the Transform structure uses an Attention (Attention) mechanism to carry out sequence modeling, and the best result is obtained on a machine translation task, so that the traditional mode that an encoding-decoding (encoding-decoding) model is combined with a cyclic neural network (Recurrent Neural Network, RNN) is broken, and the parallelism of the model is greatly improved on the premise that the effect is not lost and even improved. The structural network key part of the Transform structure comprises:
multi-head self-Attention (Multi-Headsself-Attention): applying a self-Attention mechanism (Se lf-Attention) to the sequence, the interrelationship between each item (item) in the sequence and all other items can be mined simultaneously. Information mining can be done from different vector subspaces using multi-headed attention.
Position-Feed-Forward Network: after Attention (Attention), a layer of feedforward network is added to endow the model with nonlinear expression capability, and interactive relations among different dimensions can be mined.
Change layer (Transformer Layer): a Transformer Layer is composed of a multi-headed self-Attention Layer and a position feed forward network, wherein both the Attention Layer and FFN use residual networks in the output section and perform Layer normalization (Layer Normalization).
For laminate (Stacking Transformer Layers): stacking together a plurality of Transformer layer allows more complex higher order interactions to be learned.
The following describes the above-mentioned interactive text processing method in its entirety:
the application scenario of the embodiment of the application may be: for text files uploaded by users in an instant messaging group in a social network, text files transmitted in a point-to-point chat process or links of file web pages, or text files stored in an online storage service (such as a network disk, etc.), the text files can be effectively understood and processed, answer replies can be given according to targeted questions proposed by the users, specific positions of the answers in the text files can also be given, if the answers are related in the text files, the answers are returned, otherwise, the users are prompted to not relate to the contents related to the questions in the text files.
FIG. 7 is a flowchart III of an interactive text processing method according to an exemplary embodiment, as shown in FIG. 7, the interactive text processing method may include:
1) Acquiring an interactive text and a query text proposed for the interactive text; the interactive text may be in the form of PDF, word, web, txt, etc., or various electronic books, etc.
2) Carrying out structural analysis processing on the interactive text to obtain a text fragment; the text segment includes at least one of a chapter segment, a paragraph segment, and a sentence segment. And vectorizing the text fragments to obtain at least one of chapter fragment vectors, paragraph fragment vectors corresponding to the paragraph fragments and sentence fragment vectors corresponding to the sentence fragments.
In one embodiment, when the preset service is an instant messaging service in a social network, the process of obtaining interactive text, querying the text and parsing the text by the server may include:
fig. 8 is a flowchart of an interactive text processing method according to an exemplary embodiment, and as shown in fig. 8, a terminal object opens an instant messaging service, enters an instant messaging group or enters a page for performing peer-to-peer chat with other objects, searches a file control in a group application of the instant messaging group or in the page for performing peer-to-peer chat, and clicks the file control, so that all texts uploaded by the terminal object and other objects before the current time are displayed in a text display page.
When the terminal object wants to parse some files, some files can be operated (including but not limited to clicking, long pressing, dragging, etc.) to trigger a selection operation for some files, and the server responds to the selection operation to determine some files selected by the terminal object as interactive text to be parsed finally. It should be noted that the "some files" may be one file or a batch of files, which is not limited in particular.
When the terminal object operates some files, the client may also display the interactive text, pop up the file assistant tool in the instant messaging service, and the terminal object operates (e.g. clicks on) the file assistant tool to display a function page corresponding to the file assistant tool, where various functions for operating the files, such as a file parsing function, a file compiling function, etc., are displayed. The terminal object clicks the file analysis function to trigger text analysis operation, and the server responds to the text analysis operation and transmits the interactive text into the file assistant tool to perform structural analysis processing to obtain a text fragment. The server sends the text segment to the terminal, and the terminal displays the text segment in a target page in the instant communication service.
The terminal may also display a query text editing area in the target page, where the query text editing area may be displayed at any position of the target page, for example, in an area below, above, etc. the text segment, which is not limited specifically. And the terminal object edits the query text editing area to trigger an editing operation, and the server responds to the editing operation to make the text corresponding to the editing operation as the query text.
In another embodiment, when the preset service is an online storage service, the process of obtaining the interactive text, querying the text and parsing the text by the server may include:
the terminal object opens the online storage service, and all texts uploaded by the terminal object before the current time are displayed in a text display page in the online storage service. When the terminal object wants to parse some files, some files can be operated (including but not limited to clicking, long pressing, dragging, etc.) to trigger a selection operation for some files, and the server responds to the selection operation to determine some files selected by the terminal object as interactive text to be parsed finally.
When the terminal object operates on some files, the client can pop up a file assistant tool, and the terminal object clicks on the file assistant tool to display a function page corresponding to the file assistant tool, wherein various functions for operating the files, such as a file analysis function, a file compiling function and the like, are displayed in the function page. The terminal object clicks the file analysis function to trigger text analysis operation, and the server responds to the text analysis operation and transmits the interactive text into the file assistant tool to perform structural analysis processing to obtain a text fragment. The server sends the text segment to the terminal, and the terminal displays the text segment in a target page in the online storage service.
The terminal may also display a query text editing area in the target page, where the query text editing area may be displayed at any position of the target page, for example, in an area below, above, etc. the text segment, which is not limited specifically. And the terminal object edits the query text editing area to trigger an editing operation, and the server responds to the editing operation to make the text corresponding to the editing operation as the query text.
3) And establishing index information corresponding to the text fragments. The index information comprises at least one of chapter fragment index information corresponding to the chapter fragment vector, paragraph fragment index information corresponding to the paragraph fragment vector, sentence fragment index information corresponding to the sentence fragment vector, display index information and structure index information.
4) And encoding the query text to obtain the semantic vector of the query text.
5) And inputting the chapter fragment vector and the semantic vector to a chapter semantic similarity model for similarity matching processing so as to acquire a target chapter fragment vector, the similarity of which with the semantic vector meets a first preset condition, from the chapter fragment vector.
6) And inputting the target chapter fragment vector and the semantic vector into a paragraph semantic similarity model for similarity matching processing so as to obtain a target paragraph fragment vector with similarity meeting a second preset condition from paragraph fragment vectors corresponding to the target chapter fragment vector.
7) Combining each sentence fragment vector corresponding to the target paragraph fragment vector with the semantic vector to obtain a sentence combination result of each sentence fragment vector corresponding to the target paragraph fragment vector; and inputting each sentence combination result into a sentence semantic similarity model to perform similarity matching processing so as to obtain a target sentence fragment vector with similarity meeting a third preset condition from at least two sentence fragment vectors corresponding to the target paragraph fragment vector. And determining the target sentence fragment vector as a target vector.
8) Target index information corresponding to the target vector is determined from at least one of chapter fragment index information, paragraph fragment index information, sentence fragment index information. And acquiring a target text segment corresponding to the target index information from the text segment.
9) And generating the context information of the query text according to the target text segment.
10 Generating prompt information according to the context information and the query text.
11 Inputting prompt information to the large language model to perform query result prediction processing to obtain a query result of the query text.
It should be noted that, the processes from "establishing the index information corresponding to the text segment" to "obtaining the query result of the query text" may be implemented by a file assistant tool.
12 Sending the query result to the terminal so that the terminal displays the text fragment, the query text and the query result in the target page in the instant messaging service or the online storage service.
FIG. 9 is a system diagram illustrating an interactive text processing, as shown in FIG. 9, according to an exemplary embodiment, the interactive text processing system may include:
one end is provided with
(1) The message function uplink and downlink are completed by communicating with the message interface service;
(2) Realizing various functions and message processing of file understanding at a product end, calling a group file understanding and question-answering service function, and completing the capability realization of group file understanding and interaction with a user;
(3) Various functions and message interaction of the group chat at the end, group management and the like, uploading and downloading of group files and the like are realized;
(4) Reporting various feedback information understood by a user on the file through reporting analysis and interface service, so that a follow-up model is subjected to fine tuning and alignment to human expectations;
second, access server
(1) Synchronizing with the terminal, and completing the uplink and downlink communication and synchronization of the message;
(2) The message content is in butt joint with a message database storage and index system through a message queue system, so that the core service logic of message processing is completed;
(3) The method comprises the steps of communicating with a group service server, and completing various functions of a group, including adding and deleting the group and uploading and downloading an intermediate bridge of a group file;
third, message content database
(1) Temporarily storing the user dialogue information to realize the roaming of the information and the synchronization of the multi-terminal information;
(2) As a core module of the message system, the storage and index processing of the message is optimized with high efficiency;
(3) Information sources of multi-terminal synchronization of the information;
fourth, message system
(1) The whole flow responsible for message synchronization and communication is transferred and distributed;
(2) Responsible for communicating with a message content database to complete the distribution and processing of the message, including the message content of various groups;
fifth, reporting and analyzing interface service
(1) The service comprises user feedback of the file depth understanding question and answer generation result;
sixth, file database and index information
(1) The method comprises the steps of communicating with an access service period, wherein the communication comprises a display index of a document, a structure index of the document, a chapter index, a paragraph index and a sentence level granularity index, and index information is mainly used for rapidly positioning actual text content and simultaneously storing content block entity text information with various granularities after file analysis;
(2) Meanwhile, various reading understanding and question-answering related public and manual labeling data sets are stored;
(3) Providing original supervision sample data service for fine tuning large language models and constructing text similarity models such as chapters, paragraphs and sentence level semantic similarity basic models with multiple granularity
Seven group file understanding and question-answering model
(1) Completing construction of an understanding and question-answering model according to the method based on the large language model prompt construction and the context positioning method, and carrying out service on the basis of the model to obtain final service of file understanding and question-answering generation;
(2) The terminal communicates with the terminal, and the text files appointed and screened by the user are subjected to understanding and question-answering processing and the result is returned for the message terminal to display;
eight group file understanding and question-answering service
(1) The constructed group file understanding and question-answering service and a series of dependent foundations, such as a basic model with chapter, paragraph and sentence granularity, are well served, and the positioning of answers corresponding to user questions is completed;
(2) On the basis of positioning, constructing a promt to finish the generation of a final question-answer result based on a large language model;
(3) The terminal communicates with the terminal, finishes the process of understanding and asking and answering the files appointed and screened by the user, and returns the result to the terminal for display;
Nine-large language model
The embodiment is not limited to one fixed large language model, and any model using the generated transformation architecture may be classified as a large language model.
Tenth group service system
(1) Completing the synchronization and processing of various messages of the group;
(2) And meanwhile, the index storage and sharing of various group files uploaded and released by the group members are completed, and meanwhile, the files are communicated with a file database and an index system to provide an original file data source for file depth understanding and question-answering processing.
Fig. 10 is a block diagram of an interactive text processing apparatus according to an exemplary embodiment, as shown in fig. 10, including:
the text obtaining module 401 is configured to obtain an interactive text and a query text for the interactive text.
The parsing module 403 is configured to perform structural parsing on the interactive text to obtain a text segment; the text segment includes at least one of a chapter segment, a paragraph segment, and a sentence segment.
An index establishing module 405, configured to establish index information corresponding to the text segment; the index information is used for representing the position information of the text segment in the interactive text, and comprises at least one of chapter segment index information corresponding to the chapter segment, paragraph segment index information corresponding to the paragraph segment and sentence segment index information corresponding to the sentence segment.
The index obtaining module 407 is configured to obtain, from at least one of the chapter fragment index information, the paragraph fragment index information, and the sentence fragment index information, target index information that the similarity of the query text corresponding to the interactive text satisfies a preset condition.
And a target text segment obtaining module 409, configured to obtain a target text segment corresponding to the target index information from the text segments.
A context generating module 4011 is configured to generate context information of the query text according to the target text segment.
A query result generation module 4013, configured to input the context information and the query text into a large language model for performing query result prediction processing, so as to obtain a query result of the query text; the large-scale language model is obtained by performing instruction fine adjustment on an initial large-scale language model based on preset context information of a preset field, preset query text aiming at the preset context information and a preset query result corresponding to the preset query text.
In an alternative embodiment, the apparatus further comprises:
the vectorization module is used for vectorizing the text fragments to obtain text fragment vectors corresponding to the text fragments; the text segment vector comprises at least one of a chapter segment vector corresponding to the chapter segment, a paragraph segment vector corresponding to the paragraph segment and a sentence segment vector corresponding to the sentence segment.
Correspondingly, the index establishing module is configured to establish index information corresponding to at least one of the chapter fragment vector, the paragraph fragment vector, and the sentence fragment vector, and obtain index information corresponding to the text fragment.
Accordingly, the index acquisition module includes:
and the vector retrieval unit is used for retrieving a target vector with the similarity with the semantic vector of the query text meeting the preset condition from at least one of the chapter fragment vector, the paragraph fragment vector and the sentence fragment vector.
And a target index information determining unit configured to determine the target index information corresponding to the target vector from at least one of the chapter fragment index information, the paragraph fragment index information, and the sentence fragment index information.
In an alternative embodiment, in a case where the text segment includes a chapter segment, a paragraph segment, and a sentence segment, and the text segment vector includes the chapter segment vector, the paragraph segment vector, and the sentence segment vector, the above-mentioned vector retrieving unit includes:
and the first vector acquisition subunit is used for acquiring a target chapter fragment vector, the similarity between the target chapter fragment vector and the semantic vector of which meets a first preset condition, from the chapter fragment vector.
And the second vector obtaining subunit is used for obtaining the target paragraph fragment vector with the similarity meeting the second preset condition from the paragraph fragment vector corresponding to the target paragraph fragment vector.
A third vector obtaining subunit, configured to obtain, from sentence fragment vectors corresponding to the target paragraph fragment vectors, a target sentence fragment vector whose similarity with the semantic vector satisfies a third preset condition; and determining the target sentence fragment vector as the target vector.
In an alternative embodiment, the first vector acquisition subunit is configured to:
inputting the chapter fragment vector and the semantic vector to a chapter semantic similarity model to perform similarity matching processing so as to acquire a target chapter fragment vector, the similarity of which with the semantic vector meets the first preset condition, from the chapter fragment vector;
the chapter semantic similarity model is obtained by training a first pre-training model based on anchored sample chapter data corresponding to a first sample query text, positive sample chapter fragments and negative sample chapter fragments in a sample chapter fragment set, the title content of the positive sample chapter fragment is matched with the content of the anchored sample chapter data, and the title content of the negative sample chapter fragment is not matched with the content of the anchored sample chapter data.
In an alternative embodiment, the apparatus further comprises:
and the first sample acquisition module is used for acquiring the sample chapter fragment set and the first sample query text.
And the anchoring sample chapter data generation module is used for generating the anchoring sample chapter data according to the first sample query text.
And the positive and negative sample chapter fragment determining unit is used for determining the positive sample chapter fragment and the negative sample chapter fragment from the sample chapter fragment set.
The first feature extraction unit is configured to input the anchor sample chapter data, the positive sample chapter segment, and the negative sample chapter segment to the first pre-training model to perform feature extraction, so as to obtain an anchor sample chapter data vector corresponding to the anchor sample chapter data, a positive sample chapter data vector corresponding to the positive sample chapter segment, and a negative sample chapter data vector corresponding to the negative sample chapter segment.
A first and second difference calculation unit for calculating a first difference between the anchor sample chapter data vector and the negative sample chapter data vector, and a second difference between the anchor sample chapter data vector and the positive sample chapter data vector.
And a first loss data calculation unit configured to calculate first loss data based on the first difference and the second difference.
And the first adjusting unit is used for adjusting the network parameters of the first pre-training model according to the first loss data until a preset training ending condition is met to obtain the chapter semantic similarity model.
In an alternative embodiment, the second vector acquisition subunit is configured to:
inputting the target chapter fragment vector and the semantic vector to a paragraph semantic similarity model for similarity matching processing so as to obtain a target paragraph fragment vector with similarity meeting a second preset condition from paragraph fragment vectors corresponding to the target chapter fragment vector;
the paragraph semantic similarity model is obtained by training a second pre-training model based on anchored paragraph data corresponding to a second sample query text, positive sample paragraph fragments and negative sample paragraph fragments in a sample paragraph fragment set, the content of the positive sample paragraph fragments is matched with the content of the anchored sample paragraph data, and the content of the negative sample paragraph fragments is not matched with the content of the anchored sample paragraph data.
In an alternative embodiment, the transpose further comprises:
and the second sample text acquisition unit is used for acquiring a sample paragraph fragment set corresponding to the second sample query text and the sample chapter fragment.
And the anchor sample paragraph data generating unit is used for generating the anchor sample paragraph data according to the sample second sample query text.
And the positive and negative sample paragraph segment determining unit is used for determining the positive sample paragraph segment and the negative sample paragraph segment from the sample paragraph segment set.
And the second feature extraction unit is used for inputting the anchoring sample paragraph data, the positive sample paragraph fragment and the negative sample paragraph fragment into the second pre-training model to perform feature extraction to obtain an anchoring sample paragraph data vector corresponding to the anchoring sample paragraph data, a positive sample paragraph data vector corresponding to the positive sample paragraph fragment and a negative sample paragraph data vector corresponding to the negative sample paragraph fragment.
A third fourth difference calculation unit for calculating a third difference between the anchor sample paragraph data vector and the negative sample paragraph data vector, and a fourth difference between the anchor sample paragraph data vector and the positive sample paragraph data vector.
And a second loss data calculation unit configured to calculate second loss data based on the third difference and the fourth difference.
And the second adjusting unit is used for adjusting the network parameters of the second pre-training model according to the second loss data until a preset training ending condition is met to obtain the paragraph semantic similarity model.
In an optional embodiment, the number of sentence fragment vectors corresponding to the target paragraph fragment vector is at least two, and the third vector obtaining subunit is configured to:
combining each sentence fragment vector corresponding to the target paragraph fragment vector with the semantic vector to obtain a sentence combination result of each sentence fragment vector corresponding to the target paragraph fragment vector;
inputting each sentence combination result to a sentence semantic similarity model for similarity matching processing, so as to obtain a target sentence fragment vector, the similarity of which and the semantic vector meet the third preset condition, from at least two sentence fragment vectors corresponding to the target paragraph fragment vector;
the sentence semantic similarity model is obtained by training a third pre-training model based on a third sample query text marked with a sample query result label and a sample paragraph fragment.
In an alternative embodiment, the apparatus further comprises:
and a third sample text acquisition unit, configured to acquire the sample paragraph segment and the third sample query text.
And the segmentation unit is used for segmenting the sample paragraph fragments to obtain at least two sample sentence fragments.
And the combination unit is used for combining the sample sentence fragment vector of each sample sentence fragment with the sample semantic vector of the sample query text to obtain a sample sentence combination result corresponding to each sample sentence fragment vector.
And the prediction processing unit is used for inputting each sample sentence combination result to the third pre-training model to perform query prediction processing, so as to obtain a prediction matching result of each sample sentence combination result matched with the sample query result label.
The third adjusting unit is used for adjusting network parameters of the third pre-training model according to the difference between the predicted matching result and the actual matching result until the difference between the predicted matching result and the actual matching result meets a fourth preset condition, so as to obtain the sentence semantic similarity model; the actual matching result is an actual similarity matching result between each sample sentence combination result and the sample query result label.
In an alternative embodiment, in a case where the text segment includes a paragraph segment and a sentence segment, and the text segment vector includes one of the paragraph segment vector and the sentence segment vector, the vector retrieving unit includes:
a fourth vector obtaining subunit, configured to obtain, from the paragraph segment vectors, a target paragraph segment vector whose similarity with the semantic vector satisfies a fifth preset condition.
A fifth vector obtaining subunit, configured to obtain, from the sentence fragment vectors corresponding to the target paragraph fragment vectors that satisfy the fifth preset condition, a target sentence fragment vector whose similarity with the semantic vector satisfies the sixth preset condition.
And the vector determining unit is used for determining the target sentence fragment vector meeting the sixth preset condition as the target vector.
In an alternative embodiment, in a case where the text segment includes a sentence segment and the text segment vector includes the sentence segment vector, the vector retrieving unit includes:
a sixth vector obtaining subunit, configured to obtain, from the sentence fragment vectors, a target paragraph sentence vector whose similarity with the semantic vector satisfies a seventh preset condition.
A seventh vector obtaining subunit, configured to determine, as the target vector, a target paragraph sentence vector whose similarity satisfies a seventh preset condition.
In an alternative embodiment, the query result generation module includes:
and the prompt information generation unit is used for generating prompt information according to the context information and the query text.
And the query result prediction unit is used for inputting the prompt information to the large language model to perform query result prediction processing so as to obtain a query result of the query text.
In an optional embodiment, the text obtaining module is configured to respond to a text selection operation triggered by a text display page of a terminal object in a preset service, and determine a text corresponding to the text selection operation as the interactive text; the preset service is an online storage service or an instant messaging service in a social network.
Correspondingly, the analysis module is further used for responding to text analysis operation triggered by the terminal object based on the file assistant tool, and transmitting the interactive text into the file assistant tool for structural analysis to obtain the text fragment; the text segment is sent to a terminal, so that the terminal displays the text segment on a target page in the preset service; the text file assistant tool is displayed on the terminal when the terminal object triggers the text selection operation.
In an alternative embodiment, the target page has a query text input area displayed therein, and the apparatus further includes: and the editing module is used for responding to the editing operation triggered by the terminal object based on the query text input area and determining the text corresponding to the editing operation as the query text.
Correspondingly, the device further comprises:
and the sending module is used for sending the query result to the terminal so that the terminal displays the text segment, the query text and the query result on the target page.
It should be noted that the device embodiments provided in the embodiments of the present application are based on the same inventive concept as the method embodiments described above.
The embodiment of the application also provides an electronic device for interactive text processing, which comprises a processor and a memory, wherein at least one instruction or at least one section of program is stored in the memory, and the at least one instruction or the at least one section of program is loaded and executed by the processor to realize the interactive text processing method provided by any embodiment.
The embodiment of the application also provides an electronic device for interactive text processing, which comprises a processor and a memory, wherein at least one instruction or at least one section of program is stored in the memory, and the at least one instruction or the at least one section of program is loaded and executed by the processor to realize the interactive text processing method provided by any embodiment.
Embodiments of the present application also provide a computer readable storage medium that may be provided in a terminal to store at least one instruction or at least one program for implementing an interactive text processing method in a method embodiment, where the at least one instruction or the at least one program is loaded and executed by a processor to implement an interactive text processing method as provided in the method embodiment described above.
Alternatively, in the present description embodiment, the storage medium may be located in at least one network server among a plurality of network servers of the computer network. Alternatively, in the present embodiment, the storage medium may include, but is not limited to: a U-disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), a removable hard disk, a magnetic disk, or an optical disk, or other various media capable of storing program codes.
The memory of the embodiments of the present specification may be used for storing software programs and modules, and the processor executes various functional applications and data processing by executing the software programs and modules stored in the memory. The memory may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, application programs required for functions, and the like; the storage data area may store data created according to the use of the device, etc. In addition, the memory may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid-state storage device. Accordingly, the memory may also include a memory controller to provide access to the memory by the processor.
Embodiments of the present application also provide a computer program product or computer program comprising computer instructions stored in a computer-readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the interactive text processing method provided by the above method embodiment.
The embodiments of the interactive text processing method provided in the embodiments of the present application may be executed in a terminal, a computer terminal, a server, or a similar computing device. Taking the example of running on a server, fig. 11 is a block diagram of a hardware structure of a server according to an exemplary embodiment. As shown in fig. 11, the server 500 may vary considerably in configuration or performance, and may include one or more central processing units (Central Processing Units, CPU) 510 (the central processing unit 510 may include, but is not limited to, a microprocessor MCU or a processing device such as a programmable logic device FPGA), a memory 530 for storing data, one or more storage mediums 520 (e.g., one or more mass storage devices) storing applications 523 or data 522. Wherein the memory 530 and storage medium 520 may be transitory or persistent storage. The program stored on the storage medium 520 may include one or more modules, each of which may include a series of instruction operations on a server. Still further, the central processor 410 may be configured to communicate with the storage medium 520 and execute a series of instruction operations in the storage medium 520 on the server 500. The server 500 may also include one or more power supplies 560, one or more wired or wireless network interfaces 550, one or more input/output interfaces 540, and/or one or more operating systems 521, such as Windows ServerTM, mac OS XTM, unixTM, linuxTM, freeBSDTM, and the like.
Input-output interface 540 may be used to receive or transmit data via a network. The specific example of the network described above may include a wireless network provided by a communication provider of the server 500. In one example, the input/output interface 540 includes a network adapter (Network Interface Controller, NIC) that can connect to other network devices through a base station to communicate with the internet. In one example, the input/output interface 540 may be a Radio Frequency (RF) module for communicating with the internet wirelessly.
It will be appreciated by those of ordinary skill in the art that the configuration shown in fig. 11 is merely illustrative and is not intended to limit the configuration of the electronic device described above. For example, the server 500 may also include more or fewer components than shown in fig. 11, or have a different configuration than shown in fig. 11.
It should be noted that: the foregoing sequence of the embodiments of the present application is only for describing, and does not represent the advantages and disadvantages of the embodiments. And the foregoing description has been directed to specific embodiments of this specification. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims can be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
In this specification, each embodiment is described in a progressive manner, and identical and similar parts of each embodiment are all referred to each other, and each embodiment mainly describes differences from other embodiments. In particular, for the device and server embodiments, since they are substantially similar to the method embodiments, the description is relatively simple, and references to the parts of the description of the method embodiments are only required.
It will be appreciated by those of ordinary skill in the art that all or part of the steps of implementing the above embodiments may be implemented by hardware, or may be implemented by a program to instruct related hardware, and the program may be stored in a computer readable storage medium, where the storage medium may be a read-only memory, a magnetic disk or an optical disk, etc.
The foregoing description of the preferred embodiments of the present application is not intended to be limiting, but rather is intended to cover any and all modifications, equivalents, alternatives, and improvements within the spirit and principles of the present application.

Claims (15)

1. An interactive text processing method, the method comprising:
acquiring an interactive text;
carrying out structural analysis processing on the interactive text to obtain a text fragment; the text segment comprises at least one of a chapter segment, a paragraph segment and a sentence segment;
Establishing index information corresponding to the text fragments; the index information is used for representing the position information of the text segment in the interactive text, and comprises at least one of chapter segment index information corresponding to the chapter segment, paragraph segment index information corresponding to the paragraph segment and sentence segment index information corresponding to the sentence segment;
obtaining target index information, of which the similarity of the query text corresponding to the interactive text meets a preset condition, from at least one of the chapter fragment index information, the paragraph fragment index information and the sentence fragment index information;
acquiring a target text segment corresponding to the target index information from the text segment;
generating context information of the query text according to the target text segment;
inputting the context information and the query text to a large language model for query result prediction processing to obtain a query result of the query text; the large-scale language model is obtained by performing instruction fine adjustment on an initial large-scale language model based on preset context information of a preset field, preset query text aiming at the preset context information and a preset query result corresponding to the preset query text.
2. The interactive text processing method according to claim 1, wherein after the interactive text is subjected to the structural parsing process to obtain a text segment, the method further comprises:
vectorizing the text segment to obtain a text segment vector corresponding to the text segment; the text segment vector comprises at least one of a chapter segment vector corresponding to the chapter segment, a paragraph segment vector corresponding to the paragraph segment and a sentence segment vector corresponding to the sentence segment;
correspondingly, the establishing the index information corresponding to the text segment includes:
establishing index information corresponding to at least one of the chapter fragment vector, the paragraph fragment vector and the sentence fragment vector to obtain the index information corresponding to the text fragment;
correspondingly, the obtaining target index information that the similarity of the query text corresponding to the interactive text meets the preset condition from at least one of the chapter fragment index information, the paragraph fragment index information and the sentence fragment index information comprises:
retrieving a target vector with similarity with a semantic vector of the query text meeting the preset condition from at least one of the chapter fragment vector, the paragraph fragment vector and the sentence fragment vector;
And determining the target index information corresponding to the target vector from at least one of the chapter fragment index information, the paragraph fragment index information and the sentence fragment index information.
3. The interactive text processing method according to claim 2, wherein, in the case where the text segment includes a chapter segment, a paragraph segment, and a sentence segment, and the text segment vector includes the chapter segment vector, the paragraph segment vector, and the sentence segment vector, the retrieving a target vector having a similarity with a semantic vector of the query text satisfying a preset condition from at least one of the chapter segment vector, the paragraph segment vector, and the sentence segment vector, comprises:
obtaining a target chapter fragment vector with similarity meeting a first preset condition from the chapter fragment vector;
obtaining a target paragraph fragment vector with the similarity between the target paragraph fragment vector and the semantic vector meeting a second preset condition from the paragraph fragment vector corresponding to the target paragraph fragment vector;
obtaining a target sentence fragment vector with the similarity between the target sentence fragment vector and the semantic vector meeting a third preset condition from sentence fragment vectors corresponding to the target paragraph fragment vector; and determining the target sentence fragment vector as the target vector.
4. The interactive text processing method of claim 3, wherein the obtaining the target chapter fragment vector having a similarity with the semantic vector satisfying a first preset condition from the chapter fragment vector comprises:
inputting the chapter fragment vector and the semantic vector to a chapter semantic similarity model to perform similarity matching processing so as to acquire a target chapter fragment vector, the similarity of which with the semantic vector meets the first preset condition, from the chapter fragment vector;
the chapter semantic similarity model is obtained by training a first pre-training model based on anchored sample chapter data corresponding to a first sample query text, positive sample chapter fragments and negative sample chapter fragments in a sample chapter fragment set, the title content of the positive sample chapter fragment is matched with the content of the anchored sample chapter data, and the title content of the negative sample chapter fragment is not matched with the content of the anchored sample chapter data.
5. The interactive text processing method according to claim 4, wherein the training method of the chapter semantic similarity model comprises:
acquiring the sample chapter fragment set and the first sample query text;
Generating the anchor sample chapter data according to the first sample query text;
determining the positive sample chapter fragment and the negative sample chapter fragment from the sample chapter fragment set;
inputting the anchoring sample chapter data, the positive sample chapter fragment and the negative sample chapter fragment to the first pre-training model for feature extraction to obtain an anchoring sample chapter data vector corresponding to the anchoring sample chapter data, a positive sample chapter data vector corresponding to the positive sample chapter fragment and a negative sample chapter data vector corresponding to the negative sample chapter fragment;
calculating a first difference between the anchor sample chapter data vector and the negative sample chapter data vector, and a second difference between the anchor sample chapter data vector and the positive sample chapter data vector;
calculating first loss data based on the first difference and the second difference;
and adjusting network parameters of the first pre-training model according to the first loss data until a preset training ending condition is met to obtain the chapter semantic similarity model.
6. The interactive text processing method according to claim 3, wherein obtaining the target paragraph segment vector having a similarity with the semantic vector satisfying a second preset condition from the paragraph segment vector corresponding to the target paragraph segment vector comprises:
Inputting the target chapter fragment vector and the semantic vector to a paragraph semantic similarity model for similarity matching processing so as to obtain a target paragraph fragment vector with similarity meeting a second preset condition from paragraph fragment vectors corresponding to the target chapter fragment vector;
the paragraph semantic similarity model is obtained by training a second pre-training model based on anchored paragraph data corresponding to a second sample query text, positive sample paragraph fragments and negative sample paragraph fragments in a sample paragraph fragment set, the content of the positive sample paragraph fragments is matched with the content of the anchored sample paragraph data, and the content of the negative sample paragraph fragments is not matched with the content of the anchored sample paragraph data.
7. The interactive text processing method according to claim 6, wherein the training method of the paragraph semantic similarity model comprises:
acquiring a sample paragraph fragment set corresponding to the second sample query text and the sample chapter fragment;
generating the anchor sample paragraph data according to the sample second sample query text;
determining the positive sample paragraph segment and the negative sample paragraph segment from the sample paragraph segment set;
Inputting the anchoring sample paragraph data, the positive sample paragraph segment and the negative sample paragraph segment into the second pre-training model for feature extraction to obtain an anchoring sample paragraph data vector corresponding to the anchoring sample paragraph data, a positive sample paragraph data vector corresponding to the positive sample paragraph segment and a negative sample paragraph data vector corresponding to the negative sample paragraph segment;
calculating a third difference between the anchor sample paragraph data vector and the negative sample paragraph data vector, and a fourth difference between the anchor sample paragraph data vector and the positive sample paragraph data vector;
calculating second loss data based on the third difference and the fourth difference;
and adjusting network parameters of the second pre-training model according to the second loss data until a preset training ending condition is met to obtain the paragraph semantic similarity model.
8. The interactive text processing method according to claim 3, wherein the number of sentence fragment vectors corresponding to the target paragraph fragment vector is at least two, and the obtaining, from the sentence fragment vectors corresponding to the target paragraph fragment vector, a target sentence fragment vector having a similarity with the semantic vector satisfying a third preset condition includes:
Combining each sentence fragment vector corresponding to the target paragraph fragment vector with the semantic vector to obtain a sentence combination result of each sentence fragment vector corresponding to the target paragraph fragment vector;
inputting each sentence combination result to a sentence semantic similarity model for similarity matching processing, so as to obtain a target sentence fragment vector, the similarity of which and the semantic vector meet the third preset condition, from at least two sentence fragment vectors corresponding to the target paragraph fragment vector;
the sentence semantic similarity model is obtained by training a third pre-training model based on a third sample query text marked with a sample query result label and a sample paragraph fragment.
9. The interactive text processing method according to claim 8, wherein the training method of the sentence semantic similarity model comprises:
acquiring the sample paragraph fragments and the third sample query text;
dividing the sample paragraph fragments to obtain at least two sample sentence fragments;
combining the sample sentence fragment vector of each sample sentence fragment with the sample semantic vector of the sample query text to obtain a sample sentence combination result corresponding to each sample sentence fragment vector;
Inputting each sample sentence combination result to the third pre-training model for query prediction processing to obtain a prediction matching result of each sample sentence combination result matched with the sample query result label;
according to the difference between the predicted matching result and the actual matching result, adjusting network parameters of the third pre-training model until the difference between the predicted matching result and the actual matching result meets a fourth preset condition, and obtaining the sentence semantic similarity model; the actual matching result is an actual similarity matching result between each sample sentence combination result and the sample query result label.
10. The interactive text processing method according to claim 2, wherein in the case where the text segment includes a paragraph segment and a sentence segment, and the text segment vector includes one of the paragraph segment vector and the sentence segment vector, the retrieving a target vector having a similarity to a semantic vector of the query text satisfying a preset condition from at least one of the chapter segment vector, the paragraph segment vector, and the sentence segment vector, comprises:
Obtaining a target paragraph fragment vector with the similarity between the paragraph fragment vector and the semantic vector meeting a fifth preset condition from the paragraph fragment vector;
obtaining target sentence fragment vectors with similarity between the target sentence fragment vectors and the semantic vectors meeting a sixth preset condition from the sentence fragment vectors corresponding to the target paragraph fragment vectors meeting the fifth preset condition;
and determining the target sentence fragment vector meeting a sixth preset condition as the target vector.
11. The interactive text processing method according to claim 2, wherein in the case where the text segment includes a sentence segment and the text segment vector includes one of the sentence segment vectors, the retrieving a target vector having a similarity with a semantic vector of the query text satisfying a preset condition from at least one of the chapter segment vector, the paragraph segment vector, and the sentence segment vector includes:
obtaining a target paragraph sentence vector with the similarity between the sentence fragment vector and the semantic vector meeting a seventh preset condition from the sentence fragment vector;
and determining the target paragraph sentence vector with the similarity meeting a seventh preset condition as the target vector.
12. The interactive text processing method according to any one of claims 1 to 3, wherein the inputting the context information and the query text into a large language model performs a query result prediction process to obtain a query result of the query text, comprising:
generating prompt information according to the context information and the query text;
and inputting the prompt information to the large language model to perform query result prediction processing to obtain a query result of the query text.
13. The interactive text processing method according to any one of claims 1 to 3, wherein the acquiring interactive text comprises:
responding to text selection operation triggered by a text display page of a terminal object in preset service, and determining a text corresponding to the text selection operation as the interactive text; the preset service is an online storage service or an instant messaging service in a social network;
correspondingly, the step of carrying out structural analysis processing on the interactive text to obtain a text segment comprises the following steps:
responding to text analysis operation triggered by the terminal object based on a file assistant tool, and transmitting the interactive text into the file assistant tool for structural analysis to obtain the text fragment;
The text segment is sent to a terminal, so that the terminal displays the text segment on a target page in the preset service; the text file assistant tool is displayed on the terminal when the terminal object triggers the text selection operation.
14. The interactive text processing method of claim 13, wherein a query text editing area is displayed in the target page, and after the sending the text segment to a terminal, so that the terminal displays the text segment on the target page in the preset service, the method further comprises: responding to the editing operation triggered by the terminal object based on the query text editing area, and determining a text corresponding to the editing operation as the query text;
accordingly, after the query result of the query text is obtained, the method further includes:
and sending the query result to the terminal so that the terminal displays the text segment, the query text and the query result on the target page.
15. An interactive text processing apparatus, the apparatus comprising:
the text acquisition module is used for acquiring the interactive text;
The analysis module is used for carrying out structural analysis processing on the interactive text to obtain a text fragment; the text segment comprises at least one of a chapter segment, a paragraph segment and a sentence segment;
the index establishing module is used for establishing index information corresponding to the text fragments; the index information is used for representing the position information of the text segment in the interactive text, and comprises at least one of chapter segment index information corresponding to the chapter segment, paragraph segment index information corresponding to the paragraph segment and sentence segment index information corresponding to the sentence segment;
the index acquisition module is used for acquiring target index information, of which the similarity of the query text corresponding to the interactive text meets a preset condition, from at least one of the chapter fragment index information, the paragraph fragment index information and the sentence fragment index information;
a target text segment obtaining module, configured to obtain a target text segment corresponding to the target index information from the text segment;
the context generation module is used for generating context information of the query text according to the target text segment;
the query result generation module is used for inputting the context information and the query text into a large language model to perform query result prediction processing so as to obtain a query result of the query text; the large-scale language model is obtained by performing instruction fine adjustment on an initial large-scale language model based on preset context information of a preset field, preset query text aiming at the preset context information and a preset query result corresponding to the preset query text.
CN202311163655.6A 2023-09-11 2023-09-11 Interactive text processing method and device, electronic equipment and storage medium Pending CN117473034A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311163655.6A CN117473034A (en) 2023-09-11 2023-09-11 Interactive text processing method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311163655.6A CN117473034A (en) 2023-09-11 2023-09-11 Interactive text processing method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN117473034A true CN117473034A (en) 2024-01-30

Family

ID=89622828

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311163655.6A Pending CN117473034A (en) 2023-09-11 2023-09-11 Interactive text processing method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117473034A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117909993A (en) * 2024-03-01 2024-04-19 典基网络科技(上海)有限公司 Method and device for detecting loopholes of Internet of things equipment

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117909993A (en) * 2024-03-01 2024-04-19 典基网络科技(上海)有限公司 Method and device for detecting loopholes of Internet of things equipment
CN117909993B (en) * 2024-03-01 2024-06-21 典基网络科技(上海)有限公司 Method and device for detecting loopholes of Internet of things equipment

Similar Documents

Publication Publication Date Title
CN111026842B (en) Natural language processing method, natural language processing device and intelligent question-answering system
WO2021159632A1 (en) Intelligent questioning and answering method and apparatus, computer device, and computer storage medium
CN109325040B (en) FAQ question-answer library generalization method, device and equipment
CN104076944A (en) Chat emoticon input method and device
CN110866093A (en) Machine question-answering method and device
CN109857846B (en) Method and device for matching user question and knowledge point
KR102169382B1 (en) Artificial Intelligence-Based Personalized Expert Cross Matching and Proposal System
CN113392651A (en) Training word weight model, and method, device, equipment and medium for extracting core words
CN110457585B (en) Negative text pushing method, device and system and computer equipment
CN111931061A (en) Label mapping method and device, computer equipment and storage medium
CN112632258A (en) Text data processing method and device, computer equipment and storage medium
CN112749556B (en) Multi-language model training method and device, storage medium and electronic equipment
CN116796045B (en) Multi-dimensional book grading method, system and readable medium
CN113392179A (en) Text labeling method and device, electronic equipment and storage medium
CN117473034A (en) Interactive text processing method and device, electronic equipment and storage medium
CN113641797A (en) Data processing method, device, equipment, storage medium and computer program product
CN113723853A (en) Method and device for processing post competence demand data
CN113011126A (en) Text processing method and device, electronic equipment and computer readable storage medium
CN114840685A (en) Emergency plan knowledge graph construction method
CN117668181A (en) Information processing method, device, terminal equipment and storage medium
CN114911893A (en) Method and system for automatically constructing knowledge base based on knowledge graph
CN112989024B (en) Method, device and equipment for extracting relation of text content and storage medium
CN113342944B (en) Corpus generalization method, apparatus, device and storage medium
CN117828024A (en) Plug-in retrieval method, device, storage medium and equipment
CN114372454A (en) Text information extraction method, model training method, device and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication