Papers
Topics
Authors
Recent
Search
2000 character limit reached

CAKI: Class-Aware Knowledge Injection

Updated 5 July 2026
  • CAKI is a class-aware technique that injects knowledge conditioned on class identity to enhance discrimination among classes.
  • It employs class-specific prompt generation from few-shot samples and retrieval via query-key matching to refine coarse predictions.
  • Empirical results demonstrate CAKI improves generalization and accuracy in few-shot learning, domain adaptation, and object detection tasks.

Class-Aware Knowledge Injection (CAKI) denotes a class-conditioned form of knowledge injection in which the injected supervisory signal, memory, or prompt is explicitly tied to class identity rather than being only class-shared, instance-specific, or task-specific. In the most explicit usage of the term, CAKI is a plug-and-play prompt-learning framework for CLIP-style vision-LLMs that learns a prompt for each class from few-shot samples of that class, stores these prompts in a class-level knowledge bank, and retrieves relevant class-level knowledge at test time through query-key prompt matching to refine coarse predictions (Yin et al., 7 May 2026). More broadly, the same design principle appears across adjacent work on image classification, logit distillation, federated continual learning, and continual test-time adaptation, where class-linked supervision or class-conditioned memory is used to improve class discrimination, semantic organization, and knowledge transfer (Tian et al., 2024).

1. Definition and conceptual boundaries

CAKI is defined by what conditions the injected knowledge. In strict CAKI, the conditioning variable is the class or category identity. This distinguishes it from several neighboring mechanisms. Class-shared prompt learning learns one prompt or one prompt set shared across all classes in a target domain; instance-specific prompt learning generates prompts per test sample; and task-aware knowledge injection conditions on task identity rather than class identity. MulGT, for example, uses task-specific latent token sets TjT_j to transfer shared graph embeddings into task-specific feature spaces, but its conditioning axis is tumor typing versus tumor staging, not the class/category identity within a task; it is therefore a neighboring concept rather than CAKI in the strict sense (Zhao et al., 2023).

Within the prompt-learning formulation that explicitly uses the name CAKI, the conceptual contrast is threefold. First, class-specific prompts are said to offer more fine-grained supervision than coarse class-shared prompts, helping prevent misclassification of data from different classes into a single class. Second, compared to instance-specific prompts, class-specific prompts retain richer class-level information across multiple instances, reducing the risk that data from the same class are divided into multiple classes. Third, the framework is designed to preserve the existing prompt learner as a coarse-grained model while adding a class-aware retrieval-and-refinement layer on top of it (Yin et al., 7 May 2026).

A separate but related distinction concerns the depth of injection. A four-tier knowledge injection framework has defined memorization, retrieval, reasoning, and association as progressively deeper levels of integration, with shallow injection corresponding to memorization and retrieval and deep injection corresponding to reasoning and association (Xu et al., 1 Apr 2025). This suggests that class awareness and injection depth are orthogonal design axes: a system may be class-aware while still only achieving shallow recall, or may aim for class-aware reasoning-level integration.

2. Core formulation in prompt learning for vision-LLMs

The canonical CAKI formulation is built on a frozen CLIP backbone. For zero-shot prediction, the class posterior is written as

p(ycx)=exp(wc,f/τ)c=1Cexp(wc,f/τ),p(y_c|x) = \frac{\exp(\langle w_c, f \rangle / \tau)}{\sum_{c=1}^C \exp(\langle w_c, f \rangle / \tau)},

where ff is the image feature, wcw_c is the text feature for class cc, and τ\tau is the temperature (Yin et al., 7 May 2026). Generic prompt learning then optimizes a prompt PP through

P=argminPE(x,y)D[LCE(FP(x),y)],P^{*} = \arg\min_{P} \mathbb{E}_{(x,y) \sim D} [\mathcal{L}_{CE}(\mathbf{F}_P(x), y)],

with

FP(x)=Etext({P;Y}),Evisual(x).\mathbf{F}_P(x) = \left\langle \mathbf{E}_{\text{text}}(\{P; \mathcal{Y}\}), \mathbf{E}_{\text{visual}}(x)\right\rangle .

CAKI augments this baseline with Class-Specific Prompt Generation (CSPG). Starting from the hand-crafted prompt template “a photo of a,” the framework initializes learnable context vectors from CLIP’s pretrained word embeddings of that phrase. For each class ycy_c, it uses only few-shot samples from that class to learn a class-specific prompt p(ycx)=exp(wc,f/τ)c=1Cexp(wc,f/τ),p(y_c|x) = \frac{\exp(\langle w_c, f \rangle / \tau)}{\sum_{c=1}^C \exp(\langle w_c, f \rangle / \tau)},0. The class-specific prediction is written as

p(ycx)=exp(wc,f/τ)c=1Cexp(wc,f/τ),p(y_c|x) = \frac{\exp(\langle w_c, f \rangle / \tau)}{\sum_{c=1}^C \exp(\langle w_c, f \rangle / \tau)},1

and the class-specific prompt is optimized by

p(ycx)=exp(wc,f/τ)c=1Cexp(wc,f/τ),p(y_c|x) = \frac{\exp(\langle w_c, f \rangle / \tau)}{\sum_{c=1}^C \exp(\langle w_c, f \rangle / \tau)},2

Although the notation in the paper is not fully uniform, the operational meaning is explicit: each p(ycx)=exp(wc,f/τ)c=1Cexp(wc,f/τ),p(y_c|x) = \frac{\exp(\langle w_c, f \rangle / \tau)}{\sum_{c=1}^C \exp(\langle w_c, f \rangle / \tau)},3 is trained from same-class few-shot samples and is intended to encode class-level knowledge rather than domain-level or instance-level variation (Yin et al., 7 May 2026).

The resulting class-specific prompts are stored in a class-level key-value knowledge bank,

p(ycx)=exp(wc,f/τ)c=1Cexp(wc,f/τ),p(y_c|x) = \frac{\exp(\langle w_c, f \rangle / \tau)}{\sum_{c=1}^C \exp(\langle w_c, f \rangle / \tau)},4

where each key p(ycx)=exp(wc,f/τ)c=1Cexp(wc,f/τ),p(y_c|x) = \frac{\exp(\langle w_c, f \rangle / \tau)}{\sum_{c=1}^C \exp(\langle w_c, f \rangle / \tau)},5 is the text embedding of the original class name and each value p(ycx)=exp(wc,f/τ)c=1Cexp(wc,f/τ),p(y_c|x) = \frac{\exp(\langle w_c, f \rangle / \tau)}{\sum_{c=1}^C \exp(\langle w_c, f \rangle / \tau)},6 is the learned class-specific prompt. This design makes the injected knowledge explicitly class indexed.

3. Retrieval, matching, and prediction refinement

The second CAKI component is Query-Key Prompt Matching (QKPM). At test time, the framework first obtains a coarse prediction p(ycx)=exp(wc,f/τ)c=1Cexp(wc,f/τ),p(y_c|x) = \frac{\exp(\langle w_c, f \rangle / \tau)}{\sum_{c=1}^C \exp(\langle w_c, f \rangle / \tau)},7 from an existing prompt learner such as CoOp, CoCoOp, MaPLe, PromptSRC, TCP, GalLoP, or TPT. It then treats the image feature p(ycx)=exp(wc,f/τ)c=1Cexp(wc,f/τ),p(y_c|x) = \frac{\exp(\langle w_c, f \rangle / \tau)}{\sum_{c=1}^C \exp(\langle w_c, f \rangle / \tau)},8 as a query and matches it against the class-text keys p(ycx)=exp(wc,f/τ)c=1Cexp(wc,f/τ),p(y_c|x) = \frac{\exp(\langle w_c, f \rangle / \tau)}{\sum_{c=1}^C \exp(\langle w_c, f \rangle / \tau)},9 in the knowledge bank by a score function ff0 (Yin et al., 7 May 2026).

Top-ff1 retrieval is defined as

ff2

Each retrieved prompt ff3 produces a prompt-conditioned prediction ff4, and these are aggregated as

ff5

The final refined prediction is

ff6

where ff7 balances the retrieved class-aware prediction against the coarse baseline. The injection step is therefore not a hard replacement of the coarse model, but a weighted fusion of coarse and retrieved class-specific evidence (Yin et al., 7 May 2026).

The framework is described as plug-and-play because the CLIP image encoder and text encoder remain frozen and the retrieval-and-fusion stage is training-free at inference. The reported implementation uses pretrained CLIP ViT-B/16, 4 prompt tokens, prompt initialization from “a photo of a,” 5 optimization steps, 5 training epochs, batch size 1, learning rate ff8, AdamW, ff9, default wcw_c0, and default wcw_c1 (Yin et al., 7 May 2026). The principal overhead is linear in the number of classes and the number of retrieved prompts. On Flower102, storage rises from 0.32 G for 20 classes to 1.60 G for 102 classes, while per-image inference time rises from 0.092 s at wcw_c2 to 0.196 s at wcw_c3; the paper uses wcw_c4 as the default operating point (Yin et al., 7 May 2026).

The CAKI principle has antecedents and variants outside prompt learning. The clearest precursor in image classification is a knowledge-injected model that pairs each image class with matching triples describing class features, part relations, and broader semantic context. Its knowledge types include class feature knowledge encoded with BERT, class relationship knowledge embedded by a random-walk/SkipGram procedure, and wide feature knowledge gathered from Wikipedia-related categories. Hidden visual features are aligned to the corresponding class knowledge tensor by a cosine-similarity-style loss before a separate classification stage (Tian et al., 2024). The method is explicitly class linked at the data-construction level—images of class wcw_c5 are paired with a class-specific knowledge representation wcw_c6—but its interpretability evidence is qualitative and its “multi-level hierarchical” terminology is stronger than the architectural specification actually provided.

A second closely related line is logit-based distillation. Class-aware Logit Knowledge Distillation (CLKD) interprets the columns of a mini-batch logit matrix as class representations and supplements conventional row-wise instance distillation with class-wise matching and a Class Correlation Loss. The core decomposition is

wcw_c7

with

wcw_c8

followed by

wcw_c9

Here the injected knowledge is teacher-induced class structure in logit space rather than external symbolic knowledge, but the method is explicitly class-aware in both representation and loss design (Zhang et al., 2022).

Two later works extend class-aware knowledge injection into continual and distributed settings. Ccc0Prompt addresses federated continual learning through a Local Class Distribution Compensation mechanism and a Class-aware Prompt Aggregation scheme. It sends class-wise feature statistics to a server, estimates global class means and variances,

cc1

and uses prompt-class affinity histograms to perform class-relevant prompt aggregation across clients (Xu et al., 24 Sep 2025). KFF addresses continual test-time adaptation with a paired class-aware domain prompt pool: class prompts are matched per sample using pseudo-label similarity, domain prompts are matched per batch using cc2, and the system dynamically fissions new prompts or fuses compatible ones to bound memory (Zhou et al., 14 Oct 2025).

5. Empirical profile

The explicit CAKI prompt-learning framework reports gains across base-to-novel generalization, few-shot learning, domain generalization, semantic segmentation, and object detection. In 1-shot base-to-novel generalization, examples include CoOp on Flower102 improving in harmonic mean from cc3 to cc4, CoOp on Aircraft from cc5 to cc6, CoCoOp on EuroSAT from cc7 to cc8, and PromptSRC on Aircraft from cc9 to τ\tau0. Improvements persist at 4-shot and 16-shot, though they are often smaller (Yin et al., 7 May 2026). The same paper reports compatibility with test-time prompt tuning; for example, CoOp+TPT on Flower102 improves in harmonic mean from τ\tau1 to τ\tau2, and CoCoOp+TPT on Flower102 from τ\tau3 to τ\tau4 (Yin et al., 7 May 2026).

The auxiliary evidence from adjacent class-aware methods is consistent with the same general pattern. The knowledge-injected image classifier based on class-linked triples reports accuracy gains across both CNN and ViT backbones, such as ResNet-18 improving from τ\tau5 to τ\tau6, ResNet-50 from τ\tau7 to τ\tau8, and ViT-L/16 from τ\tau9 to PP0 when all three knowledge scales are combined (Tian et al., 2024). CLKD reports that class-aware column matching and class-correlation alignment materially improve over vanilla KD and strong feature-based baselines, with ResNet-32PP1 PP2 ResNet-8PP3 on CIFAR-100 rising from PP4 for KD to PP5 for CLKD, and ResNet-34 PP6 ResNet-18 on ImageNet reaching PP7 top-1 (Zhang et al., 2022).

In sequential and distribution-shifted settings, class-aware mechanisms again appear beneficial. CPP8Prompt improves over Powder on ImageNet-R, DomainNet, and CIFAR-100; on ImageNet-R, Avg rises from PP9 to P=argminPE(x,y)D[LCE(FP(x),y)],P^{*} = \arg\min_{P} \mathbb{E}_{(x,y) \sim D} [\mathcal{L}_{CE}(\mathbf{F}_P(x), y)],0, and the ablation reports P=argminPE(x,y)D[LCE(FP(x),y)],P^{*} = \arg\min_{P} \mathbb{E}_{(x,y) \sim D} [\mathcal{L}_{CE}(\mathbf{F}_P(x), y)],1 from LCDC alone, P=argminPE(x,y)D[LCE(FP(x),y)],P^{*} = \arg\min_{P} \mathbb{E}_{(x,y) \sim D} [\mathcal{L}_{CE}(\mathbf{F}_P(x), y)],2 from CPA alone, and P=argminPE(x,y)D[LCE(FP(x),y)],P^{*} = \arg\min_{P} \mathbb{E}_{(x,y) \sim D} [\mathcal{L}_{CE}(\mathbf{F}_P(x), y)],3 from the combination (Xu et al., 24 Sep 2025). KFF reduces mean classification error on non-repeating ImageNet-C from P=argminPE(x,y)D[LCE(FP(x),y)],P^{*} = \arg\min_{P} \mathbb{E}_{(x,y) \sim D} [\mathcal{L}_{CE}(\mathbf{F}_P(x), y)],4 for DPCore to P=argminPE(x,y)D[LCE(FP(x),y)],P^{*} = \arg\min_{P} \mathbb{E}_{(x,y) \sim D} [\mathcal{L}_{CE}(\mathbf{F}_P(x), y)],5, and remains stable across 10 repeating rounds, with mean error P=argminPE(x,y)D[LCE(FP(x),y)],P^{*} = \arg\min_{P} \mathbb{E}_{(x,y) \sim D} [\mathcal{L}_{CE}(\mathbf{F}_P(x), y)],6 against DPCore’s P=argminPE(x,y)D[LCE(FP(x),y)],P^{*} = \arg\min_{P} \mathbb{E}_{(x,y) \sim D} [\mathcal{L}_{CE}(\mathbf{F}_P(x), y)],7 (Zhou et al., 14 Oct 2025).

6. Limitations, misconceptions, and research directions

CAKI is not synonymous with generic knowledge injection. Task-aware token routing, class-shared prompt learning, and instance-specific conditioning are adjacent but distinct. MulGT explicitly demonstrates this boundary: it is methodologically informative for CAKI, but it is task-aware rather than class-aware because its learned latent tokens are indexed by task branch, not class (Zhao et al., 2023). A second common misconception is that CAKI necessarily implies symbolic reasoning. The main prompt-learning CAKI framework, the class-linked image-classification precursor, and CLKD all inject class-aware knowledge without using a symbolic rule engine (Yin et al., 7 May 2026).

The explicit prompt-learning CAKI framework also has clear operating assumptions. Its performance depends on the coarse model being semantically reasonable; if the coarse model does not rank the true class near relevant classes, retrieval becomes less informative. The paper also identifies failure cases when novel classes are not well covered by the semantics of base classes and when severe visual ambiguity remains among fine-grained classes (Yin et al., 7 May 2026). More generally, class-aware injection does not by itself guarantee rigorous interpretability: in the precursor image-classification work, Grad-CAM and hidden-layer plots are used, but there are no standard interpretability metrics, no concept bottleneck, and no user study (Tian et al., 2024).

A broader open issue concerns how deeply each class should be injected. The four-level taxonomy of memorization, retrieval, reasoning, and association indicates that success at one level does not imply success at the next (Xu et al., 1 Apr 2025). This suggests that future CAKI systems may need per-class target depth, rather than a single aggregate objective. A plausible implication is that class-aware prompt retrieval, class-aware latent alignment, and class-aware memory fusion could be coupled to class-specific evaluation profiles rather than treated as uniformly sufficient.

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to Class-Aware Knowledge Injection (CAKI).