All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.cdklabs.generative_ai_cdk_constructs.bedrock.InferenceConfiguration Maven / Gradle / Ivy

Go to download

AWS Generative AI CDK Constructs is a library for well-architected generative AI patterns.

There is a newer version: 0.1.271
Show newest version
package io.github.cdklabs.generative_ai_cdk_constructs.bedrock;

/**
 * (experimental) LLM inference configuration.
 */
@javax.annotation.Generated(value = "jsii-pacmak/1.103.1 (build bef2dea)", date = "2024-09-23T18:35:37.393Z")
@software.amazon.jsii.Jsii(module = io.github.cdklabs.generative_ai_cdk_constructs.$Module.class, fqn = "@cdklabs/generative-ai-cdk-constructs.bedrock.InferenceConfiguration")
@software.amazon.jsii.Jsii.Proxy(InferenceConfiguration.Jsii$Proxy.class)
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental)
public interface InferenceConfiguration extends software.amazon.jsii.JsiiSerializable {

    /**
     * (experimental) The maximum number of tokens to generate in the response.
     * 

* Integer *

* min 0 * max 4096 */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) @org.jetbrains.annotations.NotNull java.lang.Number getMaximumLength(); /** * (experimental) A list of stop sequences. *

* A stop sequence is a sequence of characters that * causes the model to stop generating the response. *

* length 0-4 */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) @org.jetbrains.annotations.NotNull java.util.List getStopSequences(); /** * (experimental) The likelihood of the model selecting higher-probability options while generating a response. *

* A lower value makes the model more likely to choose * higher-probability options, while a higher value makes the model more * likely to choose lower-probability options. *

* Floating point *

* min 0 * max 1 */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) @org.jetbrains.annotations.NotNull java.lang.Number getTemperature(); /** * (experimental) While generating a response, the model determines the probability of the following token at each point of generation. *

* The value that you set for * topK is the number of most-likely candidates from which the model chooses * the next token in the sequence. For example, if you set topK to 50, the * model selects the next token from among the top 50 most likely choices. *

* Integer *

* min 0 * max 500 */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) @org.jetbrains.annotations.NotNull java.lang.Number getTopK(); /** * (experimental) While generating a response, the model determines the probability of the following token at each point of generation. *

* The value that you set for * Top P determines the number of most-likely candidates from which the model * chooses the next token in the sequence. For example, if you set topP to * 80, the model only selects the next token from the top 80% of the * probability distribution of next tokens. *

* Floating point *

* min 0 * max 1 */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) @org.jetbrains.annotations.NotNull java.lang.Number getTopP(); /** * @return a {@link Builder} of {@link InferenceConfiguration} */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) static Builder builder() { return new Builder(); } /** * A builder for {@link InferenceConfiguration} */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public static final class Builder implements software.amazon.jsii.Builder { java.lang.Number maximumLength; java.util.List stopSequences; java.lang.Number temperature; java.lang.Number topK; java.lang.Number topP; /** * Sets the value of {@link InferenceConfiguration#getMaximumLength} * @param maximumLength The maximum number of tokens to generate in the response. This parameter is required. * Integer *

* min 0 * max 4096 * @return {@code this} */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public Builder maximumLength(java.lang.Number maximumLength) { this.maximumLength = maximumLength; return this; } /** * Sets the value of {@link InferenceConfiguration#getStopSequences} * @param stopSequences A list of stop sequences. This parameter is required. * A stop sequence is a sequence of characters that * causes the model to stop generating the response. *

* length 0-4 * @return {@code this} */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public Builder stopSequences(java.util.List stopSequences) { this.stopSequences = stopSequences; return this; } /** * Sets the value of {@link InferenceConfiguration#getTemperature} * @param temperature The likelihood of the model selecting higher-probability options while generating a response. This parameter is required. * A lower value makes the model more likely to choose * higher-probability options, while a higher value makes the model more * likely to choose lower-probability options. *

* Floating point *

* min 0 * max 1 * @return {@code this} */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public Builder temperature(java.lang.Number temperature) { this.temperature = temperature; return this; } /** * Sets the value of {@link InferenceConfiguration#getTopK} * @param topK While generating a response, the model determines the probability of the following token at each point of generation. This parameter is required. * The value that you set for * topK is the number of most-likely candidates from which the model chooses * the next token in the sequence. For example, if you set topK to 50, the * model selects the next token from among the top 50 most likely choices. *

* Integer *

* min 0 * max 500 * @return {@code this} */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public Builder topK(java.lang.Number topK) { this.topK = topK; return this; } /** * Sets the value of {@link InferenceConfiguration#getTopP} * @param topP While generating a response, the model determines the probability of the following token at each point of generation. This parameter is required. * The value that you set for * Top P determines the number of most-likely candidates from which the model * chooses the next token in the sequence. For example, if you set topP to * 80, the model only selects the next token from the top 80% of the * probability distribution of next tokens. *

* Floating point *

* min 0 * max 1 * @return {@code this} */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) public Builder topP(java.lang.Number topP) { this.topP = topP; return this; } /** * Builds the configured instance. * @return a new instance of {@link InferenceConfiguration} * @throws NullPointerException if any required attribute was not provided */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) @Override public InferenceConfiguration build() { return new Jsii$Proxy(this); } } /** * An implementation for {@link InferenceConfiguration} */ @software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Experimental) @software.amazon.jsii.Internal final class Jsii$Proxy extends software.amazon.jsii.JsiiObject implements InferenceConfiguration { private final java.lang.Number maximumLength; private final java.util.List stopSequences; private final java.lang.Number temperature; private final java.lang.Number topK; private final java.lang.Number topP; /** * Constructor that initializes the object based on values retrieved from the JsiiObject. * @param objRef Reference to the JSII managed object. */ protected Jsii$Proxy(final software.amazon.jsii.JsiiObjectRef objRef) { super(objRef); this.maximumLength = software.amazon.jsii.Kernel.get(this, "maximumLength", software.amazon.jsii.NativeType.forClass(java.lang.Number.class)); this.stopSequences = software.amazon.jsii.Kernel.get(this, "stopSequences", software.amazon.jsii.NativeType.listOf(software.amazon.jsii.NativeType.forClass(java.lang.String.class))); this.temperature = software.amazon.jsii.Kernel.get(this, "temperature", software.amazon.jsii.NativeType.forClass(java.lang.Number.class)); this.topK = software.amazon.jsii.Kernel.get(this, "topK", software.amazon.jsii.NativeType.forClass(java.lang.Number.class)); this.topP = software.amazon.jsii.Kernel.get(this, "topP", software.amazon.jsii.NativeType.forClass(java.lang.Number.class)); } /** * Constructor that initializes the object based on literal property values passed by the {@link Builder}. */ protected Jsii$Proxy(final Builder builder) { super(software.amazon.jsii.JsiiObject.InitializationMode.JSII); this.maximumLength = java.util.Objects.requireNonNull(builder.maximumLength, "maximumLength is required"); this.stopSequences = java.util.Objects.requireNonNull(builder.stopSequences, "stopSequences is required"); this.temperature = java.util.Objects.requireNonNull(builder.temperature, "temperature is required"); this.topK = java.util.Objects.requireNonNull(builder.topK, "topK is required"); this.topP = java.util.Objects.requireNonNull(builder.topP, "topP is required"); } @Override public final java.lang.Number getMaximumLength() { return this.maximumLength; } @Override public final java.util.List getStopSequences() { return this.stopSequences; } @Override public final java.lang.Number getTemperature() { return this.temperature; } @Override public final java.lang.Number getTopK() { return this.topK; } @Override public final java.lang.Number getTopP() { return this.topP; } @Override @software.amazon.jsii.Internal public com.fasterxml.jackson.databind.JsonNode $jsii$toJson() { final com.fasterxml.jackson.databind.ObjectMapper om = software.amazon.jsii.JsiiObjectMapper.INSTANCE; final com.fasterxml.jackson.databind.node.ObjectNode data = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode(); data.set("maximumLength", om.valueToTree(this.getMaximumLength())); data.set("stopSequences", om.valueToTree(this.getStopSequences())); data.set("temperature", om.valueToTree(this.getTemperature())); data.set("topK", om.valueToTree(this.getTopK())); data.set("topP", om.valueToTree(this.getTopP())); final com.fasterxml.jackson.databind.node.ObjectNode struct = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode(); struct.set("fqn", om.valueToTree("@cdklabs/generative-ai-cdk-constructs.bedrock.InferenceConfiguration")); struct.set("data", data); final com.fasterxml.jackson.databind.node.ObjectNode obj = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode(); obj.set("$jsii.struct", struct); return obj; } @Override public final boolean equals(final Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; InferenceConfiguration.Jsii$Proxy that = (InferenceConfiguration.Jsii$Proxy) o; if (!maximumLength.equals(that.maximumLength)) return false; if (!stopSequences.equals(that.stopSequences)) return false; if (!temperature.equals(that.temperature)) return false; if (!topK.equals(that.topK)) return false; return this.topP.equals(that.topP); } @Override public final int hashCode() { int result = this.maximumLength.hashCode(); result = 31 * result + (this.stopSequences.hashCode()); result = 31 * result + (this.temperature.hashCode()); result = 31 * result + (this.topK.hashCode()); result = 31 * result + (this.topP.hashCode()); return result; } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy