Package smile.llm.llama
Class FeedForward
java.lang.Object
smile.llm.llama.FeedForward
Feedforward layer in Transformer. It has two linear transformations and
an intermediate SiLU activation function.
-
Constructor Summary
ConstructorDescriptionFeedForward
(int dim, int hiddenDim, int multipleOf, Double ffnDimMultiplier) Constructor. -
Method Summary
-
Constructor Details
-
FeedForward
Constructor.- Parameters:
dim
- the dimension of input tensor.hiddenDim
- the dimension of hidden layer. First, hiddenDim is set to two-thirds of the provided hiddenDim value. If ffnDimMultiplier is provided, hiddenDim is further multiplied by this value. The hiddenDim is then adjusted to ensure it is a multiple of multipleOf.multipleOf
- make SwiGLU hidden layer size multiple of large power of 2.ffnDimMultiplier
- the multiplier for the hidden dimension of the feedforward layers.
-
-
Method Details
-
forward
Feed forward.- Parameters:
x
- the input tensor.- Returns:
- the output tensor.
-