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.scaledRope- scale RoPE positional encoding if true.maxBatchSize- the maximum batch size.maxSeqLen- the maximum sequence length for input data.
-
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- if fail to open the parameter file.
-
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. -
dim
-
numLayers
-
numHeads
-
numKvHeads
Returns the value of thenumKvHeadsrecord component.- Returns:
- the value of the
numKvHeadsrecord component
-
vocabSize
-
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
-
ropeTheta
-
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
-