TransHP: Image Classification with Hierarchical Prompting

This paper explores a hierarchical prompting mechanism for the hierarchical image classification (HIC) task. Different from prior HIC methods, our hierarchical prompting is the first to explicitly inject ancestor-class information as a tokenized hint that benefits the descendant-class discrimination. We think it well imitates human visual recognition, i.e., humans may use the ancestor class as a prompt to draw focus on the subtle differences among descendant classes. We model this prompting mechanism into a Transformer with Hierarchical Prompting (TransHP). TransHP consists of three steps: 1) learning a set of prompt tokens to represent the coarse (ancestor) classes, 2) on-the-fly predicting the coarse class of the input image at an intermediate block, and 3) injecting the prompt token of the predicted coarse class into the intermediate feature. Though the parameters of TransHP maintain the same for all input images, the injected coarse-class prompt conditions (modifies) the subsequent feature extraction and encourages a dynamic focus on relatively subtle differences among the descendant classes. Extensive experiments show that TransHP improves image classification on accuracy (e.g., improving ViT-B/16 by +2.83% ImageNet classification accuracy), training data efficiency (e.g., +12.69% improvement under 10% ImageNet training data), and model explainability. Moreover, TransHP also performs favorably against prior HIC methods, showing that TransHP well exploits the hierarchical information. The code is available at: https://github.com/WangWenhao0716/TransHP.

Paper

Similar papers

Peer review

Reviewer 7VFy6/10 · confidence 4/52023-07-03

Summary

This paper studies the problem of image classification leveraging the idea of hierarchical image classification (HIC), which exploits semantic relations across target classes to learn meaningful distinctive features. The core idea of hierarchical classification is that if a model should classify plants and it knows that two species of flowers are from the “rose” family, it can focus on determining features that characterize the two classes instead of looking for more general features that help it associate the classes to the flowers category. The authors consider visual transformers as models and introduce a new “prompting block” that aims at modeling the coarse class to which target classes belong so that the features extracted by the transformer are dynamic with respect to this task-and-image-specific information. At an intermediate layer of the transformer, a set of learnable vectors, i.e., prompt tokens which correspond to the number of coarse classes, is prepended to the feature tokens of an image (composed of the class token and the patch tokens). The transformed version of prompt tokens is used to compute the similarity between the tokens and learnable prototypes of the coarse classes via a cross-entropy loss. In this setting, the prompting block explicitly learns the coarse-class prompts while learning to predict the coarse class of the input image. Experiments demonstrate that training transformers with the prompting block(s) improve performances on tasks where a hierarchy can be defined (e.g., Imagenet, iNaturalist). An ablation study shows that embedding the information of the coarse classes without coarse class prompts already helps to improve the results, but prompting does it even more. Compared to the baselines, the methods are more data-efficient. Moreover, a qualitative study shows that the methods put attention to more distinctive features of the images.

Strengths

1. The paper is easy to follow and supports the method explanation with good visualizations. 2. The experiments support the validity of the method and more importantly the claims of the authors 3. The results confirm the intuition of the authors about the capability of focusing on more discriminant features

Weaknesses

1. Although the method consistently works on the tested tasks, what are the characteristics of the tasks that let us understand that the method generalizes? Number of classes? Number of added prompt blocks (determined by the number of hierarchical levels)? Or other characteristics? 2. The application of the method is limited to the cases where we have access to a hierarchy among target tasks. In the question section, I ask if we can show that the method allows us to learn better pre-training embeddings that lead to improvements on other downstream tasks.

Questions

1. The authors explain that for tasks with multiple hierarchical levels, they add a prompting block for each of them. Do you think it is necessary to exploit all the hierarchical levels? Or maybe the more granular coarse levels are enough for better conditioning? 2. By construction, the method it’s limited to cases where one is able to build a hierarchical relation across target tasks. However, training ViT on Imagenet with the hierarchical information added via prompting block might help in learning a space that generalizes better than standard ViT. Did you try to use TransHP pre-trained on Imagenet as the backbone to finetune with a few labels on other downstream tasks? Maybe fine-grained?

Rating

6: Weak Accept: Technically solid, moderate-to-high impact paper, with no major concerns with respect to evaluation, resources, reproducibility, ethical considerations.

Confidence

4: You are confident in your assessment, but not absolutely certain. It is unlikely, but not impossible, that you did not understand some parts of the submission or that you are unfamiliar with some pieces of related work.

Soundness

3 good

Presentation

3 good

Contribution

2 fair

Limitations

Limitations were mentioned and I asked follow-up questions in a previous section.

Reviewer e5cs5/10 · confidence 4/52023-07-04

Summary

This paper aims to improve image classification accuracy by introducing hierarchical prompts. For a dataset with L hierarchy with M prompt at each level, the author proposed to inserting M prompt at each of the L randomly selected transformer layers. Each prompt is tasked to predict the intermediate coarse label in the hierarchy using a supervised manner. While the proposed idea is interesting, its scalability and novelty are limited. See weakness for more details.

Strengths

1. Figure 4 highlights the difference between the proposed method and the baselines. 2. Figure 2 clearly summarizes the high-level idea of the paper. 3. The paper is simple to follow.

Weaknesses

Major 1. The proposed method inserted M prompt in the lth prompt block (See Eq5 and Eq6). Since each prompt represents a coarse class (L129-L131) at the lth layer of the hierarchy, the underlying assumption is that the hierarchy is a balanced tree (e.g. each level of the hierarchy has M coarse classes). What will happen if the hierarchy is imbalanced? Will the proposed method still work? The author is suggested to conduct experiments on a dataset that has an imbalanced hierarchy. 2. L103-104 is confusing. Does the model optimize the entire backbone model (e.g. model parameter other than the prompt) + prompt? Or just the prompt? 3. Caption of Figure 2. As shown in Eq2, the prompt is appended after the class and patch token. This contradicts the caption of Figure 2, which claims “the prompting block pre-pends the whole prompt pool consisting of M prompts”. 4. It is unclear how the proposed method TransHP selects an intermediate transformer block for inserting the prompt (L127). As mentioned by the author in L159-L160, there is no explicit guidance on how to select the block for prompt insertion. Furthermore, there is no discussion for the case where the level of dataset hierarchy exceeds that of the transformer blocks. This indicates that the proposed method is not applicable to deep hierarchy. 5. Figure 4 is a bit misleading and there are some missing baselines (L221). For example, one could insert prompts (purple dots in figure 4) and do coarse classification using the [CLS] token. Is the proposed method better than this baseline? 6. The caption of Figure 3 mentioned that the prompt is autonomously selected. However, the Eq5 is nothing but a cross-entropy loss. There is nothing to be selected. 7. How is the proposed method different from a simple baseline that combines HD-CNN [a] into the transformer architecture? 8. The author is suggested to compare with VPT. [a] HD-CNN: Hierarchical Deep Convolutional Neural Network for Large Scale Visual Recognition

Questions

The author is suggested to address the concerns in the weakness section.

Rating

5: Borderline accept: Technically solid paper where reasons to accept outweigh reasons to reject, e.g., limited evaluation. Please use sparingly.

Confidence

4: You are confident in your assessment, but not absolutely certain. It is unlikely, but not impossible, that you did not understand some parts of the submission or that you are unfamiliar with some pieces of related work.

Soundness

2 fair

Presentation

3 good

Contribution

2 fair

Limitations

Limitation is mentioned in the end of the paper.

Reviewer rPvW5/10 · confidence 5/52023-07-05

Summary

The paper proposes to use coarse token prompting for the task of image classification. The basic idea is to add coarse label tokens at intermediate layers of ViT and add additional coarse classification loss at intermediate level. It in some way correlates to convolutional networks based Hierarchical classification which incorporate additional branches for coarse level classification at intermediate levels. However, the idea is applied through prompting and the authors claim that this is the first paper to apply prompting for the task of hierarchical classification.

Strengths

- The idea of coarse label prompting appears novel - Apart from some missing details, the paper is well written and the general idea is easy to comprehend - The results show that proposed hierarchical promoting leads to consistent gains across ImageNet, iNaturalist2018/19, CIFAR 100 datasets.

Weaknesses

- Related work is not well covered. For instance, there are ideas from prior art which could be applied without much difficulty. For instance, [A] uses marginalization over the predicted fine grained labels to obtain coarse level predictions and applies an additional loss there. [B] simply trains two networks (one for each hierarchy and makes a post hoc correction). Comparison with atleast peer reviewer papers like [A] is warranted. Also a flavour of how these different papers have tackled the problem is worthwhile. Authors do mention that do not compare again convolutional methods, however, giving a general idea on branching and contrasting it with prompting will add value to the paper. - Many details are either not clear or missing. (a) For example, where exactly do they add the prompting, the exact location has to be given. Especially when you use multiple hierarchies, the locations of prompting blocks need to be clarified. Line 159, mentions that they do not have an exact position scheme and lower levels are better. However, they would have used some schema and the authors should mention that? (b) How many hierarchies are used in the main paper results. It should be clearly mentioned. I could gather that for iNaturalist only two levels are used, however, there are no detail regarding other datasets. (c) iNaturalist19 in my knowledge has 7 levels of hierarchy (3-kingdom, 4 phylum, 9-class, 34-order, 57-family, 72-genus, 1010 -species). In supplementary the authors mention to use 6 levels for genus and 1010 for species. Where did the 6 come from? (d) In Table5, supplementary material, how did you get level 11 for iNaturalist dataset? Is the the block number or level number in the Table? - Is it meaningful to do Ablation 2? Thats like sending some random vectors and checking if that helps. Not sure, if that is worthwhile to show. - I could not fully understand the use of absorption weights in equation 7. Is it just used for explainability and statistics (Figure 2) for illustrating how the model is behaving or is it used while training? Please clarify. - Another variation of your method could be to predict something like P^hat_{cls} and use that for coarse prediction. Did authors try this variation, reducing the need of the learnable prototypes w_i. Please clarify. - Other ablations like changing the position of the prompting level or varying the number of hierarchies used, would be valuable. What if only the bottom two hierarchies are used (leaf and just above). Compare that against full hierarchy. [A] Jong-Chyi Su and Subhransu Maji. Semi-supervised learning with taxonomic labels. arXiv:2111.11595, 2021 [B] Kanishk Jain, Shyamgopal Karthik and Vineet Gandhi. Test-Time Amendment with a Coarse Classifier for Fine-Grained Classification arXiv 2023

Questions

- Please provide clarifications on missing details, as mentioned in limitations sections. Clarify on other points raised in the previous section as well.

Rating

5: Borderline accept: Technically solid paper where reasons to accept outweigh reasons to reject, e.g., limited evaluation. Please use sparingly.

Confidence

5: You are absolutely certain about your assessment. You are very familiar with the related work and checked the math/other details carefully.

Soundness

3 good

Presentation

3 good

Contribution

3 good

Limitations

Task level limitations are mentioned. However, there is nothing which reflects on the functioning of the proposed framework.

Reviewer Y5zG5/10 · confidence 4/52023-07-07

Summary

This paper introduces a new approach called hierarchical prompting for hierarchical image classification (HIC). It's incorporated into a model named TransHP, which uses broader class 'prompts' to better distinguish between similar classes. The process improves image classification accuracy, data training efficiency, and model explainability. For example, it enhanced ViT-B/16's ImageNet classification accuracy by 2.83%.

Strengths

1. The innovative concept of utilizing additive tokens to garner coarse class data, aimed at enhancing fine visual recognition, holds great potential. 2. The methodology proposed in this paper appears to be a valuable tool in understanding and interpreting the ViT backbone's functioning and structure.

Weaknesses

1. The foundation established in this paper seems to lack strength. I recommend utilizing a more robust baseline within the High Interaction Control (HIC) domain. The chosen backbone, a lightweight Vision Transformer (ViT), does not exhibit wide applicability. It would enhance the argument's validity and strength if the authors considered employing the standard ViT-B as a baseline. 2. The diagram in Figure 4 implies that the bulk of the performance improvement arises from the coarse loss. This renders the necessity of prompt introductions potentially insignificant, as they contribute to less than a single point in improvements. Therefore, the authors should provide a deeper insight into the rationale behind incorporating prompts.

Questions

1. In the method part, what does "soft weighting" mean? If I understand correctly, soft weighting happens without learning any special weighting parameters, instead it means the attention value toward "correct" course prompt increases along the training more epochs.

Rating

5: Borderline accept: Technically solid paper where reasons to accept outweigh reasons to reject, e.g., limited evaluation. Please use sparingly.

Confidence

4: You are confident in your assessment, but not absolutely certain. It is unlikely, but not impossible, that you did not understand some parts of the submission or that you are unfamiliar with some pieces of related work.

Soundness

2 fair

Presentation

3 good

Contribution

2 fair

Limitations

1. There appear to be certain limitations to the methods employed, particularly for datasets devoid of HIC structures. Understanding the process of implementing these methods on such datasets would be enlightening.

Reviewer 9axF4/10 · confidence 3/52023-07-10

Summary

This works presents a novel hierarchical prompting mechanism for hierarchical image classification, named TransHP. In TransHP, a set of prompt tokens are learnt to represent coarse classes and was injected in the prompting block for coarse class prediction, and the injected prompt token can strengthen the feature. The proposed method was evaluated in several benchmarks and show consistently improvements compared with baseline model.

Strengths

- This work is well-written and well-organized, and the proposed method is simple and easy to implement. - Good performance compared to previous methods and baseline model. - Visualization in Fig. 5 gives intuition to understand the proposed method. - Studies on data-scarce scenario is good.

Weaknesses

- The ImageNet performance of HiMulConE used in this work is even worse than the official paper that adopt ResNet-50. - Lacking intuitive explanation on the data efficiency of the proposed method. - Table 4 shows that in data-scarce senario, the performance of all methods decreases significantly, and the results suggest that TransHP has better performance. However, I wonder if the settings used in this work is too weak? This is because recent semi-supervised work has shown that very high accuracy can be achieved with only 10% of ImageNet data, and some self-supervised pre-training methods (\eg MIM) can also alleviate the problem of data scarcity. - The main experiments are conducts on a lightweight ViT, which is a weak baseline. It would be best to conduct more experiments on a stronger backbone & pre-train models.

Questions

I hope the author could address my questions in the weakness.

Rating

4: Borderline reject: Technically solid paper where reasons to reject, e.g., limited evaluation, outweigh reasons to accept, e.g., good evaluation. Please use sparingly.

Confidence

3: You are fairly confident in your assessment. It is possible that you did not understand some parts of the submission or that you are unfamiliar with some pieces of related work. Math/other details were not carefully checked.

Soundness

3 good

Presentation

3 good

Contribution

2 fair

Limitations

Yes. The author adequately addressed the limitations.

Reviewer 7VFy2023-08-18

Thank you for the clarifications! After reading the other reviews and discussions - I am still leaning toward the acceptance of the paper thus confirming my score. One suggestion for the authors is to expand a bit more on questions from other reviewers letting them understand why you made particular choices they are skeptical about.

Authorsrebuttal2023-08-18

Many thanks for your positive rating and suggestions. We will try to address all the other reviewers' concerns.

Reviewer Y5zG2023-08-19

Thank you for the author's rebuttal; I will maintain my current score.

Reviewer e5cs2023-08-19

Thank the authors for providing the rebuttal. However, my major concerns are not well addressed. 7. "The difference ... lie in how the mapping function of the deep model is learned". This is not very clear to me. Prior works in HIC (such as HD-CNN) also pass the coarse-grained prediction into later layers for finer-grained predictions. The idea is the same here. 8. It is true that VPT is designed for parameter-efficient training, but it should not be the reason why such a comparison cannot be made. The authors also adopt ImageNet pretrained model and fine-tune it for other datasets (i.e. the w Pre setting). I think the comparison is needed to justify the significance of the technical contribution.

Authorsrebuttal2023-08-20

Thanks for your time and discussion. We provide extra clarification for the remaining concerns. **7.** Compared to previous HIC methods, a distinct feature of our method is that we condition the subsequential feature extraction on the preceding coarse prediction. In other words, in TransHP, the **mapping** from the input image to the final feature space is dynamically conditioned on the intermediate (coarse) prediction, whereas previous methods, including HD-CNN, employ static feature extraction. This is the primary difference, along with others, such as the prompting mechanism. More specifically, let’s consider the comparison with HD-CNN. Although HD-CNN also utilizes coarse predictions to modify the fine-grained predictions, it doesn’t alter the feature extraction for the fine-grained classes and relies on a heuristic strategy to merge the coarse and fine predictions. In contrast, our TransHP dynamically conditions the feature extraction for fine-grained classes, which consequently influences the fine-grained predictions. We don’t use any heuristic strategy to merge the coarse and fine predictions. **8.** Thanks. Following your instruction, we conduct experiments on our employed datasets with the publicly-released code of VPT. The comparisons are summarised in the below table. Currently, we have only finished the experiments on CIFAR-100. We will update the results for the other datasets in 24 hours. We observe that on CIFAR-100, the VPT does not improve the baseline. This is reasonable because VPT’s benefit is mainly for the training efficiency (when the downstream task has limited data) and barely brings accuracy improvement when the downstream task has sufficient data. In contrast, our method lays no emphasis on fine-tuning efficiency (please kindly note that prompting and prompt-tuning are indeed two different concepts), but brings non-trivial improvement by modeling the hierarchical knowledge into prompting. | Model | iNaturalist-2018 (%) | iNaturalist-2019 (%) | CIFAR-100 (%) | DeepFashion (%) | |-------------|----------------------|----------------------|---------------|-----------------| | Baseline (w Pre) | 63.01 | 69.31 | 84.98 | 88.54 | | VPT (w Pre) | - | - | 82.74 | - | | TransHP (w Pre) | 64.21 | 71.62 | 86.85 | 89.93 |

Authorsrebuttal2023-08-20

We have completed all the experiments with VPT on our employed datasets, as shown below. It is observed that TransHP maintains higher accuracy than VPT on all the datasets. Moreover, VPT is even lower than the baselines, especially on large-scale datasets, such as iNaturalist and DeepFashion. It is because VPT has very few tunable parameters and is prone to the underfitting problem. | Model | iNaturalist-2018 (%) | iNaturalist-2019 (%) | CIFAR-100 (%) | DeepFashion (%) | |-------------|----------------------|----------------------|---------------|-----------------| | Baseline (w Pre) | 63.01 | 69.31 | 84.98 | 88.54 | | VPT (w Pre) | 49.47 | 54.46 | 82.74 | 73.14 | | TransHP (w Pre) | 64.21 | 71.62 | 86.85 | 89.93 |

Reviewer e5cs2023-08-20

Thank the authors for providing further clarification and additional experiments, which addressed my concerns and I raised my rating to borderline accept.

Reviewer rPvW2023-08-19

Post rebuttal comment

I have carefully read the author rebuttal. The authors do address some of my comments in a satisfactory manner, hence I am increasing my rating to borderline accept. It appears that the method gives similar performance without the learnable prototypes, that does raise a concern about unnecessary complexity. I would expect that the authors will compute and update all tables without learnable prototypes (directly predicting P^hat_{cls} and using that for coarse prediction). I also suggest the authors to add discussion with other methods like [A] and [B]. Also requesting for some other clarifications: - Are you using only two hierarchies in the iNaturalist dataset? "Amphibians, birds, fungi, insects, plants, and reptiles" appear to be coarse labels not hierarchy. - The prompting with multiple Hierarchies is not entirely clear. Can you expand on that aspect a bit, while clearly mentioning the promoting positions.

Authorsrebuttal2023-08-20

Many thanks for your time and discussion. We sincerely appreciate that you increased your rating and recommended acceptance. We will revise the paper according to your suggestions and answer your two new questions below: **1.** Yes, we use two hierarchies in the iNaturalist dataset, *i.e.*, **hier_1**: 6 coarse classes (iconic category): amphibians, birds, fungi, insects, plants, and reptiles; **hier_2**: 1010 fine classes (category name) **2.** Sure, we will add the implementation details below: **ImageNet:** The ImageNet dataset contains **12** hierarchies, and the Transformer backbone has 12 hierarchies. Therefore, **each** transformer block is used as the prompting block. From bottom to the top, the number of coarse/fine classes are: 2, 2, 2, 4, 9, 16, 25, 49, 90, 170, 406, 1000. **DeepFashion:** The DeepFashion dataset contains **3** hierarchies; according to our qualitative principle, the promoting positions are arranged as follows: the coarsest hierarchy (with 2 classes) is arranged at the **6th** transformer block; the inner hierarchy (with 17 classes) is arranged at the **8th** transformer block; the finest hierarchy (with 7,982 classes) is arranged at the last transformer block. The other three datasets contain **2** hierarchies: **iNaturalist-2018/2019:** the promoting position is at the **6th** transformer block with 14/6 coarse classes; **CIFAR-100:** the promoting position is at the **8th** transformer block with 20 coarse classes.

Program Chairsdecision2023-09-21

Decision

Accept (poster)

© 2026 NYSGPT2525 LLC