MCPcopy Create free account
hub / github.com/cli99/llm-analysis / get_num_params_embedding

Method get_num_params_embedding

llm_analysis/analysis.py:244–259  ·  view source on GitHub ↗

Get the number of parameters in the embedding layer. Args: shared_embedding (bool, optional): whether the output embedding \ shares weights with the input embedding. Defaults to True. Returns: int: the number of parameters in the embedding l

(self, shared_embedding: bool = True)

Source from the content-addressed store, hash-verified

242 return pivot
243
244 def get_num_params_embedding(self, shared_embedding: bool = True) -> int:
245 """Get the number of parameters in the embedding layer.
246
247 Args:
248 shared_embedding (bool, optional): whether the output embedding \
249 shares weights with the input embedding. Defaults to True.
250
251 Returns:
252 int: the number of parameters in the embedding layer
253 """
254 num_params_input_embedding = (self.model_config.hidden_dim *
255 self.model_config.vocab_size)
256 num_params_output_embedding = (self.model_config.hidden_dim *
257 self.model_config.vocab_size
258 if not shared_embedding else 0)
259 return num_params_input_embedding + num_params_output_embedding
260
261 def get_num_params_per_layer_attn(self) -> int:
262 """Get the number of parameters in the attention linear layers, including the

Calls

no outgoing calls

Tested by

no test coverage detected