Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 57 additions & 50 deletions Season1.step_into_chatgpt/4.GPT2/gpt2_modules.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"id": "e60ce5a7-b42a-4669-affa-99fb526e3c35",
"metadata": {},
"outputs": [],
Expand All @@ -44,7 +44,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"id": "6e6f72a8-30cd-44ec-a884-4be46b6059bd",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -100,15 +100,19 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": 3,
"id": "52f84d8f-746d-4a87-af68-2dadf693f002",
"metadata": {},
"outputs": [],
"source": [
"%%capture captured_output\n",
"!pip install https://ms-release.obs.cn-north-4.myhuaweicloud.com/2.2.14/MindSpore/unified/x86_64/mindspore-2.2.14-cp39-cp39-linux_x86_64.whl --trusted-host ms-release.obs.cn-north-4.myhuaweicloud.com -i https://pypi.tuna.tsinghua.edu.cn/simple\n",
"#修改为在线 并锁定版本\n",
"!pip install mindspore==2.2.14 -i https://mirrors.aliyun.com/pypi/simple \n",
"#!pip install https://ms-release.obs.cn-north-4.myhuaweicloud.com/2.2.14/MindSpore/unified/x86_64/mindspore-2.2.14-cp39-cp39-linux_x86_64.whl --trusted-host ms-release.obs.cn-north-4.myhuaweicloud.com -i https://pypi.tuna.tsinghua.edu.cn/simple\n",
"!pip install tokenizers==0.15.0 -i https://pypi.tuna.tsinghua.edu.cn/simple\n",
"\n",
"!wget https://repo.mindspore.cn/mindspore-lab/mindnlp/daily/202402/20240229/master_20240229160016_c5444092d8cfe47d73e292f25d9a9a56fb04828a_newest/any/mindnlp-0.2.0.20240229-py3-none-any.whl\n",
"\n",
"!pip install mindnlp"
]
},
Expand All @@ -122,7 +126,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"id": "074df3ae-4bfc-4655-be9f-8041fc211f96",
"metadata": {
"tags": []
Expand All @@ -134,7 +138,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 1,
"id": "9a161bfb-a15e-4a07-9bb0-688b76f87de3",
"metadata": {
"tags": []
Expand Down Expand Up @@ -164,7 +168,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 2,
"id": "76d2591f-26c2-4961-bca3-be30c4352aef",
"metadata": {
"tags": []
Expand All @@ -181,7 +185,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 3,
"id": "2d315a4e-5663-404e-b93d-efb1cf354414",
"metadata": {
"tags": []
Expand All @@ -191,9 +195,12 @@
"name": "stderr",
"output_type": "stream",
"text": [
"/home/ma-user/anaconda3/envs/python-3.9.0/lib/python3.9/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
"\n",
" from .autonotebook import tqdm as notebook_tqdm\n"
"/home/filament/.local/lib/python3.10/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
" from .autonotebook import tqdm as notebook_tqdm\n",
"Building prefix dict from the default dictionary ...\n",
"Loading model from cache /tmp/jieba.cache\n",
"Loading model cost 0.308 seconds.\n",
"Prefix dict has been built successfully.\n"
]
},
{
Expand All @@ -202,7 +209,7 @@
"((1, 10, 768), (1, 10, 768), (1, 10, 768))"
]
},
"execution_count": 5,
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
Expand Down Expand Up @@ -230,7 +237,7 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 4,
"id": "abb7ccac-7cfe-401a-ab32-763de70b4669",
"metadata": {
"tags": []
Expand All @@ -250,7 +257,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": 5,
"id": "72abe0fe-5225-425b-9bda-0723f3fb27cf",
"metadata": {
"tags": []
Expand All @@ -262,7 +269,7 @@
"((1, 12, 10, 64), (1, 12, 10, 64), (1, 12, 10, 64))"
]
},
"execution_count": 7,
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
Expand Down Expand Up @@ -293,7 +300,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 6,
"id": "9f952236-de74-4419-9469-7e78d3b7c3e4",
"metadata": {
"tags": []
Expand All @@ -305,7 +312,7 @@
"(1, 12, 10, 10)"
]
},
"execution_count": 8,
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -331,7 +338,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 7,
"id": "0ff22248-deff-4962-afae-55772f63f142",
"metadata": {
"tags": []
Expand All @@ -350,7 +357,7 @@
" [ True, True, True ... True, True, True]]]])"
]
},
"execution_count": 9,
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -377,7 +384,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 8,
"id": "d957ce17-6df6-4f5e-a262-24ff3a8ce0d1",
"metadata": {
"tags": []
Expand All @@ -395,7 +402,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": 9,
"id": "dee63bfd-f394-4558-9e9f-e102a2fd283c",
"metadata": {
"tags": []
Expand All @@ -407,7 +414,7 @@
"-3.4028235e+38"
]
},
"execution_count": 11,
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -418,24 +425,24 @@
},
{
"cell_type": "code",
"execution_count": 12,
"execution_count": 10,
"id": "d2faad14-9a3d-4495-8bcc-d7ac2695e83d",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"Tensor(shape=[10, 10], dtype=Float32, value=\n",
"[[-3.72267663e-01, -3.40282347e+38, -3.40282347e+38 ... -3.40282347e+38, -3.40282347e+38, -3.40282347e+38],\n",
" [ 4.12474960e-01, -6.20999515e-01, -3.40282347e+38 ... -3.40282347e+38, -3.40282347e+38, -3.40282347e+38],\n",
" [ 1.29110947e-01, 2.28423685e-01, -1.90024704e-01 ... -3.40282347e+38, -3.40282347e+38, -3.40282347e+38],\n",
"[[-2.52325647e-02, -3.40282347e+38, -3.40282347e+38 ... -3.40282347e+38, -3.40282347e+38, -3.40282347e+38],\n",
" [-2.40131348e-01, -3.01081717e-01, -3.40282347e+38 ... -3.40282347e+38, -3.40282347e+38, -3.40282347e+38],\n",
" [-1.63813263e-01, 3.72520477e-01, 8.26954842e-02 ... -3.40282347e+38, -3.40282347e+38, -3.40282347e+38],\n",
" ...\n",
" [ 2.14589074e-01, 1.79385528e-01, 2.11229175e-01 ... -8.21841732e-02, -3.40282347e+38, -3.40282347e+38],\n",
" [-3.86964470e-01, 1.50564313e-03, -7.81135634e-02 ... -8.60612690e-02, -3.31553906e-01, -3.40282347e+38],\n",
" [ 1.89703301e-01, -7.32186437e-02, -2.44263425e-01 ... 4.69686151e-01, -6.34481907e-01, 6.83065802e-02]])"
" [-3.40138614e-01, 7.31956363e-01, -3.32098126e-01 ... -5.13645589e-01, -3.40282347e+38, -3.40282347e+38],\n",
" [ 2.78025586e-02, -2.18080640e-01, -2.97767907e-01 ... -1.27004489e-01, 1.84989065e-01, -3.40282347e+38],\n",
" [ 1.32980525e-01, -5.72599649e-01, 6.88928843e-01 ... -1.89585343e-01, 1.92393050e-01, 4.59578540e-03]])"
]
},
"execution_count": 12,
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -454,7 +461,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 11,
"id": "df9cdaae-ac5a-4bc0-9e59-403d176c0d3b",
"metadata": {
"tags": []
Expand All @@ -466,7 +473,7 @@
"(1, 12, 10, 10)"
]
},
"execution_count": 13,
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -478,7 +485,7 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 12,
"id": "5771f68c-8b35-4b1a-83d1-287b2ce7a47e",
"metadata": {
"tags": []
Expand All @@ -489,15 +496,15 @@
"text/plain": [
"Tensor(shape=[10, 10], dtype=Float32, value=\n",
"[[ 1.00000000e+00, 0.00000000e+00, 0.00000000e+00 ... 0.00000000e+00, 0.00000000e+00, 0.00000000e+00],\n",
" [ 7.37588942e-01, 2.62411058e-01, 0.00000000e+00 ... 0.00000000e+00, 0.00000000e+00, 0.00000000e+00],\n",
" [ 3.53208542e-01, 3.90087605e-01, 2.56703824e-01 ... 0.00000000e+00, 0.00000000e+00, 0.00000000e+00],\n",
" [ 5.15232861e-01, 4.84767109e-01, 0.00000000e+00 ... 0.00000000e+00, 0.00000000e+00, 0.00000000e+00],\n",
" [ 2.50672013e-01, 4.28580821e-01, 3.20747197e-01 ... 0.00000000e+00, 0.00000000e+00, 0.00000000e+00],\n",
" ...\n",
" [ 1.25348046e-01, 1.21012121e-01, 1.24927595e-01 ... 9.31602344e-02, 0.00000000e+00, 0.00000000e+00],\n",
" [ 8.72338116e-02, 1.28645703e-01, 1.18800178e-01 ... 1.17859736e-01, 9.22039151e-02, 0.00000000e+00],\n",
" [ 1.08949542e-01, 8.37606117e-02, 7.05920979e-02 ... 1.44151926e-01, 4.77844179e-02, 9.64947045e-02]])"
" [ 9.36088935e-02, 2.73478150e-01, 9.43645760e-02 ... 7.86981434e-02, 0.00000000e+00, 0.00000000e+00],\n",
" [ 9.77324694e-02, 7.64280781e-02, 7.05739334e-02 ... 8.37157145e-02, 1.14367887e-01, 0.00000000e+00],\n",
" [ 1.11171417e-01, 5.48988841e-02, 1.93837821e-01 ... 8.05201530e-02, 1.17976539e-01, 9.77769196e-02]])"
]
},
"execution_count": 14,
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -516,7 +523,7 @@
},
{
"cell_type": "code",
"execution_count": 15,
"execution_count": 13,
"id": "0ba1e0ff-5627-4b70-8911-4ffa7383e29d",
"metadata": {
"tags": []
Expand All @@ -528,7 +535,7 @@
"(1, 12, 10, 64)"
]
},
"execution_count": 15,
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -551,7 +558,7 @@
},
{
"cell_type": "code",
"execution_count": 16,
"execution_count": 14,
"id": "80e44dd1-4013-4d01-b267-92463b296e5b",
"metadata": {
"tags": []
Expand All @@ -570,7 +577,7 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": 15,
"id": "5b35f8ee-70b4-4cb4-ad9b-d0b685482b59",
"metadata": {
"tags": []
Expand All @@ -582,7 +589,7 @@
"(1, 10, 768)"
]
},
"execution_count": 17,
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -606,7 +613,7 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": 16,
"id": "ff788df6-a6a7-4b43-9a76-95eaef4918c7",
"metadata": {
"tags": []
Expand All @@ -618,7 +625,7 @@
},
{
"cell_type": "code",
"execution_count": 19,
"execution_count": 17,
"id": "0c7d4c1f-4ddc-4605-acba-f6e17cbfe2d5",
"metadata": {
"tags": []
Expand All @@ -630,7 +637,7 @@
"(1, 10, 768)"
]
},
"execution_count": 19,
"execution_count": 17,
"metadata": {},
"output_type": "execute_result"
}
Expand Down Expand Up @@ -660,9 +667,9 @@
"name": "mindspore1.7.0-cuda10.1-py3.7-ubuntu18.04"
},
"kernelspec": {
"display_name": "ms2.2.14",
"display_name": "Python 3",
"language": "python",
"name": "ms2.2.14"
"name": "python3"
},
"language_info": {
"codemirror_mode": {
Expand All @@ -674,7 +681,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.19"
"version": "3.10.12"
}
},
"nbformat": 4,
Expand Down
Loading