Package smile.llm.llama
Record Class ModelArgs
java.lang.Object
java.lang.Record
smile.llm.llama.ModelArgs
- Record Components:
dim- the dimension of token embedding.numLayers- the number of transformer blocks.numHeads- the number of attention heads.numKvHeads- the number of key and value heads.vocabSize- the size of the vocabulary.multipleOf- make SwiGLU hidden layer size multiple of large power of 2.ffnDimMultiplier- the multiplier for the hidden dimension of the feedforward layers.normEps- the epsilon value used for numerical stability in normalization layers.ropeTheta- the theta parameter in rotary positional encoding.maxBatchSize- the maximum batch size.maxSeqLen- the maximum sequence length for input data.
public record ModelArgs(int dim, int numLayers, int numHeads, Integer numKvHeads, int vocabSize, int multipleOf, Double ffnDimMultiplier, double normEps, double ropeTheta, boolean scaledRope, int maxBatchSize, int maxSeqLen)
extends Record
LLaMA model hyperparameters.
-
Constructor Summary
ConstructorsConstructorDescriptionConstructor with default parameter values.ModelArgs(int dim, int numLayers, int numHeads, Integer numKvHeads, int vocabSize, int multipleOf, Double ffnDimMultiplier, double normEps, double ropeTheta, boolean scaledRope, int maxBatchSize, int maxSeqLen) Creates an instance of aModelArgsrecord class. -
Method Summary
Modifier and TypeMethodDescriptionintdim()Returns the value of thedimrecord component.final booleanIndicates whether some other object is "equal to" this one.Returns the value of theffnDimMultiplierrecord component.static ModelArgsLoads the model hyperparameters from a JSON file.final inthashCode()Returns a hash code value for this object.intReturns the value of themaxBatchSizerecord component.intReturns the value of themaxSeqLenrecord component.intReturns the value of themultipleOfrecord component.doublenormEps()Returns the value of thenormEpsrecord component.intnumHeads()Returns the value of thenumHeadsrecord component.Returns the value of thenumKvHeadsrecord component.intReturns the value of thenumLayersrecord component.doubleReturns the value of theropeThetarecord component.booleanReturns the value of thescaledRoperecord component.final StringtoString()Returns a string representation of this record class.intReturns the value of thevocabSizerecord component.
-
Constructor Details
-
ModelArgs
public ModelArgs()Constructor with default parameter values. -
ModelArgs
public ModelArgs(int dim, int numLayers, int numHeads, Integer numKvHeads, int vocabSize, int multipleOf, Double ffnDimMultiplier, double normEps, double ropeTheta, boolean scaledRope, int maxBatchSize, int maxSeqLen) Creates an instance of aModelArgsrecord class.- Parameters:
dim- the value for thedimrecord componentnumLayers- the value for thenumLayersrecord componentnumHeads- the value for thenumHeadsrecord componentnumKvHeads- the value for thenumKvHeadsrecord componentvocabSize- the value for thevocabSizerecord componentmultipleOf- the value for themultipleOfrecord componentffnDimMultiplier- the value for theffnDimMultiplierrecord componentnormEps- the value for thenormEpsrecord componentropeTheta- the value for theropeThetarecord componentscaledRope- the value for thescaledRoperecord componentmaxBatchSize- the value for themaxBatchSizerecord componentmaxSeqLen- the value for themaxSeqLenrecord component
-
-
Method Details
-
from
Loads the model hyperparameters from a JSON file.- Parameters:
path- the file path.maxBatchSize- the maximum batch size.maxSeqLen- the maximum sequence length for input data.- Returns:
- the model hyperparameters.
- Throws:
IOException
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
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 '=='. -
dim
public int dim()Returns the value of thedimrecord component.- Returns:
- the value of the
dimrecord component
-
numLayers
public int numLayers()Returns the value of thenumLayersrecord component.- Returns:
- the value of the
numLayersrecord component
-
numHeads
public int numHeads()Returns the value of thenumHeadsrecord component.- Returns:
- the value of the
numHeadsrecord component
-
numKvHeads
Returns the value of thenumKvHeadsrecord component.- Returns:
- the value of the
numKvHeadsrecord component
-
vocabSize
public int vocabSize()Returns the value of thevocabSizerecord component.- Returns:
- the value of the
vocabSizerecord component
-
multipleOf
public int multipleOf()Returns the value of themultipleOfrecord component.- Returns:
- the value of the
multipleOfrecord component
-
ffnDimMultiplier
Returns the value of theffnDimMultiplierrecord component.- Returns:
- the value of the
ffnDimMultiplierrecord component
-
normEps
public double normEps()Returns the value of thenormEpsrecord component.- Returns:
- the value of the
normEpsrecord component
-
ropeTheta
public double ropeTheta()Returns the value of theropeThetarecord component.- Returns:
- the value of the
ropeThetarecord component
-
scaledRope
public boolean scaledRope()Returns the value of thescaledRoperecord component.- Returns:
- the value of the
scaledRoperecord component
-
maxBatchSize
public int maxBatchSize()Returns the value of themaxBatchSizerecord component.- Returns:
- the value of the
maxBatchSizerecord component
-
maxSeqLen
public int maxSeqLen()Returns the value of themaxSeqLenrecord component.- Returns:
- the value of the
maxSeqLenrecord component
-