Document question answering processing method and electronic device
By utilizing users' historical question-and-answer information as context and filtering it within the document question-and-answer system, and combining this with the generated prompts input into a large language model, the problem of insufficient answer accuracy in existing systems is solved, achieving higher answer accuracy and less redundant data.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- HONOR DEVICE CO LTD
- Filing Date
- 2024-03-13
- Publication Date
- 2026-05-29
AI Technical Summary
Existing document question answering systems based on large language models have shortcomings in terms of answer accuracy, mainly due to the lack of historical context information, which leads to low accuracy of the answer results.
By acquiring and filtering the user's historical question-and-answer information in the current dialogue window, and combining the user's input question with the retrieved relevant text blocks to generate prompt information, the information is input into a large language model to improve the accuracy of the answer and avoid introducing redundant data.
It improves the accuracy of answers in document question-answering systems by using historical question-answering information as context-assisted model output, reducing reasoning costs and improving answer accuracy.
Smart Images

Figure CN120705248B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computers, and more particularly to a document question-and-answer processing method and an electronic device. Background Technology
[0002] Document question answering is an important branch of natural language processing. The task requires in-depth understanding and analysis of each document in an unstructured document library to extract relevant information, and then providing accurate answers to user questions. Its goal is to enable computers to possess human-like abilities to read and understand text and provide accurate answers to user questions. With the significant improvement in the performance of large language models (LLM), LLM-based document question answering systems have been widely used, capable of providing answers to questions in natural language based on given documents and questions.
[0003] Currently, the common implementation approach for LLM-based document question answering systems is as follows: First, the user-submitted document is parsed, segmented, and vectorized, and stored in a database. Then, the user-input query is parsed and vectorized, and the top-N relevant text blocks with the highest matching degree are retrieved from the database using vector similarity matching. Based on the prompt template, a prompt is generated by combining the user-input query and the retrieved relevant text blocks. This prompt is then input into a large language model, and the model's output is returned to the user as the answer. However, the accuracy of the answers obtained through this method is relatively low. Summary of the Invention
[0004] This application provides a document question-and-answer processing method and an electronic device. Based on the method described in this application, it is beneficial to improve the accuracy of the answer results.
[0005] In a first aspect, this application provides a document question-and-answer processing method, which includes: firstly obtaining a first question for a first document; and determining first historical question-and-answer information for the first document from one or more historical question-and-answer information; then determining a first text block associated with the first question from the first document; generating first prompt information; wherein the first prompt information includes the first text block, the first historical question-and-answer information, and the first question; and finally calling a large language model to process the first prompt information to obtain a first answer corresponding to the first question, and outputting the first answer corresponding to the first question.
[0006] Based on the method described in the first aspect, for document question-and-answer scenarios, since user questions are usually relevant in a single dialogue window, electronic devices can obtain one or more historical question-and-answer information from the user in the current dialogue window and use this information as the context for the current user's question to better assist the model in outputting the answer to the current question. At the same time, to avoid introducing redundant data, the information is further filtered and screened, which is more conducive to improving the accuracy of the answer results.
[0007] In one possible implementation, when determining first historical question-and-answer information for a given first document from one or more historical question-and-answer information sources, the specific implementation could be as follows: if the same identifier exists in both a first document identifier set and a second document identifier set, determine the degree of duplication of the document identifiers in the first and second document identifier sets; wherein the first document identifier set includes the identifiers of the one or more first documents, and the second document identifier set includes the identifier of the second document targeted by the historical question-and-answer information; if the degree of duplication is greater than a first threshold, then the historical question-and-answer information is determined to be first historical question-and-answer information. Since, during the process of filtering and selecting first historical question-and-answer information specifically for a given first document from one or more historical question-and-answer information sources, there may be cases where the document targeted by the historical question-and-answer information has low relevance to the document selected by the current user's question, further filtering based on document duplication is necessary to ensure the accuracy of the current question's answer while reducing reasoning costs.
[0008] In one possible implementation, if the repetition rate is greater than a first threshold, then when determining the historical question-and-answer information as the first historical question-and-answer information, the specific implementation may be as follows: if the repetition rate is greater than the first threshold, then determine the intersection document identifiers between the first document identifier set and the second document identifier set; then calculate the proportion of the document information corresponding to the intersection document identifier in the second answer included in the historical question-and-answer information; if the proportion is greater than the second threshold, then determine the historical question-and-answer information as the first historical question-and-answer information. Based on this approach, if the overlap between the second document identifier set corresponding to a certain historical question-and-answer information and the document identifiers of the first document identifier set is greater than a first threshold, it indicates that the historical question-and-answer information is highly relevant to the document selected by the current user's question. However, this does not mean that there is a lot of information about the intersecting documents in the second answer included in the historical question-and-answer information. If there is little information about the intersecting documents in the second answer included in the historical question-and-answer information, then other redundant descriptions will be introduced, thereby introducing redundant data and reducing the accuracy of the answer results. Therefore, it is necessary to evaluate the proportion of information about the intersecting documents in the answers included in the historical question-and-answer information to determine whether the historical question-and-answer information can be used directly to improve the accuracy of subsequent answer results.
[0009] In one possible implementation, when calculating the proportion of document information corresponding to the intersection document identifier in the second answer included in the historical question-and-answer information, the specific implementation method could be: determining keywords based on the document information corresponding to the intersection document identifier; calculating the proportion of first information in the second answer included in the historical question-and-answer information; wherein the first information includes the keyword. This can be understood as using keyword matching to determine the proportion of document information corresponding to the intersection document identifier in the second answer included in the historical question-and-answer information; this method is simple to operate.
[0010] In one possible implementation, determining the first text block associated with the first question from the first document can be achieved by: determining the first text block associated with both the first question and the first historical question-and-answer information from the first document. This can be understood as combining the first question and the first historical question-and-answer information into a new question (a new query), and using this new query to determine the relevant first text block in the first document, thereby further improving the accuracy of the answer. Here, the determined first text block can be one or more.
[0011] In one possible implementation, there are multiple second documents. The method further includes: if the repetition rate is less than or equal to the first threshold and the repetition rate is greater than or equal to the third threshold, then rewriting the historical question-and-answer information to obtain multiple sub-question-and-answer information; or, if the proportion value is less than or equal to the second threshold, then rewriting the historical question-and-answer information to obtain multiple sub-question-and-answer information; wherein, the multiple second documents correspond one-to-one with the multiple sub-question-and-answer information; then determining the first sub-question-and-answer information for the first document from the multiple sub-question-and-answer information; then generating second prompt information, wherein the second prompt information includes the first text block, the first sub-question-and-answer information, and the first question; finally, calling a large language model to process the second prompt information to obtain the third answer corresponding to the first question, and outputting the third answer corresponding to the first question. This can be understood as follows: if the repetition rate is less than or equal to the first threshold and greater than or equal to the third threshold, it indicates that the relevance of the historical Q&A information to the document selected by the current user is not significant. However, the second answer can be further rewritten to obtain multiple sub-Q&A information, making full use of the historical Q&A information. From these sub-Q&A information, the first sub-Q&A information for the first document can be identified. This first sub-Q&A information can then be submitted to the large language model as the context of the current user's question, which helps improve the accuracy of the answer. Conversely, if the proportion is less than or equal to the second threshold, it indicates that the information about the intersecting documents accounts for a small proportion of the second answer included in the historical Q&A information. The second answer can also be further rewritten, specifically by splitting it into multiple sub-Q&A information, making full use of the historical Q&A information. This first sub-Q&A information can then be submitted to the large language model as the context of the current user's question, which helps improve the accuracy of the answer.
[0012] It should be noted that when there are multiple historical Q&A information, depending on the situation corresponding to each historical Q&A information, some historical Q&A information can be identified as the first historical Q&A information, some historical Q&A information can be rewritten to obtain multiple sub-Q&A information, and some historical Q&A information can be discarded. Therefore, the first prompt template and the second prompt template mentioned above can also include the first text block, the first historical Q&A information, the first sub-Q&A information, and the first question.
[0013] In one possible implementation, multiple first historical question-and-answer records are provided. These records are arranged chronologically, either from front to back or from back to front. Alternatively, they can be arranged according to a first similarity score, either from highest to lowest or lowest to highest, where the first similarity score is the similarity between the first historical question-and-answer record and the first question. It can be understood that the ordering of different historical question-and-answer records affects the accuracy of the model's returned results; therefore, a certain strategy is needed to sort the multiple historical question-and-answer records. This approach helps improve the accuracy of the answer results.
[0014] Secondly, this application provides a document question-and-answer processing apparatus. This apparatus can be an electronic device, a device within an electronic device, or a device compatible with an electronic device. The document question-and-answer processing apparatus can also be a chip system, capable of executing the methods performed by the electronic device in the first aspect. The functions of the document question-and-answer processing apparatus can be implemented in hardware or by hardware executing corresponding software. The hardware or software includes one or more units corresponding to the aforementioned functions. These units can be software and / or hardware. The operations and beneficial effects performed by the document question-and-answer processing apparatus are described in the first aspect and their beneficial effects are not repeated here.
[0015] Thirdly, this application provides an electronic device including one or more processors and one or more memories. The one or more memories are coupled to the one or more processors, the memories being used to store a computer program, and the processors being used to invoke the computer program to cause the electronic device to perform the method described in the first aspect.
[0016] Fourthly, this application provides a chip system for use in an electronic device, the chip system including at least one processor and an interface for receiving instructions and transmitting them to the at least one processor; the at least one processor executes the instructions to cause the electronic device to perform the method described in the first aspect.
[0017] Fifthly, this application provides a document question-and-answer processing system, which includes an electronic device; wherein the electronic device is used to perform the method as described in the first aspect.
[0018] In a sixth aspect, this application provides a document question-and-answer processing apparatus, which includes functions or units for performing the method as described in any of the first aspects.
[0019] In a seventh aspect, this application provides a computer storage medium having a computer program / instructions stored thereon, which, when executed by a processor, implements the method and steps described in the first aspect.
[0020] Eighthly, this application provides a computer program product including a computer program / instructions that, when executed by a processor, implement the method and steps described in the first aspect. Attached Figure Description
[0021] Figure 1A This is a schematic diagram of a document question and answer system provided in an embodiment of this application;
[0022] Figure 1B This is a schematic diagram of a document question-and-answer backend processing method provided in an embodiment of this application;
[0023] Figure 2 This is a schematic diagram of the hardware structure of an electronic device provided in an embodiment of this application;
[0024] Figure 3 This is a software structure block diagram of an electronic device provided in an embodiment of this application;
[0025] Figure 4 This is a schematic diagram of a document question-and-answer processing flowchart provided in an embodiment of this application;
[0026] Figure 5A This is a schematic diagram of a desktop and text assistant provided in an embodiment of this application;
[0027] Figure 5B This is a schematic diagram of another document question and answer provided in an embodiment of this application;
[0028] Figure 5C This is a schematic diagram of a dialog range selection box provided in an embodiment of this application;
[0029] Figure 6A This is a schematic diagram illustrating a method for filtering historical question and answer information provided in an embodiment of this application;
[0030] Figure 6B This is a schematic diagram illustrating a method for rewriting historical question and answer information, provided in an embodiment of this application.
[0031] Figure 7 This is a schematic diagram of another document question-and-answer backend processing provided in an embodiment of this application;
[0032] Figure 8 This is a schematic diagram of another document question-and-answer processing flowchart provided in an embodiment of this application;
[0033] Figure 9This is a schematic diagram of another document question-and-answer processing flowchart provided in an embodiment of this application;
[0034] Figure 10 This is a schematic diagram of the structure of a task execution device provided in an embodiment of this application;
[0035] Figure 11 This is a schematic diagram of the structure of a chip provided in an embodiment of this application. Detailed Implementation
[0036] The technical solutions in the embodiments of this application will be clearly and thoroughly described below with reference to the accompanying drawings. In the description of the embodiments of this application, unless otherwise stated, " / " means "or," for example, A / B can mean A or B; the word "and / or" in the text is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Furthermore, in the description of the embodiments of this application, "multiple" refers to two or more than two.
[0037] Hereinafter, the terms "first" and "second" are used for descriptive purposes only and should not be construed as implying or suggesting relative importance or implicitly indicating the number of indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature, and in the description of the embodiments of this application, unless otherwise stated, "multiple" means two or more.
[0038] The term "user interface (UI)" used in the following embodiments of this application refers to the medium interface through which an application or operating system interacts and exchanges information with a user. It realizes the conversion between the internal form of information and the form that the user can accept. The user interface is source code written in a specific computer language such as Java or Extensible Markup Language (XML). The interface source code is parsed and rendered on the electronic device, ultimately presenting content that the user can recognize. A common form of user interface is the graphical user interface (GUI), which refers to a user interface related to computer operation displayed graphically. It can be visual interface elements such as time, date, text, icons, buttons, menus, tabs, text boxes, dialog boxes, status bars, navigation bars, and widgets displayed on the screen of an electronic device.
[0039] To facilitate understanding of the solutions provided in the embodiments of this application, the relevant concepts involved in the embodiments of this application are introduced below:
[0040] 1. Large Language Model (LLM)
[0041] LLM (Language Modeling) is a deep learning-based natural language processing model that learns the syntax and semantics of natural language, enabling it to generate human-readable text. LLMs can handle various natural language tasks, such as text classification, question answering, and dialogue, and are an important pathway to artificial intelligence. Common LLM models include ChatGPT (Chat Generative Pre-trained Transformer) and LaMDA (Language Model for Dialogue Applications). ChatGPT is an AI-driven natural language processing tool that generates responses based on patterns and statistical regularities observed during pre-training. It can also interact based on the chat context, truly engaging in human-like conversations and even performing tasks such as writing emails, video scripts, copywriting, translation, and coding. LaMDA is a large language model based on the Transformer architecture that can generate, understand, and create text content. Its unique feature is its conversational interaction method, allowing users to communicate with computers more naturally.
[0042] 2. Retrieval Augmented Generation (RAG)
[0043] RAG is a technology that assists LLM in generating answers by retrieving information from data sources. In short, RAG combines search technology with the prompting capabilities of LLM; it asks a question to the model and uses information found by the search algorithm as contextual information, which is then integrated into the prompts sent to the LLM. RAG has become one of the most popular architectures in LLM-based systems. Many products are built almost entirely on RAG, ranging from question-answering services that combine web search engines and LLM to hundreds of applications that "talk to data."
[0044] 3. Document Q&A
[0045] Document question answering (CQA) is an important branch of natural language processing (NLP). The task requires in-depth understanding and analysis of each document in an unstructured document library to extract relevant information, and then providing accurate answers to user questions. Its goal is to enable computers to possess human-like abilities to read and understand text and provide accurate answers based on user queries. With the significant improvement in the effectiveness of LLM, LLM-based CQA systems have been widely adopted, capable of providing answers to questions in natural language based on given documents and questions.
[0046] Please see Figure 1A , Figure 1A A schematic diagram of a document Q&A interface is shown. This interface includes a question input box, a dialog box, an upload document button, and a send button. Users can upload documents by clicking the upload document button, for example, uploading document 1, document 2, and document 3. After these documents are uploaded, users can enter questions about these three documents in the question input box, send them to the electronic device via the send button, and the questions will be displayed in the dialog box. The electronic device receives the user's input, parses and processes it, outputs the corresponding answer, and displays it in the dialog box.
[0047] Regarding the backend processing flow, such as Figure 1B As shown, the current implementation methods for document question-answering systems based on LLM can be:
[0048] (1) Parse and segment the documents uploaded by users.
[0049] Since the input length of the model is fixed, in order to improve the overall quality and accessibility of the text while avoiding information loss, it is necessary to parse and segment the user-uploaded documents, dividing them into appropriately sized paragraphs while preserving their original meaning (e.g., dividing the document into sentences or paragraphs, rather than splitting a single sentence into two parts). Several text segmentation tools are available for this task.
[0050] (2) Vectorize the segmented text blocks.
[0051] Text vectorization refers to representing text information as vectors that can express the semantics of the text; it uses numerical vectors to represent the semantics of the text. Word embedding is a method of converting words in text into numerical vectors, falling under the category of text vectorization processing. Common text vector and word embedding methods include one-hot models, bag-of-words models, TF-IDF (Term Frequency-Inverse Document Frequency), N-gram models, Word2vec (Word-Vector Model), and Doc2vec (Doc-Vector Model).
[0052] (3) Store the vectorized text blocks in the database.
[0053] (4) Parse and vectorize the user-input query.
[0054] (5) Retrieve the top-N relevant text blocks with the highest matching degree from the database by vector similarity matching.
[0055] Vector similarity is a measure of how close two vectors are in numerical terms. Vector similarity matching can be used to retrieve semantically relevant text blocks from a database that match a user's input question. Vector similarity matching methods can include cosine similarity, Pearson correlation coefficient, Euclidean distance, and Manhattan distance.
[0056] (6) Based on the prompt template, generate a prompt by combining the user's input question (query) and the retrieved relevant text blocks, and input LLM.
[0057] (7) Obtain the LLM output and return it to the user as the answer to the question.
[0058] However, in this dialogue window, the user's questions are usually relevant. If only the current user's single question is used to retrieve relevant text blocks to provide LLM with answers, the lack of historical context information will lead to a decrease in the accuracy of the answer results.
[0059] Therefore, to improve the accuracy of the answer results, this application provides a document question-and-answer processing method and an electronic device. This method mainly utilizes RAG technology, using the user's historical question-and-answer information in the current dialogue window as the context of the current user's question. Furthermore, it can further filter and refine the user's historical question-and-answer information. Then, it combines the filtered historical question-and-answer information, the user's input question, and retrieved relevant text blocks to generate a prompt. This prompt is then input into a large language model for answering, thereby improving the accuracy of the model's answer without introducing redundant data.
[0060] In its implementation, the document question-and-answer processing method mentioned here can be executed by electronic device 100. Electronic device 100 can be a laptop, tablet, personal computer (PC), ultra-mobile personal computer (UMPC), desktop computer, personal digital assistant (PDA), server, etc.; it can also be a mobile phone, wearable electronic device with wireless communication capabilities (such as a smartwatch), smart vehicle, etc., but is not limited to these. The server can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery network (CDN), and big data and artificial intelligence platforms. Electronic device 100 can be configured with a display screen and can have pre-installed applications (APPs), such as a document question-and-answer APP (which can be permanently displayed as an icon on the main interface), etc., without limitation. For example, users can submit documents through a document Q&A app on the screen, and ask questions about documents and get answers within the app.
[0061] The hardware structure of electronic device 100 is described below. Please refer to [link / reference]. Figure 2 , Figure 2 This is a schematic diagram of the hardware structure of the electronic device 100 provided in the embodiments of this application.
[0062] Electronic device 100 may include processor 110, external memory interface 120, internal memory 121, universal serial bus (USB) interface 130, charging management module 140, power management module 141, battery 142, antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, audio module 170, speaker 170A, receiver 170B, microphone 170C, headphone jack 170D, sensor module 180, button 190, motor 191, indicator 192, camera 193, display screen 194, and subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, a barometric pressure sensor 180C, a magnetic sensor 180D, an accelerometer sensor 180E, a distance sensor 180F, a proximity sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.
[0063] It is understood that the structures illustrated in the embodiments of the present invention do not constitute a specific limitation on the electronic device 100. In other embodiments of this application, the electronic device 100 may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0064] Processor 110 may include one or more processing units, such as: application processor (AP), modem processor, graphics processing unit (GPU), image signal processor (ISP), controller, memory, video codec, digital signal processor (DSP), baseband processor, and / or neural network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.
[0065] The controller can be the nerve center and command center of the electronic device 100. The controller can generate operation control signals according to the instruction opcode and timing signals to complete the control of fetching and executing instructions.
[0066] The processor 110 may also include a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. This memory can store instructions or data that the processor 110 has just used or that are used repeatedly. If the processor 110 needs to use the instruction or data again, it can directly retrieve it from the memory. This avoids repeated accesses, reduces the waiting time of the processor 110, and thus improves the efficiency of the system. The processor 110 retrieves the instructions or data stored in the memory, causing the electronic device 100 to execute the document question-and-answer processing method performed by the electronic device in the following method embodiments.
[0067] In some embodiments, the processor 110 may include one or more interfaces. Interfaces may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.
[0068] The charging management module 140 is used to receive charging input from the charger. The charger can be a wireless charger or a wired charger.
[0069] The power management module 141 is used to connect the battery 142, the charging management module 140, and the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140 to power the processor 110, internal memory 121, external memory, display 194, camera 193, and wireless communication module 160, etc. In some other embodiments, the power management module 141 may also be located in the processor 110.
[0070] The wireless communication function of electronic device 100 can be realized through antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, modem processor and baseband processor, etc.
[0071] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 100 can be used to cover one or more communication frequency bands. Different antennas can also be multiplexed to improve antenna utilization. For example, antenna 1 can be multiplexed as a diversity antenna for a wireless local area network. In some other embodiments, the antennas can be used in conjunction with tuning switches.
[0072] The mobile communication module 150 can provide solutions for wireless communication, including 2G / 3G / 4G / 5G, applied to the electronic device 100. The mobile communication module 150 may include at least one filter, switch, power amplifier, low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves via antenna 1, and perform filtering, amplification, and other processing on the received electromagnetic waves before transmitting them to a modem processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modem processor and convert it into electromagnetic waves for radiation via antenna 1. In some embodiments, at least some functional modules of the mobile communication module 150 may be housed in the processor 110. In some embodiments, at least some functional modules of the mobile communication module 150 and at least some modules of the processor 110 may be housed in the same device.
[0073] A modem processor may include a modulator and a demodulator. The modulator modulates the low-frequency baseband signal to be transmitted into a mid-to-high frequency signal. The demodulator demodulates the received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing. After processing by the baseband processor, the low-frequency baseband signal is transmitted to the application processor.
[0074] The wireless communication module 160 can provide solutions for wireless communication applications on the electronic device 100, including wireless local area networks (WLAN) (such as Wi-Fi networks), Bluetooth (BT), BLE broadcasting, global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), and infrared (IR) technologies. The wireless communication module 160 can be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via antenna 2, performs frequency modulation and filtering of the electromagnetic wave signals, and sends the processed signal to processor 110. The wireless communication module 160 can also receive signals to be transmitted from processor 110, perform frequency modulation and amplification, and convert them into electromagnetic waves for radiation via antenna 2.
[0075] In some embodiments, antenna 1 of electronic device 100 is coupled to mobile communication module 150, and antenna 2 is coupled to wireless communication module 160, so that electronic device 100 can communicate with networks and other devices through wireless communication technology.
[0076] Electronic device 100 implements display functions through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, connected to the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations and for graphics rendering. Processor 110 may include one or more GPUs, which execute program instructions to generate or modify display information.
[0077] The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. In some embodiments, the electronic device 100 may include one or N display screens 194, where N is a positive integer greater than 1.
[0078] Electronic device 100 can perform shooting functions through an ISP, camera 193, video codec, GPU, display 194, and application processor. The ISP processes data fed back from the camera 193. The camera 193 captures still images or video. The digital signal processor processes digital signals, including digital image signals and other digital signals. The video codec compresses or decompresses digital video. Electronic device 100 can support one or more video codecs.
[0079] NPU stands for Neural-Network (NN) Computing Processor. By drawing inspiration from the structure of biological neural networks, such as the transmission patterns between neurons in the human brain, it can quickly process input information and continuously learn on its own.
[0080] The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 through the external memory interface 120 to perform data storage functions.
[0081] Internal memory 121 can be used to store computer executable program code, which includes instructions. Processor 110 executes various functional applications and data processing of electronic device 100 by running the instructions stored in internal memory 121. Internal memory 121 may include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function (such as a sound playback function), etc. The data storage area may store data created during the use of electronic device 100 (such as audio data), etc. Furthermore, internal memory 121 may include high-speed random access memory and may also include non-volatile memory, such as flash memory devices.
[0082] Electronic device 100 can implement audio functions, such as music playback and recording, through audio module 170, speaker 170A, receiver 170B, microphone 170C, headphone jack 170D, and application processor.
[0083] The audio module 170 is used to convert digital audio information into analog audio signals for output, and also to convert analog audio input into digital audio signals. The audio module 170 can also be used for encoding and decoding audio signals. In some embodiments, the audio module 170 may be located in the processor 110, or some functional modules of the audio module 170 may be located in the processor 110.
[0084] The speaker 170A, also known as a "loudspeaker," is used to convert audio electrical signals into sound signals. The receiver 170B, also known as a "handpiece," is used to convert audio electrical signals into sound signals. The microphone 170C, also known as a "microphone" or "voice transducer," is used to convert sound signals into electrical signals. The headphone jack 170D is used to connect wired headphones. The pressure sensor 180A is used to sense pressure signals and convert them into electrical signals.
[0085] In some embodiments, a pressure sensor 180A may be disposed on a display screen 194. A gyroscope sensor 180B may be used to determine the motion posture of the electronic device 100. A barometric pressure sensor 180C is used to measure barometric pressure. A magnetic sensor 180D includes a Hall effect sensor. An accelerometer sensor 180E can detect the magnitude of acceleration of the electronic device 100 in various directions (generally triaxial). A distance sensor 180F is used to measure distance. A proximity sensor 180G may include, for example, a light-emitting diode (LED) and a photodetector. An ambient light sensor 180L is used to sense ambient light intensity. A fingerprint sensor 180H is used to collect fingerprints. A temperature sensor 180J is used to detect temperature. A touch sensor 180K, also called a "touch panel," may be disposed on the display screen 194. The touch sensor 180K and the display screen 194 together form a touch screen, also called a "touchscreen." The touch sensor 180K is used to detect touch operations applied to or near it. A bone conduction sensor 180M can acquire vibration signals. Buttons 190 include a power button, volume buttons, etc. A motor 191 can generate vibration feedback. An indicator 192 can be an indicator light, used to indicate charging status, battery level changes, and also to indicate messages, missed calls, notifications, etc. A SIM card interface 195 is used to connect a SIM card.
[0086] It is understood that the structures illustrated in the embodiments of this application do not constitute a specific limitation on the electronic device 100. In other embodiments of this application, the electronic device 100 may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0087] Furthermore, an operating system runs on top of the aforementioned components. Examples include iOS and Android. The operating system of electronic device 100 can adopt a layered architecture, event-driven architecture, microkernel architecture, microservice architecture, or cloud architecture. This application embodiment uses the layered architecture Android system as an example to exemplify the software structure of electronic device 100. It should be noted that although this application embodiment uses the Android system as an example for illustration, its basic principles are equally applicable to electronic devices with other operating systems.
[0088] Figure 3This is a software structure block diagram of the electronic device 100 according to an embodiment of this application. The software structure adopts a layered architecture, which divides the software into several layers, each with a clear role and division of labor. The layers communicate with each other through software interfaces. In this embodiment, the operating system (taking the Android system, which runs on an AP as an example) can be divided into six layers, from top to bottom: application layer (APP), application framework layer (FWK), Android runtime and system library, hardware abstraction layer (HAL), kernel layer, and hardware layer.
[0089] The application layer can include a series of application packages. For example... Figure 3 As shown, the application package can include applications such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, SMS, and document Q&A. The application layer can also include the system UI, which displays the interface of the electronic device, such as the camera interface. For example, a user can submit a document in a document Q&A application, ask questions about the document through the question box in the application interface, and get the corresponding answer through the answer box in the application interface.
[0090] The application framework layer provides application programming interfaces (APIs) and a programming framework for applications in the application layer. The application framework layer includes some predefined functions. For example... Figure 3 As shown, the application framework layer may include a window manager, content provider, view system, phone manager, resource manager, notification manager, camera service, etc., and this application embodiment does not impose any limitations on this.
[0091] The window manager is used to manage windowed applications. It can retrieve screen size, determine the presence of a status bar, lock the screen, and capture screenshots, among other things.
[0092] Content providers store and retrieve data, making that data accessible to applications. This data may include videos, images, audio, made and received phone calls, browsing history and bookmarks, phone books, etc.
[0093] A view system includes visual controls, such as controls for displaying text and controls for displaying images. View systems can be used to build applications. A display interface can consist of one or more views. For example, a display interface including a text notification icon could include views for displaying text and views for displaying images.
[0094] The phone manager is used to provide communication functions for electronic device 100. For example, it manages call status (including connection and disconnection).
[0095] The file explorer provides applications with various resources, such as localized strings, icons, images, layout files, video files, and more.
[0096] The notification manager allows applications to display notifications in the status bar. These notifications can be used to deliver informational messages and can disappear automatically after a short pause, requiring no user interaction. For example, the notification manager can be used to notify users of completed downloads or message alerts. The notification manager can also display notifications as icons or scrolling text in the top status bar, such as notifications from background applications, or as dialog boxes on the screen. Examples include displaying text messages in the status bar, emitting sounds, vibrating electronic devices, and flashing indicator lights.
[0097] The camera service is the core process module of the camera framework. It mainly provides API interface functions to the application layer and calls the camera hardware abstraction layer through HIDL (hardware interface definition language).
[0098] The Android runtime consists of core libraries and a virtual machine. The Android runtime is responsible for scheduling and managing the Android system.
[0099] The core library consists of two parts: one part is the functionalities that need to be called by the Java language, and the other part is the Android core library.
[0100] The application layer and application framework layer run in a virtual machine. The virtual machine executes the Java files of the application layer and application framework layer as binary files. The virtual machine is used to perform functions such as object lifecycle management, stack management, thread management, security and exception management, and garbage collection.
[0101] System libraries can include multiple functional modules. For example: surface manager, media libraries, 3D graphics processing libraries (e.g., OpenGL ES), 2D graphics engines (e.g., SGL), etc.
[0102] The Surface Manager is used to manage the display subsystem and provides the blending of 2D and 3D layers for multiple applications.
[0103] The media library supports playback and recording of various common audio and video formats, as well as still image files. It also supports multiple audio and video encoding formats.
[0104] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing.
[0105] A 2D graphics engine is a graphics engine for 2D drawing.
[0106] The Hardware Abstraction Layer (HAL) is an interface layer located between the operating system kernel and the hardware circuitry, its purpose being to abstract the hardware. It hides the platform-specific hardware interface details, providing the operating system with a virtual hardware platform. For example, the HAL encapsulates Linux kernel drivers, providing an interface to the upper layers and shielding them from the implementation details of the lower-level hardware. Figure 3 As shown, the hardware abstraction layer can include Wi-Fi HAL, audio HAL, camera HAL, etc.
[0107] The kernel layer is the layer between hardware and software. It is the core of an operating system, the first layer of software extension based on the hardware, providing the most basic functions of the operating system. It is the foundation for the operating system's operation, responsible for managing system processes, memory, device drivers, files, and network systems, and determining the system's performance and stability. The kernel layer can include display drivers, audio drivers, camera drivers, sensor drivers, etc. Among them, the camera driver is the driver layer for camera devices, mainly responsible for interaction with the hardware.
[0108] The hardware layer includes displays, cameras, sensors, etc.
[0109] Based on the above, taking a personal computer (PC) as an example, the document question-and-answer processing method provided in this application will be described in further detail below. Figure 4 As shown, the document question-and-answer processing method includes the following steps S401 to S406. Figure 4 The method shown can be implemented by the aforementioned electronic device. Alternatively, Figure 4 The method shown can be executed by a chip in an electronic device, but this application does not limit the implementation. Figure 4 The method will be explained using an electronic device as the executing entity.
[0110] S401, Electronic device obtains the first question for the first document.
[0111] In this embodiment of the application, the first document refers to the document in which the user is asking a question; the first question is the question raised by the user regarding the first document. The first document can be one or more documents.
[0112] like Figure 5A As shown, various apps can be installed on a PC, such as Word, Excel, PowerPoint, music, video, recycle bin, and document Q&A apps, and their icons can be displayed on the PC's home screen. When the PC boots up, the document Q&A app can be displayed as a persistent process on the home screen. For example, an icon for "Text Assistant" can be displayed on the PC's home screen, and users can directly click the "Text Assistant" icon to enter the document Q&A process and display the document Q&A interface. Figure 5B As shown, the document Q&A interface includes a dialog box, a question input box, a dialog range selection box, an upload document button, a send button, and a document display box. In this dialog window, users can upload documents to their PCs by clicking the upload document button; for example, a user can upload document 1, document 2, and document 3 to their PC. After receiving the uploaded documents, the electronic device can generate a unique identifier for each document and can also use methods such as Hush encryption and digital signatures to enhance security.
[0113] After a user uploads a document, the uploaded document can be viewed in the dialog scope selection box. The user can then select the document for their question, for example, selecting document 1. Next, the user enters their question about document 1 in the question input box and sends it to the electronic device via the send button. The electronic device then receives the user's question about document 1 and displays it in a dialog box. Here, document 1 can be considered the first document, and the question about document 1 can be considered the first question.
[0114] It should be noted that electronic devices can retain all documents uploaded by the user in the current dialog window (this can be understood as any document uploaded within the current dialog window, whether it's a previously uploaded document or a currently uploaded document), and these documents can be displayed in the dialog selection box for the user to choose from. Of course, the style of the dialog selection box can be as follows: Figure 5B The style shown can also be adopted as follows: Figure 5C The style shown can also be other styles, and no restrictions are imposed here.
[0115] S402, The electronic device determines the first historical question and answer information for the first document from one or more historical question and answer information.
[0116] In this embodiment, the electronic device saves one or more historical question-and-answer messages from the user in the current dialogue window to a historical question-and-answer database. These historical question-and-answer messages refer to the questions the user has previously asked and the corresponding answers they have provided in the current dialogue window. Since user questions are usually relevant within a single dialogue window, the electronic device can retrieve one or more historical question-and-answer messages from the database and use this information as context for the current user's question, thus better assisting the model in outputting answers.
[0117] After an electronic device acquires one or more historical question-and-answer messages, directly using all of these messages as context for the current user's question may introduce redundant data, affecting the accuracy of the model's response. For example, in a dialog window, if a user uploads document 1, document 2, and document 3, and a historical question-and-answer message is about document 1 while the current user is asking about document 2, directly using this historical message as context for the current user's question would introduce a description of document 1, thus introducing redundant data. Therefore, the electronic device needs to further filter (select) from one or more historical question-and-answer messages to extract only the first historical question-and-answer message specifically for that first document, in order to better assist the model in outputting the answer.
[0118] For example, in this dialogue window, the user first asked question 1 about document 1 and received answer 1. Question 1 and answer 1 constitute historical Q&A information 1. The user then asked question 2 about document 2 and received answer 2. Question 2 and answer 2 constitute historical Q&A information 2. Thus, two pieces of historical Q&A information are obtained: historical Q&A information 1 and historical Q&A information 2. Now, the user has asked question 3 about document 1. The electronic device needs to filter historical Q&A information 1 and historical Q&A information 2 to extract the historical Q&A information for document 1, identifying historical Q&A information 1 as the first historical Q&A information.
[0119] Specifically, since electronic devices generate unique identifiers for each document, the identifiers of one or more first documents can be summarized into a first document identifier set. Similarly, taking a historical question-and-answer message as an example, the identifiers of the second document to which that historical question-and-answer message pertains can be summarized into a second document identifier set. In the actual filtering process, it is necessary to filter and select first historical question-and-answer messages that are specific to the first document from one or more historical question-and-answer messages. Therefore, if there are identical (intersecting) identifiers in the first document identifier set and the second document identifier set (which can be understood as at least one identifier in the second document identifier set appearing in the first document identifier set), the historical question-and-answer messages corresponding to that second document identifier set can be selected as the first historical question-and-answer messages.
[0120] For example, suppose document 1 is identified as 1, document 2 as 2, and document 3 as 3. In this dialogue window, the user first asks question 1 about document 1 and document 2, and receives answer 1. Question 1 and answer 1 constitute historical Q&A information 1, and the second set of document identifiers corresponding to historical Q&A information 1 includes 1 and 2. The user then asks question 2 about document 2 and receives answer 2. Question 2 and answer 2 constitute historical Q&A information 2, and the second set of document identifiers corresponding to historical Q&A information 2 includes 2. The user then asks question 3 about document 3 and receives answer 3. Question 3 and answer 3 constitute historical Q&A information 3, and the second set of document identifiers corresponding to historical Q&A information 3 includes 3. At this point, three pieces of historical Q&A information are obtained: historical Q&A information 1, historical Q&A information 2, and historical Q&A information 3.
[0121] The current user has raised question 4 regarding documents 1 and 3. Therefore, the first set of document identifiers involved in the current question includes 1 and 3. It is evident that the second set of document identifiers corresponding to historical question-and-answer information 1 shares the same identifier as the first set of document identifiers, and the second set of document identifiers corresponding to historical question-and-answer information 3 also shares the same identifier as the first set of document identifiers. Therefore, the electronic device needs to filter historical question-and-answer information 1 and historical question-and-answer information 3 from historical question-and-answer information 1, historical question-and-answer information 2, and historical question-and-answer information 3, that is, to determine historical question-and-answer information 1 and historical question-and-answer information 3 as the first historical question-and-answer information.
[0122] It should be noted that the example of the database entry information for this historical Q&A information could be:
[0123] {
[0124] "_id":"65d16e538f35100c7805262e",
[0125] "udid":"4cb712ac-aecf-11ee-af29-c9d3c89142e6",
[0126] "conversation_id":"65bf1aed6f3813563819ba32",
[0127] “resource_id”:[ / / Second document identifier set]
[0128] "6c12a5bf1bfc3a009f4d220bf110",
[0129] "7c1yf2a5bf1bfc3a009f4d220bf1"
[0130] ],
[0131] "parent_id":"65bf1bfc3a009f4d220bf110",
[0132] "context_type":"FILE",
[0133] "prompt_text": "******", / / Question raised by the user
[0134] “prompt_answer”:“*********”, / / LLM answer
[0135] "completion_tokens":"-1",
[0136] "total_tokens":"-1",
[0137] "record_status":"KEPT",
[0138] "create_user":"4cb712ac-aecf-11ee-af29-c9d3c89142e6",
[0139] "create_time":"2024-02-04T05:11:12.784Z",
[0140] "update_user":"4cb712ac-aecf-11ee-af29-c9d3c89142e6",
[0141] "update_time":"2024-02-04T05:11:12.784Z"
[0142] }
[0143] Therefore, when this historical Q&A information is used as the context of a user's current question, it can be described in the following format:
[0144]
[0145] For example, assuming a user has three historical Q&A records, they can be represented using Table 1 below. Table 1 includes three historical Q&A records and their corresponding timestamps. Each historical Q&A record includes a question and an answer. The question included in each historical Q&A record can be referred to as the second question for the second document, and the answer included in each historical Q&A record can be referred to as the second answer for that second question.
[0146] Table 1
[0147]
[0148] Of course, the sample information for the historical Q&A information and the format used when the historical Q&A information is used as the context of the user's current question can also be represented in other ways, and no restrictions are imposed here.
[0149] However, during the filtering and selection of historical question-and-answer information, there may be cases where there is only a small overlap between the first and second document identifier sets (e.g., only one document identifier is shared between them). In such cases, using the historical question-and-answer information corresponding to the second document identifier set as the first historical question-and-answer information for subsequent processing will introduce a significant amount of redundant data, leading to a decrease in the accuracy of the answer results. For example, the first document identifier set includes 1 and 2, and the second document identifier set includes 1, 2, 3, 4, 5, 6, and 7. In this case, there is only one overlapping document identifier between the first and second document identifier sets (i.e., identifier 1). If the historical question-and-answer information corresponding to the second document identifier set is used as the first historical question-and-answer information, then the descriptions of the documents corresponding to identifiers 2, 3, 4, 5, 6, and 7 will be introduced, thus introducing a significant amount of redundant data.
[0150] Therefore, in order to better assist the model in outputting answers and further improve the accuracy of the answer results, in one possible implementation, when the electronic device determines the first historical question-and-answer information for the first document from one or more historical question-and-answer information, taking a certain historical question-and-answer information as an example, the specific implementation process can be:
[0151] If the same identifier exists in both the first document identifier set and the second document identifier set, the electronic device further determines the degree of duplication of the document identifiers in the first document identifier set and the second document identifier set. Specifically, there are one or more first documents; the first document identifier set includes the identifiers of the one or more first documents; and the second document identifier set includes the identifiers of the second documents to which the historical question-and-answer information is targeted.
[0152] The core purpose of calculating repetition here is to assess the relevance between the documents addressed by historical question-and-answer information and the document selected by the current user's question. If the relevance is very low, submitting it as context for the current user's question to the LLM will affect the accuracy of the current question's answer and increase inference costs. Specifically, the repetition rate of document identifiers in the first set of document identifiers and the second set of document identifiers can be calculated using the Jaccard similarity coefficient, as shown in the following formula:
[0153]
[0154] In formula (1), Threshold represents the degree of redundancy between the document identifiers in the first document identifier set and the second document identifier set; raw_ids represents the first document identifier set; and context_ids_filter represents the second document identifier set.
[0155] Furthermore, the action taken by the electronic device is determined based on the interval in which the repetition falls, as described in formula (2):
[0156]
[0157] In formula (2), T max The first threshold; T min This is the third threshold. It should be noted that the first and third thresholds can be set by the developers themselves or determined based on experimental data; no restrictions are imposed here.
[0158] like Figure 6A As shown below, the actions to be taken for different repetition ranges are described in detail:
[0159] Case 1: If the repeatability is greater than the first threshold (T) max If the information is obtained from the historical question and answer information, the electronic device can directly use the historical question and answer information or further determine the proportion of information about the intersecting documents in the second answer included in the historical question and answer information.
[0160] In practical implementation, if the repetition rate is greater than the first threshold, the electronic device can execute in the following two ways:
[0161] Method 1: The electronic device directly identifies the historical Q&A information as the first historical Q&A information.
[0162] This can be understood as follows: if the redundancy between the second document identifier set corresponding to a certain historical question and answer information and the document identifier of the first document identifier set is greater than the first threshold, it means that the historical question and answer information is highly relevant to the document selected by the current user in the question, and can be directly used as the first historical question and answer information. Subsequently, it can be submitted to the LLM as the context of the current user's question, that is, the following steps S403 to S406 are executed.
[0163] Method 2: The electronic device further determines the intersection document identifiers between the first document identifier set and the second document identifier set; calculates the proportion of the document information corresponding to the intersection document identifier in the second answer included in the historical question and answer information; if the proportion is greater than the second threshold, the electronic device determines the historical question and answer information as the first historical question and answer information.
[0164] This can be understood as follows: for example, the first document identifier set includes 1 and 2, and the second document identifier set includes 1 and 3; at this time, there is an intersection document between the first document identifier set and the second document identifier set (i.e., document 1 corresponding to identifier 1); the total length of the second answer in the historical question and answer information corresponding to the second document identifier set is 2000 characters, but the description of document 1 in the second answer is only 10 characters. If this historical question and answer information is directly used as the first historical question and answer information, then other redundant descriptions will be introduced, introducing more redundant data.
[0165] Therefore, if the overlap between the second document identifier set corresponding to a certain historical question and answer information and the document identifiers of the first document identifier set is greater than the first threshold, the electronic device can further determine the intersection document identifiers between the first document identifier set and the second document identifier set, and calculate the proportion of the document information corresponding to the intersection document identifier in the second answer included in the historical question and answer information. The core is to evaluate the proportion of information about the intersection document in the answer included in the historical question and answer information, so as to determine whether the historical question and answer information can be used directly.
[0166] Optionally, when calculating the proportion of the document information corresponding to the intersection document identifier in the second answer included in the historical question-and-answer information, the electronic device can specifically adopt the following methods:
[0167] Method A: The electronic device calculates the percentage using a trained model.
[0168] Specifically, electronic devices can use some training samples to train a model for calculating the proportion value, and then directly use the model to make the judgment when calculating the proportion value.
[0169] Method B: Electronic devices calculate this percentage by matching keywords.
[0170] Specifically, the electronic device determines keywords based on the document information corresponding to the intersection document identifier; then it calculates the proportion of the first information in the second answer included in the historical question-and-answer information; wherein, the first information includes the keyword, and the intersection document identifier can be one or more. In other words, the electronic device can determine the corresponding keyword for the document information corresponding to each intersection document identifier, and determine the proportion based on the sentence or paragraph in which the keyword is located.
[0171] Suppose the intersection of the second document identifier set and the first document identifier set corresponding to a certain historical question and answer information is document 1, meaning the intersection document is document 1. Based on the document information corresponding to document 1, we can determine the corresponding keyword 1, and based on the document information corresponding to document 2, we can determine the corresponding keyword 2. Then, in the second answer included in this historical question and answer information, statements containing keyword 1 (specifically, segmented by terminators to ensure sentence integrity) are considered as related content of keyword 1 (i.e., the first information); statements containing keyword 2 (ensuring sentence integrity) are considered as related content of keyword 2. If a statement contains both keyword 1 and keyword 2, it is discarded and not counted. Then, the length of the related content of keyword 1 is calculated as the proportion of the related content of all keywords (i.e., related content of keyword 1 and related content of keyword 2) in the second answer included in this historical question and answer information; this is the proportion of the first information in the second answer included in this historical question and answer information.
[0172] Taking keyword 1 as an example, the following formula (3) can be used to calculate this percentage:
[0173]
[0174] In formula (3), length(keyword1) represents the relevant content of keyword1 (i.e., the first information); length(keywordi) represents the relevant content of all keywords in the second answer included in the historical question and answer information (i.e., the relevant content of keyword1 and the relevant content of keyword2); n represents the total number of keywords.
[0175] For example, suppose the second answer included in this historical question-and-answer information is as follows:
[0176]
[0177] The second answer consists of three sentences. The first sentence contains keyword 1 and can be considered relevant content for keyword 1. The second sentence contains keyword 2 and can be considered relevant content for keyword 2. The third sentence contains both keyword 1 and keyword 2 and is not included in the statistics. Therefore, the percentage of document information corresponding to document 1 in the second answer included in this historical Q&A information is:
[0178] Of course, other methods can also be used to calculate this proportion. For example, electronic devices can segment the second answer into sentences according to the end marker, and determine the proportion of the document information corresponding to the intersection document identifier in the second answer included in the historical question and answer information through semantic clustering. This is not limited here.
[0179] Furthermore, after determining the percentage value, the electronic device can make a judgment on the percentage value and execute the corresponding action. The following is a detailed description of two possible judgment results:
[0180] Case a: If the percentage is greater than the second threshold, the electronic device determines that the historical question and answer information is the first historical question and answer information.
[0181] This can be understood as follows: if the percentage is greater than the second threshold, it indicates that the information about the intersecting documents accounts for a large proportion of the second answer included in the historical question-and-answer information. This information can then be directly used as the first historical question-and-answer information and subsequently submitted to the LLM as the context of the current user's question, i.e., executing steps S403 to S406. The second threshold here can be set by the developers themselves or determined based on experimental data; it is not limited here.
[0182] Case b: If the percentage is less than or equal to the second threshold, the electronic device rewrites the historical Q&A information to obtain multiple sub-Q&A information; from the multiple sub-Q&A information, the first sub-Q&A information for the first document is determined. Each of the multiple second documents corresponds one-to-one with each of the multiple sub-Q&A information.
[0183] This can be understood as follows: if the percentage is less than or equal to the second threshold, it indicates that the information about the intersection document accounts for a small proportion of the second answer included in the historical Q&A information. Therefore, the second answer can be further rewritten. Specifically, it can be split into multiple sub-question-answer information to fully utilize the historical Q&A information. Then, the first sub-question-answer information for the first document can be determined from these sub-question-answer information. Subsequently, the first sub-question-answer information can be submitted to the LLM as the context of the current user's question. For details, please refer to the following... Figure 8 The description of that will not be repeated here.
[0184] For example, assuming the documents covered by this historical question-and-answer information include document 1, document 2, document 3, and document 4, and the first document includes document 1 and document 2, then... Figure 6BAs shown, the second question and its corresponding second answer in the historical Q&A information can be split and rewritten as: sub-Q&A information 1 for document 1, sub-Q&A information 2 for document 2, sub-Q&A information 3 for document 3, and sub-Q&A information 4 for document 4. The electronic device then determines the first sub-Q&A information for the first document from these four sub-Q&A information, namely sub-Q&A information 1 and sub-Q&A information 2.
[0185] Of course, electronic devices can also rewrite the second answer in other ways, which is not limited here.
[0186] Case 2: If the repeatability is less than or equal to the first threshold (T) max ), and the repeatability is greater than or equal to the third threshold (T). min If the electronic device rewrites the historical question-and-answer information to obtain multiple sub-question-and-answer information, it then determines the first sub-question-and-answer information for the first document from among the multiple sub-question-and-answer information. Each of the multiple second documents corresponds one-to-one with one of the multiple sub-question-and-answer information.
[0187] In practical implementation, if the repetition rate is less than or equal to the first threshold and greater than or equal to the third threshold, it indicates that the relevance of the historical Q&A information to the document selected by the current user is not significant. However, the second answer can be further rewritten. Specifically, the second answer can be split into multiple sub-Q&A information to make full use of the historical Q&A information. Then, the first sub-Q&A information for the first document can be determined from the multiple sub-Q&A information. Subsequently, the first sub-Q&A information can be submitted to the LLM as the context of the current user's question. For details, please refer to the following. Figure 9 The description of that will not be repeated here.
[0188] For specific rewriting methods, please refer to the description in case b above, which will not be repeated here; of course, electronic devices can also use other methods to rewrite the second answer, which will not be limited here.
[0189] Scenario 3: If the repeatability is less than the third threshold (T) min If the electronic device discards the historical question and answer information, then the electronic device will discard the information.
[0190] In the specific implementation, if the redundancy between the second document identifier set corresponding to a certain historical question and answer information and the document identifier of the first document identifier set is less than the third threshold, it means that the historical question and answer information has little relevance to the document selected by the current user's question. If it is subsequently submitted to LLM as the context of the current user's question, it will affect the accuracy of the current question answer. Therefore, the historical question and answer information can be directly discarded.
[0191] S403, The electronic device determines from the first document a first text block associated with the first problem.
[0192] In this implementation, the electronic device needs to parse and segment the user-uploaded document, then vectorize the segmented text blocks and store the vectorized text blocks in a database. Additionally, the electronic device will parse and vectorize the user-inputted first question, and retrieve the Top-N first text blocks (i.e., the first text blocks associated with the first question) with the highest matching degree from the first document stored in the database using vector similarity matching. Here, N is a positive integer, which can be set by the developers or determined based on experimental data; no limitation is imposed here. See the above for details. Figure 1B The descriptions of steps (1), (2), (3), (4), and (5) are omitted here. It should be noted that when the electronic device determines the first text block associated with the first problem from the first document, the execution order of steps S402 and S403 is not limited.
[0193] In one possible implementation, when the electronic device determines the first text block associated with the first question from the first document, the specific implementation may be: the electronic device determines the first text block associated with the first question and the first historical question and answer information from the first document.
[0194] This can be understood as follows: the electronic device can combine the first question and the first historical question-and-answer information to form a new query (i.e., the third question), then parse and vectorize this new query, and retrieve the top-N first text blocks with the highest matching degree (i.e., the first text blocks associated with the first question and the first historical question-and-answer information) from the first document stored in the database through vector similarity matching. This method can further improve the accuracy of the answer results. It should be noted that when the electronic device determines the first text blocks associated with the first question and the first historical question-and-answer information from the first document, step S402 needs to be executed before step S402.
[0195] Here, the first text block identified by the electronic device can be one or more.
[0196] S404, The electronic device generates a first prompt message; the first prompt message includes the first text block, the first historical question and answer information, and the first question.
[0197] S405. The electronic device calls the large language model to process the first prompt information and obtain the first answer corresponding to the first question.
[0198] S406. The electronic device outputs the first answer corresponding to the first question.
[0199] In this application, the electronic device generates a first prompt message based on the first prompt template, combined with the first text block, the first historical question-and-answer information, and the first question; then, the first prompt message is input to the LLM for processing, outputting the first answer corresponding to the first question, and returning the first answer to the user. For example... Figure 5B As shown, after receiving the user's input of the first question for document 1, the electronic device parses and processes it, outputs the first answer corresponding to the first question, and displays it in the dialog box; in addition, it can also display the specific content of document 1 selected by the user in the document display box.
[0200] For example, the first prompt template is as follows:
[0201]
[0202] Optionally, the first prompt information also includes first sub-question and answer information. This can be understood as follows: when there are multiple historical question and answer information, depending on the situation corresponding to each historical question and answer information, some historical question and answer information can be identified as the first historical question and answer information; some historical question and answer information can be rewritten to obtain multiple sub-question and answer information; and some historical question and answer information can be discarded. Therefore, the first prompt template mentioned above can also include the first text block, the first historical question and answer information, the first sub-question and answer information, and the first question.
[0203] For example, the first prompt template can be as follows:
[0204]
[0205] Of course, other forms of first prompt templates can also be used, and no restrictions are imposed here.
[0206] In one possible implementation, the ordering of different historical question-and-answer information affects the accuracy of the model's returned results. Therefore, a strategy is needed to sort multiple pieces of historical question-and-answer information. Assuming there are multiple first historical question-and-answer pieces, these pieces of information can be sorted in the following two ways within the first prompt message:
[0207] Method a: In this first prompt message, multiple first historical Q&A messages are arranged sequentially in chronological order, either from front to back or from back to front.
[0208] In other words, the historical Q&A information can be sorted according to the time it occurred (either in reverse or forward order). As shown in Table 1 above, the three historical Q&A messages in Table 1 are arranged in chronological order of their occurrence, i.e., historical Q&A message 1, historical Q&A message 2, and historical Q&A message 3. Of course, the three historical Q&A messages in Table 1 can also be arranged in chronological order of their occurrence, i.e., historical Q&A message 3, historical Q&A message 2, and historical Q&A message 1.
[0209] Method b: In the first prompt information, multiple first historical question and answer information are arranged in order of first similarity from largest to smallest or smallest to largest. The first similarity is the similarity between the first historical question and answer information and the first question.
[0210] In other words, the similarity between the first question asked by the current user and the second question or answer in the historical question-and-answer information is calculated, and then sorted according to the order of similarity (from largest to smallest or smallest to largest). The first similarity can be represented by cosine similarity, Pearson correlation coefficient, Euclidean distance, Manhattan distance, etc.
[0211] Of course, other methods can also be used to sort multiple first-historical question and answer information, and no restrictions are imposed here.
[0212] In general, regarding the backend processing flow, such as Figure 7 As shown, after a user uploads a document, the electronic device parses and segments the uploaded document, then vectorizes the segmented text blocks and stores the vectorized text blocks in the database.
[0213] Of course, the electronic device will save one or more historical question-and-answer messages from the user in the current dialogue window to the historical question-and-answer database. This historical question-and-answer information refers to the questions the user has asked and the corresponding answers they have provided in the current dialogue window. Since user questions are usually relevant within a single dialogue window, the electronic device can also retrieve one or more historical question-and-answer messages from the database and use this information as context for the current user's question, thus better assisting the model in outputting answers.
[0214] Furthermore, if all these historical question-and-answer information are used as the context for the current user's question, redundant data may be introduced, affecting the accuracy of the model's answer. Therefore, it is necessary to filter and select one or more historical question-and-answer information to obtain the first historical question-and-answer information and / or the first sub-question-and-answer information. The specific process of filtering historical question-and-answer information can be referred to the description in step S402 above, and will not be elaborated here.
[0215] Furthermore, users can enter a first question about the first document in the question input box. The electronic device will then parse and vectorize the user's input question, and retrieve the top-N first text blocks (i.e., the first text blocks associated with the first question) with the highest matching degree from the first document stored in the database using vector similarity matching. Optionally, the user's input question about the first document can be combined with filtered first historical question-and-answer information to form a new query. This new query can then be parsed and vectorized, and the top-N first text blocks (i.e., the first text blocks associated with the first question and the first historical question-and-answer information) with the highest matching degree can be retrieved from the first document stored in the database using vector similarity matching. This approach can further improve the accuracy of the answer results.
[0216] Furthermore, the electronic device generates a first prompt message based on the first prompt template, combining the first text block, the first historical Q&A information, and the first question; then, it inputs the first prompt message into the LLM for processing, outputs the first answer corresponding to the first question, and returns the first answer to the user. Alternatively, the electronic device can also generate a second prompt message based on the second prompt template, combining the first text block, the first sub-Q&A information, and the first question; then, it inputs the second prompt message into the LLM for processing, outputs the third answer corresponding to the first question, and returns the third answer to the user. It should be noted that when there are multiple historical Q&A messages, depending on the situation of each historical Q&A message, some historical Q&A messages can be identified as the first historical Q&A message, some historical Q&A messages can be rewritten to obtain multiple sub-Q&A messages, and some historical Q&A messages can be discarded. Therefore, the first and second prompt templates mentioned above can also include the first text block, the first historical Q&A information, the first sub-Q&A information, and the first question. This completes the entire document Q&A processing flow. Thus, it can be seen that compared to... Figure 1B It adds the process of obtaining and filtering historical Q&A information.
[0217] It can be seen that, based on Figure 4 The described method, targeting document question-and-answer scenarios, allows electronic devices to obtain one or more historical question-and-answer messages from the user within a single dialogue window. These messages serve as the context for the current user's question, better assisting the model in outputting the answer to the current question. Furthermore, to avoid introducing redundant data, these historical question-and-answer messages are further filtered, which further improves the accuracy of the response.
[0218] Figure 8This is a flowchart illustrating another document question-and-answer processing method provided in an embodiment of this application. For example... Figure 8 As shown, the document question-and-answer processing method includes the following steps S801 to S808. Figure 8 The method shown can be implemented by the aforementioned electronic device. Alternatively, Figure 8 The method shown can be executed by a chip in an electronic device, but this application does not limit the implementation. Figure 8 The method will be explained using an electronic device as the executing entity.
[0219] S801, Electronic device obtains the first question for the first document.
[0220] S802, if there are identical identifiers in the first document identifier set and the second document identifier set, the electronic device determines the degree of duplication of document identifiers in the first document identifier set and the second document identifier set.
[0221] Among them, there are one or more first documents, the first document identifier set includes the identifiers of the one or more first documents, and the second document identifier set includes the identifiers of the second documents to which the historical question and answer information is targeted.
[0222] S803. If the repetition rate is greater than the first threshold, the electronic device determines the intersection document identifier between the first document identifier set and the second document identifier set; and calculates the proportion of the document information corresponding to the intersection document identifier in the second answer included in the historical question and answer information.
[0223] S804. If the percentage is less than or equal to the second threshold, the electronic device rewrites the historical Q&A information to obtain multiple sub-Q&A information; and determines the first sub-Q&A information for the first document from the multiple sub-Q&A information.
[0224] Among them, multiple second documents correspond one-to-one with multiple sub-question and answer information.
[0225] S805, the electronic device determines from the first document a first text block associated with the first problem.
[0226] The specific implementation methods of steps S801 to S805 can be referred to the specific implementation methods of steps S401 to S403 above, and will not be repeated here.
[0227] S806, the electronic device generates a second prompt message; the second prompt message includes the first text block, the first sub-question and answer message, and the first question.
[0228] S807. The electronic device calls the large language model to process the second prompt information and obtain the third answer corresponding to the first question.
[0229] S808, The electronic device outputs the third answer corresponding to the first question.
[0230] In this application, taking a historical question-and-answer information as an example, for case b in step S402 and case two in step S402, the electronic device rewrites the historical question-and-answer information to obtain multiple sub-question-and-answer information; after determining the first sub-question-and-answer information for the first document from the multiple sub-question-and-answer information, it determines the first text block associated with the first question from the first document, and then generates a second prompt based on the second prompt template, the first text block, the first sub-question-and-answer information, and the first question; then it inputs the second prompt to the LLM for processing, outputs the third answer corresponding to the first question, and returns the third answer to the user.
[0231] For example, the second prompt template is shown below:
[0232]
[0233] Optionally, the second prompt template also includes first historical Q&A information. This can be understood as follows: when there are multiple historical Q&A pieces of information, depending on the conditions met by the historical Q&A information, some of the historical Q&A information can be identified as the first historical Q&A information; some of the historical Q&A information can be rewritten to obtain multiple sub-Q&A information; and some of the historical Q&A information can be discarded. Therefore, the aforementioned second prompt template can also include the first text block, the first historical Q&A information, the first sub-Q&A information, and the first question.
[0234] For example, the second prompt template can be as follows:
[0235]
[0236] Of course, other forms of second prompt templates can also be used, and no restrictions are imposed here.
[0237] It can be seen that, based on Figure 8 The described method, targeting document question-and-answer scenarios, allows electronic devices to obtain one or more historical question-and-answer messages from the user within a single dialogue window. These messages serve as the context for the current user's question, better assisting the model in outputting the answer to the current question. Furthermore, to avoid introducing redundant data, the historical question-and-answer messages are further filtered and rewritten, thereby improving the accuracy of the answer results.
[0238] Figure 9This is a flowchart illustrating another document question-and-answer processing method provided in an embodiment of this application. For example... Figure 9 As shown, the document question-and-answer processing method includes the following steps S901 to S907. Figure 9 The method shown can be implemented by the aforementioned electronic device. Alternatively, Figure 9 The method shown can be executed by a chip in an electronic device, but this application does not limit the implementation. Figure 9 The method will be explained using an electronic device as the executing entity.
[0239] S901, Electronic device obtains the first question for the first document.
[0240] S902, if there are identical identifiers in the first document identifier set and the second document identifier set, the electronic device determines the degree of duplication of document identifiers in the first document identifier set and the second document identifier set.
[0241] Among them, there are one or more first documents, the first document identifier set includes the identifiers of the one or more first documents, and the second document identifier set includes the identifiers of the second documents to which the historical question and answer information is targeted.
[0242] S903. If the repetition is less than or equal to the first threshold and the repetition is greater than or equal to the third threshold, the electronic device rewrites the historical question and answer information to obtain multiple sub-question and answer information; and determines the first sub-question and answer information for the first document from the multiple sub-question and answer information.
[0243] Among them, multiple second documents correspond one-to-one with multiple sub-question and answer information.
[0244] S904. The electronic device determines from the first document a first text block associated with the first problem.
[0245] The specific implementation methods of steps S901 to S904 can be referred to the specific implementation methods of steps S401 to S403 above, and will not be repeated here.
[0246] S905, the electronic device generates a second prompt message; the second prompt message includes the first text block, the first sub-question and answer message, and the first question.
[0247] S906. The electronic device calls the large language model to process the second prompt information and obtain the third answer corresponding to the first question.
[0248] S907. The electronic device outputs the third answer corresponding to the first question.
[0249] The specific implementation methods of steps S905 to S907 can be referred to the specific implementation methods of steps S806 to S808 mentioned above, and will not be repeated here.
[0250] It can be seen that, based on Figure 9 The described method, targeting document question-and-answer scenarios, allows electronic devices to obtain one or more historical question-and-answer messages from the user within a single dialogue window. These messages serve as the context for the current user's question, better assisting the model in outputting the answer to the current question. Furthermore, to avoid introducing redundant data, the historical question-and-answer messages are further filtered and rewritten, thereby improving the accuracy of the answer results.
[0251] Please see Figure 10 , Figure 10 A schematic diagram of the structure of a document question-and-answer processing device 1000 according to an embodiment of this application is shown. Figure 10 The document question-and-answer processing device shown can be an electronic device, a device within an electronic device, or a device that can be used in conjunction with an electronic device. Figure 10 The document question-and-answer processing apparatus shown may include an acquisition unit 1001, a determination unit 1002, and a processing unit 1003. Wherein:
[0252] Acquisition unit 1001 is used to acquire the first question for the first document;
[0253] The determining unit 1002 is configured to determine first historical question and answer information for the first document from one or more historical question and answer information;
[0254] The determining unit 1002 is further configured to determine a first text block associated with the first question from the first document;
[0255] The processing unit 1003 is configured to generate a first prompt message; wherein the first prompt message includes the first text block, the first historical question and answer information, and the first question;
[0256] The processing unit 1003 is also used to call the large language model to process the first prompt information and obtain the first answer corresponding to the first question;
[0257] The processing unit 1003 is also used to output the first answer corresponding to the first question.
[0258] In one possible implementation, given one or more first documents, when determining the first historical question-and-answer information for a first document from one or more historical question-and-answer information, the specific implementation may be as follows: if the same identifier exists in the first document identifier set and the second document identifier set, determine the degree of duplication of the document identifiers in the first document identifier set and the second document identifier set; wherein, the first document identifier set includes the identifiers of the one or more first documents, and the second document identifier set includes the identifier of the second document for which the historical question-and-answer information is targeted; if the degree of duplication is greater than a first threshold, then determine the historical question-and-answer information as the first historical question-and-answer information.
[0259] In one possible implementation, the determining unit 1002, when determining the historical question-and-answer information as first historical question-and-answer information if the repetition degree is greater than a first threshold, may specifically be: if the repetition degree is greater than the first threshold, determine the intersection document identifier between the first document identifier set and the second document identifier set; then calculate the proportion of the document information corresponding to the intersection document identifier in the second answer included in the historical question-and-answer information; if the proportion is greater than the second threshold, determine the historical question-and-answer information as first historical question-and-answer information.
[0260] In one possible implementation, when determining the proportion of document information corresponding to the intersection document identifier in the second answer included in the historical question and answer information, the determining unit 1002 may specifically be implemented as follows: determining keywords based on the document information corresponding to the intersection document identifier; calculating the proportion of first information in the second answer included in the historical question and answer information; wherein the first information includes the keywords.
[0261] In one possible implementation, when determining the first text block associated with the first question from the first document, the determining unit 1002 may specifically determine the first text block associated with the first question and the first historical question and answer information from the first document.
[0262] In one possible implementation, there are multiple second documents. The processing unit 1003 is further configured to: if the repetition rate is less than or equal to the first threshold and the repetition rate is greater than or equal to the third threshold, then rewrite the historical question-and-answer information to obtain multiple sub-question-and-answer information; or, if the proportion value is less than or equal to the second threshold, then rewrite the historical question-and-answer information to obtain multiple sub-question-and-answer information; wherein, the multiple second documents correspond one-to-one with the multiple sub-question-and-answer information; then determine the first sub-question-and-answer information for the first document from the multiple sub-question-and-answer information; then generate second prompt information, wherein the second prompt information includes the first text block, the first sub-question-and-answer information, and the first question; finally, call the large language model to process the second prompt information to obtain the third answer corresponding to the first question, and output the third answer corresponding to the first question.
[0263] It should be noted that when there are multiple historical Q&A information, depending on the conditions met by the historical Q&A information, some of the historical Q&A information can be identified as the first historical Q&A information, some of the historical Q&A information can be rewritten to obtain multiple sub-Q&A information, and some of the historical Q&A information can be discarded. Therefore, the first prompt template and the second prompt template mentioned above can also include the first text block, the first historical Q&A information, the first sub-Q&A information, and the first question.
[0264] In one possible implementation, there are multiple first historical question-and-answer information, and the multiple first historical question-and-answer information in the first prompt information is arranged in chronological order from front to back or from back to front; or, the multiple first historical question-and-answer information in the first prompt information is arranged in chronological order from largest to smallest or smallest to largest first similarity, wherein the first similarity is the similarity between the first historical question-and-answer information and the first question.
[0265] For cases where the document question-and-answer processing device can be a chip or a chip system, please refer to [link / reference]. Figure 11 The diagram shows the structure of the chip. Figure 11 The chip 1100 shown includes a processor 1101 and an interface 1102. Optionally, it may also include a memory 1103. The number of processors 1101 can be one or more, and the number of interfaces 1102 can be multiple.
[0266] For cases where the chip is used to implement the electronic device in the embodiments of this application:
[0267] The interface 1102 is used to receive or output signals;
[0268] The processor 1101 is used to perform data processing operations of the electronic device.
[0269] It is understood that some optional features in the embodiments of this application can be implemented independently in certain scenarios without relying on other features, such as the current solution on which they are based, to solve the corresponding technical problems and achieve the corresponding effects. Alternatively, they can be combined with other features as needed in certain scenarios. Accordingly, the document question-and-answer processing device given in the embodiments of this application can also implement these features or functions, which will not be elaborated here.
[0270] It should be understood that the processor in the embodiments of this application can be an integrated circuit chip with signal processing capabilities. In implementation, the steps of the above method embodiments can be completed by integrated logic circuits in the processor's hardware or by instructions in software form. The processor described above can be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.
[0271] It is understood that the memory in the embodiments of this application can be volatile memory or non-volatile memory, or may include both volatile and non-volatile memory. The non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. The volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of RAM are available, such as static random access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous linked dynamic random access memory (SLDRAM), and direct rambus RAM (DR RAM). It should be noted that the memory used in the systems and methods described herein is intended to include, but is not limited to, these and any other suitable types of memory.
[0272] This application also provides an antenna switching system, which includes an electronic device; wherein the electronic device is used to perform the method executed by the electronic device in any of the above method embodiments.
[0273] This application also provides a computer storage medium storing a computer program / instructions thereon, which, when executed by a processor, implements the methods and steps as described in any of the above method embodiments.
[0274] This application also provides a computer program product, including a computer program / instructions that, when executed by a processor, implement the methods and steps as described in any of the above method embodiments.
[0275] As used in the specification and appended claims of this application, the singular expressions “a,” “an,” “the,” “the,” “the,” and “this” are intended to include the plural expressions as well, unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used herein refers to and includes any or all possible combinations of one or more of the listed items. As used in the above embodiments, depending on the context, the term “when” can be interpreted as meaning “if…” or “after…” or “in response to determining…” or “in response to detecting…”. Similarly, depending on the context, the phrase “when…” or “if (the stated condition or event) is interpreted as meaning “if…” or “in response to determining…” or “when (the stated condition or event) is detected” or “in response to detecting (the stated condition or event)”.
[0276] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented, in whole or in part, as a computer program product. The computer program product includes one or more computer instructions. When the computer instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium accessible to a computer or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., high-density digital video disc (DVD)), or a semiconductor medium (e.g., solid-state disk (SSD)). Those skilled in the art will understand that implementing all or part of the processes in the above embodiments can be accomplished by a computer program instructing related hardware. This program can be stored in a computer-readable storage medium, and when executed, it can include the processes described in the above method embodiments. The aforementioned storage medium includes various media capable of storing program code, such as ROM or random access memory (RAM), magnetic disks, or optical disks.
[0277] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A document question-and-answer processing method, characterized in that, The method includes: Obtain the first question for the first document; the first document may be one or more. If the same identifier exists in the first document identifier set and the second document identifier set, the degree of duplication of the document identifiers in the first document identifier set and the second document identifier set is determined; the first document identifier set includes the identifiers of one or more first documents, and the second document identifier set includes the identifiers of the second documents to which the historical question and answer information is targeted; If the repetition degree is greater than the first threshold, then the intersection document identifiers between the first document identifier set and the second document identifier set are determined; Calculate the percentage of the document information corresponding to the intersection document identifier in the second answer included in the historical question and answer information; If the percentage value is greater than the second threshold, then the historical question and answer information is determined to be the first historical question and answer information; Identify a first text block in the first document that is associated with the first question; Generate a first prompt message; the first prompt message includes the first text block, the first historical question and answer information, and the first question; The large language model is invoked to process the first prompt information to obtain the first answer corresponding to the first question; Output the first answer to the first question.
2. The method according to claim 1, characterized in that, The calculation of the proportion of document information corresponding to the intersection document identifier in the second answer included in the historical question-and-answer information includes: Keywords are determined based on the document information corresponding to the intersection document identifiers; Calculate the proportion of the first information in the second answer included in the historical question and answer information; the first information includes the keywords.
3. The method according to claim 1, characterized in that, Determining the first text block associated with the first question from the first document includes: Identify a first text block from the first document that is associated with the first question and the first historical question and answer information.
4. The method according to any one of claims 1-3, characterized in that, The method further includes having multiple second documents: If the repetition degree is less than or equal to the first threshold and the repetition degree is greater than or equal to the third threshold, the historical question and answer information is rewritten to obtain multiple sub-question and answer information; or, if the proportion value is less than or equal to the second threshold, the historical question and answer information is rewritten to obtain multiple sub-question and answer information; the multiple second documents correspond one-to-one with the multiple sub-question and answer information. Determine the first sub-question and answer information for the first document from the plurality of sub-question and answer information; Generate a second prompt message; the second prompt message includes the first text block, the first sub-question and answer information, and the first question; The large language model is invoked to process the second prompt information to obtain the third answer corresponding to the first question; Output the third answer to the first question.
5. The method according to any one of claims 1-3, characterized in that, The first prompt information contains multiple first historical question and answer records, which are arranged sequentially in chronological order from front to back or from back to front; or, The multiple first historical question and answer information mentioned in the first prompt information are arranged in descending or ascending order of first similarity, where the first similarity is the similarity between the first historical question and answer information and the first question.
6. An electronic device, characterized in that, include: One or more processors, one or more memories; wherein the one or more memories are coupled to the one or more processors, the one or more memories being used to store computer program code, the computer program code including computer instructions, which, when the one or more processors execute the computer instructions, cause the electronic device to perform the method as described in any one of claims 1-5.
7. A document question-and-answer processing system, characterized in that, Includes an electronic device; wherein the electronic device is used to perform the method as described in any one of claims 1-5.
8. A chip, characterized in that, The device includes a processor and an interface, the processor and the interface being coupled; the interface is used to receive or output signals, and the processor is used to execute code instructions to cause the method of any one of claims 1-5 to be performed.
9. A computer storage medium, characterized in that, The computer storage medium stores a computer program, which includes program instructions that, when executed on an electronic device, cause the electronic device to perform the method as described in any one of claims 1-5.
10. A computer program product, characterized in that, When the computer program product is run on a computer, it causes the computer to perform the method as described in any one of claims 1-5.