Method for performing visual question and answer by utilizing attention mechanism from word to region
By extracting image and question features through regional convolutional neural networks and collaborative attention mechanisms, the problem of insufficient fine-grained semantic information of images in visual question answering is solved, and higher quality candidate answer generation and answer prediction are achieved.
Patent Information
- Application Number
- CN202311789554.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-23
- Publication Date
- 2026-04-14
AI Technical Summary
Existing visual question answering methods struggle to fully capture fine-grained semantic information from images, and the lack of image grid features limits the improvement of model performance.
We employ a word-to-region attention mechanism, extracting image and question features through a region convolutional neural network, generating fine-grained image and question features using a collaborative attention mechanism, fusing multimodal information to generate candidate answers, and improving answer quality through answer encoding and image attention mechanisms.
It improves the accuracy of answer prediction in visual question answering models, enabling them to better understand the semantic information of images and questions, generate high-quality candidate answers, and ultimately predict the correct answer.
Smart Images

Figure CN121858776A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of artificial intelligence networks, and specifically relates to a method for visual question answering that utilizes an attention mechanism from words to regions. Background Technology
[0002] A crucial component of artificial intelligence is the automatic understanding of visual and natural language information. The semantic gap between vision and language is gradually being bridged, and the development of machine learning and deep learning has led to numerous research efforts dedicated to solving cross-modal tasks between vision and language, with visual question answering being one such task. Visual question answering not only requires understanding natural language questions but also locating relevant image regions based on linguistic information and inferring the answer by fusing information from both modalities. Inspired by biological neuroscience, attention mechanisms can assign different weights based on the relevance of data within a data sequence, and are therefore widely used in computer vision and natural language processing. In visual question answering tasks, some methods use attention mechanisms to treat the global representation of the natural language question as a query and locate relevant image regions. Other methods use stacked attention mechanisms, progressively identifying the most relevant image regions through multiple layers of attention. However, typically only a few keywords in the question contribute to locating relevant image regions. To address this issue, some methods propose networks that simultaneously apply question attention and visual attention, first focusing on important words in the question to obtain its representation, and then using this representation for visual attention. Furthermore, some methods combine attention mechanisms with multimodal features to facilitate the interaction between textual and visual information. These methods have improved model performance to some extent, but they still have shortcomings, such as the inability to obtain more expressive problem representations, and the inability of the image grid features extracted using VGGNet or ResNet to fully represent the fine-grained semantic information in the image, which limits the improvement of model performance. Summary of the Invention
[0003] The purpose of this invention is to provide a method for visual question answering that utilizes an attention mechanism from words to regions.
[0004] The objective of this invention is achieved as follows:
[0005] A method for visual question answering that utilizes a word-to-region attention mechanism includes the following steps:
[0006] (1) Feature extraction;
[0007] (2) Generating candidate answers: First, a collaborative attention mechanism is used to locate relevant image regions and keywords in the question. Then, fine-grained image features and question features are obtained. Finally, these two features are fused to generate candidate answers.
[0008] Step (1) includes:
[0009] (1.1) Extracting target features from the image:
[0010] Target features are extracted for each image using a region convolutional neural network. For a given image, X target features are extracted, and each feature vector has a dimension of q. i Target features For algebraic number fields;
[0011] (1.2) Extracting problem features:
[0012] Determine the word sequence of the problem The word is the question word, y d It is the length of the problem, q v It is at the word level;
[0013] (1.3) Encoding word vectors:
[0014] Determine the size q of the word vector j Using pre-trained embedding matrices Embed word sequences into word vectors
[0015] The word vectors are encoded using a GRU network to obtain word representations:
[0016] H d =GRU(H j );
[0017] d q denoted as the dimension of the hidden layer in the GRU network.
[0018] Step (2) includes:
[0019] (2.1) Constructing an attention network: Constructing a question attention network, which focuses on keywords in the question; and an image attention network, which focuses on regions in the image that are relevant to the question.
[0020] In the question focus, a weight value is assigned to each word based on its importance in the question. A weighted sum of all word representations is then calculated to generate the question representation.
[0021]
[0022] c d Word weights;
[0023]
[0024] Let v be the weight of the word in the question. Let the problem be represented by a vector. This represents the first trainable parameter;
[0025] In image focus, each image region is assigned a weight value based on its relevance to the problem. A fine-grained image representation is obtained by calculating the weighted sum of features from all regions.
[0026] By fusing information from image features and question features, multimodal features are generated:
[0027]
[0028] This represents the second trainable parameter. This represents the third trainable parameter. It is a vector in which all elements are 1. This indicates part-wise multiplication;
[0029] The fused multimodal features are input into the softmax layer to generate image region weights c. i,p
[0030]
[0031] This represents the fourth trainable parameter;
[0032] Calculate the weighted sum of features from all regions to obtain a fine-grained image representation:
[0033]
[0034] Let v be the weight of the v-th image region. The feature representation of the v-th word;
[0035] (2.2) Generating the answer:
[0036] By fusing visual image representation with problem representation, a multimodal representation is obtained:
[0037]
[0038] This represents the fifth trainable parameter. Represents the sixth trainable parameter; q u The size of the hidden layer;
[0039] The multimodal representations are input into the softmax layer to generate a probability vector for the answer:
[0040]
[0041] Denotes the seventh trainable parameter, A a Indicates the classifier size;
[0042] Choose the A answers with the highest probability;
[0043] (2.3) Predict the final answer:
[0044] Determine the one-hot representation of the v-th word in the candidate answers:
[0045]
[0046] Calculate the number of words v in the candidate answers n ;
[0047] Summing the word vectors of each candidate answer generates a candidate answer representation:
[0048]
[0049] By fusing the problem representation, image region features, and answer representation, a joint feature representation is obtained:
[0050]
[0051] This represents the eighth trainable parameter; This represents the ninth trainable parameter; Indicates the tenth trainable parameter;
[0052] The joint feature representation is input into the softmax layer to generate the joint feature representation weights c. i,o
[0053]
[0054] This represents the eleventh trainable parameter;
[0055] Calculate the weighted sum of all joint feature representations to obtain a refined image representation:
[0056]
[0057] Let the weight of the v-th joint feature be denoted as . The feature representation of the v-th word;
[0058] The final image representation is generated by fusing the fine-grained image representation with the detailed image representation:
[0059]
[0060] ⊙ represents a fusion operation;
[0061] Generate the answer probability distribution vector using a soft layer:
[0062]
[0063] This represents the twelfth trainable parameter; This represents the thirteenth trainable parameter; This represents the fourteenth trainable parameter; This represents the fifteenth trainable parameter;
[0064] The answer with the highest probability will be used as the final answer predicted by this method.
[0065] The beneficial effects of this invention are as follows:
[0066] This invention proposes a visual question-answering method based on a cascaded question-answering model, utilizing an attention mechanism from words to regions. To generate higher-quality candidate answers, the traditional single-stage visual model is extended to a two-stage model by cascading two question-answering stages. This fully mines the semantic information contained in the answers to improve the accuracy of the final answer prediction. Through this method, we can extract and utilize image regions and keywords related to the question, thereby generating more accurate candidate answers. Furthermore, we use answer encoding and image attention mechanisms to further enhance the quality of the answers, and transform these optimized candidate answers into the final correct answer through the answer prediction part. Through this process, we can fully mine the semantic information in the answers, thereby improving the prediction accuracy of the final answer. Attached Figure Description
[0067] Figure 1 This is a schematic diagram of the method of the present invention.
[0068] Figure 2 This is a schematic diagram illustrating a comparison with existing methods. Detailed Implementation
[0069] The present invention will now be further described with reference to the accompanying drawings.
[0070] A visual question answering method utilizing a word-to-region attention mechanism mainly consists of three parts: feature extraction, candidate answer generation, and final answer prediction. In the feature extraction process, target-based image features and question features are extracted using a region-based convolutional neural network. Candidate answer generation includes a visual question answering model with a collaborative attention network to generate high-quality candidate answers. Finally, the final answer prediction effectively fuses candidate answer information, image information, and question information to predict the final answer, specifically including the following steps:
[0071] (1) Feature extraction:
[0072] This method extracts target-level features for each image using a region-based convolutional neural network. These image features are target-based, thus more natural and expressive than grid features, specifically including the extraction of target features from the image:
[0073] Target features are extracted for each image using a region convolutional neural network. For a given image, X target features are extracted, and each feature vector has a dimension of q. i Target features For algebraic number fields;
[0074] Extracting problem features:
[0075] Determine the word sequence of the problem The word is the question word, y d It is the length of the problem, q v It is at the word level;
[0076] Encoding word vectors:
[0077] Determine the size q of the word vector j Using pre-trained embedding matrices Embed word sequences into word vectors
[0078] The word vectors are encoded using a GRU network to obtain word representations:
[0079] H d =GRU(H j );
[0080] d q The dimension of the hidden layer in the GRU network;
[0081] (2) Generate candidate answers:
[0082] In generating candidate answers, a collaborative attention mechanism is first used to identify regions and keywords related to the question and image. Fine-grained image and question features are acquired and then fused to generate candidate answers. Answers generated in this way have a high probability of being closely related to the question-image pair and are likely to contain the correct answer. For a given image, the question usually focuses on a specific topic and is only related to one or a few image regions. Therefore, in most cases, we only need to focus on some image regions related to the question to answer it. At the same time, the semantic information contained in each word in the question is different, so their contributions to answering the question are also different. Based on the above ideas, this method establishes a region collaborative attention mechanism, including question attention and image attention. Question attention is used to focus on keywords in the question, while image attention is used to focus on image regions related to the question. Through this mechanism, we can effectively obtain relevant information between the question and the image, thereby generating more accurate candidate answers.
[0083] First, a collaborative attention mechanism is used to locate relevant image regions and keywords in the question. Then, fine-grained image features and question features are obtained. Finally, these two features are fused to generate candidate answers.
[0084] (2.1) Constructing an attention network: Constructing a question attention network, which focuses on keywords in the question; and an image attention network, which focuses on regions in the image that are relevant to the question.
[0085] In the question focus, a weight value is assigned to each word based on its importance in the question. A weighted sum of all word representations is then calculated to generate the question representation.
[0086]
[0087] c d Word weights;
[0088]
[0089] Let v be the weight of the word in the question. Let the problem be represented by a vector. This represents the first trainable parameter;
[0090] In image focus, each image region is assigned a weight value based on its relevance to the problem. A fine-grained image representation is obtained by calculating the weighted sum of features from all regions.
[0091] By fusing information from image features and question features, multimodal features are generated:
[0092]
[0093] This represents the second trainable parameter. This represents the third trainable parameter. It is a vector in which all elements are 1. This indicates part-wise multiplication;
[0094] The fused multimodal features are input into the softmax layer to generate image region weights c. i,p
[0095]
[0096] This represents the fourth trainable parameter;
[0097] Calculate the weighted sum of features from all regions to obtain a fine-grained image representation:
[0098]
[0099] Let v be the weight of the v-th image region. The feature representation of the v-th word;
[0100] (2.2) Generating the answer:
[0101] By fusing visual image representation with problem representation, a multimodal representation is obtained:
[0102]
[0103] This represents the fifth trainable parameter. Represents the sixth trainable parameter; q u The size of the hidden layer;
[0104] The multimodal representations are input into the softmax layer to generate a probability vector for the answer:
[0105]
[0106] Denotes the seventh trainable parameter, A a Indicates the classifier size;
[0107] Choose the A answers with the highest probability;
[0108] (2.3) Predict the final answer:
[0109] In multiple-choice tasks in visual question answering, existing techniques typically select the final answer directly from candidate answers labeled by users. While these candidate answers often contain the correct answer, the mechanism for generating candidate answers does not guarantee the generation of answers of the same quality. In other words, some generated candidate answers may not contain the correct answer. Therefore, this method treats candidate answers as supplementary knowledge information and utilizes the original answer space again to predict the final answer. In this way, our model can fully utilize the generated candidate answers while also reducing its dependence on them to some extent. The generation of the final answer consists of three parts: answer encoding, image attention, and answer prediction. Answer embedding is used to generate the representation of the answer, image attention is used to generate image features related to the question and answer, and the answer prediction part is used to predict the final answer, specifically including:
[0110] Determine the one-hot representation of the v-th word in the candidate answers:
[0111]
[0112] Calculate the number of words v in the candidate answers n ;
[0113] Summing the word vectors of each candidate answer generates a candidate answer representation:
[0114]
[0115] By fusing the problem representation, image region features, and answer representation, a joint feature representation is obtained:
[0116]
[0117] This represents the eighth trainable parameter; This represents the ninth trainable parameter; Indicates the tenth trainable parameter;
[0118] The joint feature representation is input into the softmax layer to generate the joint feature representation weights c. i,o
[0119]
[0120] This represents the eleventh trainable parameter;
[0121] Calculate the weighted sum of all joint feature representations to obtain a refined image representation:
[0122]
[0123] Let the weight of the v-th joint feature be denoted as . The feature representation of the v-th word;
[0124] The final image representation is generated by fusing the fine-grained image representation with the detailed image representation:
[0125]
[0126] ⊙ represents a fusion operation;
[0127] Generate the answer probability distribution vector using a soft layer:
[0128]
[0129] This represents the twelfth trainable parameter; This represents the thirteenth trainable parameter; This represents the fourteenth trainable parameter; This represents the fifteenth trainable parameter;
[0130] The answer with the highest probability will be used as the final answer predicted by this method.
[0131] The following is a verification experiment of our method, compared with existing technologies. The data used, experimental details, and results are described in detail below: Given an image, X = 1000 image region features are extracted, each with a dimension of 1024. The dimensions of the question representation vector and word vector are 4800 and 1240, respectively. The hidden layer size is set to 512, and the length of the question after data processing is 30. When generating candidate answers, only the top 5 answers with the highest probability are selected as candidate answers, and the number of words in these answers is uniformly set to 12. In the final answer classification, the number of answers is set to 1500. The Adam algorithm is used for optimization during the training phase, with a training epoch and an initial learning rate of 200 and 0.0002, respectively. The batch size of the training data is 512. To improve the convergence of the proposed model, the learning rate is reduced to one-tenth of its original value every 40 training epochs. The random inactivation rate in the GRU is 0.5, and the other random inactivation rates are set to 0.25. Table 1 shows the comparative experimental results of our method with several single-stage structural variants.
[0132] Figure 1 Performance comparison of this method with other benchmark models
[0133] Model Y / N Num Other Overall The method 84.67 46.07 58.96 66.93 CAG 84.33 45.04 57.92 66.15 FAP 84.18 45.54 58.39 66.37 Stack 83.59 44.91 57.92 65.96
[0134] Comparative analysis verified that the proposed two-stage structure can fully utilize the semantic information contained in the candidate answers, thereby improving the superiority of the final answer prediction. This invention can infer more correct answers beyond the candidate answer set, which also means that the proposed method can effectively utilize candidate answers and, to some extent, overcome the limitations imposed by them. Figure 2 The paper demonstrates the prediction instances of the proposed model on a dataset and compares the prediction results of the proposed method with those of other methods. Compared to traditional methods, the main advantage of this method is its ability to generate and utilize high-quality candidate answers. For example, when answering the question "What is on the boy's hand?", the proposed model can generate high-quality candidate answers such as "hat", "nothing", "balloon", and "fingers". (A) shows the prediction result of this method, and (B) shows the prediction result of another method. These candidate answers contain much semantic information closely related to the question-image pair, which can effectively facilitate the visual question answering model in making further predictions. However, other methods are limited by the candidate answers, increasing the probability of errors.
[0135] In summary, this method offers several advantages for visual question answering tasks. First, it leverages a word-to-region attention mechanism, enabling a better understanding and capture of semantic information in images and questions. Second, its feature extraction via region-based convolutional neural networks effectively extracts both image and question features. Furthermore, the candidate answer generation component incorporates a visual question answering model with a collaborative attention network, generating high-quality candidate answers. Finally, the final answer prediction effectively integrates candidate answer information, image information, and question information, thereby improving the accuracy of answer prediction.
[0136] Compared to existing technologies, the advantages of this method are mainly reflected in:
[0137] 1. Introduction of Attention Mechanism: The attention mechanism can automatically learn and selectively focus on important information in the input, improving the model's performance and generalization ability. 2. Fusion of Multimodal Information: This method fully utilizes the interactivity between images and text, improving the reasoning process for question answering. 3. Utilization of External Knowledge: In addition to image and question information, this method can also utilize image descriptions and external knowledge to enhance the representation, further improving the accuracy of answer prediction.
[0138] In summary, this method, by comprehensively utilizing attention mechanisms, multimodal information, and external knowledge, can perform visual question answering tasks more accurately and has high practical value.
Claims
1. A method for visual question answering utilizing a word-to-region attention mechanism, characterized in that, Includes the following steps: (1) Feature extraction; (2) Generating candidate answers: First, a collaborative attention mechanism is used to locate relevant image regions and keywords in the question. Then, fine-grained image features and question features are obtained. Finally, these two features are fused to generate candidate answers.
2. The method for visual question answering using a word-to-region attention mechanism according to claim 1, characterized in that, Step (1) includes: (1.1) Extracting target features from the image: Target features are extracted for each image using a region convolutional neural network. For a given image, X target features are extracted, and each feature vector has a dimension of q. i Target features For algebraic number fields; (1.2) Extracting problem features: Determine the word sequence of the problem The word is the question word, y d It is the length of the problem, q v It is at the word level; (1.3) Encoding word vectors: Determine the size q of the word vector j Using pre-trained embedding matrices Embed word sequences into word vectors The word vectors are encoded using a GRU network to obtain word representations: H d =GRU(H j ); d q denoted as the dimension of the hidden layer in the GRU network.
3. The method for visual question answering using a word-to-region attention mechanism according to claim 1, characterized in that, Step (2) includes: (2.1) Constructing an attention network: Constructing a question attention network, which focuses on keywords in the question; and an image attention network, which focuses on regions in the image that are relevant to the question. In the question focus, a weight value is assigned to each word based on its importance in the question. A weighted sum of all word representations is then calculated to generate the question representation. c d Word weights; Let v be the weight of the word in the question. Let the problem be represented by a vector. This represents the first trainable parameter; In image focus, each image region is assigned a weight value based on its relevance to the problem. A fine-grained image representation is obtained by calculating the weighted sum of features from all regions. By fusing information from image features and question features, multimodal features are generated: This represents the second trainable parameter. This represents the third trainable parameter. It is a vector in which all elements are 1. This indicates part-wise multiplication; The fused multimodal features are input into the softmax layer to generate image region weights c. i,p This represents the fourth trainable parameter; Calculate the weighted sum of features from all regions to obtain a fine-grained image representation: The weight of the v-th image region is... The feature representation of the v-th word; (2.2) Generating the answer: By fusing visual image representation with problem representation, a multimodal representation is obtained: This represents the fifth trainable parameter. Represents the sixth trainable parameter; q u The size of the hidden layer; The multimodal representations are input into the softmax layer to generate a probability vector for the answer: A represents the seventh trainable parameter. a Indicates the classifier size; Choose the A answers with the highest probability; (2.3) Predict the final answer: Determine the one-hot representation of the v-th word in the candidate answers: q n =q j ; Calculate the number of words v in the candidate answers n ; Summing the word vectors of each candidate answer generates a candidate answer representation: By fusing the problem representation, image region features, and answer representation, a joint feature representation is obtained: This represents the eighth trainable parameter; This represents the ninth trainable parameter; Indicates the tenth trainable parameter; The joint feature representation is input into the softmax layer to generate the joint feature representation weights c. i,o This represents the eleventh trainable parameter; Calculate the weighted sum of all joint feature representations to obtain a refined image representation: Let the weight of the v-th joint feature be denoted as . The feature representation of the v-th word; The final image representation is generated by fusing the fine-grained image representation with the detailed image representation: ⊙ represents a fusion operation; Generate the answer probability distribution vector using a soft layer: This represents the twelfth trainable parameter; This represents the thirteenth trainable parameter; This represents the fourteenth trainable parameter; This represents the fifteenth trainable parameter; The answer with the highest probability will be used as the final answer predicted by this method.
