Skip to content

Prompt optimization

bolt.PO128

Prompt optimization via search in a 128-dimensional embedding space.

The search space consists of 128-dimensional truncated embeddings from EmbeddingGemma. The full discrete candidate set is accessible at prob.obj_func.Xs, and can be used directly for discrete optimization. Evaluating any point X via prob(X) returns the Math500 0-shot accuracy of its nearest neighbor in the candidate set.

Example usage:

import torch
from bolt import PO128

prob = PO128(noise_std=0.001, negate=False)
X = torch.zeros(1, prob.dim, dtype=torch.double)
y = prob(X)

Source code in bolt/problems/prompt_opt.py
class PO128(PO):
    r"""Prompt optimization via search in a 128-dimensional embedding space.

    The search space consists of 128-dimensional truncated embeddings from EmbeddingGemma.
    The full discrete candidate set is accessible at ``prob.obj_func.Xs``, and
    can be used directly for discrete optimization. Evaluating any point X via
    ``prob(X)`` returns the Math500 0-shot accuracy of its nearest neighbor in
    the candidate set.

    Example usage:
    ```python
    import torch
    from bolt import PO128

    prob = PO128(noise_std=0.001, negate=False)
    X = torch.zeros(1, prob.dim, dtype=torch.double)
    y = prob(X)
    ```
    """

    name = "po128"
    dim = 128

bolt.PO256

Prompt optimization via search in a 256-dimensional embedding space.

The search space consists of 256-dimensional truncated embeddings from EmbeddingGemma. The full discrete candidate set is accessible at prob.obj_func.Xs, and can be used directly for discrete optimization. Evaluating any point X via prob(X) returns the Math500 0-shot accuracy of its nearest neighbor in the candidate set.

Example usage:

import torch
from bolt import PO256

prob = PO256(noise_std=0.001, negate=False)
X = torch.zeros(1, prob.dim, dtype=torch.double)
y = prob(X)

Source code in bolt/problems/prompt_opt.py
class PO256(PO):
    r"""Prompt optimization via search in a 256-dimensional embedding space.

    The search space consists of 256-dimensional truncated embeddings from EmbeddingGemma.
    The full discrete candidate set is accessible at ``prob.obj_func.Xs``, and
    can be used directly for discrete optimization. Evaluating any point X via
    ``prob(X)`` returns the Math500 0-shot accuracy of its nearest neighbor in
    the candidate set.

    Example usage:
    ```python
    import torch
    from bolt import PO256

    prob = PO256(noise_std=0.001, negate=False)
    X = torch.zeros(1, prob.dim, dtype=torch.double)
    y = prob(X)
    ```
    """

    name = "po256"
    dim = 256

bolt.PO512

Prompt optimization via search in a 512-dimensional embedding space.

The search space consists of 512-dimensional truncated embeddings from EmbeddingGemma. The full discrete candidate set is accessible at prob.obj_func.Xs, and can be used directly for discrete optimization. Evaluating any point X via prob(X) returns the Math500 0-shot accuracy of its nearest neighbor in the candidate set.

Example usage:

import torch
from bolt import PO512

prob = PO512(noise_std=0.001, negate=False)
X = torch.zeros(1, prob.dim, dtype=torch.double)
y = prob(X)

Source code in bolt/problems/prompt_opt.py
class PO512(PO):
    r"""Prompt optimization via search in a 512-dimensional embedding space.

    The search space consists of 512-dimensional truncated embeddings from EmbeddingGemma.
    The full discrete candidate set is accessible at ``prob.obj_func.Xs``, and
    can be used directly for discrete optimization. Evaluating any point X via
    ``prob(X)`` returns the Math500 0-shot accuracy of its nearest neighbor in
    the candidate set.

    Example usage:
    ```python
    import torch
    from bolt import PO512

    prob = PO512(noise_std=0.001, negate=False)
    X = torch.zeros(1, prob.dim, dtype=torch.double)
    y = prob(X)
    ```
    """

    name = "po512"
    dim = 512

bolt.PO768

Prompt optimization via search in a 768-dimensional embedding space.

The search space consists of 768-dimensional truncated embeddings from EmbeddingGemma. The full discrete candidate set is accessible at prob.obj_func.Xs, and can be used directly for discrete optimization. Evaluating any point X via prob(X) returns the Math500 0-shot accuracy of its nearest neighbor in the candidate set.

Example usage:

import torch
from bolt import PO768

prob = PO768(noise_std=0.001, negate=False)
X = torch.zeros(1, prob.dim, dtype=torch.double)
y = prob(X)

Source code in bolt/problems/prompt_opt.py
class PO768(PO):
    r"""Prompt optimization via search in a 768-dimensional embedding space.

    The search space consists of 768-dimensional truncated embeddings from EmbeddingGemma.
    The full discrete candidate set is accessible at ``prob.obj_func.Xs``, and
    can be used directly for discrete optimization. Evaluating any point X via
    ``prob(X)`` returns the Math500 0-shot accuracy of its nearest neighbor in
    the candidate set.

    Example usage:
    ```python
    import torch
    from bolt import PO768

    prob = PO768(noise_std=0.001, negate=False)
    X = torch.zeros(1, prob.dim, dtype=torch.double)
    y = prob(X)
    ```
    """

    name = "po768"
    dim = 768