Share via


PromptExecutionSettings Class

  • java.lang.Object
    • com.microsoft.semantickernel.orchestration.PromptExecutionSettings

public class PromptExecutionSettings

Configuration settings for prompt execution.

Field Summary

Modifier and Type Field and Description
static final int DEFAULT_BEST_OF

The default for getBestOf() if best_of is not provided.

static final double DEFAULT_FREQUENCY_PENALTY

The default for getFrequencyPenalty() if Builder#withFrequencyPenalty(double) frequency_penalty} is not provided.

static final int DEFAULT_MAX_TOKENS

The default for getMaxTokens() if max_tokens is not provided.

static final double DEFAULT_PRESENCE_PENALTY

The default for getPresencePenalty() if presence_penalty is not provided.

static final int DEFAULT_RESULTS_PER_PROMPT

The default for getResultsPerPrompt() if results per prompt (n) is not provided.

static final java.lang.String DEFAULT_SERVICE_ID

The default for getServiceId() if a service id is not provided.

static final double DEFAULT_TEMPERATURE

The default for getTemperature() if temperature is not provided.

static final double DEFAULT_TOP_P

The default for getTopP() if top_p is not provided.

Constructor Summary

Constructor Description
PromptExecutionSettings(String serviceId, String modelId, Double temperature, Double topP, Double presencePenalty, Double frequencyPenalty, Integer maxTokens, Integer resultsPerPrompt, Integer bestOf, String user, List<String> stopSequences, Map<Integer,Integer> tokenSelectionBiases, ResponseFormat responseFormat)

Create a new instance of PromptExecutionSettings.

Method Summary

Modifier and Type Method and Description
static Builder builder()

Create a new builder for PromptExecutionSettings.

boolean equals(Object obj)
int getBestOf()

The log probability threshold for a result to be considered.

double getFrequencyPenalty()

Frequency penalty encourages the model to avoid repeating the same token in the output.

int getMaxTokens()

The maximum number of tokens to generate in the output.

java.lang.String getModelId()

Get the id of the model to use for prompt execution.

double getPresencePenalty()

Presence penalty encourages the model to use a more or less diverse range of tokens in the output.

ResponseFormat getResponseFormat()

The response format to use for prompt execution.

int getResultsPerPrompt()

The number of results to generate for each prompt.

java.lang.String getServiceId()

Get the id of the AI service to use for prompt execution.

java.util.List<java.lang.String> getStopSequences()

The stop sequences to use for prompt execution.

double getTemperature()

The temperature setting controls the randomness of the output.

java.util.Map<java.lang.Integer,java.lang.Integer> getTokenSelectionBiases()

The token selection biases to use for prompt execution.

double getTopP()

The topP setting controls how many different words or phrases are considered to predict the next token.

java.lang.String getUser()

The user to associate with the prompt execution.

int hashCode()

Methods inherited from java.lang.Object

java.lang.Object.clone java.lang.Object.equals java.lang.Object.finalize java.lang.Object.getClass java.lang.Object.hashCode java.lang.Object.notify java.lang.Object.notifyAll java.lang.Object.toString java.lang.Object.wait java.lang.Object.wait java.lang.Object.wait

Field Details

DEFAULT_BEST_OF

public static final int DEFAULT_BEST_OF

The default for getBestOf() if best_of is not provided. Defaults to 1

DEFAULT_FREQUENCY_PENALTY

public static final double DEFAULT_FREQUENCY_PENALTY

The default for getFrequencyPenalty() if Builder#withFrequencyPenalty(double) frequency_penalty} is not provided. Defaults to 0.0

DEFAULT_MAX_TOKENS

public static final int DEFAULT_MAX_TOKENS

The default for getMaxTokens() if max_tokens is not provided. Defaults to 256

DEFAULT_PRESENCE_PENALTY

public static final double DEFAULT_PRESENCE_PENALTY

The default for getPresencePenalty() if presence_penalty is not provided. Defaults to 0.0

DEFAULT_RESULTS_PER_PROMPT

public static final int DEFAULT_RESULTS_PER_PROMPT

The default for getResultsPerPrompt() if results per prompt (n) is not provided. Defaults to 1

DEFAULT_SERVICE_ID

public static final String DEFAULT_SERVICE_ID

The default for getServiceId() if a service id is not provided. Defaults to "default"

DEFAULT_TEMPERATURE

public static final double DEFAULT_TEMPERATURE

The default for getTemperature() if temperature is not provided. Defaults to 1.0

DEFAULT_TOP_P

public static final double DEFAULT_TOP_P

The default for getTopP() if top_p is not provided. Defaults to 1.0

Constructor Details

PromptExecutionSettings

public PromptExecutionSettings(String serviceId, String modelId, Double temperature, Double topP, Double presencePenalty, Double frequencyPenalty, Integer maxTokens, Integer resultsPerPrompt, Integer bestOf, String user, List stopSequences, Map tokenSelectionBiases, ResponseFormat responseFormat)

Create a new instance of PromptExecutionSettings.

Parameters:

serviceId - The id of the AI service to use for prompt execution.
modelId - The id of the model to use for prompt execution.
temperature - The temperature setting for prompt execution.
topP - The topP setting for prompt execution.
presencePenalty - The presence penalty setting for prompt execution.
frequencyPenalty - The frequency penalty setting for prompt execution.
maxTokens - The maximum number of tokens to generate in the output.
resultsPerPrompt - The number of results to generate for each prompt.
bestOf - The best of setting for prompt execution.
user - The user to associate with the prompt execution.
stopSequences - The stop sequences to use for prompt execution.
tokenSelectionBiases - The token selection biases to use for prompt execution.
responseFormat - The response format to use for prompt execution ResponseFormat, Defaults to TextResponseFormat.

Method Details

builder

public static PromptExecutionSettings.Builder builder()

Create a new builder for PromptExecutionSettings.

Returns:

A new builder for PromptExecutionSettings.

equals

public boolean equals(Object obj)

Overrides:

PromptExecutionSettings.equals(Object obj)

Parameters:

obj

getBestOf

public int getBestOf()

The log probability threshold for a result to be considered.

Returns:

The log probability threshold for a result to be considered.

getFrequencyPenalty

public double getFrequencyPenalty()

Frequency penalty encourages the model to avoid repeating the same token in the output. A higher value means that the model will be less likely to repeat a token.

Returns:

The frequency penalty setting.

getMaxTokens

public int getMaxTokens()

The maximum number of tokens to generate in the output.

Returns:

The maximum number of tokens to generate in the output.

getModelId

public String getModelId()

Get the id of the model to use for prompt execution.

Returns:

The id of the model to use for prompt execution.

getPresencePenalty

public double getPresencePenalty()

Presence penalty encourages the model to use a more or less diverse range of tokens in the output. A higher value means that the model will try to use a greater variety of tokens in the output.

Returns:

The presence penalty setting.

getResponseFormat

public ResponseFormat getResponseFormat()

The response format to use for prompt execution. Currently this only applies to chat completions.

Returns:

The response format to use for prompt execution.

getResultsPerPrompt

public int getResultsPerPrompt()

The number of results to generate for each prompt.

Returns:

The number of results to generate for each prompt.

getServiceId

public String getServiceId()

Get the id of the AI service to use for prompt execution.

Returns:

The id of the AI service to use for prompt execution.

getStopSequences

public List getStopSequences()

The stop sequences to use for prompt execution.

Returns:

The stop sequences to use for prompt execution.

getTemperature

public double getTemperature()

The temperature setting controls the randomness of the output. Lower values produce more deterministic outputs, while higher values produce more random outputs.

Returns:

The temperature setting.

getTokenSelectionBiases

public Map getTokenSelectionBiases()

The token selection biases to use for prompt execution. The key is the token id from the tokenizer, and the value is the bias. A negative bias will make the model less likely to use the token, and a positive bias will make the model more likely to use the token.

Returns:

The token selection biases to use for prompt execution.

getTopP

public double getTopP()

The topP setting controls how many different words or phrases are considered to predict the next token. The value is a probability threshold, and the model considers the most likely tokens whose cumulative probability mass is greater than the threshold. For example, if the value is 0.1, the model considers only the tokens that make up the top 10% of the cumulative probability mass.

Returns:

The topP setting.

getUser

public String getUser()

The user to associate with the prompt execution.

Returns:

The user to associate with the prompt execution.

hashCode

public int hashCode()

Overrides:

PromptExecutionSettings.hashCode()

Applies to