在StarryOS上运行InfiniLM

Date: May 25, 2024

Topic: LLaMA模型概述

Notes

模型配置参数文件:

// config.json
{  
  "_name_or_path": "meta-llama/Llama-2-7b-hf",
  "architectures": [
    "LlamaForCausalLM"
  ],
  "bos_token_id": 1,
  "eos_token_id": 2,
  "hidden_act": "silu",
  "hidden_size": 4096,
  "initializer_range": 0.02,
  "intermediate_size": 11008,
  "max_position_embeddings": 4096,
  "model_type": "llama",
  "num_attention_heads":32,
  "num_hidden_layers": 32,
  "num_key_value_heads": 32,
  "pretraining_tp": 1,
  "rms_norm_eps": 1e-05,
  "rope_scaling": null,
  "tie_word_embeddings": false,
  "torch_dtype": "float16",
  "transformers_version": "4.31.0.dev0",
  "use_cache": true,
  "vocab size": 32000
}

Untitled

<aside> 💡 标记器(Tokenizer)— 将文本中的词转化成序号

Untitled

<aside> 💡 将token转换成向量 — One-hot Encoding — 以vocab_size作为向量长度表示一个词

</aside>

Untitled

<aside> 💡 Word Embedding文本嵌入 — 一个非常大的矩阵,大小vocab_size * hidden_size,一个词对应一个向量

<aside> 💡 层归一化(RMS Norm)— 对每一层的输入都会做一次RMS Norm操作

</aside>