{"id":2424,"date":"2024-03-11T01:30:25","date_gmt":"2024-03-10T17:30:25","guid":{"rendered":"https:\/\/www.aqwu.net\/wp\/?p=2424"},"modified":"2024-04-28T20:03:06","modified_gmt":"2024-04-28T12:03:06","slug":"%e4%ba%86%e8%a7%a3-llama-2-%e6%a8%a1%e5%9e%8b%e7%bb%93%e6%9e%842","status":"publish","type":"post","link":"https:\/\/www.aqwu.net\/wp\/?p=2424","title":{"rendered":"\u4e86\u89e3 LLaMA-2 \u6a21\u578b\u7ed3\u6784(2)"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\"><strong>5. \u5982\u4f55\u6253\u5370\u6a21\u578b\u53c2\u6570\uff1f<\/strong><\/h2>\n\n\n\n<p>\u5728\u4f7f\u7528\u50cfPyTorch\u8fd9\u6837\u7684\u6df1\u5ea6\u5b66\u4e60\u6846\u67b6\u65f6\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u51e0\u79cd\u65b9\u6cd5\u6253\u5370\u6a21\u578b\u7684\u53c2\u6570\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u7528\u7684\u65b9\u6cd5\uff1a<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u65b9\u6cd5 1: \u6253\u5370\u6a21\u578b\u7684\u6240\u6709\u53c2\u6570<\/strong><\/h3>\n\n\n\n<p>\u8fd9\u79cd\u65b9\u6cd5\u4f1a\u904d\u5386\u6a21\u578b\u7684\u6240\u6709\u53c2\u6570\uff0c\u5e76\u6253\u5370\u5b83\u4eec\u3002\u8fd9\u5bf9\u4e8e\u5c0f\u578b\u6a21\u578b\u53ef\u80fd\u662f\u53ef\u884c\u7684\uff0c\u4f46\u5bf9\u4e8e\u50cfLlama2\u8fd9\u6837\u7684\u5927\u578b\u6a21\u578b\uff0c\u8fd9\u53ef\u80fd\u4f1a\u4ea7\u751f\u5927\u91cf\u7684\u8f93\u51fa\u3002<\/p>\n\n\n\n<p>\u547d\u540d\u4e3a test03.py\uff0c\u6587\u4ef6\u4fdd\u5b58\u5230 newsrc \u76ee\u5f55\u4e0b\uff1a<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:python decode:true \">from transformers import AutoModelForCausalLM\n\n# \u6307\u5b9a\u6a21\u578b\u8def\u5f84\nmodel_path = \"meta-llama\/Llama-2-7b-chat-hf\"\n\n# \u52a0\u8f7d\u6a21\u578b\nhf_model = AutoModelForCausalLM.from_pretrained(model_path)\n\nfor param_tensor in hf_model.parameters():\n    print(param_tensor)\n<\/pre><\/div>\n\n\n\n<p>\u8fd0\u884ctest03.py<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:sh decode:true \"> python newsrc\/test03.py\nLoading checkpoint shards: 100%|\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588| 2\/2 [01:35&lt;00:00, 47.67s\/it]\nParameter containing:\ntensor([[ 1.1921e-06, -1.7881e-06, -4.2915e-06,  ...,  8.3447e-07,\n         -6.4373e-06,  8.9407e-07],\n        [ 1.8387e-03, -3.8147e-03,  9.6130e-04,  ..., -9.0332e-03,\n          2.6550e-03, -3.7537e-03],\n        [ 1.0193e-02,  9.7656e-03, -5.2795e-03,  ...,  2.9297e-03,\n          4.0817e-04, -5.0964e-03],\n        ...,\n        [-1.3550e-02, -3.5095e-03, -1.8921e-02,  ..., -9.3384e-03,\n          8.7891e-03, -1.2741e-03],\n        [-1.0681e-02,  8.9722e-03,  1.2573e-02,  ..., -3.3691e-02,\n         -1.6235e-02,  3.0212e-03],\n        [-9.0942e-03, -1.8082e-03, -6.9809e-04,  ...,  3.8452e-03,\n         -1.2085e-02,  7.2861e-04]], requires_grad=True)\nParameter containing:\ntensor([[-0.0060, -0.0146, -0.0021,  ...,  0.0042,  0.0018, -0.0035],\n        [ 0.0142, -0.0043,  0.0032,  ..., -0.0092, -0.0108,  0.0073],\n        [-0.0137,  0.0121,  0.0002,  ...,  0.0061,  0.0181, -0.0030],\n        ...,\n        [ 0.0018,  0.0093, -0.0006,  ...,  0.0092, -0.0289,  0.0085],\n        [ 0.0249,  0.0116,  0.0035,  ..., -0.0322, -0.0165, -0.0111],\n        [-0.0136, -0.0067,  0.0016,  ...,  0.0176,  0.0175, -0.0083]],\n       requires_grad=True)\n...\nParameter containing:\ntensor([[-0.0022, -0.0255, -0.0085,  ..., -0.0349, -0.0154,  0.0232],\n        [ 0.0415,  0.0025, -0.0031,  ..., -0.0028, -0.0156,  0.0137],\n        [-0.0136, -0.0101,  0.0239,  ...,  0.0304, -0.0019,  0.0238],\n        ...,\n        [ 0.0040,  0.0322, -0.0021,  ...,  0.0102,  0.0062,  0.0210],\n        [-0.0006,  0.0483, -0.0078,  ..., -0.0070,  0.0210,  0.0219],\n        [ 0.0258, -0.0342,  0.0166,  ...,  0.0068,  0.0016,  0.0269]],\n       requires_grad=True)\nParameter containing:\ntensor([0.4824, 0.4805, 0.4336,  ..., 0.4258, 0.4531, 0.4785],\n       requires_grad=True)\nParameter containing:\ntensor([0.4297, 0.4297, 0.4355,  ..., 0.4180, 0.4043, 0.4238],\n       requires_grad=True)\nParameter containing:\ntensor([1.8594, 1.8516, 1.7969,  ..., 1.7109, 1.8125, 1.5938],\n       requires_grad=True)\nParameter containing:\ntensor([[-0.0036,  0.0027, -0.0074,  ...,  0.0039, -0.0084,  0.0065],\n        [-0.0311,  0.0449, -0.0029,  ..., -0.0228,  0.0147,  0.0320],\n        [-0.0125,  0.0014,  0.0188,  ..., -0.0264,  0.0156, -0.0073],\n        ...,\n        [-0.0294, -0.0172, -0.0029,  ...,  0.0140, -0.0116, -0.0234],\n        [ 0.0204,  0.0239,  0.0272,  ...,  0.0048, -0.0097, -0.0064],\n        [ 0.0081, -0.0057,  0.0082,  ..., -0.0282, -0.0164,  0.0311]],\n       requires_grad=True)<\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u65b9\u6cd5 2: \u6253\u5370\u53c2\u6570\u7684\u5f62\u72b6\u548c\u540d\u79f0<\/strong><\/h3>\n\n\n\n<p>\u8fd9\u79cd\u65b9\u6cd5\u4e0d\u4f1a\u76f4\u63a5\u6253\u5370\u6bcf\u4e2a\u53c2\u6570\u7684\u503c\uff0c\u800c\u662f\u6253\u5370\u53c2\u6570\u7684\u540d\u79f0\u548c\u5f62\u72b6\uff0c\u8fd9\u5bf9\u4e8e\u4e86\u89e3\u6a21\u578b\u7684\u7ed3\u6784\u975e\u5e38\u6709\u5e2e\u52a9\u3002<\/p>\n\n\n\n<p>\u547d\u540d\u4e3a test04.py\uff0c\u6587\u4ef6\u4fdd\u5b58\u5230 newsrc \u76ee\u5f55\u4e0b\uff1a<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:python decode:true \">from transformers import AutoModelForCausalLM\n\n# \u6307\u5b9a\u6a21\u578b\u8def\u5f84\nmodel_path = \"meta-llama\/Llama-2-7b-chat-hf\"\n\n# \u52a0\u8f7d\u6a21\u578b\nhf_model = AutoModelForCausalLM.from_pretrained(model_path)\n\nfor name, param in hf_model.named_parameters():\n    print(f\"{name}: {param.size()}\")\n<\/pre><\/div>\n\n\n\n<p>\u8fd0\u884ctest04.py<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:sh decode:true \"> python newsrc\/test04.py\nLoading checkpoint shards: 100%|\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588| 2\/2 [01:36&lt;00:00, 48.46s\/it]\nmodel.embed_tokens.weight: torch.Size([32000, 4096])\nmodel.layers.0.self_attn.q_proj.weight: torch.Size([4096, 4096])\nmodel.layers.0.self_attn.k_proj.weight: torch.Size([4096, 4096])\nmodel.layers.0.self_attn.v_proj.weight: torch.Size([4096, 4096])\nmodel.layers.0.self_attn.o_proj.weight: torch.Size([4096, 4096])\nmodel.layers.0.mlp.gate_proj.weight: torch.Size([11008, 4096])\nmodel.layers.0.mlp.up_proj.weight: torch.Size([11008, 4096])\nmodel.layers.0.mlp.down_proj.weight: torch.Size([4096, 11008])\nmodel.layers.0.input_layernorm.weight: torch.Size([4096])\nmodel.layers.0.post_attention_layernorm.weight: torch.Size([4096])\nmodel.layers.1.self_attn.q_proj.weight: torch.Size([4096, 4096])\nmodel.layers.1.self_attn.k_proj.weight: torch.Size([4096, 4096])\nmodel.layers.1.self_attn.v_proj.weight: torch.Size([4096, 4096])\nmodel.layers.1.self_attn.o_proj.weight: torch.Size([4096, 4096])\nmodel.layers.1.mlp.gate_proj.weight: torch.Size([11008, 4096])\nmodel.layers.1.mlp.up_proj.weight: torch.Size([11008, 4096])\nmodel.layers.1.mlp.down_proj.weight: torch.Size([4096, 11008])\nmodel.layers.1.input_layernorm.weight: torch.Size([4096])\nmodel.layers.1.post_attention_layernorm.weight: torch.Size([4096])\n...\nmodel.layers.31.self_attn.q_proj.weight: torch.Size([4096, 4096])\nmodel.layers.31.self_attn.k_proj.weight: torch.Size([4096, 4096])\nmodel.layers.31.self_attn.v_proj.weight: torch.Size([4096, 4096])\nmodel.layers.31.self_attn.o_proj.weight: torch.Size([4096, 4096])\nmodel.layers.31.mlp.gate_proj.weight: torch.Size([11008, 4096])\nmodel.layers.31.mlp.up_proj.weight: torch.Size([11008, 4096])\nmodel.layers.31.mlp.down_proj.weight: torch.Size([4096, 11008])\nmodel.layers.31.input_layernorm.weight: torch.Size([4096])\nmodel.layers.31.post_attention_layernorm.weight: torch.Size([4096])\nmodel.norm.weight: torch.Size([4096])\nlm_head.weight: torch.Size([32000, 4096])<\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>\u65b9\u6cd5 3: \u6253\u5370\u7279\u5b9a\u5c42\u7684\u53c2\u6570<\/strong><\/h3>\n\n\n\n<p>\u5982\u679c\u4f60\u53ea\u5bf9\u6a21\u578b\u4e2d\u7279\u5b9a\u5c42\u7684\u53c2\u6570\u611f\u5174\u8da3\uff0c\u53ef\u4ee5\u76f4\u63a5\u8bbf\u95ee\u8fd9\u4e9b\u5c42\u5e76\u6253\u5370\u5b83\u4eec\u7684\u53c2\u6570\u3002\u4f8b\u5982\uff0c\u5982\u679c\u4f60\u60f3\u6253\u5370\u7b2c\u4e00\u4e2a\u89e3\u7801\u5668\u5c42\u7684\u53c2\u6570\uff1a<\/p>\n\n\n\n<p>\u547d\u540d\u4e3a test05.py\uff0c\u6587\u4ef6\u4fdd\u5b58\u5230 newsrc \u76ee\u5f55\u4e0b\uff1a<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:python decode:true \">from transformers import AutoModelForCausalLM\n\n# \u6307\u5b9a\u6a21\u578b\u8def\u5f84\nmodel_path = \"meta-llama\/Llama-2-7b-chat-hf\"\n\n# \u52a0\u8f7d\u6a21\u578b\nhf_model = AutoModelForCausalLM.from_pretrained(model_path)\n\nprint(\"1:\")\nfor name, module in hf_model.named_children():\n    print(f\"{name}: {module.__class__.__name__}\")\n\nprint(\"2:\")\nfor name, module in hf_model.model.named_children():\n    print(f\"{name}: {module.__class__.__name__}\")\n\nprint(\"3:\")\nfor name, param in hf_model.lm_head.named_parameters():\n    print(f\"{name}: {param.size()}\")\n<\/pre><\/div>\n\n\n\n<p>\u8fd0\u884ctest05.py<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:sh decode:true \">python newsrc\/test05.py\nLoading checkpoint shards: 100%|\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588| 2\/2 [01:35&lt;00:00, 47.92s\/it]\n1:\nmodel: LlamaModel\nlm_head: Linear\n2:\nembed_tokens: Embedding\nlayers: ModuleList\nnorm: LlamaRMSNorm\n3:\nweight: torch.Size([32000, 4096])<\/pre><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>6. \u6253\u5370\u51fa\u6a21\u578b\u7684\u914d\u7f6e\u4fe1\u606f<\/strong><\/h2>\n\n\n\n<p>\u6a21\u578b\u7684\u914d\u7f6e\u4fe1\u606f\uff0c\u5305\u62ec\u6a21\u578b\u7684\u5404\u79cd\u53c2\u6570\u548c\u8bbe\u7f6e\u3002<code>config<\/code>\u5bf9\u8c61\u901a\u5e38\u5305\u542b\u4e86\u521b\u5efa\u6216\u521d\u59cb\u5316\u6a21\u578b\u65f6\u4f7f\u7528\u7684\u6240\u6709\u914d\u7f6e\u9009\u9879\uff0c\u5982\u6a21\u578b\u5927\u5c0f\u3001\u8bcd\u6c47\u8868\u5927\u5c0f\u3001\u5d4c\u5165\u7ef4\u5ea6\u3001\u6ce8\u610f\u529b\u673a\u5236\u7684\u5934\u6570\u7b49\u3002\u8fd9\u4e9b\u4fe1\u606f\u5bf9\u4e8e\u7406\u89e3\u6a21\u578b\u7684\u80fd\u529b\u548c\u8bbe\u8ba1\u81f3\u5173\u91cd\u8981\u3002<\/p>\n\n\n\n<p>\u547d\u540d\u4e3a test06.py\uff0c\u6587\u4ef6\u4fdd\u5b58\u5230 newsrc \u76ee\u5f55\u4e0b\uff1a<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:python decode:true \" >from transformers import AutoModelForCausalLM\n# \u6307\u5b9a\u6a21\u578b\u8def\u5f84\nmodel_path = \"meta-llama\/Llama-2-7b-chat-hf\"\n\n# \u52a0\u8f7d\u6a21\u578b\nhf_model = AutoModelForCausalLM.from_pretrained(model_path)\n\nprint(hf_model.config)\n<\/pre><\/div>\n\n\n\n<p>\u8fd0\u884ctest06.py<\/p>\n\n\n\n<div class=\"wp-block-urvanov-syntax-highlighter-code-block\"><pre class=\"lang:sh decode:true \">python newsrc\/test06.py\nLoading checkpoint shards: 100%|\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588| 2\/2 [01:35&lt;00:00, 47.94s\/it]\nLlamaConfig {\n  \"_name_or_path\": \"meta-llama\/Llama-2-7b-chat-hf\",\n  \"architectures\": [\n    \"LlamaForCausalLM\"\n  ],\n  \"attention_bias\": false,\n  \"attention_dropout\": 0.0,\n  \"bos_token_id\": 1,\n  \"eos_token_id\": 2,\n  \"hidden_act\": \"silu\",\n  \"hidden_size\": 4096,\n  \"initializer_range\": 0.02,\n  \"intermediate_size\": 11008,\n  \"max_position_embeddings\": 4096,\n  \"model_type\": \"llama\",\n  \"num_attention_heads\": 32,\n  \"num_hidden_layers\": 32,\n  \"num_key_value_heads\": 32,\n  \"pretraining_tp\": 1,\n  \"rms_norm_eps\": 1e-05,\n  \"rope_scaling\": null,\n  \"rope_theta\": 10000.0,\n  \"tie_word_embeddings\": false,\n  \"torch_dtype\": \"float16\",\n  \"transformers_version\": \"4.38.2\",\n  \"use_cache\": true,\n  \"vocab_size\": 32000\n}<\/pre><\/div>\n\n\n\n<p>\u4ece\u63d0\u4f9b\u7684<code>LlamaConfig<\/code>\u914d\u7f6e\u8f93\u51fa\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u5230Llama2\u6a21\u578b\u7684\u5173\u952e\u914d\u7f6e\u53c2\u6570\u3002\u8fd9\u4e9b\u53c2\u6570\u63d0\u4f9b\u4e86\u6a21\u578b\u67b6\u6784\u7684\u6df1\u5165\u4e86\u89e3\uff0c\u4e0b\u9762\u662f\u5176\u4e2d\u4e00\u4e9b\u91cd\u8981\u53c2\u6570\u7684\u89e3\u91ca\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong><code>_name_or_path<\/code><\/strong>: \u6307\u5b9a\u4e86\u6a21\u578b\u52a0\u8f7d\u7684\u8def\u5f84\u6216\u540d\u79f0\uff0c\u8fd9\u91cc\u662f<code>\"meta-llama\/Llama-2-7b-chat-hf\"<\/code>\u3002<\/li>\n\n\n\n<li><strong><code>architectures<\/code><\/strong>: \u5305\u542b\u4e86\u6a21\u578b\u4f7f\u7528\u7684\u67b6\u6784\u7c7b\u578b\uff0c\u8fd9\u91cc\u662f<code>\"LlamaForCausalLM\"<\/code>\uff0c\u8868\u660e\u8fd9\u662f\u4e00\u4e2a\u56e0\u679c\u8bed\u8a00\u6a21\u578b\u3002<\/li>\n\n\n\n<li><strong><code>attention_dropout<\/code><\/strong>: \u6ce8\u610f\u529b\u5c42\u4e2d\u4f7f\u7528\u7684dropout\u6bd4\u7387\uff0c\u8fd9\u91cc\u8bbe\u7f6e\u4e3a0.0\uff0c\u610f\u5473\u7740\u6ca1\u6709\u5e94\u7528dropout\u3002<\/li>\n\n\n\n<li><strong><code>bos_token_id<\/code><\/strong> \u548c <strong><code>eos_token_id<\/code><\/strong>: \u5206\u522b\u8868\u793a\u6587\u672c\u5e8f\u5217\u5f00\u59cb\uff08BOS\uff09\u548c\u7ed3\u675f\uff08EOS\uff09\u7684\u7279\u6b8a\u6807\u8bb0\u7684ID\u3002<\/li>\n\n\n\n<li><strong><code>hidden_act<\/code><\/strong>: \u9690\u85cf\u5c42\u4f7f\u7528\u7684\u6fc0\u6d3b\u51fd\u6570\uff0c\u8fd9\u91cc\u662f<code>\"silu\"<\/code>\uff08Sigmoid\u7ebf\u6027\u5355\u5143\uff0c\u4e5f\u79f0\u4e3aSwish\u6fc0\u6d3b\u51fd\u6570\uff09\u3002<\/li>\n\n\n\n<li><strong><code>hidden_size<\/code><\/strong>: \u9690\u85cf\u5c42\u7684\u5927\u5c0f\uff0c\u8fd9\u91cc\u662f4096\uff0c\u8868\u660e\u6bcf\u4e2a\u9690\u85cf\u5c42\u7684\u8f93\u51fa\u7ef4\u5ea6\u3002<\/li>\n\n\n\n<li><strong><code>intermediate_size<\/code><\/strong>: \u524d\u9988\u7f51\u7edc\uff08feed-forward network\uff09\u5c42\u4e2d\u95f4\u5c42\u7684\u5927\u5c0f\uff0c\u8fd9\u91cc\u662f11008\u3002<\/li>\n\n\n\n<li><strong><code>max_position_embeddings<\/code><\/strong>: \u6700\u5927\u7684\u4f4d\u7f6e\u5d4c\u5165\u7ef4\u5ea6\uff0c\u8fd9\u91cc\u662f4096\uff0c\u9650\u5b9a\u4e86\u6a21\u578b\u80fd\u5904\u7406\u7684\u6700\u5927\u5e8f\u5217\u957f\u5ea6\u3002<\/li>\n\n\n\n<li><strong><code>model_type<\/code><\/strong>: \u6a21\u578b\u7684\u7c7b\u578b\uff0c\u8fd9\u91cc\u662f<code>\"llama\"<\/code>\u3002<\/li>\n\n\n\n<li><strong><code>num_attention_heads<\/code><\/strong>: \u6ce8\u610f\u529b\u673a\u5236\u4e2d\u4f7f\u7528\u7684\u5934\u6570\uff0c\u8fd9\u91cc\u662f32\u3002<\/li>\n\n\n\n<li><strong><code>num_hidden_layers<\/code><\/strong>: \u9690\u85cf\u5c42\u7684\u6570\u91cf\uff0c\u8fd9\u91cc\u662f32\u3002<\/li>\n\n\n\n<li><strong><code>vocab_size<\/code><\/strong>: \u8bcd\u6c47\u8868\u7684\u5927\u5c0f\uff0c\u8fd9\u91cc\u662f32000\u3002<\/li>\n\n\n\n<li><strong><code>torch_dtype<\/code><\/strong>: \u6a21\u578b\u4e2d\u4f7f\u7528\u7684\u6570\u636e\u7c7b\u578b\uff0c\u8fd9\u91cc\u662f<code>\"float16\"<\/code>\uff0c\u8868\u660e\u6a21\u578b\u53c2\u6570\u4f7f\u7528\u7684\u662f\u534a\u7cbe\u5ea6\u6d6e\u70b9\u6570\uff0c\u8fd9\u6709\u52a9\u4e8e\u51cf\u5c11\u6a21\u578b\u7684\u5185\u5b58\u5360\u7528\uff0c\u52a0\u5feb\u8ba1\u7b97\u901f\u5ea6\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u8fd9\u4e2a\u914d\u7f6e\u6982\u89c8\u63ed\u793a\u4e86Llama2\u6a21\u578b\u7684\u4e00\u4e9b\u5173\u952e\u7279\u6027\uff0c\u5305\u62ec\u5176\u6df1\u5ea6\u3001\u5bbd\u5ea6\u548c\u64cd\u4f5c\u7684\u6280\u672f\u7ec6\u8282\u3002\u4f8b\u5982\uff0c32\u5c42\u7684\u6df1\u5ea6\u4e0e4096\u7684\u9690\u85cf\u5927\u5c0f\u548c32\u7684\u6ce8\u610f\u529b\u5934\u6570\u5171\u540c\u51b3\u5b9a\u4e86\u6a21\u578b\u7684\u80fd\u529b\u548c\u590d\u6742\u6027\uff0c\u4f7f\u5176\u9002\u5408\u5904\u7406\u590d\u6742\u7684\u8bed\u8a00\u7406\u89e3\u548c\u751f\u6210\u4efb\u52a1\u3002\u4f7f\u7528\u534a\u7cbe\u5ea6\u6d6e\u70b9\u6570\uff08<code>float16<\/code>\uff09\u662f\u4e3a\u4e86\u4f18\u5316\u6027\u80fd\u548c\u8d44\u6e90\u4f7f\u7528\uff0c\u7279\u522b\u662f\u5728\u652f\u6301\u534a\u7cbe\u5ea6\u8ba1\u7b97\u7684\u786c\u4ef6\u4e0a\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>5. \u5982\u4f55\u6253\u5370\u6a21\u578b\u53c2\u6570\uff1f \u5728\u4f7f\u7528\u50cfPyTorch\u8fd9\u6837\u7684\u6df1\u5ea6\u5b66\u4e60\u6846\u67b6\u65f6\uff0c\u4f60\u53ef\u4ee5\u901a\u8fc7\u51e0\u79cd\u65b9\u6cd5\u6253\u5370\u6a21\u578b\u7684\u53c2\u6570\u3002\u4ee5\u4e0b\u662f [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"set","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[313,289,443,442,312],"tags":[242,314],"class_list":["post-2424","post","type-post","status-publish","format-standard","hentry","category-chatgpt","category-gpt","category-llm","category-llms","category-openai","tag-chatgpt","tag-openai-api"],"views":3799,"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.aqwu.net\/wp\/index.php?rest_route=\/wp\/v2\/posts\/2424","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.aqwu.net\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.aqwu.net\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.aqwu.net\/wp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.aqwu.net\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2424"}],"version-history":[{"count":13,"href":"https:\/\/www.aqwu.net\/wp\/index.php?rest_route=\/wp\/v2\/posts\/2424\/revisions"}],"predecessor-version":[{"id":2468,"href":"https:\/\/www.aqwu.net\/wp\/index.php?rest_route=\/wp\/v2\/posts\/2424\/revisions\/2468"}],"wp:attachment":[{"href":"https:\/\/www.aqwu.net\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2424"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.aqwu.net\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2424"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.aqwu.net\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2424"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}