0 / 0
Saving your work
Last updated: Dec 12, 2024
Saving your work

Prompt engineering involves trial and error. Keep track of your experimentation and save model-and-prompt combinations that generate the output you want.

When you save your work, you can choose to save it as different asset types. Saving your work as an asset makes it possible to share your work with collaborators in the current project.

Table 1: Asset types
Asset type When to use this asset type What is saved How to retrieve the asset
Prompt template asset When you find a combination of prompt static text, prompt variables, and prompt engineering parameters that generate the results you want from a specific model and want to reuse it. Prompt text, model, prompt engineering parameters, prompt variables, and AI guardrails settings.
Note: The output that is generated by the model is not saved as part of the prompt template unless the prompt was created in chat mode.
From the Saved prompt templates tab
Prompt session asset When you want to keep track of the steps involved with your experimentation so you know what you've tried and what you haven't. Prompt text, model, prompt engineering parameters, AI guardrails settings, and model output for up to 500 prompts that are submitted during a prompt engineering session. From the History tab
Standard notebook asset When you want to work with models programmatically, but want to start from the Prompt Lab interface for a better prompt engineering experience. Prompt text, model, prompt engineering parameters, and prompt variable names and default values are formatted as Python code and stored as a Python notebook. From the Assets page of the project
Deployment notebook When your prompt can do advanced functions such as search grounding documents for answers to questions from a chat and you want to deploy the function as an AI service. A deployable Python function that can be consumed by REST APIs.
Note: You can save your work as a deployment notebook only when you select a vector index and use a chat model.
From the Assets page of the project

Each of these asset types is available from the project's Assets page. Project collaborators with the Admin or Editor role can open and work with them. Your prompt template and prompt session assets are locked automatically, but you can unlock them by clicking the Lock icon Lock icon.

Editors and Admins can use locked prompt template assets to generate inferences. Only the lock owner can use a locked prompt session asset to generate inferences.

Saving your work

To save your prompt engineering work, complete the following steps:

  1. From the header of the prompt editor, click the Save work icon Save icon, and then click Save as.

  2. Choose an asset type.

    If you choose to create a deployable Gen AI flow notebook, you must associate the prompt with a deployment space. For more information, see Deployment spaces.

  3. Name the asset, and then optionally add a description.

  4. Watsonx.governance only: Choose the task type that best matches your goal.

  5. If you save the prompt as a notebook asset only: Select View in project after saving.

  6. Click Save.

Working with prompts saved in a notebook

When you save your work as a notebook asset, a Python notebook is built.

To work with a prompt notebook asset, complete the following steps depending on the type of notebook:

Standard notebook

  1. Open the notebook asset from the Assets tab of your project.

  2. Click the Edit icon Edit icon to instantiate the notebook so you can step through the code.

    The notebook contains runnable code that manages the following steps for you:

    • Authenticates with the service.
    • Defines a Python class.
    • Defines the input text for the model and declares any prompt variables. You can edit the static prompt text and assign values to prompt variables.
    • Uses the defined class to call the watsonx.ai inferencing API and pass your input to the foundation model.
    • Shows the output that is generated by the foundation model.
    Note: For prompts that inference tuned models that are stored in the project, replace the space ID with the project ID.
  3. Use the notebook as is, or change it to meet the needs of your use case.

    The Python code that is generated by using the Prompt Lab executes successfully. You must test and validate any changes that you make to the code.

Deployment notebook

  1. Open the notebook asset from the Assets tab of your project.

  2. Click the Edit icon Edit icon to instantiate the notebook so you can step through the code.

    The notebook contains runnable code that manages the following steps for you:

    • Authenticates with the service.
    • Connects to the target space and promotes the vector index.
    • Defines the python function to be deployed. This includes code to initialize the vector index, make queries against the vector index, format the input for the model, and run inferences.
    • Tests the python function locally.
    • Deploys the python function to the target space.
    • Tests the deployed python function.
  3. Use the notebook as is, or change it to meet the needs of your use case.

    The Python code that is generated by using the Prompt Lab executes successfully. You must test and validate any changes that you make to the code.

  4. The Python function deployed by the notebook can be consumed using a REST API. The following is an example cURL request to call your deployment:

    curl --location '${PUBLIC_ENDPOINT}' \
    --header 'Content-Type: application/json' \
    --header 'Authorization: Bearer ${IAM_TOKEN}' \
    --data '{ \
      "input_data": [{
          "fields": ["Search", "Access token"],
          "values": [
            [${MESSAGES}],
            [${IAM_TOKEN}]]
        }]
    }'
    

    where

    {
       "role": type, // "user" or "assistant"
       "content": content // The text content of the message
    }
    

Working with saved prompt templates

To continue working with a saved prompt, open it from the Saved prompt templates tab of the Prompt Lab.

When you open a saved prompt template, Autosave is on, which means that any changes you make to the prompt will be reflected in the saved prompt template asset. If you want the prompt template that you saved to remain unchanged, click New prompt to start a new prompt.

You cannot change edit modes from a saved prompt template.

Unlike other edit modes, a prompt template that is saved in chat mode also stores the model output. You cannot switch to a different mode from a prompt template that was saved in chat mode.

When watsonx.governance is provisioned, if your prompt template includes at least one prompt variable, you can evaluate the effectiveness of model responses.

Note: You cannot deploy or evaluate saved prompt templates that inference deploy on-demand foundation models.

Working with saved prompt sessions

To continue working with a saved prompt session, open it from the History tab of the Prompt Lab.

To review previous prompt submissions, you can click a prompt entry from the history to open it in the prompt editor. If you prefer the results from the earlier prompt, you can reset it as your current prompt by clicking Restore. When you restore an earlier prompt, your current prompt session is replaced by the earlier version of the prompt session.

Learn more

Parent topic: Prompt Lab

Generative AI search and answer
These answers are generated by a large language model in watsonx.ai based on content from the product documentation. Learn more