CAKI: Class-Aware Knowledge Injection
- 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 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
where is the image feature, is the text feature for class , and is the temperature (Yin et al., 7 May 2026). Generic prompt learning then optimizes a prompt through
with
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 , it uses only few-shot samples from that class to learn a class-specific prompt 0. The class-specific prediction is written as
1
and the class-specific prompt is optimized by
2
Although the notation in the paper is not fully uniform, the operational meaning is explicit: each 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,
4
where each key 5 is the text embedding of the original class name and each value 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 7 from an existing prompt learner such as CoOp, CoCoOp, MaPLe, PromptSRC, TCP, GalLoP, or TPT. It then treats the image feature 8 as a query and matches it against the class-text keys 9 in the knowledge bank by a score function 0 (Yin et al., 7 May 2026).
Top-1 retrieval is defined as
2
Each retrieved prompt 3 produces a prompt-conditioned prediction 4, and these are aggregated as
5
The final refined prediction is
6
where 7 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 8, AdamW, 9, default 0, and default 1 (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 2 to 0.196 s at 3; the paper uses 4 as the default operating point (Yin et al., 7 May 2026).
4. Related formulations across adjacent research areas
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 5 are paired with a class-specific knowledge representation 6—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
7
with
8
followed by
9
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. C0Prompt 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,
1
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 2, 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 3 to 4, CoOp on Aircraft from 5 to 6, CoCoOp on EuroSAT from 7 to 8, and PromptSRC on Aircraft from 9 to 0. 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 1 to 2, and CoCoOp+TPT on Flower102 from 3 to 4 (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 5 to 6, ResNet-50 from 7 to 8, and ViT-L/16 from 9 to 0 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-321 2 ResNet-83 on CIFAR-100 rising from 4 for KD to 5 for CLKD, and ResNet-34 6 ResNet-18 on ImageNet reaching 7 top-1 (Zhang et al., 2022).
In sequential and distribution-shifted settings, class-aware mechanisms again appear beneficial. C8Prompt improves over Powder on ImageNet-R, DomainNet, and CIFAR-100; on ImageNet-R, Avg rises from 9 to 0, and the ablation reports 1 from LCDC alone, 2 from CPA alone, and 3 from the combination (Xu et al., 24 Sep 2025). KFF reduces mean classification error on non-repeating ImageNet-C from 4 for DPCore to 5, and remains stable across 10 repeating rounds, with mean error 6 against DPCore’s 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.