Video question and answer method and device, electronic equipment and readable storage medium
By analyzing users' questions and generating answers using a pre-built knowledge base, it solves the problem that existing video control methods cannot meet users' diverse question needs, implements video question and answer functions, improves user experience and saves costs.
Patent Information
- Application Number
- CN202311610574.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-11-29
- Publication Date
- 2024-10-18
AI Technical Summary
Existing video control methods cannot meet the diverse needs of users and cannot provide immediate and accurate answers.
By obtaining the user's input questions for the video, parsing them to obtain keywords and vector representations, using the pre-built knowledge base to select relevant text information, and generate answers to the questions.
It achieves instant response to users' diverse problems, improves users' video viewing experience, meets diverse problem needs, and saves the cost of additional device access.
Smart Images

Figure CN118797097A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of artificial intelligence technology, and specifically relates to a video question-answering method, device, electronic device, and readable storage medium. Background Art
[0002] In the related art, users can improve their viewing experience in a variety of ways while watching videos. For example, users can control playback devices through smart assistants to adjust volume, switch channels, search for movies, etc., thereby achieving a convenient viewing experience. However, since smart assistants can usually only recognize simple control operations, they cannot meet the diverse needs of users. Summary of the invention
[0003] The purpose of the embodiments of the present application is to provide a video question-and-answer method, device, electronic device, and readable storage medium to solve the problem that the current video control method cannot meet the diverse question needs of users.
[0004] In order to solve the above technical problems, this application is implemented as follows:
[0005] In a first aspect, a video question-answering method is provided, which is applied to an electronic device and includes:
[0006] Get the user's input question for the video;
[0007] Parsing the question to obtain keywords included in the question and a target vector representation of the question;
[0008] Selecting target text information related to the question from a pre-built knowledge base according to the keywords and the target vector representation;
[0009] An answer to the question is generated according to the target text information.
[0010] In a second aspect, a video question-answering device is provided, which is applied to an electronic device, including:
[0011] An acquisition module is used to obtain questions input by users regarding the video;
[0012] A parsing module, used to parse the question to obtain keywords included in the question and a vector representation of the question;
[0013] A selection module, configured to select target text information related to the question from a pre-built knowledge base according to the keywords and the target vector representation;
[0014] A generating module is used to generate an answer to the question according to the target text information.
[0015] In a third aspect, an electronic device is provided, comprising a processor, a memory, and a program or instruction stored in the memory and executable on the processor, wherein the program or instruction, when executed by the processor, implements the steps of the method described in the first aspect.
[0016] In a fourth aspect, a readable storage medium is provided, on which a program or instruction is stored. When the program or instruction is executed by a processor, the steps of the method described in the first aspect are implemented.
[0017] In the embodiment of the present application, the question input by the user for the video can be obtained, the question can be parsed, the keywords included in the question and the target vector representation of the question can be obtained, and the target text information related to the question can be selected from the pre-built knowledge base according to the keywords and the target vector representation, and the answer to the question can be generated according to the target text information. Thus, with the help of the analysis of the video question and the pre-built knowledge base, the corresponding answer to the question can be generated, thereby meeting the user's diverse question needs and improving the user's video viewing experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] Figure 1 is a flow chart of a video question-and-answer method provided in an embodiment of the present application;
[0019] Figure 2 It is a flowchart of the video question-and-answer process in an embodiment of the present application;
[0020] Figure 3 It is a schematic diagram of the prompt process in the embodiment of the present application;
[0021] Figure 4 It is a structural diagram of a video question-and-answer device provided in an embodiment of the present application;
[0022] Figure 5 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0023] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0024] The terms "first", "second", etc. in the specification and claims of the present application are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable under appropriate circumstances, so that the embodiments of the present application can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, "and / or" in the specification and claims represents at least one of the connected objects, and the character " / " generally indicates that the objects associated with each other are in an "or" relationship.
[0025] The video question-and-answer method, device, electronic device, and readable storage medium provided in the embodiments of the present application are described in detail below with reference to the accompanying drawings through specific embodiments and their application scenarios.
[0026] See also Figure 1 , Figure 1 1 is a flow chart of a video question-answering method provided in an embodiment of the present application. The method is applied to electronic devices, which may include but are not limited to televisions, mobile phones, tablet computers, laptops, personal computers, etc. Figure 1 As shown, the method comprises the following steps:
[0027] Step 11: Obtain the user's question regarding the video input;
[0028] Step 12: Parse the question to obtain keywords included in the question and a target vector representation of the question;
[0029] Step 13: Selecting target text information related to the question from a pre-built knowledge base according to the keywords and the target vector representation;
[0030] Step 14: Generate an answer to the question based on the target text information.
[0031] In the embodiment of the present application, the user's input questions for the video can be obtained during the video viewing process. The input question can be based on voice input questions to achieve interaction between the device and the user through voice control, or based on text input questions, which is not limited to this.
[0032] The video may be, but is not limited to, a TV series, a variety show, a documentary, etc.
[0033] The questions may be various entertainment questions, which may be related to the video plot or not. For example, the questions may involve at least one of the following four types of entertainment knowledge: the first type is basic entertainment knowledge; the second type is basic information of the current video; the third type is image information of the current plot; and the fourth type is audio information of the current plot.
[0034] Optionally, when parsing the question, the keywords included in the question can be obtained using keyword extraction technology, and the target vector representation of the question can be obtained using an existing vectorization method. The solution in this application does not limit the keyword extraction technology and vectorization method, and can be selected based on actual needs.
[0035] Optionally, the above-mentioned pre-built knowledge base is an entertainment knowledge base, which can integrate both plot data such as film reviews, scripts, lines, video strips, and basic entertainment data such as directors, actors, and awards; it can integrate both text data and multimodal data such as video images. Considering that entertainment questions can basically be divided into two categories: one is related to media asset plot / video plot, and the other is unrelated to media asset plot / video plot, such as personal information about actors, directors, singers, etc., therefore, the pre-built knowledge base can include two types of knowledge bases, one is a plot knowledge base related to video plot, and the other is a general knowledge base unrelated to video plot. Among them, the plot knowledge base is used to support answering questions related to media asset plot / video plot, including both text information such as film reviews and scripts, and multimodal video image description information. The general knowledge base is used to support answering entertainment knowledge questions, including both text information of actors, directors, singers, hosts, etc. (such as name, age, debut time, representative works, awards, etc.), and production companies, various awards, etc.
[0036] Optionally, after selecting the target text information, the target text information may be directly analyzed to generate a corresponding answer to the question, or the target text information may be processed using a pre-trained model to obtain a corresponding answer to the question.
[0037] The video question-and-answer method of the embodiment of the present application obtains the question input by the user for the video, parses the question, obtains the keywords included in the question and the target vector representation of the question, selects target text information related to the question from a pre-built knowledge base based on the keywords and the target vector representation, and generates the answer to the question based on the target text information. With the help of the analysis of the video question and the pre-built knowledge base, the corresponding answer to the question can be generated, thereby meeting the user's diverse question needs; for example, with the help of the solution in the present application, various entertainment questions raised by the user in the process of watching the video can be answered, thereby improving the user's video viewing experience.
[0038] In addition, when implementing video control with the solution in the present application, there is no need to access expensive additional equipment, such as virtual reality (VR) equipment or augmented reality (AR) equipment, thus saving costs.
[0039] In an embodiment of the present application, since it is difficult to accurately identify whether the question is related to the video plot or to entertainment knowledge after obtaining the question, the answer to the question can be generated based on both the plot knowledge base related to the video plot and the general knowledge base unrelated to the video plot.
[0040] Optionally, if the pre-built knowledge base is an entertainment knowledge base, including a plot knowledge base related to the video plot and a general knowledge base unrelated to the video plot, the process of selecting target text information related to the question from the pre-built knowledge base may include:
[0041] According to the keyword, selecting first text information from the plot knowledge base and selecting second text information from the general knowledge base;
[0042] According to the target vector representation, selecting third text information from the plot knowledge base, and selecting fourth text information from the general knowledge base;
[0043] The target text information is determined according to the first text information, the second text information, the third text information and the fourth text information. For example, the first text information, the second text information, the third text information and the fourth text information may be directly merged to obtain the target text information; or part of the text information may be selected from the first text information, the second text information, the third text information and the fourth text information as the target text information based on a preset rule.
[0044] In this way, the plot knowledge base related to the video plot and the general knowledge base unrelated to the video plot can be considered in parallel to determine the target text information related to the question, so as to obtain more comprehensive information related to the question and then accurately generate the corresponding answer to the question.
[0045] Optionally, relevant text information may be selected from a pre-built knowledge base by calculating similarity. The above process of selecting the first text information from the plot knowledge base and the second text information from the general knowledge base according to the keyword may include:
[0046] Calculate the similarity between the keyword and the text information stored in the plot knowledge base, and select n text information with the highest similarity to the keyword from the plot knowledge base as the first text information, and calculate the similarity between the keyword and the text information stored in the general knowledge base, and select m text information with the highest similarity to the keyword from the general knowledge base as the second text information. Wherein, n and m are integers greater than 0, and the specific sizes of n and m can be preset based on actual needs.
[0047] The process of selecting the third text information from the plot knowledge base and selecting the fourth text information from the general knowledge base according to the target vector representation may include:
[0048] Calculate the similarity between the target vector representation and the vector representation corresponding to the text information stored in the plot knowledge base, and select p text information corresponding to the p vector representations with the highest similarity to the target vector representation from the plot knowledge base as the third text information, and calculate the similarity between the target vector representation and the vector representation corresponding to the text information stored in the general knowledge base, and select q text information corresponding to the q vector representations with the highest similarity to the target vector representation from the general knowledge base as the fourth text information. Wherein, p and q are integers greater than 0, and the specific sizes of p and q can be preset based on actual needs.
[0049] It should be noted that n and p may be the same or different. m and q may be the same or different. In this way, text information more relevant to the question may be selected from the plot knowledge base and the general knowledge base as target text information, thereby obtaining question-related information more accurately and then accurately generating the corresponding answer to the question.
[0050] Optionally, determining the target text information according to the first text information, the second text information, the third text information, and the fourth text information may include:
[0051] The n text information and the p text information are sorted according to the similarity from high to low, and the first x text information are selected as the first target text information; x is an integer greater than 0 and can be preset based on actual needs;
[0052] The m text information and the q text information are sorted according to the similarity from high to low, and the first y text information are selected as the second target text information; y is an integer greater than 0 and can be preset based on actual needs;
[0053] The first target text information and the second target text information are merged to obtain the target text information.
[0054] It should be noted that x and y can be the same or different. For example, if 9 text information are selected as target text information in advance, and the ratio of selected text information based on keywords and vector representation is 2:7, then x is equal to 2 and y is equal to 7. In this way, more relevant text information can be further classified and selected, so as to filter out the most useful text information to generate answers to questions, thereby improving the accuracy of the generated answers to questions.
[0055] Optionally, the plot knowledge base is divided based on video names, that is, video names are used as main search fields; the general knowledge base is divided based on characters, producers and awards, that is, characters, producers and awards are used as main search fields; the process of selecting the first text information from the plot knowledge base and the second text information from the general knowledge base according to the keywords includes:
[0056] According to the keyword, the first text information is selected from the text information under the video name of the video (i.e., the video targeted by the input question) in the plot knowledge base, and the second text information is selected from the text information under the target object of the general knowledge base; wherein the target object is the one of the characters, producers, and awards that is most relevant to the question, which can be obtained based on the analysis of the question. For example, if the input question is "Who plays role 1?", the target object corresponding to the search field is the character; if the input question is "What awards did this drama win?", the target object corresponding to the search field is the award.
[0057] The process of selecting the third text information from the plot knowledge base and selecting the fourth text information from the general knowledge base according to the target vector representation includes:
[0058] According to the target vector representation, the third text information is selected from the text information under the video name of the video (i.e., the video targeted by the input question) in the plot knowledge base, and the fourth text information is selected from the text information under the target object of the general knowledge base; wherein the target object is the one of the characters, producers, and awards that is most relevant to the question, and can be obtained based on the analysis of the question. For example, if the input question is "Who plays role 1?", the target object corresponding to the search field is the character; if the input question is "What awards did this drama win?", the target object corresponding to the search field is the award.
[0059] In this way, by dividing the plot knowledge base and the general knowledge base, the amount of calculation can be reduced, so that the problem-related information can be selected from the plot knowledge base and the general knowledge base more quickly.
[0060] Optionally, the target vector representation includes a first vector representation and a second vector representation. Among them, the first vector representation is obtained by vectorizing the question using a word vector method, and the word vector method is, for example, a word vector method based on ChatGLM. The second vector representation is obtained by vectorizing the question using a sentence vector method, and the sentence vector method is, for example, a sentence vector method based on Bert4vec. At this time, for the first vector representation and the second vector representation, relevant text information can be selected from the pre-constructed plot knowledge base and the general knowledge base as the target text information related to the question, and the specific process is similar to the above-mentioned processing process for the target vector representation, so as to obtain more comprehensive information related to the question, and then accurately generate the corresponding answer to the question.
[0061] Optionally, generating an answer to the question according to the target text information includes:
[0062] Construct a prompt template according to the target text information;
[0063] The prompt template is input into a pre-trained multimodal model for processing to obtain an answer to the question.
[0064] For example, the prompt template includes roles and tasks. The specific construction method is as follows: prompt_model = f"""Role: Assume that you are a question-answering system with rich experience; Task: Please think carefully step by step according to the text prompts in the three single quotes, analyze the text logic, and then use 50 to 80 words to answer the question in the dashes, "'{text}"'-{query_general}""". In this construction method, fill in the target text information in "'{text}"' and fill in the input video question in {query_general} to construct the prompt template of the input model.
[0065] Optionally, in order to make the model output more accurate and to improve the model's ability to extract answers from multiple text segments, question and answer training samples can be constructed according to specific entertainment business scenarios, and the basic multimodal large model can be supervised fine-tuned (Supervised Fine Tuning, SFT) based on the question and answer training samples, so that the multimodal large model after SFT (i.e., the pre-trained multimodal model) can acquire entertainment knowledge, and then when reasoning / answering questions, it can obtain answers to questions that are more in line with expectations.
[0066] The present application is described below in conjunction with specific embodiments.
[0067] In the present application embodiment, Figure 2 As shown in the figure, it is mainly divided into two parts: entertainment knowledge base construction and entertainment knowledge question and answer:
[0068] Construction of entertainment knowledge base: Considering that entertainment questions can basically be divided into two categories: one is related to media asset plot / video plot, and the other is unrelated to media asset plot / video plot, two types of knowledge bases can be constructed. One is the plot knowledge base related to video plot, which is used to support answering questions related to media asset plot / video plot, including text information such as film reviews and scripts, as well as multimodal video image description information; the other is a general knowledge base unrelated to video plot, which is used to support answering entertainment knowledge questions, including text information of actors, directors, singers, hosts and other characters (such as name, age, debut time, representative works, etc.), as well as information such as production companies and various awards.
[0069] Entertainment knowledge question and answer: In order to support knowledge question and answer based on audio and images, the basic large model must be a multimodal large model, and it must be a multimodal large model that has been fine-tuned with entertainment field knowledge. The model can correspond the image content to the current script content of the video / film. When a user asks a question while watching a video, since it is difficult to directly distinguish whether the question is related to the video plot or entertainment knowledge, question-related information is recalled / obtained from the plot knowledge base and the general knowledge base at the same time, and the user's intention is recognized through a sorting module (for example, based on similarity). If the user asks a question related to the plot, the content recalled from the plot knowledge base is ranked first; if the user asks a question related to basic entertainment knowledge, the content recalled from the general knowledge base is ranked first; after sorting, the first preset text information is taken to generate the answer to the question.
[0070] The specific knowledge base construction and question-answering process includes:
[0071] Step 1: Build an entertainment knowledge base. The purpose of this step is to build an entertainment knowledge base that can cover the entire network; in order to quickly locate whether it is plot knowledge or general knowledge, you can build a plot knowledge base and a general knowledge base separately. The specific process includes:
[0072] Step 1.1: Construct a data pool. For example, the content of the data pool is shown in Table 1 below:
[0073] Table 1
[0074]
[0075] Step 1.2: Data preprocessing. Since randomly collected data will inevitably contain some data that does not comply with security policies, and the video field has very high requirements for data security, after constructing the data pool, the data in the data pool must be filtered; in addition, some content may be repeated, so the content in the data pool needs to be deduplicated.
[0076] Step 1.3: Construction of evaluation data set and evaluation indicators.
[0077] Since existing common data sets may not meet the requirements of business scenarios, it is necessary to customize evaluation data sets for business scenarios. For example, you can use a pre-trained large model to automatically extract questions and answers from business text content, and then manually screen and correct them. For example, you can organize 1,000+ question-answer pairs and use the answers as labels.
[0078] Regarding the evaluation indicators, we can calculate the similarity between the generated answer and the label. However, due to the variety of Chinese expressions, the same meaning may have multiple expressions. Although the text similarity calculation method can reflect the degree of similarity to a certain extent, it cannot be well compatible with different expressions of the same meaning. Therefore, this solution extracts multiple keywords from the answer and calculates the hit rate of keywords to make up for the disadvantage that text similarity calculation cannot be well compatible with different expressions of the same meaning. Regarding text similarity calculation, BERTscore can be selected as the final evaluation indicator.
[0079] Step 1.4: Corpus division. In order to support the rapid retrieval of entertainment knowledge, the content stored in the database is piece by piece, and in order to improve the accuracy of retrieval, the corpus is stored in episodes, segments, and sentences.
[0080] Step 1.5: Build a knowledge base. In order to support the rapid retrieval of entertainment knowledge in online knowledge quizzes, the preprocessed data can be converted into embedding vectors and stored in a high-performance database that can quickly retrieve vectors. For example, the ElasticSearch technology search engine can be used to build a plot knowledge base and a general knowledge base. The plot knowledge base uses the media asset / video name as the main search field, which includes the plot, film reviews, lines, etc., as well as video strip descriptions that integrate the plot; the general knowledge base uses characters, producers or awards as the main search fields, which includes actors, directors, singers, etc., as well as production companies, awards, etc.
[0081] Step 2: Entertainment knowledge quiz.
[0082] When a user asks a question during the movie, it is difficult to directly identify whether the question is related to the current video plot or entertainment knowledge. Therefore, the relevant information of the question is recalled / obtained from the plot knowledge base and the general knowledge base at the same time, and the recalled results are simultaneously input into the sorting model for sorting. The top N (for example, 9) pieces of corpus information are selected and fused into a prompt template, which is input into the multimodal entertainment model to obtain the answer to the question. The specific process includes:
[0083] Step 2.1: Recall relevant information of the question. In the recall stage, since it is uncertain whether the question raised by the user is related to the current video plot or to entertainment knowledge, in order to recall relevant content more comprehensively, relevant content is recalled from the plot knowledge base and the general knowledge base in parallel. From the plot knowledge base, both text corpus knowledge and corresponding image frame description information are recalled; from the general knowledge base, relevant corpus knowledge is recalled. For example, three paths can be selected for recall: ES-based keyword recall, ChatGLM-based word vector recall, and Bert4vec-based sentence vector recall. The ratio of the number of recalls of these three is, for example, 2:3:4, etc., which can be set based on demand.
[0084] Step 2.2: Sort the recall results.
[0085] There are two reasons for sorting the recall results: first, since the length of information received by the large model is limited, it is necessary to filter out the most useful information and input it into the large model; second, since the recall stage recalls relevant content from the plot database and the general database in parallel, if the user asks a plot-related question, then the content recalled from the general database is likely to be less relevant. If the user asks a question related to general entertainment knowledge, then the content recalled from the plot database is likely to be less relevant. Irrelevant information will interfere with the accuracy of the large model's answer, so it is necessary to extract more accurate corpus knowledge and input it into the large model.
[0086] Since the similarity scores calculated in each of the three-way recall are not at the same granularity, they are incomparable to each other but comparable to themselves. Therefore, the sorting rules are as follows: the plot knowledge base content and the general knowledge base content based on keyword recall are sorted and the topN1 is selected, the plot knowledge base content and the general knowledge base content based on ChatGLM's word vector recall are sorted and the topN2 is selected, and the plot knowledge base content and the general knowledge base content based on Bert4vec's sentence vector recall are sorted and the topN3 is selected. Taking into account the length and performance of the text received by the multimodal large model, this scheme selects the top9 corpora through evaluation indicators, among which the top2 is selected through keyword recall and sorting corpora, the top4 is selected through word vector recall and sorting corpora, and the top3 is selected through sentence vector recall and sorting corpora, and then the final result is taken as the union. Since the union may make the final number of items less than 9, the items less than 9 are supplemented with the content based on ChatGLM's word vector recall, such as Figure 3 shown.
[0087] Step 2.3: Construct the prompt template.
[0088] For example, the prompt template is constructed as follows: prompt_model = f"""Role: Assume that you are a question-answering system with rich experience; Task: Please think carefully step by step according to the text prompt in the three single quotes, analyze the text logic, and then use 50 to 80 words to answer the question in the dash, "'{text}"'-{query_general}""". If the initial prompt has enough words, you can directly build a prompt template; if the initial prompt does not have enough words, you can use the content recalled by the ChatGLM word vector to supplement and build a prompt template; then input the constructed prompt template into the large model to answer the question, such as Figure 3 shown.
[0089] Step 2.4: Train the multimodal entertainment model.
[0090] In order to make the model output more accurate and improve the model's ability to extract answers from multiple text segments, we construct question-answering training samples based on specific entertainment business scenarios, and continue pre-training (Continue Pre-train) and supervise fine-tuning SFT on the basic multimodal large model based on the question-answering training samples, so that the multimodal large model after SFT can obtain entertainment knowledge, and then get more expected answers when reasoning / answering questions. The format of the constructed training samples is as follows: Q: What role does actor 1 play in TV series 2? A: Actor 1 plays a people's policeman.
[0091] It should be noted that the video question-and-answer method provided in the embodiment of the present application can be executed by a video question-and-answer device or a control module in the video question-and-answer device for executing the video question-and-answer method. In the embodiment of the present application, the video question-and-answer device executing the video question-and-answer method is taken as an example to illustrate the video question-and-answer device provided in the embodiment of the present application.
[0092] See also Figure 4 , Figure 4 is a schematic diagram of the structure of a video question-answering device provided in an embodiment of the present application, and the device is applied to electronic devices such as Figure 4 As shown, the video question-answering device 40 includes:
[0093] An acquisition module 41 is used to acquire questions input by the user regarding the video;
[0094] A parsing module 42, used to parse the question to obtain keywords included in the question and a vector representation of the question;
[0095] A selection module 43, configured to select target text information related to the question from a pre-built knowledge base according to the keywords and the target vector representation;
[0096] The generating module 44 is used to generate an answer to the question according to the target text information.
[0097] Therefore, with the help of the analysis of video questions and the pre-built knowledge base, corresponding answers to questions can be generated to meet the diverse needs of users; for example, with the help of the solution in this application, various entertainment questions raised by users during video viewing can be answered, thereby improving the user's video viewing experience. In addition, when implementing video control with the solution in this application, there is no need to connect expensive additional equipment, such as VR equipment or AR equipment, etc., which saves costs.
[0098] Optionally, the pre-built knowledge base is an entertainment knowledge base, including a plot knowledge base related to the video plot and a general knowledge base unrelated to the video plot; the selection module 43 includes:
[0099] A first selection unit, configured to select first text information from the plot knowledge base and second text information from the general knowledge base according to the keyword;
[0100] a second selection unit, configured to select third text information from the plot knowledge base and fourth text information from the general knowledge base according to the target vector representation;
[0101] A determination unit is used to determine the target text information according to the first text information, the second text information, the third text information and the fourth text information.
[0102] Optionally, the first selection unit is specifically used to: calculate the similarity between the keyword and the text information stored in the plot knowledge base, and select n text information with the highest similarity to the keyword from the plot knowledge base as the first text information, and calculate the similarity between the keyword and the text information stored in the general knowledge base, and select m text information with the highest similarity to the keyword from the general knowledge base as the second text information; wherein n and m are integers greater than 0;
[0103] The second selection unit is specifically used to: calculate the similarity between the target vector representation and the vector representation corresponding to the text information stored in the plot knowledge base, and select p text information corresponding to the p vector representations with the highest similarity to the target vector representation from the plot knowledge base as the third text information, and calculate the similarity between the target vector representation and the vector representation corresponding to the text information stored in the general knowledge base, and select q text information corresponding to the q vector representations with the highest similarity to the target vector representation from the general knowledge base as the fourth text information; wherein p and q are integers greater than 0.
[0104] Optionally, the determination unit is specifically used to: sort the n text information and the p text information according to similarity from high to low, and select the first x text information as the first target text information, where x is an integer greater than 0; sort the m text information and the q text information according to similarity from high to low, and select the first y text information as the second target text information, where y is an integer greater than 0; merge the first target text information and the second target text information to obtain the target text information.
[0105] Optionally, the target vector representation includes a first vector representation and a second vector representation; wherein the first vector representation is obtained by vectorizing the question using a word vector method, and the second vector representation is obtained by vectorizing the question using a sentence vector method.
[0106] Optionally, the plot knowledge base is divided based on video names, and the general knowledge base is divided based on characters, producers, and awards; the first selection unit is specifically used to: select the first text information from the text information under the video name of the video in the plot knowledge base according to the keyword, and select the second text information from the text information under the target object in the general knowledge base; wherein the target object is the one of the characters, producers, and awards that is most relevant to the question;
[0107] The second selection unit is specifically used to: select the third text information from the text information under the video name of the video in the plot knowledge base according to the target vector representation, and select the fourth text information from the text information under the target object in the general knowledge base; wherein the target object is the one of the character, producer and award that is most relevant to the problem.
[0108] Optionally, the generation module 44 is specifically used to: construct a prompt template according to the target text information; input the prompt template into a pre-trained multimodal model for processing to obtain an answer to the question.
[0109] The video question-answering device 40 of the embodiment of the present application can realize the above Figure 1 The various processes of the method embodiment shown can achieve the same technical effect, and will not be described again here to avoid repetition.
[0110] Optional, such as Figure 5 As shown, an embodiment of the present application also provides an electronic device 50, including a processor 51, a memory 52, and a program or instruction stored in the memory 52 and executable on the processor 51. When the program or instruction is executed by the processor 51, each process of the above-mentioned video question-and-answer method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0111] An embodiment of the present application also provides a readable storage medium on which a program or instruction is stored. When the program or instruction is executed by a processor, the various processes of the above-mentioned video question-and-answer method embodiment can be implemented and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0112] Computer readable media include permanent and non-permanent, removable and non-removable media, and can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0113] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0114] The serial numbers of the above-mentioned embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.
[0115] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for enabling a service classification device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of the present application.
[0116] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A video question-answering method, applied to an electronic device, characterized in that: include: Get the questions that the user inputs for the video; Parsing the question to obtain keywords included in the question and a target vector representation of the question; Selecting target text information related to the question from a pre-built knowledge base according to the keywords and the target vector representation; An answer to the question is generated according to the target text information.
2. The method according to claim 1, characterized in that: The knowledge base is an entertainment knowledge base, including a plot knowledge base related to the video plot and a general knowledge base unrelated to the video plot; The step of selecting target text information related to the question from a pre-built knowledge base according to the keyword and the target vector representation includes: According to the keyword, selecting first text information from the plot knowledge base, and selecting second text information from the general knowledge base; According to the target vector representation, selecting third text information from the plot knowledge base and selecting fourth text information from the general knowledge base; The target text information is determined according to the first text information, the second text information, the third text information and the fourth text information.
3. The method according to claim 2, characterized in that The selecting, according to the keyword, first text information from the plot knowledge base, and selecting second text information from the general knowledge base, comprises: Calculating the similarity between the keyword and the text information stored in the plot knowledge base, and selecting n text information with the highest similarity to the keyword from the plot knowledge base as the first text information, and calculating the similarity between the keyword and the text information stored in the general knowledge base, and selecting m text information with the highest similarity to the keyword from the general knowledge base as the second text information; wherein n and m are integers greater than 0; The step of selecting the third text information from the plot knowledge base and selecting the fourth text information from the general knowledge base according to the target vector representation includes: Calculate the similarity between the target vector representation and the vector representation corresponding to the text information stored in the plot knowledge base, and select p pieces of text information corresponding to the p vector representations with the highest similarity to the target vector representation from the plot knowledge base as the third text information, and calculate the similarity between the target vector representation and the vector representation corresponding to the text information stored in the general knowledge base, and select q pieces of text information corresponding to the q vector representations with the highest similarity to the target vector representation from the general knowledge base as the fourth text information; wherein p and q are integers greater than 0.
4. The method according to claim 3, characterized in that The determining the target text information according to the first text information, the second text information, the third text information and the fourth text information includes: Sort the n text information and the p text information according to the similarity from high to low, and select the first x text information as the first target text information, where x is an integer greater than 0; Sort the m text information and the q text information according to similarity from high to low, and select the first y text information as the second target text information, where y is an integer greater than 0; The first target text information and the second target text information are merged to obtain the target text information.
5. The method according to any one of claims 1 to 4, characterized in that: The target vector representation includes a first vector representation and a second vector representation; wherein the first vector representation is obtained by vectorizing the question using a word vector method, and the second vector representation is obtained by vectorizing the question using a sentence vector method.
6. The method according to any one of claims 2 to 4, characterized in that: The plot knowledge base is divided based on video names, and the general knowledge base is divided based on characters, producers and awards; Wherein, selecting the first text information from the plot knowledge base and selecting the second text information from the general knowledge base according to the keyword includes: According to the keyword, the first text information is selected from the text information under the video name of the video in the plot knowledge base, and the second text information is selected from the text information under the target object in the general knowledge base; wherein the target object is the one of the person, producer and award that is most relevant to the question; The step of selecting the third text information from the plot knowledge base and selecting the fourth text information from the general knowledge base according to the target vector representation includes: According to the target vector representation, the third text information is selected from the text information under the video name of the video in the plot knowledge base, and the fourth text information is selected from the text information under the target object in the general knowledge base; wherein the target object is the one of the character, producer and award that is most relevant to the question.
7. The method according to claim 1, characterized in that Generating an answer to the question according to the target text information includes: Construct a prompt template according to the target text information; The prompt template is input into a pre-trained multimodal model for processing to obtain an answer to the question.
8. A video question-answering device, characterized in that: include: An acquisition module is used to obtain questions input by users regarding the video; A parsing module, used to parse the question to obtain keywords included in the question and a vector representation of the question; A selection module, configured to select target text information related to the question from a pre-built knowledge base according to the keywords and the target vector representation; A generating module is used to generate an answer to the question according to the target text information.
9. An electronic device, characterized in that: It includes a processor, a memory, and a program or instruction stored in the memory and executable on the processor, wherein the program or instruction, when executed by the processor, implements the steps of the video question-and-answer method as described in any one of claims 1 to 7.
10. A readable storage medium, characterized in that: The readable storage medium stores a program or instruction, and when the program or instruction is executed by the processor, the steps of the video question-and-answer method as described in any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Method and device for outputting information
CN110263142A
Retrieval method, device and equipment and computer readable storage medium
CN111460114A
Question and answer method, question and answer system, electronic equipment and storage medium
CN111460116A
Intelligent question and answer implementation method, device and equipment
CN112597291A
Intelligent question and answer method and device, computer equipment and storage medium
CN112765306A
