Record Class GenerationRequest
java.lang.Object
java.lang.Record
smile.llm.engine.GenerationRequest
- Record Components:
promptTokens- token ids (required unlessdialogis set).dialog- optional chat turns; encoded by the engine whenpromptTokensisnull.multimodal- optional Qwen VL preprocess result (images/video); when set,promptTokensshould matchmultimodal.inputIds().maxGenLen- max new tokens.temperature- sampling temperature.topp- nucleus top-p.logprobs- whether to return log-probabilities.seed- RNG seed;0= non-deterministic.listener- optional per-request listener.chatOptions- optional tool-calling options.speculative- whentrue, use native MTP draft/verify if available.numSpeculativeTokens- draft depth;<= 0uses the model default.
public record GenerationRequest(int[] promptTokens, Message[] dialog, QwenVlProcessor.ProcessedMultimodal multimodal, int maxGenLen, double temperature, double topp, boolean logprobs, long seed, GenerationListener listener, ChatOptions chatOptions, boolean speculative, int numSpeculativeTokens)
extends Record
One generation job submitted to
InferenceEngine.-
Constructor Summary
ConstructorsConstructorDescriptionGenerationRequest(int[] promptTokens, Message[] dialog, QwenVlProcessor.ProcessedMultimodal multimodal, int maxGenLen, double temperature, double topp, boolean logprobs, long seed, GenerationListener listener, ChatOptions chatOptions, boolean speculative, int numSpeculativeTokens) Creates an instance of aGenerationRequestrecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thechatOptionsrecord component.Message[]dialog()Returns the value of thedialogrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.booleanReturns whether vision prefill is required.listener()Returns the value of thelistenerrecord component.booleanlogprobs()Returns the value of thelogprobsrecord component.intReturns the value of themaxGenLenrecord component.Returns the value of themultimodalrecord component.intReturns the value of thenumSpeculativeTokensrecord component.static GenerationRequestofDialog(Message[] dialog, int maxGenLen, double temperature, double topp, boolean logprobs, long seed, GenerationListener listener) Builds a request from a chat dialog (encoded at execution time).static GenerationRequestofDialog(Message[] dialog, ChatOptions chatOptions, int maxGenLen, double temperature, double topp, boolean logprobs, long seed, GenerationListener listener) Builds a request from a chat dialog with chat options.static GenerationRequestofDialog(Message[] dialog, ChatOptions chatOptions, int maxGenLen, double temperature, double topp, boolean logprobs, long seed, GenerationListener listener, boolean speculative, int numSpeculativeTokens) Builds a request from a chat dialog with speculation flags.static GenerationRequestofMultimodal(QwenVlProcessor.ProcessedMultimodal multimodal, int maxGenLen, double temperature, double topp, boolean logprobs, long seed, GenerationListener listener) Builds a multimodal request (vision embeds spliced during prefill).static GenerationRequestofMultimodal(QwenVlProcessor.ProcessedMultimodal multimodal, int maxGenLen, double temperature, double topp, boolean logprobs, long seed, GenerationListener listener, ChatOptions chatOptions) Builds a multimodal request with chat options.static GenerationRequestofMultimodal(QwenVlProcessor.ProcessedMultimodal multimodal, int maxGenLen, double temperature, double topp, boolean logprobs, long seed, GenerationListener listener, ChatOptions chatOptions, boolean speculative, int numSpeculativeTokens) Builds a multimodal request with speculation flags.static GenerationRequestofTokens(int[] promptTokens, int maxGenLen, double temperature, double topp, boolean logprobs, long seed, GenerationListener listener) Builds a request from already-tokenized prompt ids.static GenerationRequestofTokens(int[] promptTokens, int maxGenLen, double temperature, double topp, boolean logprobs, long seed, GenerationListener listener, ChatOptions chatOptions) Builds a request from already-tokenized prompt ids with chat options.static GenerationRequestofTokens(int[] promptTokens, int maxGenLen, double temperature, double topp, boolean logprobs, long seed, GenerationListener listener, ChatOptions chatOptions, boolean speculative, int numSpeculativeTokens) Builds a request from already-tokenized prompt ids with speculation flags.int[]Returns the value of thepromptTokensrecord component.longseed()Returns the value of theseedrecord component.booleanReturns the value of thespeculativerecord component.doubleReturns the value of thetemperaturerecord component.doubletopp()Returns the value of thetopprecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
GenerationRequest
public GenerationRequest(int[] promptTokens, Message[] dialog, QwenVlProcessor.ProcessedMultimodal multimodal, int maxGenLen, double temperature, double topp, boolean logprobs, long seed, GenerationListener listener, ChatOptions chatOptions, boolean speculative, int numSpeculativeTokens) Creates an instance of aGenerationRequestrecord class.- Parameters:
promptTokens- the value for thepromptTokensrecord componentdialog- the value for thedialogrecord componentmultimodal- the value for themultimodalrecord componentmaxGenLen- the value for themaxGenLenrecord componenttemperature- the value for thetemperaturerecord componenttopp- the value for thetopprecord componentlogprobs- the value for thelogprobsrecord componentseed- the value for theseedrecord componentlistener- the value for thelistenerrecord componentchatOptions- the value for thechatOptionsrecord componentspeculative- the value for thespeculativerecord componentnumSpeculativeTokens- the value for thenumSpeculativeTokensrecord component
-
-
Method Details
-
ofTokens
public static GenerationRequest ofTokens(int[] promptTokens, int maxGenLen, double temperature, double topp, boolean logprobs, long seed, GenerationListener listener) Builds a request from already-tokenized prompt ids.- Parameters:
promptTokens- prompt token ids.maxGenLen- maximum generated tokens.temperature- sampling temperature.topp- nucleus sampling threshold.logprobs- whether to return log probabilities.seed- RNG seed.listener- optional generation listener, ornull.- Returns:
- new generation request.
-
ofTokens
public static GenerationRequest ofTokens(int[] promptTokens, int maxGenLen, double temperature, double topp, boolean logprobs, long seed, GenerationListener listener, ChatOptions chatOptions) Builds a request from already-tokenized prompt ids with chat options.- Parameters:
promptTokens- prompt token ids.maxGenLen- maximum generated tokens.temperature- sampling temperature.topp- nucleus sampling threshold.logprobs- whether to return log probabilities.seed- RNG seed.listener- optional generation listener, ornull.chatOptions- optional chat options, ornull.- Returns:
- new generation request.
-
ofTokens
public static GenerationRequest ofTokens(int[] promptTokens, int maxGenLen, double temperature, double topp, boolean logprobs, long seed, GenerationListener listener, ChatOptions chatOptions, boolean speculative, int numSpeculativeTokens) Builds a request from already-tokenized prompt ids with speculation flags.- Parameters:
promptTokens- prompt token ids.maxGenLen- maximum generated tokens.temperature- sampling temperature.topp- nucleus sampling threshold.logprobs- whether to return log probabilities.seed- RNG seed.listener- optional generation listener, ornull.chatOptions- optional chat options, ornull.speculative- whether speculative decoding is requested.numSpeculativeTokens- draft tokens when speculative.- Returns:
- new generation request.
-
ofMultimodal
public static GenerationRequest ofMultimodal(QwenVlProcessor.ProcessedMultimodal multimodal, int maxGenLen, double temperature, double topp, boolean logprobs, long seed, GenerationListener listener) Builds a multimodal request (vision embeds spliced during prefill).- Parameters:
multimodal- processed multimodal inputs.maxGenLen- maximum generated tokens.temperature- sampling temperature.topp- nucleus sampling threshold.logprobs- whether to return log probabilities.seed- RNG seed.listener- optional generation listener, ornull.- Returns:
- new generation request.
-
ofMultimodal
public static GenerationRequest ofMultimodal(QwenVlProcessor.ProcessedMultimodal multimodal, int maxGenLen, double temperature, double topp, boolean logprobs, long seed, GenerationListener listener, ChatOptions chatOptions) Builds a multimodal request with chat options.- Parameters:
multimodal- processed multimodal inputs.maxGenLen- maximum generated tokens.temperature- sampling temperature.topp- nucleus sampling threshold.logprobs- whether to return log probabilities.seed- RNG seed.listener- optional generation listener, ornull.chatOptions- optional chat options, ornull.- Returns:
- new generation request.
-
ofMultimodal
public static GenerationRequest ofMultimodal(QwenVlProcessor.ProcessedMultimodal multimodal, int maxGenLen, double temperature, double topp, boolean logprobs, long seed, GenerationListener listener, ChatOptions chatOptions, boolean speculative, int numSpeculativeTokens) Builds a multimodal request with speculation flags.- Parameters:
multimodal- processed multimodal inputs.maxGenLen- maximum generated tokens.temperature- sampling temperature.topp- nucleus sampling threshold.logprobs- whether to return log probabilities.seed- RNG seed.listener- optional generation listener, ornull.chatOptions- optional chat options, ornull.speculative- whether speculative decoding is requested.numSpeculativeTokens- draft tokens when speculative.- Returns:
- new generation request.
-
ofDialog
public static GenerationRequest ofDialog(Message[] dialog, int maxGenLen, double temperature, double topp, boolean logprobs, long seed, GenerationListener listener) Builds a request from a chat dialog (encoded at execution time).- Parameters:
dialog- chat messages.maxGenLen- maximum generated tokens.temperature- sampling temperature.topp- nucleus sampling threshold.logprobs- whether to return log probabilities.seed- RNG seed.listener- optional generation listener, ornull.- Returns:
- new generation request.
-
ofDialog
public static GenerationRequest ofDialog(Message[] dialog, ChatOptions chatOptions, int maxGenLen, double temperature, double topp, boolean logprobs, long seed, GenerationListener listener) Builds a request from a chat dialog with chat options.- Parameters:
dialog- chat messages.chatOptions- chat options, ornull.maxGenLen- maximum generated tokens.temperature- sampling temperature.topp- nucleus sampling threshold.logprobs- whether to return log probabilities.seed- RNG seed.listener- optional generation listener, ornull.- Returns:
- new generation request.
-
ofDialog
public static GenerationRequest ofDialog(Message[] dialog, ChatOptions chatOptions, int maxGenLen, double temperature, double topp, boolean logprobs, long seed, GenerationListener listener, boolean speculative, int numSpeculativeTokens) Builds a request from a chat dialog with speculation flags.- Parameters:
dialog- chat messages.chatOptions- chat options, ornull.maxGenLen- maximum generated tokens.temperature- sampling temperature.topp- nucleus sampling threshold.logprobs- whether to return log probabilities.seed- RNG seed.listener- optional generation listener, ornull.speculative- whether speculative decoding is requested.numSpeculativeTokens- draft tokens when speculative.- Returns:
- new generation request.
-
hasMultimodal
public boolean hasMultimodal()Returns whether vision prefill is required.- Returns:
truewhen vision prefill is required.
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
promptTokens
public int[] promptTokens()Returns the value of thepromptTokensrecord component.- Returns:
- the value of the
promptTokensrecord component
-
dialog
-
multimodal
Returns the value of themultimodalrecord component.- Returns:
- the value of the
multimodalrecord component
-
maxGenLen
-
temperature
public double temperature()Returns the value of thetemperaturerecord component.- Returns:
- the value of the
temperaturerecord component
-
topp
-
logprobs
-
seed
-
listener
-
chatOptions
Returns the value of thechatOptionsrecord component.- Returns:
- the value of the
chatOptionsrecord component
-
speculative
public boolean speculative()Returns the value of thespeculativerecord component.- Returns:
- the value of the
speculativerecord component
-
numSpeculativeTokens
public int numSpeculativeTokens()Returns the value of thenumSpeculativeTokensrecord component.- Returns:
- the value of the
numSpeculativeTokensrecord component
-