Scalable prompt learning for large vision-language models
A method of generating text-driven prompts and class prediction probabilities using a vision-language model (VLM) includes receiving candidate class names associated with a plurality of candidate classes for images, generating class text tokens based on a text description of the candidate class names, and generating a plurality of context prompt vectors using a prompt generator. The context prompt vectors define context information associated with an image classification task to be performed by the VLM. The method further includes generating prompts for each of the plurality of candidate classes by appending respective class text tokens to the context prompt vectors for each of the plurality of candidate classes, and, using the VLM, generating and outputting a class prediction probability for a sample image based on the plurality of context prompt vectors.
1 . A method of generating text-driven prompts and class prediction probabilities using a vision-language model (VLM), the method comprising:
receiving candidate class names associated with a plurality of candidate classes for images;
generating class text tokens based on a text description of the candidate class names;
generating, based on the text description and separate from the class text tokens, a plurality of context prompt vectors using a prompt generator, wherein the context prompt vectors define context information associated with an image classification task to be performed by the VLM;
subsequent to generating the plurality of context prompt vectors, generating prompts for each of the plurality of candidate classes by appending respective class text tokens to the context prompt vectors for each of the plurality of candidate classes; and
using the VLM, generating and outputting a class prediction probability for a sample image based on the plurality of context prompt vectors, wherein using the VLM includes providing, to a text encoder of the VLM, the context prompt vectors.
2 . The method of claim 1 , wherein the VLM is a Contrastive Language-Image Pre-training (CLIP) model.
3 . The method of claim 1 , further comprising receiving the text description at an interface.
4 . The method of claim 3 , wherein receiving the text description includes providing a predefined text template and receiving the text description in accordance with the predefined text template.
5 . The method of claim 1 , further comprising providing the text description to a large language model (LLM) and generating the text embeddings using the large language model.
6 . The method of claim 1 , further comprising generating the plurality of context prompt vectors using a prompt generator model f θ .
7 . The method of claim 6 , further comprising, using the prompt generator model f θ , mapping the text embeddings to the plurality of context prompt vectors.
8 . The method of claim 6 , further comprising aggregating respective parameters of a plurality of the prompt generator models f θ and outputting an aggregated prompt generator model based on the aggregated respective parameters.
9 . A computing device configured to generate text-driven prompts and class prediction probabilities using a vision-language model (VLM), the computing device including a processing device configured to execute instructions stored in memory to:
receive candidate class names associated with a plurality of candidate classes for images;
generate class text tokens based on a text description of the candidate class names;
generate, based on the text description and separate from the class text tokens, a plurality of context prompt vectors using a prompt generator, wherein the context prompt vectors define context information associated with an image classification task to be performed by the VLM;
subsequent to generating the plurality of context prompt vectors, generate prompts for each of the plurality of candidate classes by appending respective class text tokens to the context prompt vectors for each of the plurality of candidate classes; and
using the VLM, generate and output a class prediction probability for a sample image based on the plurality of context prompt vectors, wherein using the VLM includes providing, to a text encoder of the VIM, the context prompt vectors.
10 . The computing device of claim 9 , wherein the VLM is a Contrastive Language-Image Pre-training (CLIP) model.
11 . The computing device of claim 9 , further comprising an interface configured to receive the text description.
12 . The computing device of claim 11 , wherein the interface is configured to provide a predefined text template and receive the text description in accordance with the predefined text template.
13 . The computing device of claim 9 , further comprising a large language model (LLM) configured to generate the text embeddings.
14 . The computing device of claim 9 , further comprising a prompt generator model f θ configured to generate the plurality of context prompt vectors.
15 . The computing device of claim 14 , wherein the prompt generator model is configured to map the text embeddings to the plurality of context prompt vectors.
16 . The computing device of claim 9 , wherein the VLM includes the text encoder and an image encoder.
17 . A computer-controlled machine, comprising:
at least one sensor configured to generate an input image;
a control system configured to generate text-driven prompts and class prediction probabilities using a vision-language model (VLM), the control system configured to
receive candidate class names associated with a plurality of candidate classes for the input image,
generate, based on the text description and separate from the class text tokens, a plurality of context prompt vectors using a prompt generator, wherein the context prompt vectors define context information associated with an image classification task to be performed by the VLM,
subsequent to generating the plurality of context prompt vectors, generate prompts for each of the plurality of candidate classes by appending respective class text tokens to the context prompt vectors for each of the plurality of candidate classes, and
using the VLM, generate and output a class prediction probability for the input image based on the plurality of context prompt vectors, wherein using the VLM includes providing, to a text encoder of the VLM, the context prompt vectors; and
an actuator configured to control an operation of the computer-controlled machine based on the class prediction probability.
18 . The computer-controlled machine of claim 17 , wherein the VLM is a Contrastive Language-Image Pre-training (CLIP) model.
19 . The computer-controlled machine of claim 17 , further comprising a prompt generator model f θ configured to generate the plurality of context prompt vectors.
20 . The computer-controlled machine of claim 19 , wherein the prompt generator model is configured to map the text embeddings to the plurality of context prompt vectors.