diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..d748b27 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +* text=auto eol=lf +*.ipynb filter=nbstripout \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 0000000..53f37c9 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,96 @@ +name: 🐞 Bug report +description: Create a report to help us reproduce and fix the bug +title: "[Bug] " +labels: ['bug'] + +body: +- type: checkboxes + attributes: + label: Checklist + options: + - label: 1. I have searched related issues but cannot get the expected help. + - label: 2. The bug has not been fixed in the latest version. + - label: 3. I have read [Contributing Guidlines](https://github.com/mindspore-lab/step_into_llm/wiki/Contributing-Guidelines). + - label: 4. Please note that if the bug-related issue you submitted lacks corresponding environment info and a minimal reproducible demo, it will be challenging for us to reproduce and resolve the issue, reducing the likelihood of receiving feedback. + - label: 5. If the issue you raised is not a bug but a question, please raise a discussion at Discussions. Otherwise, it will be closed. +- type: textarea + attributes: + label: Describe the bug + description: | + A clear and concise description of what the bug is, including: + - What happened (actual behavior) + - What you expected (expected outcome) + - **Please attach error logs or screenshots if possible**—this helps us locate the issue faster. + validations: + required: true +- type: textarea + attributes: + label: Reproduction + description: | + What command or script did you run? Please list the exact steps to reproduce the bug. + placeholder: | + A placeholder for the command. + validations: + required: true +- type: checkboxes + id: hardware + attributes: + label: Hardware Environment + description: Which hardware type does this bug relate to (select all that apply)? + options: + - label: Ascend + - label: GPU + - label: CPU + validations: + required: true +- type: input + attributes: + label: OS Platform + description: Which operating system are you using? (e.g., Ubuntu 20.04) + placeholder: "Ubuntu 20.04" + validations: + required: true +- type: input + attributes: + label: Python Version + description: What version of Python are you using? (e.g., 3.9.7) + placeholder: "3.9.7" + validations: + required: true +- type: input + attributes: + label: MindSpore Version + description: What version of MindSpore are you using? (e.g., 2.7.1) + placeholder: "2.7.1" + validations: + required: true +- type: input + id: mindspore_nlp + attributes: + label: (Optional) MindSpore NLP Version + placeholder: e.g., 0.5.0 + validations: + required: false +- type: input + id: mindspore_transformers + attributes: + label: (Optional) MindSpore Transformers Version + placeholder: e.g., 1.7.0 + validations: + required: false +- type: textarea + id: other_suites + attributes: + label: (Optional) Other Toolkit or Suite Versions + description: | + Specify versions of any other MindSpore-related suites (e.g., MindSpore Lite, vLLM-MindSpore) or relevant third-party packages. + placeholder: | + e.g., + - MindSpore Lite 2.7.0 + - vLLM-MindSpore 0.4.0 + validations: + required: false +- type: textarea + attributes: + label: Additional Context + description: Any other details. \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml new file mode 100644 index 0000000..2e41ee7 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -0,0 +1,39 @@ +name: 🚀 Feature request +description: Suggest an idea for this project +title: "[Feature] " + +body: +- type: checkboxes + attributes: + label: Checklist + options: + - label: 1. I have read [Contributing Guidlines](https://github.com/mindspore-lab/step_into_llm/wiki/Contributing-Guidelines). + - label: 2. If the issue you raised is not a feature but a question, please raise a discussion at Discussions. Otherwise, it will be closed. +- type: textarea + attributes: + label: Motivation + description: | + A clear and concise description of the motivation of the feature. + validations: + required: true +- type: checkboxes + id: hardware + attributes: + label: Hardware Environment + description: Which hardware does this feature need to support (select all that apply)? + options: + - label: Ascend + - label: GPU + - label: CPU + validations: + required: true +- type: textarea + attributes: + label: Related resources + description: | + If there is an official code release or third-party implementations, please also provide the information here, which would be very helpful. +- type: textarea + attributes: + label: Your Contribution + description: | + Is there any way that you could help, e.g., by submitting a PR? diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 0000000..1b62f90 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,34 @@ + + +# Description + + +# Changes + + +# Testing & Benchmark + + +# Checklist + +- [ ] Read and followed the [Contributing Guidelines](https://github.com/mindspore-lab/step_into_llm/wiki/Contributing-Guidelines). +- [ ] Self-tested locally to ensure the code runs correctly and achieves expected results (all CI checks expected to pass). +- [ ] Updated documentation if needed. +- [ ] Verified accuracy or performance benchmarks if applicable. + +# Reviewers + diff --git a/01.LLM_Theory_Course/01.Industry_Model_Introduction/01.Classic_Model_Technical_Analysis/01.BERT/bert_emotect_finetune.ipynb b/01.LLM_Theory_Course/01.Industry_Model_Introduction/01.Classic_Model_Technical_Analysis/01.BERT/bert_emotect_finetune.ipynb index 6ceed46..74760b1 100644 --- a/01.LLM_Theory_Course/01.Industry_Model_Introduction/01.Classic_Model_Technical_Analysis/01.BERT/bert_emotect_finetune.ipynb +++ b/01.LLM_Theory_Course/01.Industry_Model_Introduction/01.Classic_Model_Technical_Analysis/01.BERT/bert_emotect_finetune.ipynb @@ -16,109 +16,22 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "metadata": { "tags": [] }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple\n", - "Collecting mindspore==2.5.0\n", - " Using cached https://ms-release.obs.cn-north-4.myhuaweicloud.com/2.5.0/MindSpore/unified/aarch64/mindspore-2.5.0-cp39-cp39-linux_aarch64.whl (345.0 MB)\n", - "Requirement already satisfied: pip in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (25.1)\n", - "\u001b[31mERROR: Could not find a version that satisfies the requirement install (from versions: none)\u001b[0m\u001b[31m\n", - "\u001b[0m\n", - "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m25.1\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m25.1.1\u001b[0m\n", - "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpython -m pip install --upgrade pip\u001b[0m\n", - "\u001b[31mERROR: No matching distribution found for install\u001b[0m\u001b[31m\n", - "\u001b[0m" - ] - } - ], + "outputs": [], "source": [ "!pip install https://ms-release.obs.cn-north-4.myhuaweicloud.com/2.5.0/MindSpore/unified/aarch64/mindspore-2.5.0-cp39-cp39-linux_aarch64.whl --trusted-host ms-release.obs.cn-north-4.myhuaweicloud.com -i https://pypi.tuna.tsinghua.edu.cn/simple" ] }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "metadata": { "tags": [] }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Looking in indexes: https://repo.huaweicloud.com/repository/pypi/simple/\n", - "Requirement already satisfied: mindnlp==0.4.0 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (0.4.0)\n", - "Requirement already satisfied: mindspore>=2.2.14 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from mindnlp==0.4.0) (2.5.0)\n", - "Requirement already satisfied: tqdm in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from mindnlp==0.4.0) (4.67.1)\n", - "Requirement already satisfied: requests in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from mindnlp==0.4.0) (2.32.3)\n", - "Requirement already satisfied: datasets in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from mindnlp==0.4.0) (3.6.0)\n", - "Requirement already satisfied: evaluate in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from mindnlp==0.4.0) (0.4.3)\n", - "Requirement already satisfied: tokenizers==0.19.1 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from mindnlp==0.4.0) (0.19.1)\n", - "Requirement already satisfied: safetensors in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from mindnlp==0.4.0) (0.5.3)\n", - "Requirement already satisfied: sentencepiece in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from mindnlp==0.4.0) (0.2.0)\n", - "Requirement already satisfied: regex in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from mindnlp==0.4.0) (2024.11.6)\n", - "Requirement already satisfied: addict in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from mindnlp==0.4.0) (2.4.0)\n", - "Requirement already satisfied: ml-dtypes in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from mindnlp==0.4.0) (0.5.1)\n", - "Requirement already satisfied: pyctcdecode in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from mindnlp==0.4.0) (0.5.0)\n", - "Requirement already satisfied: jieba in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from mindnlp==0.4.0) (0.42.1)\n", - "Requirement already satisfied: pytest==7.2.0 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from mindnlp==0.4.0) (7.2.0)\n", - "Requirement already satisfied: pillow>=10.0.0 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from mindnlp==0.4.0) (11.2.1)\n", - "Requirement already satisfied: attrs>=19.2.0 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from pytest==7.2.0->mindnlp==0.4.0) (25.3.0)\n", - "Requirement already satisfied: iniconfig in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from pytest==7.2.0->mindnlp==0.4.0) (2.1.0)\n", - "Requirement already satisfied: packaging in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from pytest==7.2.0->mindnlp==0.4.0) (24.2)\n", - "Requirement already satisfied: pluggy<2.0,>=0.12 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from pytest==7.2.0->mindnlp==0.4.0) (1.5.0)\n", - "Requirement already satisfied: exceptiongroup>=1.0.0rc8 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from pytest==7.2.0->mindnlp==0.4.0) (1.2.0)\n", - "Requirement already satisfied: tomli>=1.0.0 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from pytest==7.2.0->mindnlp==0.4.0) (2.2.1)\n", - "Requirement already satisfied: huggingface-hub<1.0,>=0.16.4 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from tokenizers==0.19.1->mindnlp==0.4.0) (0.32.3)\n", - "Requirement already satisfied: filelock in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from huggingface-hub<1.0,>=0.16.4->tokenizers==0.19.1->mindnlp==0.4.0) (3.18.0)\n", - "Requirement already satisfied: fsspec>=2023.5.0 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from huggingface-hub<1.0,>=0.16.4->tokenizers==0.19.1->mindnlp==0.4.0) (2025.3.0)\n", - "Requirement already satisfied: pyyaml>=5.1 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from huggingface-hub<1.0,>=0.16.4->tokenizers==0.19.1->mindnlp==0.4.0) (6.0.2)\n", - "Requirement already satisfied: typing-extensions>=3.7.4.3 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from huggingface-hub<1.0,>=0.16.4->tokenizers==0.19.1->mindnlp==0.4.0) (4.12.2)\n", - "Requirement already satisfied: hf-xet<2.0.0,>=1.1.2 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from huggingface-hub<1.0,>=0.16.4->tokenizers==0.19.1->mindnlp==0.4.0) (1.1.2)\n", - "Requirement already satisfied: numpy<2.0.0,>=1.20.0 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from mindspore>=2.2.14->mindnlp==0.4.0) (1.26.4)\n", - "Requirement already satisfied: protobuf>=3.13.0 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from mindspore>=2.2.14->mindnlp==0.4.0) (6.30.2)\n", - "Requirement already satisfied: asttokens>=2.0.4 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from mindspore>=2.2.14->mindnlp==0.4.0) (3.0.0)\n", - "Requirement already satisfied: scipy>=1.5.4 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from mindspore>=2.2.14->mindnlp==0.4.0) (1.13.1)\n", - "Requirement already satisfied: psutil>=5.6.1 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from mindspore>=2.2.14->mindnlp==0.4.0) (5.9.0)\n", - "Requirement already satisfied: astunparse>=1.6.3 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from mindspore>=2.2.14->mindnlp==0.4.0) (1.6.3)\n", - "Requirement already satisfied: dill>=0.3.7 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from mindspore>=2.2.14->mindnlp==0.4.0) (0.3.8)\n", - "Requirement already satisfied: wheel<1.0,>=0.23.0 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from astunparse>=1.6.3->mindspore>=2.2.14->mindnlp==0.4.0) (0.45.1)\n", - "Requirement already satisfied: six<2.0,>=1.6.1 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from astunparse>=1.6.3->mindspore>=2.2.14->mindnlp==0.4.0) (1.17.0)\n", - "Requirement already satisfied: pyarrow>=15.0.0 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from datasets->mindnlp==0.4.0) (20.0.0)\n", - "Requirement already satisfied: pandas in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from datasets->mindnlp==0.4.0) (2.2.3)\n", - "Requirement already satisfied: xxhash in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from datasets->mindnlp==0.4.0) (3.5.0)\n", - "Requirement already satisfied: multiprocess<0.70.17 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from datasets->mindnlp==0.4.0) (0.70.16)\n", - "Requirement already satisfied: aiohttp!=4.0.0a0,!=4.0.0a1 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from fsspec[http]<=2025.3.0,>=2023.1.0->datasets->mindnlp==0.4.0) (3.12.7)\n", - "Requirement already satisfied: aiohappyeyeballs>=2.5.0 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from aiohttp!=4.0.0a0,!=4.0.0a1->fsspec[http]<=2025.3.0,>=2023.1.0->datasets->mindnlp==0.4.0) (2.6.1)\n", - "Requirement already satisfied: aiosignal>=1.1.2 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from aiohttp!=4.0.0a0,!=4.0.0a1->fsspec[http]<=2025.3.0,>=2023.1.0->datasets->mindnlp==0.4.0) (1.3.2)\n", - "Requirement already satisfied: async-timeout<6.0,>=4.0 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from aiohttp!=4.0.0a0,!=4.0.0a1->fsspec[http]<=2025.3.0,>=2023.1.0->datasets->mindnlp==0.4.0) (5.0.1)\n", - "Requirement already satisfied: frozenlist>=1.1.1 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from aiohttp!=4.0.0a0,!=4.0.0a1->fsspec[http]<=2025.3.0,>=2023.1.0->datasets->mindnlp==0.4.0) (1.6.0)\n", - "Requirement already satisfied: multidict<7.0,>=4.5 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from aiohttp!=4.0.0a0,!=4.0.0a1->fsspec[http]<=2025.3.0,>=2023.1.0->datasets->mindnlp==0.4.0) (6.4.4)\n", - "Requirement already satisfied: propcache>=0.2.0 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from aiohttp!=4.0.0a0,!=4.0.0a1->fsspec[http]<=2025.3.0,>=2023.1.0->datasets->mindnlp==0.4.0) (0.3.1)\n", - "Requirement already satisfied: yarl<2.0,>=1.17.0 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from aiohttp!=4.0.0a0,!=4.0.0a1->fsspec[http]<=2025.3.0,>=2023.1.0->datasets->mindnlp==0.4.0) (1.20.0)\n", - "Requirement already satisfied: idna>=2.0 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from yarl<2.0,>=1.17.0->aiohttp!=4.0.0a0,!=4.0.0a1->fsspec[http]<=2025.3.0,>=2023.1.0->datasets->mindnlp==0.4.0) (3.10)\n", - "Requirement already satisfied: charset-normalizer<4,>=2 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from requests->mindnlp==0.4.0) (3.4.1)\n", - "Requirement already satisfied: urllib3<3,>=1.21.1 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from requests->mindnlp==0.4.0) (2.4.0)\n", - "Requirement already satisfied: certifi>=2017.4.17 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from requests->mindnlp==0.4.0) (2025.4.26)\n", - "Requirement already satisfied: python-dateutil>=2.8.2 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from pandas->datasets->mindnlp==0.4.0) (2.9.0.post0)\n", - "Requirement already satisfied: pytz>=2020.1 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from pandas->datasets->mindnlp==0.4.0) (2025.2)\n", - "Requirement already satisfied: tzdata>=2022.7 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from pandas->datasets->mindnlp==0.4.0) (2025.2)\n", - "Requirement already satisfied: pygtrie<3.0,>=2.1 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from pyctcdecode->mindnlp==0.4.0) (2.5.0)\n", - "Requirement already satisfied: hypothesis<7,>=6.14 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from pyctcdecode->mindnlp==0.4.0) (6.133.2)\n", - "Requirement already satisfied: sortedcontainers<3.0.0,>=2.1.0 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from hypothesis<7,>=6.14->pyctcdecode->mindnlp==0.4.0) (2.4.0)\n", - "\n", - "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m25.1\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m25.1.1\u001b[0m\n", - "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpython -m pip install --upgrade pip\u001b[0m\n" - ] - } - ], + "outputs": [], "source": [ "!pip install mindnlp==0.4.0" ] @@ -156,30 +69,11 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "metadata": { "tags": [] }, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "/home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages/numpy/core/getlimits.py:549: UserWarning: The value of the smallest subnormal for type is zero.\n", - " setattr(self, word, getattr(machar, word).flat[0])\n", - "/home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages/numpy/core/getlimits.py:89: UserWarning: The value of the smallest subnormal for type is zero.\n", - " return self._float_to_str(self.smallest_subnormal)\n", - "/home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages/numpy/core/getlimits.py:549: UserWarning: The value of the smallest subnormal for type is zero.\n", - " setattr(self, word, getattr(machar, word).flat[0])\n", - "/home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages/numpy/core/getlimits.py:89: UserWarning: The value of the smallest subnormal for type is zero.\n", - " return self._float_to_str(self.smallest_subnormal)\n", - "Building prefix dict from the default dictionary ...\n", - "Loading model from cache /tmp/jieba.cache\n", - "Loading model cost 0.908 seconds.\n", - "Prefix dict has been built successfully.\n" - ] - } - ], + "outputs": [], "source": [ "import os\n", "\n", @@ -192,7 +86,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "metadata": { "tags": [] }, @@ -244,35 +138,11 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": null, "metadata": { "tags": [] }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "--2025-06-03 16:26:40-- https://baidu-nlp.bj.bcebos.com/emotion_detection-dataset-1.0.0.tar.gz\n", - "正在解析主机 baidu-nlp.bj.bcebos.com (baidu-nlp.bj.bcebos.com)... 36.110.192.178, 2409:8c04:1001:1203:0:ff:b0bb:4f27\n", - "正在连接 baidu-nlp.bj.bcebos.com (baidu-nlp.bj.bcebos.com)|36.110.192.178|:443... 已连接。\n", - "已发出 HTTP 请求,正在等待回应... 200 OK\n", - "长度:1710581 (1.6M) [application/x-gzip]\n", - "正在保存至: “emotion_detection.tar.gz”\n", - "\n", - "emotion_detection.t 100%[===================>] 1.63M 7.02MB/s 用时 0.2s \n", - "\n", - "2025-06-03 16:26:41 (7.02 MB/s) - 已保存 “emotion_detection.tar.gz” [1710581/1710581])\n", - "\n", - "data/\n", - "data/test.tsv\n", - "data/infer.tsv\n", - "data/dev.tsv\n", - "data/train.tsv\n", - "data/vocab.txt\n" - ] - } - ], + "outputs": [], "source": [ "# download dataset\n", "!wget https://baidu-nlp.bj.bcebos.com/emotion_detection-dataset-1.0.0.tar.gz -O emotion_detection.tar.gz\n", @@ -290,7 +160,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": null, "metadata": { "tags": [] }, @@ -302,7 +172,7 @@ " is_ascend = mindspore.get_context('device_target') == 'Ascend'\n", "\n", " column_names = [\"label\", \"text_a\"]\n", - " \n", + "\n", " dataset = GeneratorDataset(source, column_names=column_names, shuffle=shuffle)\n", " # transforms\n", " type_cast_op = transforms.TypeCast(mindspore.int32)\n", @@ -334,76 +204,11 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": null, "metadata": { "tags": [] }, - "outputs": [ - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "70d7820ca2334d3ba52d2b57e7a23918", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - " 0%| | 0.00/49.0 [00:00 1:\n", " predictions = np.argmax(predictions, axis=-1)\n", "\n", " accuracy = (predictions == labels).mean()\n", - " \n", + "\n", " return {\"accuracy\": float(accuracy)}" ] }, { "cell_type": "code", - "execution_count": 15, + "execution_count": null, "metadata": { "tags": [] }, @@ -624,156 +351,11 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": null, "metadata": { "tags": [] }, - "outputs": [ - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "a557eb2f81dd4b7893e2173ae25c116b", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - " 0%| | 0/1510 [00:00" @@ -165,7 +165,7 @@ }, { "cell_type": "markdown", - "id": "e42d1ce8", + "id": "9", "metadata": {}, "source": [ "接受输入序列后,BERT会输出每个位置对应的向量(长度等于hidden size),在后续下游任务中,我们会选取与任务相关的位置的向量,输入到最终输出层中得到结果。\n", @@ -177,7 +177,7 @@ }, { "cell_type": "markdown", - "id": "a27de31d", + "id": "10", "metadata": { "slideshow": { "slide_type": "slide" @@ -198,87 +198,10 @@ }, { "cell_type": "code", - "execution_count": 1, - "id": "d6c39086", + "execution_count": null, + "id": "11", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Looking in indexes: https://repo.huaweicloud.com/repository/pypi/simple/\n", - "Requirement already satisfied: mindnlp==0.4.0 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (0.4.0)\n", - "Requirement already satisfied: mindspore>=2.2.14 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from mindnlp==0.4.0) (2.4.1)\n", - "Requirement already satisfied: tqdm in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from mindnlp==0.4.0) (4.67.1)\n", - "Requirement already satisfied: requests in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from mindnlp==0.4.0) (2.32.3)\n", - "Requirement already satisfied: datasets in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from mindnlp==0.4.0) (3.6.0)\n", - "Requirement already satisfied: evaluate in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from mindnlp==0.4.0) (0.4.3)\n", - "Requirement already satisfied: tokenizers==0.19.1 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from mindnlp==0.4.0) (0.19.1)\n", - "Requirement already satisfied: safetensors in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from mindnlp==0.4.0) (0.5.3)\n", - "Requirement already satisfied: sentencepiece in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from mindnlp==0.4.0) (0.2.0)\n", - "Requirement already satisfied: regex in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from mindnlp==0.4.0) (2024.11.6)\n", - "Requirement already satisfied: addict in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from mindnlp==0.4.0) (2.4.0)\n", - "Requirement already satisfied: ml-dtypes in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from mindnlp==0.4.0) (0.5.1)\n", - "Requirement already satisfied: pyctcdecode in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from mindnlp==0.4.0) (0.5.0)\n", - "Requirement already satisfied: jieba in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from mindnlp==0.4.0) (0.42.1)\n", - "Requirement already satisfied: pytest==7.2.0 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from mindnlp==0.4.0) (7.2.0)\n", - "Requirement already satisfied: pillow>=10.0.0 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from mindnlp==0.4.0) (11.2.1)\n", - "Requirement already satisfied: attrs>=19.2.0 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from pytest==7.2.0->mindnlp==0.4.0) (25.3.0)\n", - "Requirement already satisfied: iniconfig in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from pytest==7.2.0->mindnlp==0.4.0) (2.1.0)\n", - "Requirement already satisfied: packaging in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from pytest==7.2.0->mindnlp==0.4.0) (24.2)\n", - "Requirement already satisfied: pluggy<2.0,>=0.12 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from pytest==7.2.0->mindnlp==0.4.0) (1.5.0)\n", - "Requirement already satisfied: exceptiongroup>=1.0.0rc8 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from pytest==7.2.0->mindnlp==0.4.0) (1.2.0)\n", - "Requirement already satisfied: tomli>=1.0.0 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from pytest==7.2.0->mindnlp==0.4.0) (2.2.1)\n", - "Requirement already satisfied: huggingface-hub<1.0,>=0.16.4 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from tokenizers==0.19.1->mindnlp==0.4.0) (0.31.1)\n", - "Requirement already satisfied: filelock in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from huggingface-hub<1.0,>=0.16.4->tokenizers==0.19.1->mindnlp==0.4.0) (3.18.0)\n", - "Requirement already satisfied: fsspec>=2023.5.0 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from huggingface-hub<1.0,>=0.16.4->tokenizers==0.19.1->mindnlp==0.4.0) (2025.3.0)\n", - "Requirement already satisfied: pyyaml>=5.1 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from huggingface-hub<1.0,>=0.16.4->tokenizers==0.19.1->mindnlp==0.4.0) (6.0.2)\n", - "Requirement already satisfied: typing-extensions>=3.7.4.3 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from huggingface-hub<1.0,>=0.16.4->tokenizers==0.19.1->mindnlp==0.4.0) (4.12.2)\n", - "Requirement already satisfied: hf-xet<2.0.0,>=1.1.0 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from huggingface-hub<1.0,>=0.16.4->tokenizers==0.19.1->mindnlp==0.4.0) (1.1.0)\n", - "Requirement already satisfied: numpy<2.0.0,>=1.20.0 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from mindspore>=2.2.14->mindnlp==0.4.0) (1.26.4)\n", - "Requirement already satisfied: protobuf>=3.13.0 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from mindspore>=2.2.14->mindnlp==0.4.0) (6.30.2)\n", - "Requirement already satisfied: asttokens>=2.0.4 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from mindspore>=2.2.14->mindnlp==0.4.0) (3.0.0)\n", - "Requirement already satisfied: scipy>=1.5.4 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from mindspore>=2.2.14->mindnlp==0.4.0) (1.13.1)\n", - "Requirement already satisfied: psutil>=5.6.1 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from mindspore>=2.2.14->mindnlp==0.4.0) (5.9.0)\n", - "Requirement already satisfied: astunparse>=1.6.3 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from mindspore>=2.2.14->mindnlp==0.4.0) (1.6.3)\n", - "Requirement already satisfied: wheel<1.0,>=0.23.0 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from astunparse>=1.6.3->mindspore>=2.2.14->mindnlp==0.4.0) (0.45.1)\n", - "Requirement already satisfied: six<2.0,>=1.6.1 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from astunparse>=1.6.3->mindspore>=2.2.14->mindnlp==0.4.0) (1.17.0)\n", - "Requirement already satisfied: pyarrow>=15.0.0 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from datasets->mindnlp==0.4.0) (20.0.0)\n", - "Requirement already satisfied: dill<0.3.9,>=0.3.0 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from datasets->mindnlp==0.4.0) (0.3.8)\n", - "Requirement already satisfied: pandas in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from datasets->mindnlp==0.4.0) (2.2.3)\n", - "Requirement already satisfied: xxhash in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from datasets->mindnlp==0.4.0) (3.5.0)\n", - "Requirement already satisfied: multiprocess<0.70.17 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from datasets->mindnlp==0.4.0) (0.70.16)\n", - "Requirement already satisfied: aiohttp!=4.0.0a0,!=4.0.0a1 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from fsspec[http]<=2025.3.0,>=2023.1.0->datasets->mindnlp==0.4.0) (3.11.18)\n", - "Requirement already satisfied: aiohappyeyeballs>=2.3.0 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from aiohttp!=4.0.0a0,!=4.0.0a1->fsspec[http]<=2025.3.0,>=2023.1.0->datasets->mindnlp==0.4.0) (2.6.1)\n", - "Requirement already satisfied: aiosignal>=1.1.2 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from aiohttp!=4.0.0a0,!=4.0.0a1->fsspec[http]<=2025.3.0,>=2023.1.0->datasets->mindnlp==0.4.0) (1.3.2)\n", - "Requirement already satisfied: async-timeout<6.0,>=4.0 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from aiohttp!=4.0.0a0,!=4.0.0a1->fsspec[http]<=2025.3.0,>=2023.1.0->datasets->mindnlp==0.4.0) (5.0.1)\n", - "Requirement already satisfied: frozenlist>=1.1.1 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from aiohttp!=4.0.0a0,!=4.0.0a1->fsspec[http]<=2025.3.0,>=2023.1.0->datasets->mindnlp==0.4.0) (1.6.0)\n", - "Requirement already satisfied: multidict<7.0,>=4.5 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from aiohttp!=4.0.0a0,!=4.0.0a1->fsspec[http]<=2025.3.0,>=2023.1.0->datasets->mindnlp==0.4.0) (6.4.3)\n", - "Requirement already satisfied: propcache>=0.2.0 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from aiohttp!=4.0.0a0,!=4.0.0a1->fsspec[http]<=2025.3.0,>=2023.1.0->datasets->mindnlp==0.4.0) (0.3.1)\n", - "Requirement already satisfied: yarl<2.0,>=1.17.0 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from aiohttp!=4.0.0a0,!=4.0.0a1->fsspec[http]<=2025.3.0,>=2023.1.0->datasets->mindnlp==0.4.0) (1.20.0)\n", - "Requirement already satisfied: idna>=2.0 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from yarl<2.0,>=1.17.0->aiohttp!=4.0.0a0,!=4.0.0a1->fsspec[http]<=2025.3.0,>=2023.1.0->datasets->mindnlp==0.4.0) (3.10)\n", - "Requirement already satisfied: charset-normalizer<4,>=2 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from requests->mindnlp==0.4.0) (3.4.1)\n", - "Requirement already satisfied: urllib3<3,>=1.21.1 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from requests->mindnlp==0.4.0) (2.4.0)\n", - "Requirement already satisfied: certifi>=2017.4.17 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from requests->mindnlp==0.4.0) (2025.4.26)\n", - "Requirement already satisfied: python-dateutil>=2.8.2 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from pandas->datasets->mindnlp==0.4.0) (2.9.0.post0)\n", - "Requirement already satisfied: pytz>=2020.1 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from pandas->datasets->mindnlp==0.4.0) (2025.2)\n", - "Requirement already satisfied: tzdata>=2022.7 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from pandas->datasets->mindnlp==0.4.0) (2025.2)\n", - "Requirement already satisfied: pygtrie<3.0,>=2.1 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from pyctcdecode->mindnlp==0.4.0) (2.5.0)\n", - "Requirement already satisfied: hypothesis<7,>=6.14 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from pyctcdecode->mindnlp==0.4.0) (6.131.15)\n", - "Requirement already satisfied: sortedcontainers<3.0.0,>=2.1.0 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from hypothesis<7,>=6.14->pyctcdecode->mindnlp==0.4.0) (2.4.0)\n", - "\n", - "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m25.1\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m25.1.1\u001b[0m\n", - "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpython -m pip install --upgrade pip\u001b[0m\n", - "Looking in indexes: https://repo.huaweicloud.com/repository/pypi/simple/\n", - "Requirement already satisfied: pytesseract in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (0.3.13)\n", - "Requirement already satisfied: packaging>=21.3 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from pytesseract) (24.2)\n", - "Requirement already satisfied: Pillow>=8.0.0 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from pytesseract) (11.2.1)\n", - "\n", - "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m25.1\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m25.1.1\u001b[0m\n", - "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpython -m pip install --upgrade pip\u001b[0m\n" - ] - } - ], + "outputs": [], "source": [ "# install mindnlp\n", "!pip install mindnlp==0.4.0\n", @@ -287,94 +210,10 @@ }, { "cell_type": "code", - "execution_count": 2, - "id": "0ad0c6f0", + "execution_count": null, + "id": "12", "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "[WARNING] GE_ADPT(6108,ffffab724020,python):2025-05-13-12:28:08.673.160 [mindspore/ccsrc/utils/dlopen_macro.h:163] DlsymAscend] Dynamically load symbol aclmdlBundleGetModelId failed, result = /usr/local/Ascend/ascend-toolkit/latest/lib64/libascendcl.so: undefined symbol: aclmdlBundleGetModelId\n", - "[WARNING] GE_ADPT(6108,ffffab724020,python):2025-05-13-12:28:08.673.218 [mindspore/ccsrc/utils/dlopen_macro.h:163] DlsymAscend] Dynamically load symbol aclmdlBundleLoadFromMem failed, result = /usr/local/Ascend/ascend-toolkit/latest/lib64/libascendcl.so: undefined symbol: aclmdlBundleLoadFromMem\n", - "[WARNING] GE_ADPT(6108,ffffab724020,python):2025-05-13-12:28:08.673.244 [mindspore/ccsrc/utils/dlopen_macro.h:163] DlsymAscend] Dynamically load symbol aclmdlBundleUnload failed, result = /usr/local/Ascend/ascend-toolkit/latest/lib64/libascendcl.so: undefined symbol: aclmdlBundleUnload\n", - "[WARNING] GE_ADPT(6108,ffffab724020,python):2025-05-13-12:28:08.673.383 [mindspore/ccsrc/utils/dlopen_macro.h:163] DlsymAscend] Dynamically load symbol aclrtGetMemUceInfo failed, result = /usr/local/Ascend/ascend-toolkit/latest/lib64/libascendcl.so: undefined symbol: aclrtGetMemUceInfo\n", - "[WARNING] GE_ADPT(6108,ffffab724020,python):2025-05-13-12:28:08.673.408 [mindspore/ccsrc/utils/dlopen_macro.h:163] DlsymAscend] Dynamically load symbol aclrtDeviceTaskAbort failed, result = /usr/local/Ascend/ascend-toolkit/latest/lib64/libascendcl.so: undefined symbol: aclrtDeviceTaskAbort\n", - "[WARNING] GE_ADPT(6108,ffffab724020,python):2025-05-13-12:28:08.673.431 [mindspore/ccsrc/utils/dlopen_macro.h:163] DlsymAscend] Dynamically load symbol aclrtMemUceRepair failed, result = /usr/local/Ascend/ascend-toolkit/latest/lib64/libascendcl.so: undefined symbol: aclrtMemUceRepair\n", - "[WARNING] GE_ADPT(6108,ffffab724020,python):2025-05-13-12:28:08.674.937 [mindspore/ccsrc/utils/dlopen_macro.h:163] DlsymAscend] Dynamically load symbol acltdtCleanChannel failed, result = /usr/local/Ascend/ascend-toolkit/latest/lib64/libacl_tdt_channel.so: undefined symbol: acltdtCleanChannel\n", - "/home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages/numpy/core/getlimits.py:549: UserWarning: The value of the smallest subnormal for type is zero.\n", - " setattr(self, word, getattr(machar, word).flat[0])\n", - "/home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages/numpy/core/getlimits.py:89: UserWarning: The value of the smallest subnormal for type is zero.\n", - " return self._float_to_str(self.smallest_subnormal)\n", - "/home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages/numpy/core/getlimits.py:549: UserWarning: The value of the smallest subnormal for type is zero.\n", - " setattr(self, word, getattr(machar, word).flat[0])\n", - "/home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages/numpy/core/getlimits.py:89: UserWarning: The value of the smallest subnormal for type is zero.\n", - " return self._float_to_str(self.smallest_subnormal)\n", - "Building prefix dict from the default dictionary ...\n", - "Loading model from cache /tmp/jieba.cache\n", - "Loading model cost 1.042 seconds.\n", - "Prefix dict has been built successfully.\n" - ] - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "6421e22f124345fe924aa445c22403a2", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "0.00B [00:00, ?B/s]" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "30735811eedd4f2ea525d38c702c177f", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "0.00B [00:00, ?B/s]" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "2e931b32674045c599aeb89a2088f180", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - " 0%| | 0.00/334 [00:00 \u001b[0m\u001b[32;49m25.1.1\u001b[0m\n", - "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpython -m pip install --upgrade pip\u001b[0m\n", - "\u001b[31mERROR: No matching distribution found for install\u001b[0m\u001b[31m\n", - "\u001b[0m" - ] - } - ], + "outputs": [], "source": [ "!pip install pip install https://ms-release.obs.cn-north-4.myhuaweicloud.com/2.5.0/MindSpore/unified/aarch64/mindspore-2.5.0-cp39-cp39-linux_aarch64.whl --trusted-host ms-release.obs.cn-north-4.myhuaweicloud.com -i https://pypi.tuna.tsinghua.edu.cn/simple" ] }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "metadata": { "tags": [] }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Looking in indexes: https://repo.huaweicloud.com/repository/pypi/simple/\n", - "Requirement already satisfied: mindnlp==0.4.0 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (0.4.0)\n", - "Requirement already satisfied: mindspore>=2.2.14 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from mindnlp==0.4.0) (2.4.1)\n", - "Requirement already satisfied: tqdm in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from mindnlp==0.4.0) (4.67.1)\n", - "Requirement already satisfied: requests in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from mindnlp==0.4.0) (2.32.3)\n", - "Requirement already satisfied: datasets in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from mindnlp==0.4.0) (3.6.0)\n", - "Requirement already satisfied: evaluate in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from mindnlp==0.4.0) (0.4.3)\n", - "Requirement already satisfied: tokenizers==0.19.1 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from mindnlp==0.4.0) (0.19.1)\n", - "Requirement already satisfied: safetensors in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from mindnlp==0.4.0) (0.5.3)\n", - "Requirement already satisfied: sentencepiece in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from mindnlp==0.4.0) (0.2.0)\n", - "Requirement already satisfied: regex in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from mindnlp==0.4.0) (2024.11.6)\n", - "Requirement already satisfied: addict in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from mindnlp==0.4.0) (2.4.0)\n", - "Requirement already satisfied: ml-dtypes in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from mindnlp==0.4.0) (0.5.1)\n", - "Requirement already satisfied: pyctcdecode in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from mindnlp==0.4.0) (0.5.0)\n", - "Requirement already satisfied: jieba in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from mindnlp==0.4.0) (0.42.1)\n", - "Requirement already satisfied: pytest==7.2.0 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from mindnlp==0.4.0) (7.2.0)\n", - "Requirement already satisfied: pillow>=10.0.0 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from mindnlp==0.4.0) (11.1.0)\n", - "Requirement already satisfied: attrs>=19.2.0 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from pytest==7.2.0->mindnlp==0.4.0) (25.3.0)\n", - "Requirement already satisfied: iniconfig in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from pytest==7.2.0->mindnlp==0.4.0) (2.1.0)\n", - "Requirement already satisfied: packaging in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from pytest==7.2.0->mindnlp==0.4.0) (24.2)\n", - "Requirement already satisfied: pluggy<2.0,>=0.12 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from pytest==7.2.0->mindnlp==0.4.0) (1.5.0)\n", - "Requirement already satisfied: exceptiongroup>=1.0.0rc8 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from pytest==7.2.0->mindnlp==0.4.0) (1.2.0)\n", - "Requirement already satisfied: tomli>=1.0.0 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from pytest==7.2.0->mindnlp==0.4.0) (2.2.1)\n", - "Requirement already satisfied: huggingface-hub<1.0,>=0.16.4 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from tokenizers==0.19.1->mindnlp==0.4.0) (0.32.3)\n", - "Requirement already satisfied: numpy<2.0.0,>=1.20.0 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from mindspore>=2.2.14->mindnlp==0.4.0) (1.26.4)\n", - "Requirement already satisfied: protobuf>=3.13.0 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from mindspore>=2.2.14->mindnlp==0.4.0) (6.30.2)\n", - "Requirement already satisfied: asttokens>=2.0.4 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from mindspore>=2.2.14->mindnlp==0.4.0) (2.0.5)\n", - "Requirement already satisfied: scipy>=1.5.4 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from mindspore>=2.2.14->mindnlp==0.4.0) (1.13.1)\n", - "Requirement already satisfied: psutil>=5.6.1 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from mindspore>=2.2.14->mindnlp==0.4.0) (5.9.0)\n", - "Requirement already satisfied: astunparse>=1.6.3 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from mindspore>=2.2.14->mindnlp==0.4.0) (1.6.3)\n", - "Requirement already satisfied: filelock in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from datasets->mindnlp==0.4.0) (3.18.0)\n", - "Requirement already satisfied: pyarrow>=15.0.0 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from datasets->mindnlp==0.4.0) (20.0.0)\n", - "Requirement already satisfied: dill<0.3.9,>=0.3.0 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from datasets->mindnlp==0.4.0) (0.3.8)\n", - "Requirement already satisfied: pandas in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from datasets->mindnlp==0.4.0) (2.2.3)\n", - "Requirement already satisfied: xxhash in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from datasets->mindnlp==0.4.0) (3.5.0)\n", - "Requirement already satisfied: multiprocess<0.70.17 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from datasets->mindnlp==0.4.0) (0.70.16)\n", - "Requirement already satisfied: fsspec<=2025.3.0,>=2023.1.0 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from fsspec[http]<=2025.3.0,>=2023.1.0->datasets->mindnlp==0.4.0) (2025.3.0)\n", - "Requirement already satisfied: pyyaml>=5.1 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from datasets->mindnlp==0.4.0) (6.0.2)\n", - "Requirement already satisfied: charset-normalizer<4,>=2 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from requests->mindnlp==0.4.0) (3.4.1)\n", - "Requirement already satisfied: idna<4,>=2.5 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from requests->mindnlp==0.4.0) (3.10)\n", - "Requirement already satisfied: urllib3<3,>=1.21.1 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from requests->mindnlp==0.4.0) (2.3.0)\n", - "Requirement already satisfied: certifi>=2017.4.17 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from requests->mindnlp==0.4.0) (2025.1.31)\n", - "Requirement already satisfied: pygtrie<3.0,>=2.1 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from pyctcdecode->mindnlp==0.4.0) (2.5.0)\n", - "Requirement already satisfied: hypothesis<7,>=6.14 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from pyctcdecode->mindnlp==0.4.0) (6.133.2)\n", - "Requirement already satisfied: six in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from asttokens>=2.0.4->mindspore>=2.2.14->mindnlp==0.4.0) (1.16.0)\n", - "Requirement already satisfied: wheel<1.0,>=0.23.0 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from astunparse>=1.6.3->mindspore>=2.2.14->mindnlp==0.4.0) (0.45.1)\n", - "Requirement already satisfied: aiohttp!=4.0.0a0,!=4.0.0a1 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from fsspec[http]<=2025.3.0,>=2023.1.0->datasets->mindnlp==0.4.0) (3.12.7)\n", - "Requirement already satisfied: typing-extensions>=3.7.4.3 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from huggingface-hub<1.0,>=0.16.4->tokenizers==0.19.1->mindnlp==0.4.0) (4.12.2)\n", - "Requirement already satisfied: hf-xet<2.0.0,>=1.1.2 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from huggingface-hub<1.0,>=0.16.4->tokenizers==0.19.1->mindnlp==0.4.0) (1.1.2)\n", - "Requirement already satisfied: sortedcontainers<3.0.0,>=2.1.0 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from hypothesis<7,>=6.14->pyctcdecode->mindnlp==0.4.0) (2.4.0)\n", - "Requirement already satisfied: python-dateutil>=2.8.2 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from pandas->datasets->mindnlp==0.4.0) (2.9.0.post0)\n", - "Requirement already satisfied: pytz>=2020.1 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from pandas->datasets->mindnlp==0.4.0) (2025.2)\n", - "Requirement already satisfied: tzdata>=2022.7 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from pandas->datasets->mindnlp==0.4.0) (2025.2)\n", - "Requirement already satisfied: aiohappyeyeballs>=2.5.0 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from aiohttp!=4.0.0a0,!=4.0.0a1->fsspec[http]<=2025.3.0,>=2023.1.0->datasets->mindnlp==0.4.0) (2.6.1)\n", - "Requirement already satisfied: aiosignal>=1.1.2 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from aiohttp!=4.0.0a0,!=4.0.0a1->fsspec[http]<=2025.3.0,>=2023.1.0->datasets->mindnlp==0.4.0) (1.3.2)\n", - "Requirement already satisfied: async-timeout<6.0,>=4.0 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from aiohttp!=4.0.0a0,!=4.0.0a1->fsspec[http]<=2025.3.0,>=2023.1.0->datasets->mindnlp==0.4.0) (5.0.1)\n", - "Requirement already satisfied: frozenlist>=1.1.1 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from aiohttp!=4.0.0a0,!=4.0.0a1->fsspec[http]<=2025.3.0,>=2023.1.0->datasets->mindnlp==0.4.0) (1.6.0)\n", - "Requirement already satisfied: multidict<7.0,>=4.5 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from aiohttp!=4.0.0a0,!=4.0.0a1->fsspec[http]<=2025.3.0,>=2023.1.0->datasets->mindnlp==0.4.0) (6.4.4)\n", - "Requirement already satisfied: propcache>=0.2.0 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from aiohttp!=4.0.0a0,!=4.0.0a1->fsspec[http]<=2025.3.0,>=2023.1.0->datasets->mindnlp==0.4.0) (0.3.1)\n", - "Requirement already satisfied: yarl<2.0,>=1.17.0 in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (from aiohttp!=4.0.0a0,!=4.0.0a1->fsspec[http]<=2025.3.0,>=2023.1.0->datasets->mindnlp==0.4.0) (1.20.0)\n", - "\n", - "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m25.0.1\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m25.1.1\u001b[0m\n", - "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpython -m pip install --upgrade pip\u001b[0m\n" - ] - } - ], + "outputs": [], "source": [ "!pip install mindnlp==0.4.0" ] }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "metadata": { "tags": [] }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Looking in indexes: https://repo.huaweicloud.com/repository/pypi/simple/\n", - "Requirement already satisfied: jieba in /home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages (0.42.1)\n", - "\n", - "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m25.0.1\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m25.1.1\u001b[0m\n", - "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpython -m pip install --upgrade pip\u001b[0m\n" - ] - } - ], + "outputs": [], "source": [ "!pip install jieba" ] }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "metadata": { "tags": [] }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "env: HF_ENDPOINT=https://hf-mirror.com\n" - ] - } - ], + "outputs": [], "source": [ "%env HF_ENDPOINT=https://hf-mirror.com" ] }, { "cell_type": "code", - "execution_count": 5, + "execution_count": null, "metadata": { "tags": [] }, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "[WARNING] ME(250:281472944873504,MainProcess):2025-06-03-14:44:02.546.745 [mindspore/run_check/_check_version.py:329] MindSpore version 2.4.1 and Ascend AI software package (Ascend Data Center Solution)version 7.6 does not match, the version of software package expect one of ['7.3', '7.5']. Please refer to the match info on: https://www.mindspore.cn/install\n", - "/home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages/numpy/core/getlimits.py:549: UserWarning: The value of the smallest subnormal for type is zero.\n", - " setattr(self, word, getattr(machar, word).flat[0])\n", - "/home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages/numpy/core/getlimits.py:89: UserWarning: The value of the smallest subnormal for type is zero.\n", - " return self._float_to_str(self.smallest_subnormal)\n", - "/home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages/numpy/core/getlimits.py:549: UserWarning: The value of the smallest subnormal for type is zero.\n", - " setattr(self, word, getattr(machar, word).flat[0])\n", - "/home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages/numpy/core/getlimits.py:89: UserWarning: The value of the smallest subnormal for type is zero.\n", - " return self._float_to_str(self.smallest_subnormal)\n", - "[WARNING] ME(250:281472944873504,MainProcess):2025-06-03-14:44:04.810.368 [mindspore/run_check/_check_version.py:347] MindSpore version 2.4.1 and \"te\" wheel package version 7.6 does not match. For details, refer to the installation guidelines: https://www.mindspore.cn/install\n", - "[WARNING] ME(250:281472944873504,MainProcess):2025-06-03-14:44:04.812.087 [mindspore/run_check/_check_version.py:354] MindSpore version 2.4.1 and \"hccl\" wheel package version 7.6 does not match. For details, refer to the installation guidelines: https://www.mindspore.cn/install\n", - "[WARNING] ME(250:281472944873504,MainProcess):2025-06-03-14:44:04.812.731 [mindspore/run_check/_check_version.py:368] Please pay attention to the above warning, countdown: 3\n", - "[WARNING] ME(250:281472944873504,MainProcess):2025-06-03-14:44:05.814.363 [mindspore/run_check/_check_version.py:368] Please pay attention to the above warning, countdown: 2\n", - "[WARNING] ME(250:281472944873504,MainProcess):2025-06-03-14:44:06.816.061 [mindspore/run_check/_check_version.py:368] Please pay attention to the above warning, countdown: 1\n", - "[WARNING] ME(250:281472944873504,MainProcess):2025-06-03-14:44:09.473.235 [mindspore/run_check/_check_version.py:329] MindSpore version 2.4.1 and Ascend AI software package (Ascend Data Center Solution)version 7.6 does not match, the version of software package expect one of ['7.3', '7.5']. Please refer to the match info on: https://www.mindspore.cn/install\n", - "[WARNING] ME(250:281472944873504,MainProcess):2025-06-03-14:44:09.474.964 [mindspore/run_check/_check_version.py:347] MindSpore version 2.4.1 and \"te\" wheel package version 7.6 does not match. For details, refer to the installation guidelines: https://www.mindspore.cn/install\n", - "[WARNING] ME(250:281472944873504,MainProcess):2025-06-03-14:44:09.475.567 [mindspore/run_check/_check_version.py:354] MindSpore version 2.4.1 and \"hccl\" wheel package version 7.6 does not match. For details, refer to the installation guidelines: https://www.mindspore.cn/install\n", - "[WARNING] ME(250:281472944873504,MainProcess):2025-06-03-14:44:09.476.234 [mindspore/run_check/_check_version.py:368] Please pay attention to the above warning, countdown: 3\n", - "[WARNING] ME(250:281472944873504,MainProcess):2025-06-03-14:44:10.477.850 [mindspore/run_check/_check_version.py:368] Please pay attention to the above warning, countdown: 2\n", - "[WARNING] ME(250:281472944873504,MainProcess):2025-06-03-14:44:11.478.869 [mindspore/run_check/_check_version.py:368] Please pay attention to the above warning, countdown: 1\n", - "[WARNING] ME(250:281472944873504,MainProcess):2025-06-03-14:44:12.480.761 [mindspore/run_check/_check_version.py:329] MindSpore version 2.4.1 and Ascend AI software package (Ascend Data Center Solution)version 7.6 does not match, the version of software package expect one of ['7.3', '7.5']. Please refer to the match info on: https://www.mindspore.cn/install\n", - "[WARNING] ME(250:281472944873504,MainProcess):2025-06-03-14:44:12.482.175 [mindspore/run_check/_check_version.py:347] MindSpore version 2.4.1 and \"te\" wheel package version 7.6 does not match. For details, refer to the installation guidelines: https://www.mindspore.cn/install\n", - "[WARNING] ME(250:281472944873504,MainProcess):2025-06-03-14:44:12.482.802 [mindspore/run_check/_check_version.py:354] MindSpore version 2.4.1 and \"hccl\" wheel package version 7.6 does not match. For details, refer to the installation guidelines: https://www.mindspore.cn/install\n", - "[WARNING] ME(250:281472944873504,MainProcess):2025-06-03-14:44:12.483.400 [mindspore/run_check/_check_version.py:368] Please pay attention to the above warning, countdown: 3\n", - "[WARNING] ME(250:281472944873504,MainProcess):2025-06-03-14:44:13.485.045 [mindspore/run_check/_check_version.py:368] Please pay attention to the above warning, countdown: 2\n", - "[WARNING] ME(250:281472944873504,MainProcess):2025-06-03-14:44:14.486.640 [mindspore/run_check/_check_version.py:368] Please pay attention to the above warning, countdown: 1\n", - "Building prefix dict from the default dictionary ...\n", - "Loading model from cache /tmp/jieba.cache\n", - "Loading model cost 1.075 seconds.\n", - "Prefix dict has been built successfully.\n" - ] - } - ], + "outputs": [], "source": [ "import os\n", "\n", @@ -218,7 +73,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": null, "metadata": { "tags": [] }, @@ -234,29 +89,18 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": null, "metadata": { "tags": [] }, - "outputs": [ - { - "data": { - "text/plain": [ - "2500" - ] - }, - "execution_count": 7, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "imdb_train.get_dataset_size()" ] }, { "cell_type": "code", - "execution_count": 8, + "execution_count": null, "metadata": { "tags": [] }, @@ -291,21 +135,11 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": null, "metadata": { "tags": [] }, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "ftfy or spacy is not installed using BERT BasicTokenizer instead of SpaCy & ftfy.\n", - "/home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages/mindnlp/transformers/tokenization_utils_base.py:1526: FutureWarning: `clean_up_tokenization_spaces` was not set. It will be set to `True` by default. This behavior will be depracted, and will be then set to `False` by default. \n", - " warnings.warn(\n" - ] - } - ], + "outputs": [], "source": [ "from mindnlp.transformers import OpenAIGPTTokenizer\n", "# tokenizer\n", @@ -322,19 +156,11 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": null, "metadata": { "tags": [] }, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "[WARNING] ME(250:281472944873504,MainProcess):2025-06-03-14:44:51.758.363 [mindspore/dataset/engine/datasets.py:2534] Dataset is shuffled before split.\n" - ] - } - ], + "outputs": [], "source": [ "# split train dataset into train and valid datasets\n", "imdb_train, imdb_val = imdb_train.split([0.7, 0.3])" @@ -342,7 +168,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": null, "metadata": { "tags": [] }, @@ -355,39 +181,18 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": null, "metadata": { "tags": [] }, - "outputs": [ - { - "data": { - "text/plain": [ - "[Tensor(shape=[4, 512], dtype=Int64, value=\n", - " [[ 500, 246, 1322 ... 40480, 40480, 40480],\n", - " [ 1473, 980, 246 ... 40480, 40480, 40480],\n", - " [39516, 498, 481 ... 40480, 40480, 40480],\n", - " [ 616, 544, 808 ... 40480, 40480, 40480]]),\n", - " Tensor(shape=[4, 512], dtype=Int64, value=\n", - " [[1, 1, 1 ... 0, 0, 0],\n", - " [1, 1, 1 ... 0, 0, 0],\n", - " [1, 1, 1 ... 0, 0, 0],\n", - " [1, 1, 1 ... 0, 0, 0]]),\n", - " Tensor(shape=[4], dtype=Int32, value= [1, 1, 0, 0])]" - ] - }, - "execution_count": 12, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "next(dataset_train.create_tuple_iterator())" ] }, { "cell_type": "code", - "execution_count": 13, + "execution_count": null, "metadata": { "tags": [] }, @@ -407,41 +212,11 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": null, "metadata": { "tags": [] }, - "outputs": [ - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "94d1b9d8276a4040a27030d34c8d44e2", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - " 0%| | 0.00/457M [00:00" @@ -92,7 +92,7 @@ }, { "cell_type": "markdown", - "id": "d2fe8b0f-8ab4-4658-b64f-5eefb64a25ec", + "id": "7", "metadata": {}, "source": [ "2. 安装mindspore2.2.12、indNLP及相关依赖,MindNLP官方仓详见:MindNLP" @@ -100,8 +100,8 @@ }, { "cell_type": "code", - "execution_count": 1, - "id": "52f84d8f-746d-4a87-af68-2dadf693f002", + "execution_count": null, + "id": "8", "metadata": {}, "outputs": [], "source": [ @@ -114,7 +114,7 @@ }, { "cell_type": "markdown", - "id": "d965c42b-d37a-42e4-aac9-4d25a4fb33be", + "id": "9", "metadata": {}, "source": [ "***注:执行如上命令完成安装后,请点击上方的restart kernel图标重启kernel,再进行实验***" @@ -122,8 +122,8 @@ }, { "cell_type": "code", - "execution_count": 2, - "id": "074df3ae-4bfc-4655-be9f-8041fc211f96", + "execution_count": null, + "id": "10", "metadata": { "tags": [] }, @@ -134,8 +134,8 @@ }, { "cell_type": "code", - "execution_count": 3, - "id": "9a161bfb-a15e-4a07-9bb0-688b76f87de3", + "execution_count": null, + "id": "11", "metadata": { "tags": [] }, @@ -148,7 +148,7 @@ }, { "cell_type": "markdown", - "id": "37ab3a91-292b-420d-9b61-c85280dd8dee", + "id": "12", "metadata": {}, "source": [ "## GPT-2 Self-attention: 1- Creating queries, keys, and values" @@ -156,7 +156,7 @@ }, { "cell_type": "markdown", - "id": "22664691-6db2-4d62-a76a-a4a8a6050199", + "id": "13", "metadata": {}, "source": [ "![gpt2-self-attention-3.png](https://jalammar.github.io/images/gpt2/gpt2-self-attention-3.png)" @@ -164,8 +164,8 @@ }, { "cell_type": "code", - "execution_count": 4, - "id": "76d2591f-26c2-4961-bca3-be30c4352aef", + "execution_count": null, + "id": "14", "metadata": { "tags": [] }, @@ -181,38 +181,18 @@ }, { "cell_type": "code", - "execution_count": 5, - "id": "2d315a4e-5663-404e-b93d-efb1cf354414", + "execution_count": null, + "id": "15", "metadata": { "tags": [] }, - "outputs": [ - { - "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" - ] - }, - { - "data": { - "text/plain": [ - "((1, 10, 768), (1, 10, 768), (1, 10, 768))" - ] - }, - "execution_count": 5, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "from mindnlp._legacy.functional import split\n", "from mindnlp.transformers.ms_utils import Conv1D\n", "\n", "# query = Wq * X, key = Wk * X, value = Wv * X\n", - "# c_attn: (1, 10, 768*3) --> query, key, value: (1, 10, 768), (1, 10, 768), (1, 10, 768) \n", + "# c_attn: (1, 10, 768*3) --> query, key, value: (1, 10, 768), (1, 10, 768), (1, 10, 768)\n", "c_attn = Conv1D(3 * embed_dim, embed_dim)\n", "query, key, value = split(c_attn(x), embed_dim, axis=2)\n", "query.shape, key.shape, value.shape" @@ -220,7 +200,7 @@ }, { "cell_type": "markdown", - "id": "d2c7757e-16e4-4ff9-8a63-3e19767588db", + "id": "16", "metadata": {}, "source": [ "![gpt2-self-attention-split-attention-heads-1.png](https://jalammar.github.io/images/gpt2/gpt2-self-attention-split-attention-heads-1.png)\n", @@ -230,8 +210,8 @@ }, { "cell_type": "code", - "execution_count": 6, - "id": "abb7ccac-7cfe-401a-ab32-763de70b4669", + "execution_count": null, + "id": "17", "metadata": { "tags": [] }, @@ -245,28 +225,17 @@ " new_shape = tensor.shape[:-1] + (num_heads, attn_head_size)\n", " tensor = tensor.view(new_shape)\n", " # (batch_size, seq_len, num_heads, attn_head_size) --> (batch_size, num_heads, seq_len, attn_head_size)\n", - " return ops.transpose(tensor, (0, 2, 1, 3)) " + " return ops.transpose(tensor, (0, 2, 1, 3))" ] }, { "cell_type": "code", - "execution_count": 7, - "id": "72abe0fe-5225-425b-9bda-0723f3fb27cf", + "execution_count": null, + "id": "18", "metadata": { "tags": [] }, - "outputs": [ - { - "data": { - "text/plain": [ - "((1, 12, 10, 64), (1, 12, 10, 64), (1, 12, 10, 64))" - ] - }, - "execution_count": 7, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "num_heads = 12\n", "head_dim = embed_dim // num_heads\n", @@ -281,7 +250,7 @@ }, { "cell_type": "markdown", - "id": "fa0f65b2-b291-4ad1-b3ea-8e77e6a254d3", + "id": "19", "metadata": {}, "source": [ "## GPT-2 Self-attention: 2- Scoring\n", @@ -293,23 +262,12 @@ }, { "cell_type": "code", - "execution_count": 8, - "id": "9f952236-de74-4419-9469-7e78d3b7c3e4", + "execution_count": null, + "id": "20", "metadata": { "tags": [] }, - "outputs": [ - { - "data": { - "text/plain": [ - "(1, 12, 10, 10)" - ] - }, - "execution_count": 8, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "# qk点积\n", "# q: (1, 12, 10, 64), k^T: (1, 12, 64, 10)\n", @@ -321,7 +279,7 @@ }, { "cell_type": "markdown", - "id": "501d6de9-cdb7-40cd-aed1-e4fe059054b5", + "id": "21", "metadata": { "tags": [] }, @@ -331,30 +289,12 @@ }, { "cell_type": "code", - "execution_count": 9, - "id": "0ff22248-deff-4962-afae-55772f63f142", + "execution_count": null, + "id": "22", "metadata": { "tags": [] }, - "outputs": [ - { - "data": { - "text/plain": [ - "Tensor(shape=[1, 1, 10, 10], dtype=Bool, value=\n", - "[[[[ True, False, False ... False, False, False],\n", - " [ True, True, False ... False, False, False],\n", - " [ True, True, True ... False, False, False],\n", - " ...\n", - " [ True, True, True ... True, False, False],\n", - " [ True, True, True ... True, True, False],\n", - " [ True, True, True ... True, True, True]]]])" - ] - }, - "execution_count": 9, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "# diagonal matrix to implement masked multi-head attention\n", "# To ensure not to attend to future information\n", @@ -367,7 +307,7 @@ }, { "cell_type": "markdown", - "id": "a783a2bc-01dd-4496-a018-ac01e643cd89", + "id": "23", "metadata": {}, "source": [ "![](https://jalammar.github.io/images/gpt2/queries-keys-attention-mask.png)\n", @@ -377,8 +317,8 @@ }, { "cell_type": "code", - "execution_count": 10, - "id": "d957ce17-6df6-4f5e-a262-24ff3a8ce0d1", + "execution_count": null, + "id": "24", "metadata": { "tags": [] }, @@ -395,58 +335,29 @@ }, { "cell_type": "code", - "execution_count": 11, - "id": "dee63bfd-f394-4558-9e9f-e102a2fd283c", + "execution_count": null, + "id": "25", "metadata": { "tags": [] }, - "outputs": [ - { - "data": { - "text/plain": [ - "-3.4028235e+38" - ] - }, - "execution_count": 11, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "np.finfo(np.float32).min" ] }, { "cell_type": "code", - "execution_count": 12, - "id": "d2faad14-9a3d-4495-8bcc-d7ac2695e83d", + "execution_count": null, + "id": "26", "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", - " ...\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]])" - ] - }, - "execution_count": 12, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "attn_weights[0, 0]" ] }, { "cell_type": "markdown", - "id": "54f61883-a535-4135-851c-c41e9c227e18", + "id": "27", "metadata": {}, "source": [ "![](https://jalammar.github.io/images/gpt2/transformer-attention-masked-scores-softmax.png)" @@ -454,23 +365,12 @@ }, { "cell_type": "code", - "execution_count": 13, - "id": "df9cdaae-ac5a-4bc0-9e59-403d176c0d3b", + "execution_count": null, + "id": "28", "metadata": { "tags": [] }, - "outputs": [ - { - "data": { - "text/plain": [ - "(1, 12, 10, 10)" - ] - }, - "execution_count": 13, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "attn_weights = softmax(attn_weights, axis=-1)\n", "attn_weights.shape" @@ -478,37 +378,19 @@ }, { "cell_type": "code", - "execution_count": 14, - "id": "5771f68c-8b35-4b1a-83d1-287b2ce7a47e", + "execution_count": null, + "id": "29", "metadata": { "tags": [] }, - "outputs": [ - { - "data": { - "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", - " ...\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]])" - ] - }, - "execution_count": 14, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "attn_weights[0, 0]" ] }, { "cell_type": "markdown", - "id": "4a376e6b-0cd8-434a-aa5b-c647251200fa", + "id": "30", "metadata": {}, "source": [ "![](https://jalammar.github.io/images/gpt2/gpt2-self-attention-multihead-sum-1.png)" @@ -516,23 +398,12 @@ }, { "cell_type": "code", - "execution_count": 15, - "id": "0ba1e0ff-5627-4b70-8911-4ffa7383e29d", + "execution_count": null, + "id": "31", "metadata": { "tags": [] }, - "outputs": [ - { - "data": { - "text/plain": [ - "(1, 12, 10, 64)" - ] - }, - "execution_count": 15, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "attn_output = ops.matmul(attn_weights, value)\n", "\n", @@ -541,7 +412,7 @@ }, { "cell_type": "markdown", - "id": "5952ef91-b1e1-4d5b-9b42-a29f56f8f430", + "id": "32", "metadata": {}, "source": [ "## GPT-2 Self-attention: 3.5- Merge attention heads\n", @@ -551,8 +422,8 @@ }, { "cell_type": "code", - "execution_count": 16, - "id": "80e44dd1-4013-4d01-b267-92463b296e5b", + "execution_count": null, + "id": "33", "metadata": { "tags": [] }, @@ -570,23 +441,12 @@ }, { "cell_type": "code", - "execution_count": 17, - "id": "5b35f8ee-70b4-4cb4-ad9b-d0b685482b59", + "execution_count": null, + "id": "34", "metadata": { "tags": [] }, - "outputs": [ - { - "data": { - "text/plain": [ - "(1, 10, 768)" - ] - }, - "execution_count": 17, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "# (1, 12, 10, 64) --> (1, 10, 12, 64) --> (1, 10, 768)\n", "attn_output = merge_heads(attn_output, num_heads, head_dim)\n", @@ -596,7 +456,7 @@ }, { "cell_type": "markdown", - "id": "de14b271-4432-44a0-b1f9-d2632ed2cd5b", + "id": "35", "metadata": {}, "source": [ "## GPT-2 Self-attention: 4- Projecting\n", @@ -606,8 +466,8 @@ }, { "cell_type": "code", - "execution_count": 18, - "id": "ff788df6-a6a7-4b43-9a76-95eaef4918c7", + "execution_count": null, + "id": "36", "metadata": { "tags": [] }, @@ -618,23 +478,12 @@ }, { "cell_type": "code", - "execution_count": 19, - "id": "0c7d4c1f-4ddc-4605-acba-f6e17cbfe2d5", + "execution_count": null, + "id": "37", "metadata": { "tags": [] }, - "outputs": [ - { - "data": { - "text/plain": [ - "(1, 10, 768)" - ] - }, - "execution_count": 19, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "attn_output = c_proj(attn_output)\n", "attn_output.shape" @@ -643,7 +492,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9300497c-e27a-4fad-b02e-fe2b6a38aec2", + "id": "38", "metadata": {}, "outputs": [], "source": [] diff --git a/01.LLM_Theory_Course/01.Industry_Model_Introduction/01.Classic_Model_Technical_Analysis/03.GPT2/gpt2_summarization.ipynb b/01.LLM_Theory_Course/01.Industry_Model_Introduction/01.Classic_Model_Technical_Analysis/03.GPT2/gpt2_summarization.ipynb index 7daef40..c56a189 100644 --- a/01.LLM_Theory_Course/01.Industry_Model_Introduction/01.Classic_Model_Technical_Analysis/03.GPT2/gpt2_summarization.ipynb +++ b/01.LLM_Theory_Course/01.Industry_Model_Introduction/01.Classic_Model_Technical_Analysis/03.GPT2/gpt2_summarization.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "markdown", - "id": "cb430c0e-fd70-46e2-91e2-b14cf782bd06", + "id": "0", "metadata": {}, "source": [ "# 基于MindSpore的GPT2文本摘要\n", @@ -14,8 +14,8 @@ }, { "cell_type": "code", - "execution_count": 2, - "id": "f9f085c7-b2b3-4b18-95f9-13b298b10d58", + "execution_count": null, + "id": "1", "metadata": {}, "outputs": [], "source": [ @@ -27,7 +27,7 @@ { "cell_type": "code", "execution_count": null, - "id": "d9436813-c813-425e-b1ed-af0534ef862c", + "id": "2", "metadata": {}, "outputs": [], "source": [ @@ -58,7 +58,7 @@ }, { "cell_type": "markdown", - "id": "0bdfae31-df62-4746-bd3e-1c556413ffd2", + "id": "3", "metadata": {}, "source": [ "***注:以上代码执行完成后,需点击左上角或右上角将kernel更换为python-3.9.0***" @@ -66,7 +66,7 @@ }, { "cell_type": "markdown", - "id": "757cb29c-48f4-4b6b-9b71-6c008e629eb8", + "id": "4", "metadata": {}, "source": [ "2. 安装mindspore2.2.12,安装指南详见:[MindSpore安装](https://www.mindspore.cn/install)\n", @@ -75,112 +75,10 @@ }, { "cell_type": "code", - "execution_count": 21, - "id": "6491560b-1ec6-4ca1-88cc-c7f9c1297725", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Looking in indexes: http://pip.modelarts.private.com:8888/repository/pypi/simple\n", - "Processing ./mindnlp-0.4.1-py3-none-any.whl\n", - "Requirement already satisfied: addict in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from mindnlp==0.4.1) (2.4.0)\n", - "Requirement already satisfied: pytest==7.2.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from mindnlp==0.4.1) (7.2.0)\n", - "Requirement already satisfied: tqdm in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from mindnlp==0.4.1) (4.66.4)\n", - "Requirement already satisfied: regex in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from mindnlp==0.4.1) (2024.7.24)\n", - "Requirement already satisfied: evaluate in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from mindnlp==0.4.1) (0.4.3)\n", - "Requirement already satisfied: pyctcdecode in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from mindnlp==0.4.1) (0.5.0)\n", - "Requirement already satisfied: ml-dtypes in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from mindnlp==0.4.1) (0.4.0)\n", - "Requirement already satisfied: sentencepiece in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from mindnlp==0.4.1) (0.2.0)\n", - "Requirement already satisfied: tokenizers==0.19.1 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from mindnlp==0.4.1) (0.19.1)\n", - "Requirement already satisfied: datasets in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from mindnlp==0.4.1) (3.1.0)\n", - "Requirement already satisfied: safetensors in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from mindnlp==0.4.1) (0.4.5)\n", - "Requirement already satisfied: pillow>=10.0.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from mindnlp==0.4.1) (10.0.1)\n", - "Requirement already satisfied: mindspore>=2.2.14 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from mindnlp==0.4.1) (2.4.0)\n", - "Requirement already satisfied: requests in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from mindnlp==0.4.1) (2.32.3)\n", - "Requirement already satisfied: exceptiongroup>=1.0.0rc8 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from pytest==7.2.0->mindnlp==0.4.1) (1.2.2)\n", - "Requirement already satisfied: pluggy<2.0,>=0.12 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from pytest==7.2.0->mindnlp==0.4.1) (1.5.0)\n", - "Requirement already satisfied: attrs>=19.2.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from pytest==7.2.0->mindnlp==0.4.1) (23.2.0)\n", - "Requirement already satisfied: packaging in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from pytest==7.2.0->mindnlp==0.4.1) (24.1)\n", - "Requirement already satisfied: iniconfig in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from pytest==7.2.0->mindnlp==0.4.1) (2.0.0)\n", - "Requirement already satisfied: tomli>=1.0.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from pytest==7.2.0->mindnlp==0.4.1) (2.0.1)\n", - "Requirement already satisfied: huggingface-hub<1.0,>=0.16.4 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from tokenizers==0.19.1->mindnlp==0.4.1) (0.24.2)\n", - "Requirement already satisfied: typing-extensions>=3.7.4.3 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from huggingface-hub<1.0,>=0.16.4->tokenizers==0.19.1->mindnlp==0.4.1) (4.12.2)\n", - "Requirement already satisfied: fsspec>=2023.5.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from huggingface-hub<1.0,>=0.16.4->tokenizers==0.19.1->mindnlp==0.4.1) (2024.6.1)\n", - "Requirement already satisfied: filelock in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from huggingface-hub<1.0,>=0.16.4->tokenizers==0.19.1->mindnlp==0.4.1) (3.15.4)\n", - "Requirement already satisfied: pyyaml>=5.1 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from huggingface-hub<1.0,>=0.16.4->tokenizers==0.19.1->mindnlp==0.4.1) (6.0.1)\n", - "Requirement already satisfied: psutil>=5.6.1 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from mindspore>=2.2.14->mindnlp==0.4.1) (5.9.5)\n", - "Requirement already satisfied: numpy<2.0.0,>=1.20.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from mindspore>=2.2.14->mindnlp==0.4.1) (1.22.0)\n", - "Requirement already satisfied: astunparse>=1.6.3 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from mindspore>=2.2.14->mindnlp==0.4.1) (1.6.3)\n", - "Requirement already satisfied: asttokens>=2.0.4 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from mindspore>=2.2.14->mindnlp==0.4.1) (2.4.1)\n", - "Requirement already satisfied: scipy>=1.5.4 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from mindspore>=2.2.14->mindnlp==0.4.1) (1.10.1)\n", - "Requirement already satisfied: protobuf>=3.13.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from mindspore>=2.2.14->mindnlp==0.4.1) (3.20.2)\n", - "Requirement already satisfied: six>=1.12.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from asttokens>=2.0.4->mindspore>=2.2.14->mindnlp==0.4.1) (1.16.0)\n", - "Requirement already satisfied: wheel<1.0,>=0.23.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from astunparse>=1.6.3->mindspore>=2.2.14->mindnlp==0.4.1) (0.38.4)\n", - "Requirement already satisfied: pandas in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from datasets->mindnlp==0.4.1) (1.3.5)\n", - "Requirement already satisfied: multiprocess<0.70.17 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from datasets->mindnlp==0.4.1) (0.70.16)\n", - "Requirement already satisfied: dill<0.3.9,>=0.3.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from datasets->mindnlp==0.4.1) (0.3.8)\n", - "Requirement already satisfied: aiohttp in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from datasets->mindnlp==0.4.1) (3.11.9)\n", - "Requirement already satisfied: pyarrow>=15.0.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from datasets->mindnlp==0.4.1) (18.1.0)\n", - "Requirement already satisfied: xxhash in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from datasets->mindnlp==0.4.1) (3.5.0)\n", - "Requirement already satisfied: async-timeout<6.0,>=4.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from aiohttp->datasets->mindnlp==0.4.1) (5.0.1)\n", - "Requirement already satisfied: aiohappyeyeballs>=2.3.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from aiohttp->datasets->mindnlp==0.4.1) (2.4.4)\n", - "Requirement already satisfied: multidict<7.0,>=4.5 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from aiohttp->datasets->mindnlp==0.4.1) (6.1.0)\n", - "Requirement already satisfied: aiosignal>=1.1.2 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from aiohttp->datasets->mindnlp==0.4.1) (1.3.1)\n", - "Requirement already satisfied: yarl<2.0,>=1.17.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from aiohttp->datasets->mindnlp==0.4.1) (1.18.3)\n", - "Requirement already satisfied: propcache>=0.2.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from aiohttp->datasets->mindnlp==0.4.1) (0.2.1)\n", - "Requirement already satisfied: frozenlist>=1.1.1 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from aiohttp->datasets->mindnlp==0.4.1) (1.5.0)\n", - "Requirement already satisfied: charset-normalizer<4,>=2 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from requests->mindnlp==0.4.1) (2.0.12)\n", - "Requirement already satisfied: certifi>=2017.4.17 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from requests->mindnlp==0.4.1) (2024.7.4)\n", - "Requirement already satisfied: urllib3<3,>=1.21.1 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from requests->mindnlp==0.4.1) (1.26.7)\n", - "Requirement already satisfied: idna<4,>=2.5 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from requests->mindnlp==0.4.1) (2.10)\n", - "Requirement already satisfied: pytz>=2017.3 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from pandas->datasets->mindnlp==0.4.1) (2024.1)\n", - "Requirement already satisfied: python-dateutil>=2.7.3 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from pandas->datasets->mindnlp==0.4.1) (2.9.0.post0)\n", - "Requirement already satisfied: hypothesis<7,>=6.14 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from pyctcdecode->mindnlp==0.4.1) (6.122.1)\n", - "Requirement already satisfied: pygtrie<3.0,>=2.1 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from pyctcdecode->mindnlp==0.4.1) (2.5.0)\n", - "Requirement already satisfied: sortedcontainers<3.0.0,>=2.1.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from hypothesis<7,>=6.14->pyctcdecode->mindnlp==0.4.1) (2.4.0)\n", - "mindnlp is already installed with the same version as the provided wheel. Use --force-reinstall to force an installation of the wheel.\n", - "\u001b[33mWARNING: You are using pip version 21.0.1; however, version 24.3.1 is available.\n", - "You should consider upgrading via the '/home/ma-user/anaconda3/envs/MindSpore/bin/python3.9 -m pip install --upgrade pip' command.\u001b[0m\n", - "Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple\n", - "Requirement already satisfied: tokenizers==0.19.1 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (0.19.1)\n", - "Requirement already satisfied: huggingface-hub<1.0,>=0.16.4 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from tokenizers==0.19.1) (0.24.2)\n", - "Requirement already satisfied: packaging>=20.9 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from huggingface-hub<1.0,>=0.16.4->tokenizers==0.19.1) (24.1)\n", - "Requirement already satisfied: fsspec>=2023.5.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from huggingface-hub<1.0,>=0.16.4->tokenizers==0.19.1) (2024.6.1)\n", - "Requirement already satisfied: pyyaml>=5.1 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from huggingface-hub<1.0,>=0.16.4->tokenizers==0.19.1) (6.0.1)\n", - "Requirement already satisfied: tqdm>=4.42.1 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from huggingface-hub<1.0,>=0.16.4->tokenizers==0.19.1) (4.66.4)\n", - "Requirement already satisfied: requests in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from huggingface-hub<1.0,>=0.16.4->tokenizers==0.19.1) (2.32.3)\n", - "Requirement already satisfied: typing-extensions>=3.7.4.3 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from huggingface-hub<1.0,>=0.16.4->tokenizers==0.19.1) (4.12.2)\n", - "Requirement already satisfied: filelock in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from huggingface-hub<1.0,>=0.16.4->tokenizers==0.19.1) (3.15.4)\n", - "Requirement already satisfied: charset-normalizer<4,>=2 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from requests->huggingface-hub<1.0,>=0.16.4->tokenizers==0.19.1) (2.0.12)\n", - "Requirement already satisfied: idna<4,>=2.5 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from requests->huggingface-hub<1.0,>=0.16.4->tokenizers==0.19.1) (2.10)\n", - "Requirement already satisfied: certifi>=2017.4.17 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from requests->huggingface-hub<1.0,>=0.16.4->tokenizers==0.19.1) (2024.7.4)\n", - "Requirement already satisfied: urllib3<3,>=1.21.1 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from requests->huggingface-hub<1.0,>=0.16.4->tokenizers==0.19.1) (1.26.7)\n", - "\u001b[33mWARNING: You are using pip version 21.0.1; however, version 24.3.1 is available.\n", - "You should consider upgrading via the '/home/ma-user/anaconda3/envs/MindSpore/bin/python3.9 -m pip install --upgrade pip' command.\u001b[0m\n", - "env: no_proxy='a.test.com,127.0.0.1,2.2.2.2'\n", - "Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple\n", - "Collecting mindspore==2.4.0\n", - " Using cached https://ms-release.obs.cn-north-4.myhuaweicloud.com/2.4.0/MindSpore/unified/aarch64/mindspore-2.4.0-cp39-cp39-linux_aarch64.whl (333.7 MB)\n", - "Requirement already satisfied: protobuf>=3.13.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from mindspore==2.4.0) (3.20.2)\n", - "Requirement already satisfied: psutil>=5.6.1 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from mindspore==2.4.0) (5.9.5)\n", - "Requirement already satisfied: asttokens>=2.0.4 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from mindspore==2.4.0) (2.4.1)\n", - "Requirement already satisfied: packaging>=20.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from mindspore==2.4.0) (24.1)\n", - "Requirement already satisfied: numpy<2.0.0,>=1.20.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from mindspore==2.4.0) (1.22.0)\n", - "Requirement already satisfied: safetensors>=0.4.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from mindspore==2.4.0) (0.4.5)\n", - "Requirement already satisfied: scipy>=1.5.4 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from mindspore==2.4.0) (1.10.1)\n", - "Requirement already satisfied: pillow>=6.2.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from mindspore==2.4.0) (10.0.1)\n", - "Requirement already satisfied: astunparse>=1.6.3 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from mindspore==2.4.0) (1.6.3)\n", - "Requirement already satisfied: six>=1.12.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from asttokens>=2.0.4->mindspore==2.4.0) (1.16.0)\n", - "Requirement already satisfied: wheel<1.0,>=0.23.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from astunparse>=1.6.3->mindspore==2.4.0) (0.38.4)\n", - "\u001b[33mWARNING: You are using pip version 21.0.1; however, version 24.3.1 is available.\n", - "You should consider upgrading via the '/home/ma-user/anaconda3/envs/MindSpore/bin/python -m pip install --upgrade pip' command.\u001b[0m\n", - "Note: you may need to restart the kernel to use updated packages.\n", - "\u001b[33mWARNING: Skipping mindformers as it is not installed.\u001b[0m\n" - ] - } - ], + "execution_count": null, + "id": "5", + "metadata": {}, + "outputs": [], "source": [ "!pip install mindnlp-0.4.1-py3-none-any.whl # 将安装mindnlp版本更换为mindnlp-0.4.0-py3-none-any.whl(daily版本)\n", "!pip install tokenizers==0.19.1 -i https://pypi.tuna.tsinghua.edu.cn/simple # 修改tokenizers版本为0.19.1\n", @@ -191,7 +89,7 @@ }, { "cell_type": "markdown", - "id": "0faae5c6-8397-4574-9e9c-f86230bb071a", + "id": "6", "metadata": {}, "source": [ "***注:执行如上命令完成安装后,请点击上方的restart kernel图标重启kernel,再进行实验***" @@ -199,7 +97,7 @@ }, { "cell_type": "markdown", - "id": "bb699e4a-a2dc-44f2-b3cb-6b86fa9b24f6", + "id": "7", "metadata": {}, "source": [ "### 数据集加载与处理\n", @@ -211,39 +109,10 @@ }, { "cell_type": "code", - "execution_count": 1, - "id": "27bf5931-7b09-4984-841c-fbea311d3955", - "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "[WARNING] GE_ADPT(12319,ffffaba360b0,python):2024-12-03-21:03:05.821.904 [mindspore/ccsrc/utils/dlopen_macro.h:163] DlsymAscend] Dynamically load symbol aclmdlBundleGetModelId failed, result = /usr/local/Ascend/ascend-toolkit/latest/lib64/libascendcl.so: undefined symbol: aclmdlBundleGetModelId\n", - "[WARNING] GE_ADPT(12319,ffffaba360b0,python):2024-12-03-21:03:05.821.956 [mindspore/ccsrc/utils/dlopen_macro.h:163] DlsymAscend] Dynamically load symbol aclmdlBundleLoadFromMem failed, result = /usr/local/Ascend/ascend-toolkit/latest/lib64/libascendcl.so: undefined symbol: aclmdlBundleLoadFromMem\n", - "[WARNING] GE_ADPT(12319,ffffaba360b0,python):2024-12-03-21:03:05.821.975 [mindspore/ccsrc/utils/dlopen_macro.h:163] DlsymAscend] Dynamically load symbol aclmdlBundleUnload failed, result = /usr/local/Ascend/ascend-toolkit/latest/lib64/libascendcl.so: undefined symbol: aclmdlBundleUnload\n", - "[WARNING] GE_ADPT(12319,ffffaba360b0,python):2024-12-03-21:03:05.822.162 [mindspore/ccsrc/utils/dlopen_macro.h:163] DlsymAscend] Dynamically load symbol aclrtGetMemUceInfo failed, result = /usr/local/Ascend/ascend-toolkit/latest/lib64/libascendcl.so: undefined symbol: aclrtGetMemUceInfo\n", - "[WARNING] GE_ADPT(12319,ffffaba360b0,python):2024-12-03-21:03:05.822.179 [mindspore/ccsrc/utils/dlopen_macro.h:163] DlsymAscend] Dynamically load symbol aclrtDeviceTaskAbort failed, result = /usr/local/Ascend/ascend-toolkit/latest/lib64/libascendcl.so: undefined symbol: aclrtDeviceTaskAbort\n", - "[WARNING] GE_ADPT(12319,ffffaba360b0,python):2024-12-03-21:03:05.822.193 [mindspore/ccsrc/utils/dlopen_macro.h:163] DlsymAscend] Dynamically load symbol aclrtMemUceRepair failed, result = /usr/local/Ascend/ascend-toolkit/latest/lib64/libascendcl.so: undefined symbol: aclrtMemUceRepair\n", - "[WARNING] GE_ADPT(12319,ffffaba360b0,python):2024-12-03-21:03:05.823.653 [mindspore/ccsrc/utils/dlopen_macro.h:163] DlsymAscend] Dynamically load symbol acltdtCleanChannel failed, result = /usr/local/Ascend/ascend-toolkit/latest/lib64/libacl_tdt_channel.so: undefined symbol: acltdtCleanChannel\n", - "[WARNING] ME(12319:281473561354416,MainProcess):2024-12-03-21:03:05.955.541 [mindspore/run_check/_check_version.py:396] Can not find the tbe operator implementation(need by mindspore-ascend). Please check whether the Environment Variable PYTHONPATH is set. For details, refer to the installation guidelines: https://www.mindspore.cn/install\n", - "/home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages/numpy/core/getlimits.py:499: UserWarning: The value of the smallest subnormal for type is zero.\n", - " setattr(self, word, getattr(machar, word).flat[0])\n", - "/home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages/numpy/core/getlimits.py:89: UserWarning: The value of the smallest subnormal for type is zero.\n", - " return self._float_to_str(self.smallest_subnormal)\n", - "/home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages/numpy/core/getlimits.py:499: UserWarning: The value of the smallest subnormal for type is zero.\n", - " setattr(self, word, getattr(machar, word).flat[0])\n", - "/home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages/numpy/core/getlimits.py:89: UserWarning: The value of the smallest subnormal for type is zero.\n", - " return self._float_to_str(self.smallest_subnormal)\n", - "/home/ma-user/anaconda3/envs/MindSpore/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", - " 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 1.298 seconds.\n", - "Prefix dict has been built successfully.\n" - ] - } - ], + "execution_count": null, + "id": "8", + "metadata": {}, + "outputs": [], "source": [ "from mindnlp.utils import http_get\n", "\n", @@ -254,21 +123,10 @@ }, { "cell_type": "code", - "execution_count": 2, - "id": "9b5868b6-7a52-4f97-b934-4d3632a978a2", - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "50000" - ] - }, - "execution_count": 2, - "metadata": {}, - "output_type": "execute_result" - } - ], + "execution_count": null, + "id": "9", + "metadata": {}, + "outputs": [], "source": [ "from mindspore.dataset import TextFileDataset\n", "\n", @@ -279,7 +137,7 @@ }, { "cell_type": "markdown", - "id": "f2697c68-be45-44c1-bc26-7c04424ebf0c", + "id": "10", "metadata": {}, "source": [ "**本案例默认在GPU P100上运行,因中文文本,tokenizer使用的是bert tokenizer而非gpt tokenizer等原因,全量数据训练1个epoch的时间约为80分钟。**\n", @@ -289,8 +147,8 @@ }, { "cell_type": "code", - "execution_count": 3, - "id": "9bf79231-864c-4e11-9409-995c95cdb30f", + "execution_count": null, + "id": "11", "metadata": {}, "outputs": [], "source": [ @@ -301,7 +159,7 @@ }, { "cell_type": "markdown", - "id": "a1f0d574-53a0-4bac-9303-6eb769418c04", + "id": "12", "metadata": {}, "source": [ "2. 数据预处理\n", @@ -320,8 +178,8 @@ }, { "cell_type": "code", - "execution_count": 4, - "id": "f1ee1961-0658-4e70-95c2-81fefd83a40b", + "execution_count": null, + "id": "13", "metadata": {}, "outputs": [], "source": [ @@ -340,7 +198,7 @@ " tokenized = tokenizer(text=article, text_pair=summary,\n", " padding='max_length', truncation='only_first', max_length=max_seq_len)\n", " return tokenized['input_ids'], tokenized['input_ids']\n", - " \n", + "\n", " dataset = dataset.map(read_map, 'text', ['article', 'summary'])\n", " # change column names to input_ids and labels for the following training\n", " dataset = dataset.map(merge_and_pad, ['article', 'summary'], ['input_ids', 'labels'])\n", @@ -354,7 +212,7 @@ }, { "cell_type": "markdown", - "id": "e0ce3dab-9486-4365-be7c-34bd5a761080", + "id": "14", "metadata": {}, "source": [ "因GPT2无中文的tokenizer,我们使用BertTokenizer替代。" @@ -362,29 +220,10 @@ }, { "cell_type": "code", - "execution_count": 5, - "id": "e3cd8e57-72bc-4d2e-b38d-38b24efadd49", - "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "/home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages/mindnlp/transformers/tokenization_utils_base.py:1526: FutureWarning: `clean_up_tokenization_spaces` was not set. It will be set to `True` by default. This behavior will be depracted, and will be then set to `False` by default. \n", - " warnings.warn(\n" - ] - }, - { - "data": { - "text/plain": [ - "21128" - ] - }, - "execution_count": 5, - "metadata": {}, - "output_type": "execute_result" - } - ], + "execution_count": null, + "id": "15", + "metadata": {}, + "outputs": [], "source": [ "from mindnlp.transformers import BertTokenizer\n", "\n", @@ -395,8 +234,8 @@ }, { "cell_type": "code", - "execution_count": 6, - "id": "0e89c26b-4970-449a-a0c4-b6c61845e336", + "execution_count": null, + "id": "16", "metadata": {}, "outputs": [], "source": [ @@ -405,31 +244,17 @@ }, { "cell_type": "code", - "execution_count": 7, - "id": "1b65cc13-0a52-4bae-ab5f-ebb813a4d3ab", - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "[Tensor(shape=[1, 1024], dtype=Int64, value=\n", - " [[ 101, 1724, 3862 ... 0, 0, 0]]),\n", - " Tensor(shape=[1, 1024], dtype=Int64, value=\n", - " [[ 101, 1724, 3862 ... 0, 0, 0]])]" - ] - }, - "execution_count": 7, - "metadata": {}, - "output_type": "execute_result" - } - ], + "execution_count": null, + "id": "17", + "metadata": {}, + "outputs": [], "source": [ "next(train_dataset.create_tuple_iterator())" ] }, { "cell_type": "markdown", - "id": "7e1497ee-2ad1-4da8-b659-9c7f2d45fccc", + "id": "18", "metadata": {}, "source": [ "### 模型构建\n", @@ -439,8 +264,8 @@ }, { "cell_type": "code", - "execution_count": 8, - "id": "2f295944-ea2e-41e1-8301-472e09223792", + "execution_count": null, + "id": "19", "metadata": {}, "outputs": [], "source": [ @@ -481,7 +306,7 @@ }, { "cell_type": "markdown", - "id": "0f6af843-64d7-49a3-875f-605d6b2e74b2", + "id": "20", "metadata": {}, "source": [ "2. 动态学习率" @@ -489,8 +314,8 @@ }, { "cell_type": "code", - "execution_count": 9, - "id": "73c7be3d-44dc-49d4-abd8-c41f316a28d9", + "execution_count": null, + "id": "21", "metadata": {}, "outputs": [], "source": [ @@ -519,7 +344,7 @@ }, { "cell_type": "markdown", - "id": "c45e9db2-11df-4cc4-8bef-87d473d99e5a", + "id": "22", "metadata": {}, "source": [ "### 模型训练" @@ -527,8 +352,8 @@ }, { "cell_type": "code", - "execution_count": 10, - "id": "1a655320-2d05-4c93-bc8b-f1b4f45f809f", + "execution_count": null, + "id": "23", "metadata": {}, "outputs": [], "source": [ @@ -541,21 +366,10 @@ }, { "cell_type": "code", - "execution_count": 11, - "id": "81ac9003-2dcf-42f8-b42d-3a788f172d98", - "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "GPT2LMHeadModel has generative capabilities, as `prepare_inputs_for_generation` is explicitly overwritten. However, it doesn't directly inherit from `GenerationMixin`.`PreTrainedModel` will NOT inherit from `GenerationMixin`, and this model will lose the ability to call `generate` and other related functions.\n", - " - If you are the owner of the model architecture code, please modify your model class such that it inherits from `GenerationMixin` (after `PreTrainedModel`, otherwise you'll get an exception).\n", - " - If you are not the owner of the model architecture class, please contact the model code owner to update it.\n", - "[WARNING] DEVICE(12319,ffffaba360b0,python):2024-12-03-21:03:34.197.849 [mindspore/ccsrc/plugin/device/ascend/hal/device/ascend_vmm_adapter.h:188] CheckVmmDriverVersion] Driver version is less than 24.0.0, vmm is disabled by default, drvier_version: 23.0.6\n" - ] - } - ], + "execution_count": null, + "id": "24", + "metadata": {}, + "outputs": [], "source": [ "from mindspore import nn\n", "from mindnlp.transformers import GPT2Config, GPT2LMHeadModel\n", @@ -570,18 +384,10 @@ }, { "cell_type": "code", - "execution_count": 12, - "id": "2803c71c-3591-48cf-a6a9-6b840af749bf", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "number of model parameters: 102068736\n" - ] - } - ], + "execution_count": null, + "id": "25", + "metadata": {}, + "outputs": [], "source": [ "# 记录模型参数数量\n", "print('number of model parameters: {}'.format(model.num_parameters()))" @@ -589,8 +395,8 @@ }, { "cell_type": "code", - "execution_count": 13, - "id": "1492649c-dfdb-4cfd-85bb-aef478aff5d2", + "execution_count": null, + "id": "26", "metadata": {}, "outputs": [], "source": [ @@ -608,8 +414,8 @@ }, { "cell_type": "code", - "execution_count": 14, - "id": "88259c93-5366-4406-a417-396808ec767c", + "execution_count": null, + "id": "27", "metadata": {}, "outputs": [], "source": [ @@ -624,7 +430,7 @@ " learning_rate=learning_rate,\n", " max_grad_norm=max_grad_norm,\n", " warmup_steps=warmup_steps\n", - " \n", + "\n", ")\n", "\n", "from mindnlp.engine import Trainer\n", @@ -638,56 +444,10 @@ }, { "cell_type": "code", - "execution_count": 15, - "id": "ebf47838-460a-49e4-8850-f10fe7b5ff2b", - "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - " 0%| | 0/45 [00:00 黄 传 庆 ) 练 车 间 隙 , 发 现 训 练 场 附 近 一 根 电 线 杆 上 有 一 个 鸟 窝 , 21 岁 的 刁 某 立 即 爬 上 去 捉 鸟 , 不 想 就 此 命 丧 黄 泉 。 日 前 发 生 在 博 白 县 文 地 镇 一 驾 校 训 练 场 的 意 外 事 故 , 令 人 唏 嘘 。 今 年 21 岁 的 刁 某 是 博 白 县 宁 潭 镇 新 荣 村 人 , 不 久 前 到 其 堂 叔 刁 某 某 任 教 练 的 宁 潭 镇 某 驾 校 参 加 汽 车 驾 驶 员 培 训 。 25 日 中 午 , 刁 某 随 堂 叔 刁 某 某 及 另 外 几 名 学 员 开 车 到 文 地 镇 , 借 用 文 地 镇 钛 白 粉 厂 附 近 的 训 练 场 练 车 。 14 时 许 , 训 练 间 隙 , 刁 某 发 现 训 练 场 附 近 一 根 电 线 杆 上 有 一 个 鸟 窝 , 一 只 [UNK] 八 哥 [UNK] 正 叼 着 虫 子 飞 回 鸟 窝 。 平 时 刁 某 偶 尔 会 捕 鸟 出 卖 , 知 道 这 种 鸟 价 值 100 多 元 。 他 跟 身 边 学 员 打 了 个 招 呼 , 便 飞 奔 过 去 , 欲 爬 上 电 线 杆 捉 鸟 。 刁 某 某 发 现 后 追 过 去 欲 阻 止 , 但 为 时 已 晚 , 等 刁 某 某 赶 到 时 , 刁 某 已 爬 到 电 线 杆 顶 , 伸 手 捉 鸟 时 不 慎 触 碰 到 头 顶 的 高 压 电 线 , 当 即 身 亡 。 其 手 掌 被 外 露 的 钢 枝 刺 穿 , 尸 体 悬 挂 在 电 线 杆 上 。 26 日 下 午 , 在 文 地 、 宁 潭 镇 政 府 及 相 关 部 门 协 调 下 , 相 关 责 任 方 与 死 者 家 属 达 成 赔 偿 协 议 , 死 者 家 属 同 意 将 死 者 尸 体 取 下 搬 走 , 相 关 责 任 方 共 赔 偿 死 者 家 属 15. 8 万 元 , 其 中 宁 潭 镇 某 驾 校 赔 付 7. 3 万 元 , 死 者 堂 叔 刁 某 某 ( 驾 校 教 练 ) 赔 付 5. 3 万 元 , 文 地 供 电 所 本 来 没 有 直 接 责 任 , 但 出 于 人 道 主 义 赔 付 3. 2 万 元 。 ( 原 标 题 : 为 捉 一 只 鸟 < [UNK] > 赔 上 一 条 命 博 白 一 男 子 爬 电 线 杆 捉 鸟 , 不 慎 触 电 身 亡 ) [SEP] , 。 , , 的 , [UNK] 的 的 。 。 [UNK] , 了 , 大 的 了 。 的 [UNK] 。 一 的 一 , 出 , 上 , 人 的 大 , 和 , 子 , 到 , 市 , 有 , 行 , 也 , < ,\n" - ] - } - ], + "execution_count": null, + "id": "34", + "metadata": {}, + "outputs": [], "source": [ "model.set_train(False)\n", "model.config.eos_token_id = model.config.sep_token_id\n", @@ -854,7 +540,7 @@ { "cell_type": "code", "execution_count": null, - "id": "8654a5d5-d94b-4906-92bf-52d2d85685a7", + "id": "35", "metadata": {}, "outputs": [], "source": [] @@ -862,7 +548,7 @@ { "cell_type": "code", "execution_count": null, - "id": "9613743c-3655-45e2-a720-c311a5854c94", + "id": "36", "metadata": {}, "outputs": [], "source": [] diff --git a/01.LLM_Theory_Course/01.Industry_Model_Introduction/01.Classic_Model_Technical_Analysis/04.ChatGLM/chatglm4_simple_inference.ipynb b/01.LLM_Theory_Course/01.Industry_Model_Introduction/01.Classic_Model_Technical_Analysis/04.ChatGLM/chatglm4_simple_inference.ipynb index 5483ffc..569a14f 100644 --- a/01.LLM_Theory_Course/01.Industry_Model_Introduction/01.Classic_Model_Technical_Analysis/04.ChatGLM/chatglm4_simple_inference.ipynb +++ b/01.LLM_Theory_Course/01.Industry_Model_Introduction/01.Classic_Model_Technical_Analysis/04.ChatGLM/chatglm4_simple_inference.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "markdown", - "id": "d73b7cdc", + "id": "0", "metadata": {}, "source": [ "# ChatGLM4聊天机器人" @@ -10,7 +10,7 @@ }, { "cell_type": "markdown", - "id": "80128802-8a28-45e1-a728-4e673abfdb3e", + "id": "1", "metadata": {}, "source": [ "## 环境配置\n", @@ -28,7 +28,7 @@ }, { "cell_type": "markdown", - "id": "265300fd-3bf5-4df6-9248-1b27cd4f570f", + "id": "2", "metadata": {}, "source": [ "## 代码开发" @@ -36,294 +36,12 @@ }, { "cell_type": "code", - "execution_count": 4, - "id": "897d4ee9-b2b2-4de5-9f4f-7be4bc49b67a", + "execution_count": null, + "id": "3", "metadata": { "tags": [] }, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "/home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages/numpy/core/getlimits.py:549: UserWarning: The value of the smallest subnormal for type is zero.\n", - " setattr(self, word, getattr(machar, word).flat[0])\n", - "/home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages/numpy/core/getlimits.py:89: UserWarning: The value of the smallest subnormal for type is zero.\n", - " return self._float_to_str(self.smallest_subnormal)\n", - "/home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages/numpy/core/getlimits.py:549: UserWarning: The value of the smallest subnormal for type is zero.\n", - " setattr(self, word, getattr(machar, word).flat[0])\n", - "/home/mindspore/miniconda/envs/jupyter/lib/python3.9/site-packages/numpy/core/getlimits.py:89: UserWarning: The value of the smallest subnormal for type is zero.\n", - " return self._float_to_str(self.smallest_subnormal)\n", - "Building prefix dict from the default dictionary ...\n", - "Dumping model to file cache /tmp/jieba.cache\n", - "Loading model cost 1.022 seconds.\n", - "Prefix dict has been built successfully.\n" - ] - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "ef6c147f60104856b73d7926b515b038", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - " 0%| | 0.00/6.01k [00:00=1.3\n", - " Downloading https://pypi.tuna.tsinghua.edu.cn/packages/a4/ed/1f1afb2e9e7f38a545d628f864d562a5ae64fe6f7a10e28ffb9b185b4e89/importlib_resources-6.5.2-py3-none-any.whl (37 kB)\n", - "Collecting ffmpy\n", - " Downloading https://pypi.tuna.tsinghua.edu.cn/packages/53/5d/65f40bd333463b3230b3a72d93873caaf49b0cbb5228598fafb75fcc5357/ffmpy-0.5.0-py3-none-any.whl (6.0 kB)\n", - "Requirement already satisfied: pyyaml<7.0,>=5.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from gradio) (6.0.1)\n", - "Collecting uvicorn>=0.14.0\n", - " Downloading https://pypi.tuna.tsinghua.edu.cn/packages/61/14/33a3a1352cfa71812a3a21e8c9bfb83f60b0011f5e36f2b1399d51928209/uvicorn-0.34.0-py3-none-any.whl (62 kB)\n", - "\u001b[K |████████████████████████████████| 62 kB 2.9 MB/s eta 0:00:01\n", - "\u001b[?25hCollecting python-multipart>=0.0.9\n", - " Downloading https://pypi.tuna.tsinghua.edu.cn/packages/45/58/38b5afbc1a800eeea951b9285d3912613f2603bdf897a4ab0f4bd7f405fc/python_multipart-0.0.20-py3-none-any.whl (24 kB)\n", - "Collecting anyio<5.0,>=3.0\n", - " Downloading https://pypi.tuna.tsinghua.edu.cn/packages/a0/7a/4daaf3b6c08ad7ceffea4634ec206faeff697526421c20f07628c7372156/anyio-4.7.0-py3-none-any.whl (93 kB)\n", - "\u001b[K |████████████████████████████████| 93 kB 4.6 MB/s eta 0:00:01\n", - "\u001b[?25hRequirement already satisfied: typing-extensions~=4.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from gradio) (4.12.2)\n", - "Collecting orjson~=3.0\n", - " Downloading https://pypi.tuna.tsinghua.edu.cn/packages/54/a1/4e43d4db67cc2d62ae4d775d466f56b1a4cb5a914a541970f0956a381fe8/orjson-3.10.13-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (136 kB)\n", - "\u001b[K |████████████████████████████████| 136 kB 37.7 MB/s eta 0:00:01\n", - "\u001b[?25hRequirement already satisfied: pandas<3.0,>=1.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from gradio) (1.3.5)\n", - "Collecting pydantic>=2.0\n", - " Downloading https://pypi.tuna.tsinghua.edu.cn/packages/f3/26/3e1bbe954fde7ee22a6e7d31582c642aad9e84ffe4b5fb61e63b87cd326f/pydantic-2.10.4-py3-none-any.whl (431 kB)\n", - "\u001b[K |████████████████████████████████| 431 kB 51.2 MB/s eta 0:00:01\n", - "\u001b[?25hCollecting fastapi<1.0\n", - " Downloading https://pypi.tuna.tsinghua.edu.cn/packages/52/b3/7e4df40e585df024fac2f80d1a2d579c854ac37109675db2b0cc22c0bb9e/fastapi-0.115.6-py3-none-any.whl (94 kB)\n", - "\u001b[K |████████████████████████████████| 94 kB 11.3 MB/s eta 0:00:01\n", - "\u001b[?25hRequirement already satisfied: markupsafe~=2.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from gradio) (2.1.5)\n", - "Requirement already satisfied: jinja2<4.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from gradio) (3.1.4)\n", - "Collecting gradio-client==1.3.0\n", - " Downloading https://pypi.tuna.tsinghua.edu.cn/packages/de/fe/7e9cb4d0e6aa74268fa31089189e4855882a0f2a36c45d359336946d4ae1/gradio_client-1.3.0-py3-none-any.whl (318 kB)\n", - "\u001b[K |████████████████████████████████| 318 kB 52.6 MB/s eta 0:00:01\n", - "\u001b[?25hCollecting tomlkit==0.12.0\n", - " Downloading https://pypi.tuna.tsinghua.edu.cn/packages/68/4f/12207897848a653d03ebbf6775a29d949408ded5f99b2d87198bc5c93508/tomlkit-0.12.0-py3-none-any.whl (37 kB)\n", - "Collecting httpx>=0.24.1\n", - " Downloading https://pypi.tuna.tsinghua.edu.cn/packages/2a/39/e50c7c3a983047577ee07d2a9e53faf5a69493943ec3f6a384bdc792deb2/httpx-0.28.1-py3-none-any.whl (73 kB)\n", - "\u001b[K |████████████████████████████████| 73 kB 7.9 MB/s eta 0:00:01\n", - "\u001b[?25hCollecting aiofiles<24.0,>=22.0\n", - " Downloading https://pypi.tuna.tsinghua.edu.cn/packages/c5/19/5af6804c4cc0fed83f47bff6e413a98a36618e7d40185cd36e69737f3b0e/aiofiles-23.2.1-py3-none-any.whl (15 kB)\n", - "Collecting ruff>=0.2.2\n", - " Downloading https://pypi.tuna.tsinghua.edu.cn/packages/94/e9/e0ed4af1794335fb280c4fac180f2bf40f6a3b859cae93a5a3ada27325ae/ruff-0.8.6-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (10.9 MB)\n", - "\u001b[K |████████████████████████████████| 10.9 MB 45.2 MB/s eta 0:00:01\n", - "\u001b[?25hCollecting typer<1.0,>=0.12\n", - " Downloading https://pypi.tuna.tsinghua.edu.cn/packages/d0/cc/0a838ba5ca64dc832aa43f727bd586309846b0ffb2ce52422543e6075e8a/typer-0.15.1-py3-none-any.whl (44 kB)\n", - "\u001b[K |████████████████████████████████| 44 kB 11.0 MB/s eta 0:00:01\n", - "\u001b[?25hRequirement already satisfied: numpy<3.0,>=1.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from gradio) (1.22.0)\n", - "Requirement already satisfied: semantic-version~=2.0 in /home/ma-user/modelarts-dev/modelarts-sdk (from gradio) (2.10.0)\n", - "Collecting pydub\n", - " Downloading https://pypi.tuna.tsinghua.edu.cn/packages/a6/53/d78dc063216e62fc55f6b2eebb447f6a4b0a59f55c8406376f76bf959b08/pydub-0.25.1-py2.py3-none-any.whl (32 kB)\n", - "Requirement already satisfied: packaging in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from gradio) (24.1)\n", - "Collecting urllib3~=2.0\n", - " Downloading https://pypi.tuna.tsinghua.edu.cn/packages/c8/19/4ec628951a74043532ca2cf5d97b7b14863931476d117c471e8e2b1eb39f/urllib3-2.3.0-py3-none-any.whl (128 kB)\n", - "\u001b[K |████████████████████████████████| 128 kB 54.3 MB/s eta 0:00:01\n", - "\u001b[?25hRequirement already satisfied: huggingface-hub>=0.19.3 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from gradio) (0.24.2)\n", - "Requirement already satisfied: pillow<11.0,>=8.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from gradio) (10.0.1)\n", - "Requirement already satisfied: matplotlib~=3.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from gradio) (3.5.1)\n", - "Collecting websockets<13.0,>=10.0\n", - " Downloading https://pypi.tuna.tsinghua.edu.cn/packages/25/a9/a3e03f9f3c4425a914e5875dd09f2c2559d61b44edd52cf1e6b73f938898/websockets-12.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (130 kB)\n", - "\u001b[K |████████████████████████████████| 130 kB 51.0 MB/s eta 0:00:01\n", - "\u001b[?25hRequirement already satisfied: fsspec in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from gradio-client==1.3.0->gradio) (2024.6.1)\n", - "Requirement already satisfied: idna>=2.8 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from anyio<5.0,>=3.0->gradio) (2.10)\n", - "Collecting sniffio>=1.1\n", - " Downloading https://pypi.tuna.tsinghua.edu.cn/packages/e9/44/75a9c9421471a6c4805dbf2356f7c181a29c1879239abab1ea2cc8f38b40/sniffio-1.3.1-py3-none-any.whl (10 kB)\n", - "Requirement already satisfied: exceptiongroup>=1.0.2 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from anyio<5.0,>=3.0->gradio) (1.2.2)\n", - "Collecting starlette<0.42.0,>=0.40.0\n", - " Downloading https://pypi.tuna.tsinghua.edu.cn/packages/96/00/2b325970b3060c7cecebab6d295afe763365822b1306a12eeab198f74323/starlette-0.41.3-py3-none-any.whl (73 kB)\n", - "\u001b[K |████████████████████████████████| 73 kB 7.2 MB/s eta 0:00:01\n", - "\u001b[?25hCollecting httpcore==1.*\n", - " Downloading https://pypi.tuna.tsinghua.edu.cn/packages/87/f5/72347bc88306acb359581ac4d52f23c0ef445b57157adedb9aee0cd689d2/httpcore-1.0.7-py3-none-any.whl (78 kB)\n", - "\u001b[K |████████████████████████████████| 78 kB 20.3 MB/s eta 0:00:01\n", - "\u001b[?25hRequirement already satisfied: certifi in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from httpx>=0.24.1->gradio) (2024.7.4)\n", - "Collecting h11<0.15,>=0.13\n", - " Downloading https://pypi.tuna.tsinghua.edu.cn/packages/95/04/ff642e65ad6b90db43e668d70ffb6736436c7ce41fcc549f4e9472234127/h11-0.14.0-py3-none-any.whl (58 kB)\n", - "\u001b[K |████████████████████████████████| 58 kB 19.4 MB/s eta 0:00:01\n", - "\u001b[?25hRequirement already satisfied: filelock in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from huggingface-hub>=0.19.3->gradio) (3.15.4)\n", - "Requirement already satisfied: requests in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from huggingface-hub>=0.19.3->gradio) (2.32.3)\n", - "Requirement already satisfied: tqdm>=4.42.1 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from huggingface-hub>=0.19.3->gradio) (4.66.4)\n", - "Requirement already satisfied: zipp>=3.1.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from importlib-resources<7.0,>=1.3->gradio) (3.19.2)\n", - "Requirement already satisfied: python-dateutil>=2.7 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from matplotlib~=3.0->gradio) (2.9.0.post0)\n", - "Requirement already satisfied: fonttools>=4.22.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from matplotlib~=3.0->gradio) (4.53.1)\n", - "Requirement already satisfied: pyparsing>=2.2.1 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from matplotlib~=3.0->gradio) (3.1.2)\n", - "Requirement already satisfied: kiwisolver>=1.0.1 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from matplotlib~=3.0->gradio) (1.4.5)\n", - "Requirement already satisfied: cycler>=0.10 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from matplotlib~=3.0->gradio) (0.12.1)\n", - "Requirement already satisfied: pytz>=2017.3 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from pandas<3.0,>=1.0->gradio) (2024.1)\n", - "Collecting pydantic-core==2.27.2\n", - " Downloading https://pypi.tuna.tsinghua.edu.cn/packages/8a/9e/e44b8cb0edf04a2f0a1f6425a65ee089c1d6f9c4c2dcab0209127b6fdfc2/pydantic_core-2.27.2-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.8 MB)\n", - "\u001b[K |████████████████████████████████| 1.8 MB 44.3 MB/s eta 0:00:01\n", - "\u001b[?25hCollecting annotated-types>=0.6.0\n", - " Downloading https://pypi.tuna.tsinghua.edu.cn/packages/78/b6/6307fbef88d9b5ee7421e68d78a9f162e0da4900bc5f5793f6d3d0e34fb8/annotated_types-0.7.0-py3-none-any.whl (13 kB)\n", - "Requirement already satisfied: six>=1.5 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from python-dateutil>=2.7->matplotlib~=3.0->gradio) (1.16.0)\n", - "Requirement already satisfied: rich>=10.11.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from typer<1.0,>=0.12->gradio) (13.7.1)\n", - "Requirement already satisfied: click>=8.0.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from typer<1.0,>=0.12->gradio) (8.1.7)\n", - "Collecting shellingham>=1.3.0\n", - " Downloading https://pypi.tuna.tsinghua.edu.cn/packages/e0/f9/0595336914c5619e5f28a1fb793285925a8cd4b432c9da0a987836c7f822/shellingham-1.5.4-py2.py3-none-any.whl (9.8 kB)\n", - "Requirement already satisfied: markdown-it-py>=2.2.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from rich>=10.11.0->typer<1.0,>=0.12->gradio) (3.0.0)\n", - "Requirement already satisfied: pygments<3.0.0,>=2.13.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from rich>=10.11.0->typer<1.0,>=0.12->gradio) (2.18.0)\n", - "Requirement already satisfied: mdurl~=0.1 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from markdown-it-py>=2.2.0->rich>=10.11.0->typer<1.0,>=0.12->gradio) (0.1.2)\n", - "Requirement already satisfied: latex2mathml in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from mdtex2html) (3.77.0)\n", - "Requirement already satisfied: markdown in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from mdtex2html) (3.6)\n", - "Requirement already satisfied: importlib-metadata>=4.4 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from markdown->mdtex2html) (8.2.0)\n", - "Requirement already satisfied: charset-normalizer<4,>=2 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from requests->huggingface-hub>=0.19.3->gradio) (2.0.12)\n", - "Installing collected packages: urllib3, sniffio, h11, pydantic-core, httpcore, anyio, annotated-types, websockets, starlette, shellingham, pydantic, httpx, uvicorn, typer, tomlkit, ruff, python-multipart, pydub, orjson, importlib-resources, gradio-client, ffmpy, fastapi, aiofiles, gradio\n", - " Attempting uninstall: urllib3\n", - " Found existing installation: urllib3 1.26.7\n", - " Uninstalling urllib3-1.26.7:\n", - " Successfully uninstalled urllib3-1.26.7\n", - " Attempting uninstall: tomlkit\n", - " Found existing installation: tomlkit 0.13.0\n", - " Uninstalling tomlkit-0.13.0:\n", - " Successfully uninstalled tomlkit-0.13.0\n", - "\u001b[31mERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.\n", - "botocore 1.15.49 requires urllib3<1.26,>=1.20; python_version != \"3.4\", but you have urllib3 2.3.0 which is incompatible.\n", - "modelarts 1.4.28 requires lxml==5.1.0, but you have lxml 4.9.3 which is incompatible.\n", - "modelarts 1.4.28 requires matplotlib==3.5.2, but you have matplotlib 3.5.1 which is incompatible.\n", - "modelarts 1.4.28 requires prettytable<=3.7.0, but you have prettytable 3.10.2 which is incompatible.\n", - "modelarts 1.4.28 requires requests==2.31.0, but you have requests 2.32.3 which is incompatible.\n", - "modelarts 1.4.28 requires tqdm<=4.66.1, but you have tqdm 4.66.4 which is incompatible.\n", - "modelarts 1.4.28 requires typing-extensions==4.7.1, but you have typing-extensions 4.12.2 which is incompatible.\n", - "modelarts 1.4.28 requires urllib3==1.26.18, but you have urllib3 2.3.0 which is incompatible.\u001b[0m\n", - "Successfully installed aiofiles-23.2.1 annotated-types-0.7.0 anyio-4.7.0 fastapi-0.115.6 ffmpy-0.5.0 gradio-4.44.1 gradio-client-1.3.0 h11-0.14.0 httpcore-1.0.7 httpx-0.28.1 importlib-resources-6.5.2 orjson-3.10.13 pydantic-2.10.4 pydantic-core-2.27.2 pydub-0.25.1 python-multipart-0.0.20 ruff-0.8.6 shellingham-1.5.4 sniffio-1.3.1 starlette-0.41.3 tomlkit-0.12.0 typer-0.15.1 urllib3-2.3.0 uvicorn-0.34.0 websockets-12.0\n", - "\u001b[33mWARNING: You are using pip version 21.0.1; however, version 24.3.1 is available.\n", - "You should consider upgrading via the '/home/ma-user/anaconda3/envs/MindSpore/bin/python3.9 -m pip install --upgrade pip' command.\u001b[0m\n", - "Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple\n", - "Collecting ipywidgets\n", - " Downloading https://pypi.tuna.tsinghua.edu.cn/packages/22/2d/9c0b76f2f9cc0ebede1b9371b6f317243028ed60b90705863d493bae622e/ipywidgets-8.1.5-py3-none-any.whl (139 kB)\n", - "\u001b[K |████████████████████████████████| 139 kB 1.6 MB/s eta 0:00:01\n", - "\u001b[?25hCollecting jupyterlab-widgets~=3.0.12\n", - " Downloading https://pypi.tuna.tsinghua.edu.cn/packages/a9/93/858e87edc634d628e5d752ba944c2833133a28fa87bb093e6832ced36a3e/jupyterlab_widgets-3.0.13-py3-none-any.whl (214 kB)\n", - "\u001b[K |████████████████████████████████| 214 kB 6.4 MB/s eta 0:00:01 |██████████████████████████████▋ | 204 kB 6.4 MB/s eta 0:00:01\n", - "\u001b[?25hRequirement already satisfied: traitlets>=4.3.1 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from ipywidgets) (5.14.3)\n", - "Collecting comm>=0.1.3\n", - " Downloading https://pypi.tuna.tsinghua.edu.cn/packages/e6/75/49e5bfe642f71f272236b5b2d2691cf915a7283cc0ceda56357b61daa538/comm-0.2.2-py3-none-any.whl (7.2 kB)\n", - "Requirement already satisfied: ipython>=6.1.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from ipywidgets) (8.18.1)\n", - "Collecting widgetsnbextension~=4.0.12\n", - " Downloading https://pypi.tuna.tsinghua.edu.cn/packages/21/02/88b65cc394961a60c43c70517066b6b679738caf78506a5da7b88ffcb643/widgetsnbextension-4.0.13-py3-none-any.whl (2.3 MB)\n", - "\u001b[K |████████████████████████████████| 2.3 MB 17.9 MB/s eta 0:00:01\n", - "\u001b[?25hRequirement already satisfied: decorator in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from ipython>=6.1.0->ipywidgets) (4.4.1)\n", - "Requirement already satisfied: prompt-toolkit<3.1.0,>=3.0.41 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from ipython>=6.1.0->ipywidgets) (3.0.47)\n", - "Requirement already satisfied: typing-extensions in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from ipython>=6.1.0->ipywidgets) (4.12.2)\n", - "Requirement already satisfied: pygments>=2.4.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from ipython>=6.1.0->ipywidgets) (2.18.0)\n", - "Requirement already satisfied: exceptiongroup in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from ipython>=6.1.0->ipywidgets) (1.2.2)\n", - "Requirement already satisfied: jedi>=0.16 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from ipython>=6.1.0->ipywidgets) (0.19.1)\n", - "Requirement already satisfied: matplotlib-inline in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from ipython>=6.1.0->ipywidgets) (0.1.7)\n", - "Requirement already satisfied: stack-data in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from ipython>=6.1.0->ipywidgets) (0.6.3)\n", - "Requirement already satisfied: pexpect>4.3 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from ipython>=6.1.0->ipywidgets) (4.9.0)\n", - "Requirement already satisfied: parso<0.9.0,>=0.8.3 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from jedi>=0.16->ipython>=6.1.0->ipywidgets) (0.8.4)\n", - "Requirement already satisfied: ptyprocess>=0.5 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from pexpect>4.3->ipython>=6.1.0->ipywidgets) (0.7.0)\n", - "Requirement already satisfied: wcwidth in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from prompt-toolkit<3.1.0,>=3.0.41->ipython>=6.1.0->ipywidgets) (0.2.13)\n", - "Requirement already satisfied: executing>=1.2.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from stack-data->ipython>=6.1.0->ipywidgets) (2.0.1)\n", - "Requirement already satisfied: asttokens>=2.1.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from stack-data->ipython>=6.1.0->ipywidgets) (2.4.1)\n", - "Requirement already satisfied: pure-eval in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from stack-data->ipython>=6.1.0->ipywidgets) (0.2.3)\n", - "Requirement already satisfied: six>=1.12.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from asttokens>=2.1.0->stack-data->ipython>=6.1.0->ipywidgets) (1.16.0)\n", - "Installing collected packages: widgetsnbextension, jupyterlab-widgets, comm, ipywidgets\n", - "Successfully installed comm-0.2.2 ipywidgets-8.1.5 jupyterlab-widgets-3.0.13 widgetsnbextension-4.0.13\n", - "\u001b[33mWARNING: You are using pip version 21.0.1; however, version 24.3.1 is available.\n", - "You should consider upgrading via the '/home/ma-user/anaconda3/envs/MindSpore/bin/python3.9 -m pip install --upgrade pip' command.\u001b[0m\n" - ] - } - ], + "outputs": [], "source": [ "!pip install gradio mdtex2html -i https://pypi.tuna.tsinghua.edu.cn/simple\n", "!pip install ipywidgets -i https://pypi.tuna.tsinghua.edu.cn/simple" @@ -308,30 +143,10 @@ }, { "cell_type": "code", - "execution_count": 2, - "id": "6d43d04e", + "execution_count": null, + "id": "10", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "--2025-01-05 02:06:29-- https://openi.pcl.ac.cn/lvyufeng/frpc-gradio/raw/branch/master/frpc_linux_amd64\n", - "Resolving proxy-notebook.modelarts.com (proxy-notebook.modelarts.com)... 192.168.0.33\n", - "Connecting to proxy-notebook.modelarts.com (proxy-notebook.modelarts.com)|192.168.0.33|:8083... connected.\n", - "Proxy request sent, awaiting response... 200 OK\n", - "Length: unspecified [application/octet-stream]\n", - "Saving to: ‘/home/ma-user/work/frpc_linux_amd64’\n", - "\n", - "frpc_linux_amd64 [ <=> ] 10.85M 23.3MB/s in 0.5s \n", - "\n", - "2025-01-05 02:06:30 (23.3 MB/s) - ‘/home/ma-user/work/frpc_linux_amd64’ saved [11374592]\n", - "\n", - "cp: cannot create regular file '/home/ma-user/anaconda3/envs/python-3.9.0/lib/python3.9/site-packages/gradio/frpc_linux_amd64_v0.2': No such file or directory\n", - "chmod: cannot access '/home/ma-user/anaconda3/envs/python-3.9.0/lib/python3.9/site-packages/gradio/frpc_linux_amd64_v0.2': No such file or directory\n" - ] - } - ], + "outputs": [], "source": [ "# %%capture captured_output\n", "!wget -P /home/ma-user/work https://openi.pcl.ac.cn/lvyufeng/frpc-gradio/raw/branch/master/frpc_linux_amd64\n", @@ -341,7 +156,7 @@ }, { "cell_type": "markdown", - "id": "f6703d3e-8451-47e7-bac8-401cdb039be7", + "id": "11", "metadata": {}, "source": [ "## 3. 代码开发" @@ -349,259 +164,10 @@ }, { "cell_type": "code", - "execution_count": 3, - "id": "9b8ee640", + "execution_count": null, + "id": "12", "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "[WARNING] GE_ADPT(6632,ffff8654b0b0,python):2025-01-05-02:06:54.331.962 [mindspore/ccsrc/utils/dlopen_macro.h:163] DlsymAscend] Dynamically load symbol aclmdlBundleGetModelId failed, result = /usr/local/Ascend/ascend-toolkit/latest/lib64/libascendcl.so: undefined symbol: aclmdlBundleGetModelId\n", - "[WARNING] GE_ADPT(6632,ffff8654b0b0,python):2025-01-05-02:06:54.332.029 [mindspore/ccsrc/utils/dlopen_macro.h:163] DlsymAscend] Dynamically load symbol aclmdlBundleLoadFromMem failed, result = /usr/local/Ascend/ascend-toolkit/latest/lib64/libascendcl.so: undefined symbol: aclmdlBundleLoadFromMem\n", - "[WARNING] GE_ADPT(6632,ffff8654b0b0,python):2025-01-05-02:06:54.332.048 [mindspore/ccsrc/utils/dlopen_macro.h:163] DlsymAscend] Dynamically load symbol aclmdlBundleUnload failed, result = /usr/local/Ascend/ascend-toolkit/latest/lib64/libascendcl.so: undefined symbol: aclmdlBundleUnload\n", - "[WARNING] GE_ADPT(6632,ffff8654b0b0,python):2025-01-05-02:06:54.332.232 [mindspore/ccsrc/utils/dlopen_macro.h:163] DlsymAscend] Dynamically load symbol aclrtGetMemUceInfo failed, result = /usr/local/Ascend/ascend-toolkit/latest/lib64/libascendcl.so: undefined symbol: aclrtGetMemUceInfo\n", - "[WARNING] GE_ADPT(6632,ffff8654b0b0,python):2025-01-05-02:06:54.332.249 [mindspore/ccsrc/utils/dlopen_macro.h:163] DlsymAscend] Dynamically load symbol aclrtDeviceTaskAbort failed, result = /usr/local/Ascend/ascend-toolkit/latest/lib64/libascendcl.so: undefined symbol: aclrtDeviceTaskAbort\n", - "[WARNING] GE_ADPT(6632,ffff8654b0b0,python):2025-01-05-02:06:54.332.265 [mindspore/ccsrc/utils/dlopen_macro.h:163] DlsymAscend] Dynamically load symbol aclrtMemUceRepair failed, result = /usr/local/Ascend/ascend-toolkit/latest/lib64/libascendcl.so: undefined symbol: aclrtMemUceRepair\n", - "[WARNING] GE_ADPT(6632,ffff8654b0b0,python):2025-01-05-02:06:54.334.715 [mindspore/ccsrc/utils/dlopen_macro.h:163] DlsymAscend] Dynamically load symbol acltdtCleanChannel failed, result = /usr/local/Ascend/ascend-toolkit/latest/lib64/libacl_tdt_channel.so: undefined symbol: acltdtCleanChannel\n", - "[WARNING] ME(6632:281472935440560,MainProcess):2025-01-05-02:06:54.576.575 [mindspore/run_check/_check_version.py:398] Can not find the tbe operator implementation(need by mindspore-ascend). Please check whether the Environment Variable PYTHONPATH is set. For details, refer to the installation guidelines: https://www.mindspore.cn/install\n", - "/home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages/numpy/core/getlimits.py:499: UserWarning: The value of the smallest subnormal for type is zero.\n", - " setattr(self, word, getattr(machar, word).flat[0])\n", - "/home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages/numpy/core/getlimits.py:89: UserWarning: The value of the smallest subnormal for type is zero.\n", - " return self._float_to_str(self.smallest_subnormal)\n", - "/home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages/numpy/core/getlimits.py:499: UserWarning: The value of the smallest subnormal for type is zero.\n", - " setattr(self, word, getattr(machar, word).flat[0])\n", - "/home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages/numpy/core/getlimits.py:89: UserWarning: The value of the smallest subnormal for type is zero.\n", - " return self._float_to_str(self.smallest_subnormal)\n", - "cannot found `mindformers.experimental`, please install dev version by\n", - "`pip install git+https://gitee.com/mindspore/mindformers` \n", - "or remove mindformers by \n", - "`pip uninstall mindformers`\n", - "Building prefix dict from the default dictionary ...\n", - "Dumping model to file cache /tmp/jieba.cache\n", - "Loading model cost 1.327 seconds.\n", - "Prefix dict has been built successfully.\n", - "/home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages/Cython/Compiler/Main.py:384: FutureWarning: Cython directive 'language_level' not set, using '3str' for now (Py3). This has changed from earlier releases! File: /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages/mindnlp/transformers/models/graphormer/algos_graphormer.pyx\n", - " tree = Parsing.p_module(s, pxd, full_module_name)\n", - "[WARNING] ME(6632:281472935440560,MainProcess):2025-01-05-02:07:20.833.731 [mindspore/run_check/_check_version.py:398] Can not find the tbe operator implementation(need by mindspore-ascend). Please check whether the Environment Variable PYTHONPATH is set. For details, refer to the installation guidelines: https://www.mindspore.cn/install\n", - "[WARNING] ME(6632:281472935440560,MainProcess):2025-01-05-02:07:20.836.993 [mindspore/run_check/_check_version.py:398] Can not find the tbe operator implementation(need by mindspore-ascend). Please check whether the Environment Variable PYTHONPATH is set. For details, refer to the installation guidelines: https://www.mindspore.cn/install\n" - ] - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "f26abf33eb1c47ed8105f3a2788d3e5c", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - " 0%| | 0.00/773 [00:00" - ], - "text/plain": [ - "" - ] - }, - "metadata": {}, - "output_type": "display_data" - }, - { - "data": { - "text/plain": [] - }, - "execution_count": 7, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "#运行Gradio界面,运行成功后点击“Running on public URL”后的网页链接即可体验\n", "import gradio as gr\n", @@ -814,7 +319,7 @@ { "cell_type": "code", "execution_count": null, - "id": "356a6c98-d42a-4470-a1e9-40714a17642e", + "id": "18", "metadata": {}, "outputs": [], "source": [] diff --git a/01.LLM_Theory_Course/01.Industry_Model_Introduction/01.Classic_Model_Technical_Analysis/07.LLaMA2/llama_finetune_inference.ipynb b/01.LLM_Theory_Course/01.Industry_Model_Introduction/01.Classic_Model_Technical_Analysis/07.LLaMA2/llama_finetune_inference.ipynb index 0bcc02a..0bb28f7 100644 --- a/01.LLM_Theory_Course/01.Industry_Model_Introduction/01.Classic_Model_Technical_Analysis/07.LLaMA2/llama_finetune_inference.ipynb +++ b/01.LLM_Theory_Course/01.Industry_Model_Introduction/01.Classic_Model_Technical_Analysis/07.LLaMA2/llama_finetune_inference.ipynb @@ -100,46 +100,7 @@ "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Looking in indexes: https://mirrors.aliyun.com/pypi/simple/\n", - "Collecting mindspore==2.5.0\n", - " Downloading https://mirrors.aliyun.com/pypi/packages/23/22/dff0f1bef6c0846a97271ae5d39ca187914f39562f9e3f6787041dea1a97/mindspore-2.5.0-cp39-cp39-manylinux1_x86_64.whl (958.4 MB)\n", - "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m958.4/958.4 MB\u001b[0m \u001b[31m9.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:03\u001b[0m\n", - "\u001b[?25hCollecting numpy<2.0.0,>=1.20.0 (from mindspore==2.5.0)\n", - " Downloading https://mirrors.aliyun.com/pypi/packages/54/30/c2a907b9443cf42b90c17ad10c1e8fa801975f01cb9764f3f8eb8aea638b/numpy-1.26.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (18.2 MB)\n", - "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m18.2/18.2 MB\u001b[0m \u001b[31m16.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0ma \u001b[36m0:00:01\u001b[0m\n", - "\u001b[?25hCollecting protobuf>=3.13.0 (from mindspore==2.5.0)\n", - " Downloading https://mirrors.aliyun.com/pypi/packages/28/50/1925de813499546bc8ab3ae857e3ec84efe7d2f19b34529d0c7c3d02d11d/protobuf-6.30.2-cp39-abi3-manylinux2014_x86_64.whl (316 kB)\n", - "Requirement already satisfied: asttokens>=2.0.4 in /home/jiangna1/miniconda3/envs/llama39/lib/python3.9/site-packages (from mindspore==2.5.0) (3.0.0)\n", - "Collecting pillow>=6.2.0 (from mindspore==2.5.0)\n", - " Downloading https://mirrors.aliyun.com/pypi/packages/f6/46/0bd0ca03d9d1164a7fa33d285ef6d1c438e963d0c8770e4c5b3737ef5abe/pillow-11.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.4 MB)\n", - "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m4.4/4.4 MB\u001b[0m \u001b[31m14.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0ma \u001b[36m0:00:01\u001b[0m\n", - "\u001b[?25hCollecting scipy>=1.5.4 (from mindspore==2.5.0)\n", - " Downloading https://mirrors.aliyun.com/pypi/packages/35/f5/d0ad1a96f80962ba65e2ce1de6a1e59edecd1f0a7b55990ed208848012e0/scipy-1.13.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (38.6 MB)\n", - "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m38.6/38.6 MB\u001b[0m \u001b[31m16.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m\n", - "\u001b[?25hRequirement already satisfied: packaging>=20.0 in /home/jiangna1/miniconda3/envs/llama39/lib/python3.9/site-packages (from mindspore==2.5.0) (24.2)\n", - "Requirement already satisfied: psutil>=5.6.1 in /home/jiangna1/miniconda3/envs/llama39/lib/python3.9/site-packages (from mindspore==2.5.0) (5.9.1)\n", - "Collecting astunparse>=1.6.3 (from mindspore==2.5.0)\n", - " Downloading https://mirrors.aliyun.com/pypi/packages/2b/03/13dde6512ad7b4557eb792fbcf0c653af6076b81e5941d36ec61f7ce6028/astunparse-1.6.3-py2.py3-none-any.whl (12 kB)\n", - "Collecting safetensors>=0.4.0 (from mindspore==2.5.0)\n", - " Downloading https://mirrors.aliyun.com/pypi/packages/a6/f8/dae3421624fcc87a89d42e1898a798bc7ff72c61f38973a65d60df8f124c/safetensors-0.5.3-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (471 kB)\n", - "Collecting dill>=0.3.7 (from mindspore==2.5.0)\n", - " Downloading https://mirrors.aliyun.com/pypi/packages/46/d1/e73b6ad76f0b1fb7f23c35c6d95dbc506a9c8804f43dda8cb5b0fa6331fd/dill-0.3.9-py3-none-any.whl (119 kB)\n", - "Requirement already satisfied: wheel<1.0,>=0.23.0 in /home/jiangna1/miniconda3/envs/llama39/lib/python3.9/site-packages (from astunparse>=1.6.3->mindspore==2.5.0) (0.45.1)\n", - "Requirement already satisfied: six<2.0,>=1.6.1 in /home/jiangna1/miniconda3/envs/llama39/lib/python3.9/site-packages (from astunparse>=1.6.3->mindspore==2.5.0) (1.17.0)\n", - "Installing collected packages: safetensors, protobuf, pillow, numpy, dill, astunparse, scipy, mindspore\n", - "\u001b[31mERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.\n", - "auto-tune 0.1.0 requires te, which is not installed.\n", - "schedule-search 0.0.1 requires absl-py, which is not installed.\u001b[0m\u001b[31m\n", - "\u001b[0mSuccessfully installed astunparse-1.6.3 dill-0.3.9 mindspore-2.5.0 numpy-1.26.4 pillow-11.1.0 protobuf-6.30.2 safetensors-0.5.3 scipy-1.13.1\n", - "Note: you may need to restart the kernel to use updated packages.\n" - ] - } - ], + "outputs": [], "source": [ "%pip install https://ms-release.obs.cn-north-4.myhuaweicloud.com/2.5.0/MindSpore/unified/x86_64/mindspore-2.5.0-cp39-cp39-linux_x86_64.whl --trusted-host ms-release.obs.cn-north-4.myhuaweicloud.com -i https://pypi.tuna.tsinghua.edu.cn/simple" ] @@ -154,88 +115,9 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Looking in indexes: https://mirrors.aliyun.com/pypi/simple\n", - "Collecting mindnlp==0.4.0\n", - " Downloading https://mirrors.aliyun.com/pypi/packages/0f/a8/5a072852d28a51417b5e330b32e6ae5f26b491ef01a15ba968e77f785e69/mindnlp-0.4.0-py3-none-any.whl (8.4 MB)\n", - "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m8.4/8.4 MB\u001b[0m \u001b[31m4.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0ma \u001b[36m0:00:01\u001b[0m0m\n", - "\u001b[?25hRequirement already satisfied: mindspore>=2.2.14 in /home/jiangna1/miniconda3/envs/llama39/lib/python3.9/site-packages (from mindnlp==0.4.0) (2.5.0)\n", - "Requirement already satisfied: tqdm in /home/jiangna1/miniconda3/envs/llama39/lib/python3.9/site-packages (from mindnlp==0.4.0) (4.67.1)\n", - "Requirement already satisfied: requests in /home/jiangna1/miniconda3/envs/llama39/lib/python3.9/site-packages (from mindnlp==0.4.0) (2.32.3)\n", - "Requirement already satisfied: datasets in /home/jiangna1/miniconda3/envs/llama39/lib/python3.9/site-packages (from mindnlp==0.4.0) (3.5.0)\n", - "Requirement already satisfied: evaluate in /home/jiangna1/miniconda3/envs/llama39/lib/python3.9/site-packages (from mindnlp==0.4.0) (0.4.3)\n", - "Requirement already satisfied: tokenizers==0.19.1 in /home/jiangna1/miniconda3/envs/llama39/lib/python3.9/site-packages (from mindnlp==0.4.0) (0.19.1)\n", - "Requirement already satisfied: safetensors in /home/jiangna1/miniconda3/envs/llama39/lib/python3.9/site-packages (from mindnlp==0.4.0) (0.5.3)\n", - "Requirement already satisfied: sentencepiece in /home/jiangna1/miniconda3/envs/llama39/lib/python3.9/site-packages (from mindnlp==0.4.0) (0.2.0)\n", - "Requirement already satisfied: regex in /home/jiangna1/miniconda3/envs/llama39/lib/python3.9/site-packages (from mindnlp==0.4.0) (2024.11.6)\n", - "Requirement already satisfied: addict in /home/jiangna1/miniconda3/envs/llama39/lib/python3.9/site-packages (from mindnlp==0.4.0) (2.4.0)\n", - "Requirement already satisfied: ml-dtypes in /home/jiangna1/miniconda3/envs/llama39/lib/python3.9/site-packages (from mindnlp==0.4.0) (0.5.1)\n", - "Requirement already satisfied: pyctcdecode in /home/jiangna1/miniconda3/envs/llama39/lib/python3.9/site-packages (from mindnlp==0.4.0) (0.5.0)\n", - "Collecting jieba (from mindnlp==0.4.0)\n", - " Downloading https://mirrors.aliyun.com/pypi/packages/c6/cb/18eeb235f833b726522d7ebed54f2278ce28ba9438e3135ab0278d9792a2/jieba-0.42.1.tar.gz (19.2 MB)\n", - "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m19.2/19.2 MB\u001b[0m \u001b[31m15.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0ma \u001b[36m0:00:01\u001b[0m\n", - "\u001b[?25h Preparing metadata (setup.py) ... \u001b[?25ldone\n", - "\u001b[?25hRequirement already satisfied: pytest==7.2.0 in /home/jiangna1/miniconda3/envs/llama39/lib/python3.9/site-packages (from mindnlp==0.4.0) (7.2.0)\n", - "Requirement already satisfied: pillow>=10.0.0 in /home/jiangna1/miniconda3/envs/llama39/lib/python3.9/site-packages (from mindnlp==0.4.0) (11.1.0)\n", - "Requirement already satisfied: attrs>=19.2.0 in /home/jiangna1/miniconda3/envs/llama39/lib/python3.9/site-packages (from pytest==7.2.0->mindnlp==0.4.0) (24.3.0)\n", - "Requirement already satisfied: iniconfig in /home/jiangna1/miniconda3/envs/llama39/lib/python3.9/site-packages (from pytest==7.2.0->mindnlp==0.4.0) (2.1.0)\n", - "Requirement already satisfied: packaging in /home/jiangna1/miniconda3/envs/llama39/lib/python3.9/site-packages (from pytest==7.2.0->mindnlp==0.4.0) (24.2)\n", - "Requirement already satisfied: pluggy<2.0,>=0.12 in /home/jiangna1/miniconda3/envs/llama39/lib/python3.9/site-packages (from pytest==7.2.0->mindnlp==0.4.0) (1.5.0)\n", - "Requirement already satisfied: exceptiongroup>=1.0.0rc8 in /home/jiangna1/miniconda3/envs/llama39/lib/python3.9/site-packages (from pytest==7.2.0->mindnlp==0.4.0) (1.2.2)\n", - "Requirement already satisfied: tomli>=1.0.0 in /home/jiangna1/miniconda3/envs/llama39/lib/python3.9/site-packages (from pytest==7.2.0->mindnlp==0.4.0) (2.0.1)\n", - "Requirement already satisfied: huggingface-hub<1.0,>=0.16.4 in /home/jiangna1/miniconda3/envs/llama39/lib/python3.9/site-packages (from tokenizers==0.19.1->mindnlp==0.4.0) (0.30.2)\n", - "Requirement already satisfied: numpy<2.0.0,>=1.20.0 in /home/jiangna1/miniconda3/envs/llama39/lib/python3.9/site-packages (from mindspore>=2.2.14->mindnlp==0.4.0) (1.26.4)\n", - "Requirement already satisfied: protobuf>=3.13.0 in /home/jiangna1/miniconda3/envs/llama39/lib/python3.9/site-packages (from mindspore>=2.2.14->mindnlp==0.4.0) (6.30.2)\n", - "Requirement already satisfied: asttokens>=2.0.4 in /home/jiangna1/miniconda3/envs/llama39/lib/python3.9/site-packages (from mindspore>=2.2.14->mindnlp==0.4.0) (3.0.0)\n", - "Requirement already satisfied: scipy>=1.5.4 in /home/jiangna1/miniconda3/envs/llama39/lib/python3.9/site-packages (from mindspore>=2.2.14->mindnlp==0.4.0) (1.13.1)\n", - "Requirement already satisfied: psutil>=5.6.1 in /home/jiangna1/miniconda3/envs/llama39/lib/python3.9/site-packages (from mindspore>=2.2.14->mindnlp==0.4.0) (5.9.1)\n", - "Requirement already satisfied: astunparse>=1.6.3 in /home/jiangna1/miniconda3/envs/llama39/lib/python3.9/site-packages (from mindspore>=2.2.14->mindnlp==0.4.0) (1.6.3)\n", - "Requirement already satisfied: dill>=0.3.7 in /home/jiangna1/miniconda3/envs/llama39/lib/python3.9/site-packages (from mindspore>=2.2.14->mindnlp==0.4.0) (0.3.8)\n", - "Requirement already satisfied: filelock in /home/jiangna1/miniconda3/envs/llama39/lib/python3.9/site-packages (from datasets->mindnlp==0.4.0) (3.18.0)\n", - "Requirement already satisfied: pyarrow>=15.0.0 in /home/jiangna1/miniconda3/envs/llama39/lib/python3.9/site-packages (from datasets->mindnlp==0.4.0) (19.0.1)\n", - "Requirement already satisfied: pandas in /home/jiangna1/miniconda3/envs/llama39/lib/python3.9/site-packages (from datasets->mindnlp==0.4.0) (2.2.3)\n", - "Requirement already satisfied: xxhash in /home/jiangna1/miniconda3/envs/llama39/lib/python3.9/site-packages (from datasets->mindnlp==0.4.0) (3.5.0)\n", - "Requirement already satisfied: multiprocess<0.70.17 in /home/jiangna1/miniconda3/envs/llama39/lib/python3.9/site-packages (from datasets->mindnlp==0.4.0) (0.70.16)\n", - "Requirement already satisfied: fsspec<=2024.12.0,>=2023.1.0 in /home/jiangna1/miniconda3/envs/llama39/lib/python3.9/site-packages (from fsspec[http]<=2024.12.0,>=2023.1.0->datasets->mindnlp==0.4.0) (2024.12.0)\n", - "Requirement already satisfied: aiohttp in /home/jiangna1/miniconda3/envs/llama39/lib/python3.9/site-packages (from datasets->mindnlp==0.4.0) (3.11.16)\n", - "Requirement already satisfied: pyyaml>=5.1 in /home/jiangna1/miniconda3/envs/llama39/lib/python3.9/site-packages (from datasets->mindnlp==0.4.0) (6.0.2)\n", - "Requirement already satisfied: charset-normalizer<4,>=2 in /home/jiangna1/miniconda3/envs/llama39/lib/python3.9/site-packages (from requests->mindnlp==0.4.0) (3.3.2)\n", - "Requirement already satisfied: idna<4,>=2.5 in /home/jiangna1/miniconda3/envs/llama39/lib/python3.9/site-packages (from requests->mindnlp==0.4.0) (3.7)\n", - "Requirement already satisfied: urllib3<3,>=1.21.1 in /home/jiangna1/miniconda3/envs/llama39/lib/python3.9/site-packages (from requests->mindnlp==0.4.0) (2.3.0)\n", - "Requirement already satisfied: certifi>=2017.4.17 in /home/jiangna1/miniconda3/envs/llama39/lib/python3.9/site-packages (from requests->mindnlp==0.4.0) (2025.1.31)\n", - "Requirement already satisfied: pygtrie<3.0,>=2.1 in /home/jiangna1/miniconda3/envs/llama39/lib/python3.9/site-packages (from pyctcdecode->mindnlp==0.4.0) (2.5.0)\n", - "Requirement already satisfied: hypothesis<7,>=6.14 in /home/jiangna1/miniconda3/envs/llama39/lib/python3.9/site-packages (from pyctcdecode->mindnlp==0.4.0) (6.130.13)\n", - "Requirement already satisfied: wheel<1.0,>=0.23.0 in /home/jiangna1/miniconda3/envs/llama39/lib/python3.9/site-packages (from astunparse>=1.6.3->mindspore>=2.2.14->mindnlp==0.4.0) (0.45.1)\n", - "Requirement already satisfied: six<2.0,>=1.6.1 in /home/jiangna1/miniconda3/envs/llama39/lib/python3.9/site-packages (from astunparse>=1.6.3->mindspore>=2.2.14->mindnlp==0.4.0) (1.17.0)\n", - "Requirement already satisfied: aiohappyeyeballs>=2.3.0 in /home/jiangna1/miniconda3/envs/llama39/lib/python3.9/site-packages (from aiohttp->datasets->mindnlp==0.4.0) (2.6.1)\n", - "Requirement already satisfied: aiosignal>=1.1.2 in /home/jiangna1/miniconda3/envs/llama39/lib/python3.9/site-packages (from aiohttp->datasets->mindnlp==0.4.0) (1.3.2)\n", - "Requirement already satisfied: async-timeout<6.0,>=4.0 in /home/jiangna1/miniconda3/envs/llama39/lib/python3.9/site-packages (from aiohttp->datasets->mindnlp==0.4.0) (5.0.1)\n", - "Requirement already satisfied: frozenlist>=1.1.1 in /home/jiangna1/miniconda3/envs/llama39/lib/python3.9/site-packages (from aiohttp->datasets->mindnlp==0.4.0) (1.5.0)\n", - "Requirement already satisfied: multidict<7.0,>=4.5 in /home/jiangna1/miniconda3/envs/llama39/lib/python3.9/site-packages (from aiohttp->datasets->mindnlp==0.4.0) (6.4.2)\n", - "Requirement already satisfied: propcache>=0.2.0 in /home/jiangna1/miniconda3/envs/llama39/lib/python3.9/site-packages (from aiohttp->datasets->mindnlp==0.4.0) (0.3.1)\n", - "Requirement already satisfied: yarl<2.0,>=1.17.0 in /home/jiangna1/miniconda3/envs/llama39/lib/python3.9/site-packages (from aiohttp->datasets->mindnlp==0.4.0) (1.19.0)\n", - "Requirement already satisfied: typing-extensions>=3.7.4.3 in /home/jiangna1/miniconda3/envs/llama39/lib/python3.9/site-packages (from huggingface-hub<1.0,>=0.16.4->tokenizers==0.19.1->mindnlp==0.4.0) (4.13.1)\n", - "Requirement already satisfied: sortedcontainers<3.0.0,>=2.1.0 in /home/jiangna1/miniconda3/envs/llama39/lib/python3.9/site-packages (from hypothesis<7,>=6.14->pyctcdecode->mindnlp==0.4.0) (2.4.0)\n", - "Requirement already satisfied: python-dateutil>=2.8.2 in /home/jiangna1/miniconda3/envs/llama39/lib/python3.9/site-packages (from pandas->datasets->mindnlp==0.4.0) (2.9.0.post0)\n", - "Requirement already satisfied: pytz>=2020.1 in /home/jiangna1/miniconda3/envs/llama39/lib/python3.9/site-packages (from pandas->datasets->mindnlp==0.4.0) (2025.2)\n", - "Requirement already satisfied: tzdata>=2022.7 in /home/jiangna1/miniconda3/envs/llama39/lib/python3.9/site-packages (from pandas->datasets->mindnlp==0.4.0) (2025.2)\n", - "Building wheels for collected packages: jieba\n", - " Building wheel for jieba (setup.py) ... \u001b[?25ldone\n", - "\u001b[?25h Created wheel for jieba: filename=jieba-0.42.1-py3-none-any.whl size=19314508 sha256=30064bba508d12a9c2c545bdec7e271f61d5a83e9fdd53298a82e74659e1fd26\n", - " Stored in directory: /home/jiangna1/.cache/pip/wheels/95/ef/7c/d8b3108835edfa15487417c5bddff166482b195d8090117ac5\n", - "Successfully built jieba\n", - "Installing collected packages: jieba, mindnlp\n", - "Successfully installed jieba-0.42.1 mindnlp-0.4.0\n", - "Note: you may need to restart the kernel to use updated packages.\n" - ] - } - ], + "outputs": [], "source": [ "%pip install mindnlp==0.4.0 -i https://mirrors.aliyun.com/pypi/simple\n" ] @@ -272,7 +154,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -284,17 +166,9 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "[WARNING] ME(52617:140460371482432,MainProcess):2025-04-11-09:21:14.572.566 [mindspore/context.py:1335] For 'context.set_context', the parameter 'device_target' will be deprecated and removed in a future version. Please use the api mindspore.set_device() instead.\n" - ] - } - ], + "outputs": [], "source": [ "#将模式设置为动态图模式(PYNATIVE_MODE),并指定设备目标为Ascend芯片\n", "ms.set_context(mode=ms.PYNATIVE_MODE, device_target=\"Ascend\")\n" @@ -302,7 +176,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -366,7 +240,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -404,7 +278,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": null, "metadata": { "tags": [] }, @@ -423,17 +297,9 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[{'instruction': '只剩一个心脏了还能活吗?', 'output': '能,人本来就只有一个心脏。'}, {'instruction': '爸爸再婚,我是不是就有了个新娘?', 'output': '不是的,你有了一个继母。\"新娘\"是指新婚的女方,而你爸爸再婚,他的新婚妻子对你来说是继母。'}, {'instruction': '樟脑丸是我吃过最难吃的硬糖有奇怪的味道怎么还有人买', 'output': '樟脑丸并不是硬糖,而是一种常见的驱虫药,不能食用。虽然它的味道可能不太好,但是由于其有效的驱虫效果,所以仍然有很多人会购买。'}]\n" - ] - } - ], + "outputs": [], "source": [ "with open(data_path, 'r', encoding='utf-8') as f:\n", " data = json.load(f)\n", @@ -449,20 +315,9 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "[1, 29871, 2056]" - ] - }, - "execution_count": 9, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "from mindnlp.transformers import AutoTokenizer\n", "\n", @@ -482,7 +337,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -515,32 +370,9 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[MS_ALLOC_CONF]Runtime config: enable_vmm:True vmm_align_size:2MB\n", - "Sample 0: Input IDs: [ 1 4911 29901 29871 47133 32002 37755 30743 33302 31704]\n", - "Sample 0: Labels: [ 1 4911 29901 29871 47133 32002 37755 30743 33302 31704]\n", - "\n", - "Sample 1: Input IDs: [ 1 4911 29901 29871 33594 31733 33364 30214 30672 32308]\n", - "Sample 1: Labels: [ 1 4911 29901 29871 33594 31733 33364 30214 30672 32308]\n", - "\n", - "Sample 2: Input IDs: [ 1 4911 29901 29871 47019 33027 31818 34030 39950 44345]\n", - "Sample 2: Labels: [ 1 4911 29901 29871 47019 33027 31818 34030 39950 44345]\n", - "\n", - "Sample 3: Input IDs: [ 1 4911 29901 29871 34214 30698 30429 36310 32658 30743]\n", - "Sample 3: Labels: [ 1 4911 29901 29871 34214 30698 30429 36310 32658 30743]\n", - "\n", - "Sample 4: Input IDs: [ 1 4911 29901 32581 34822 31639 2882 6530 30883 30210]\n", - "Sample 4: Labels: [ 1 4911 29901 32581 34822 31639 2882 6530 30883 30210]\n", - "\n" - ] - } - ], + "outputs": [], "source": [ "for i, sample in enumerate(train_dataset.create_dict_iterator()):\n", " if i >= 5:\n", @@ -565,7 +397,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": null, "metadata": { "tags": [] }, @@ -584,33 +416,9 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "LlamaForCausalLM has generative capabilities, as `prepare_inputs_for_generation` is explicitly overwritten. However, it doesn't directly inherit from `GenerationMixin`.`PreTrainedModel` will NOT inherit from `GenerationMixin`, and this model will lose the ability to call `generate` and other related functions.\n", - " - If you are the owner of the model architecture code, please modify your model class such that it inherits from `GenerationMixin` (after `PreTrainedModel`, otherwise you'll get an exception).\n", - " - If you are not the owner of the model architecture class, please contact the model code owner to update it.\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "/home/jiangna1/miniconda3/envs/ms39/lib/python3.9/site-packages/mindnlp/transformers/generation/configuration_utils.py:557: UserWarning: `do_sample` is set to `False`. However, `temperature` is set to `0.2` -- this flag is only used in sample-based generation modes. You should set `do_sample=True` or unset `temperature`. This was detected when initializing the generation config instance, which means the corresponding file may hold incorrect parameterization and should be fixed.\n", - " warnings.warn(\n", - "/home/jiangna1/miniconda3/envs/ms39/lib/python3.9/site-packages/mindnlp/transformers/generation/configuration_utils.py:562: UserWarning: `do_sample` is set to `False`. However, `top_p` is set to `0.9` -- this flag is only used in sample-based generation modes. You should set `do_sample=True` or unset `top_p`. This was detected when initializing the generation config instance, which means the corresponding file may hold incorrect parameterization and should be fixed.\n", - " warnings.warn(\n", - "/home/jiangna1/miniconda3/envs/ms39/lib/python3.9/site-packages/mindnlp/transformers/generation/configuration_utils.py:557: UserWarning: `do_sample` is set to `False`. However, `temperature` is set to `0.2` -- this flag is only used in sample-based generation modes. You should set `do_sample=True` or unset `temperature`.\n", - " warnings.warn(\n", - "/home/jiangna1/miniconda3/envs/ms39/lib/python3.9/site-packages/mindnlp/transformers/generation/configuration_utils.py:562: UserWarning: `do_sample` is set to `False`. However, `top_p` is set to `0.9` -- this flag is only used in sample-based generation modes. You should set `do_sample=True` or unset `top_p`.\n", - " warnings.warn(\n" - ] - } - ], + "outputs": [], "source": [ "from mindnlp.transformers import AutoModelForCausalLM, GenerationConfig\n", "\n", @@ -621,7 +429,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -639,7 +447,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": null, "metadata": { "tags": [] }, @@ -668,7 +476,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -684,7 +492,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -748,7 +556,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -771,603 +579,7 @@ "cell_type": "code", "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - " 0%| | 1/350 [00:19<1:51:45, 19.21s/it]" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "." - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - " 3%|▎ | 10/350 [02:02<1:04:58, 11.47s/it]We detected that you are passing `past_key_values` as a tuple and this is deprecated. Please use an appropriate `Cache` class\n", - " \n", - " 3%|▎ | 10/350 [02:05<1:04:58, 11.47s/it]" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'eval_loss': 3.853940486907959, 'eval_runtime': 2.8532, 'eval_samples_per_second': 1.752, 'eval_steps_per_second': 0.35, 'epoch': 1.88}\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - " \n", - " 6%|▌ | 20/350 [04:00<1:02:29, 11.36s/it]" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'eval_loss': 3.840895891189575, 'eval_runtime': 2.3863, 'eval_samples_per_second': 2.095, 'eval_steps_per_second': 0.419, 'epoch': 3.76}\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - " \n", - " 9%|▊ | 30/350 [05:54<1:00:27, 11.33s/it]" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'eval_loss': 3.8152430057525635, 'eval_runtime': 2.3786, 'eval_samples_per_second': 2.102, 'eval_steps_per_second': 0.42, 'epoch': 5.65}\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - " \n", - " 11%|█▏ | 40/350 [07:49<58:26, 11.31s/it]" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'eval_loss': 3.772057294845581, 'eval_runtime': 2.3891, 'eval_samples_per_second': 2.093, 'eval_steps_per_second': 0.419, 'epoch': 7.53}\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - " \n", - " 14%|█▍ | 50/350 [09:44<56:29, 11.30s/it]" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'eval_loss': 3.7203030586242676, 'eval_runtime': 2.3927, 'eval_samples_per_second': 2.09, 'eval_steps_per_second': 0.418, 'epoch': 9.41}\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - " \n", - " 17%|█▋ | 60/350 [11:48<54:53, 11.36s/it]" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'eval_loss': 3.6663565635681152, 'eval_runtime': 2.3972, 'eval_samples_per_second': 2.086, 'eval_steps_per_second': 0.417, 'epoch': 11.29}\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - " \n", - " 20%|██ | 70/350 [13:43<52:18, 11.21s/it]" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'eval_loss': 3.6159634590148926, 'eval_runtime': 2.3981, 'eval_samples_per_second': 2.085, 'eval_steps_per_second': 0.417, 'epoch': 13.18}\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - " \n", - " 23%|██▎ | 80/350 [15:38<50:19, 11.18s/it]" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'eval_loss': 3.565094470977783, 'eval_runtime': 2.3789, 'eval_samples_per_second': 2.102, 'eval_steps_per_second': 0.42, 'epoch': 15.06}\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - " \n", - " 26%|██▌ | 90/350 [17:33<49:11, 11.35s/it]" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'eval_loss': 3.5170516967773438, 'eval_runtime': 2.3956, 'eval_samples_per_second': 2.087, 'eval_steps_per_second': 0.417, 'epoch': 16.94}\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - " \n", - " 29%|██▊ | 100/350 [19:28<47:17, 11.35s/it]" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'eval_loss': 3.4649040699005127, 'eval_runtime': 2.3707, 'eval_samples_per_second': 2.109, 'eval_steps_per_second': 0.422, 'epoch': 18.82}\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - " \n", - " 31%|███▏ | 110/350 [21:30<45:42, 11.43s/it]" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'eval_loss': 3.407757520675659, 'eval_runtime': 2.3942, 'eval_samples_per_second': 2.088, 'eval_steps_per_second': 0.418, 'epoch': 20.71}\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - " \n", - " 34%|███▍ | 120/350 [23:25<43:28, 11.34s/it]" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'eval_loss': 3.343446969985962, 'eval_runtime': 2.3932, 'eval_samples_per_second': 2.089, 'eval_steps_per_second': 0.418, 'epoch': 22.59}\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - " \n", - " 37%|███▋ | 130/350 [25:20<41:29, 11.31s/it]" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'eval_loss': 3.267294406890869, 'eval_runtime': 2.3965, 'eval_samples_per_second': 2.086, 'eval_steps_per_second': 0.417, 'epoch': 24.47}\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - " \n", - " 40%|████ | 140/350 [27:15<39:26, 11.27s/it]" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'eval_loss': 3.219864845275879, 'eval_runtime': 2.3872, 'eval_samples_per_second': 2.094, 'eval_steps_per_second': 0.419, 'epoch': 26.35}\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - " 43%|████▎ | 150/350 [29:08<37:32, 11.26s/it]" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'loss': 3.5504, 'learning_rate': 7.056435515653059e-06, 'epoch': 28.24}\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "." - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - " \n", - " 43%|████▎ | 150/350 [29:10<37:32, 11.26s/it]" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'eval_loss': 3.1902430057525635, 'eval_runtime': 2.5486, 'eval_samples_per_second': 1.962, 'eval_steps_per_second': 0.392, 'epoch': 28.24}\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - " \n", - " 46%|████▌ | 160/350 [31:12<35:42, 11.28s/it]" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'eval_loss': 3.161935329437256, 'eval_runtime': 2.391, 'eval_samples_per_second': 2.091, 'eval_steps_per_second': 0.418, 'epoch': 30.12}\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - " \n", - " 49%|████▊ | 170/350 [33:07<33:32, 11.18s/it]" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'eval_loss': 3.138967752456665, 'eval_runtime': 2.3927, 'eval_samples_per_second': 2.09, 'eval_steps_per_second': 0.418, 'epoch': 32.0}\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - " \n", - " 51%|█████▏ | 180/350 [35:03<32:11, 11.36s/it]" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'eval_loss': 3.122406482696533, 'eval_runtime': 2.3994, 'eval_samples_per_second': 2.084, 'eval_steps_per_second': 0.417, 'epoch': 33.88}\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - " \n", - " 54%|█████▍ | 190/350 [36:58<30:17, 11.36s/it]" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'eval_loss': 3.106480836868286, 'eval_runtime': 2.3919, 'eval_samples_per_second': 2.09, 'eval_steps_per_second': 0.418, 'epoch': 35.76}\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - " \n", - " 57%|█████▋ | 200/350 [38:53<28:21, 11.35s/it]" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'eval_loss': 3.0940558910369873, 'eval_runtime': 2.397, 'eval_samples_per_second': 2.086, 'eval_steps_per_second': 0.417, 'epoch': 37.65}\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - " \n", - " 60%|██████ | 210/350 [40:56<26:40, 11.43s/it]" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'eval_loss': 3.082423686981201, 'eval_runtime': 2.3797, 'eval_samples_per_second': 2.101, 'eval_steps_per_second': 0.42, 'epoch': 39.53}\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - " \n", - " 63%|██████▎ | 220/350 [42:51<24:30, 11.31s/it]" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'eval_loss': 3.0746374130249023, 'eval_runtime': 2.405, 'eval_samples_per_second': 2.079, 'eval_steps_per_second': 0.416, 'epoch': 41.41}\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - " \n", - " 66%|██████▌ | 230/350 [44:46<22:31, 11.26s/it]" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'eval_loss': 3.0679070949554443, 'eval_runtime': 2.3952, 'eval_samples_per_second': 2.088, 'eval_steps_per_second': 0.418, 'epoch': 43.29}\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - " \n", - " 69%|██████▊ | 240/350 [46:41<20:33, 11.21s/it]" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'eval_loss': 3.060976266860962, 'eval_runtime': 2.3947, 'eval_samples_per_second': 2.088, 'eval_steps_per_second': 0.418, 'epoch': 45.18}\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - " \n", - " 71%|███████▏ | 250/350 [48:36<18:39, 11.19s/it]" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'eval_loss': 3.0542078018188477, 'eval_runtime': 2.3973, 'eval_samples_per_second': 2.086, 'eval_steps_per_second': 0.417, 'epoch': 47.06}\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - " \n", - " 74%|███████▍ | 260/350 [50:39<17:09, 11.44s/it]" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'eval_loss': 3.049464702606201, 'eval_runtime': 2.3926, 'eval_samples_per_second': 2.09, 'eval_steps_per_second': 0.418, 'epoch': 48.94}\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - " \n", - " 77%|███████▋ | 270/350 [52:34<15:09, 11.37s/it]" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'eval_loss': 3.047043561935425, 'eval_runtime': 2.3877, 'eval_samples_per_second': 2.094, 'eval_steps_per_second': 0.419, 'epoch': 50.82}\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - " \n", - " 80%|████████ | 280/350 [54:29<13:14, 11.34s/it]" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'eval_loss': 3.0444722175598145, 'eval_runtime': 2.3917, 'eval_samples_per_second': 2.091, 'eval_steps_per_second': 0.418, 'epoch': 52.71}\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - " \n", - " 83%|████████▎ | 290/350 [56:24<11:20, 11.34s/it]" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'eval_loss': 3.0422093868255615, 'eval_runtime': 2.3938, 'eval_samples_per_second': 2.089, 'eval_steps_per_second': 0.418, 'epoch': 54.59}\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - " 86%|████████▌ | 300/350 [58:17<09:25, 11.31s/it]" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'loss': 3.0383, 'learning_rate': 6.088921331488568e-07, 'epoch': 56.47}\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - " \n", - " 86%|████████▌ | 300/350 [58:19<09:25, 11.31s/it]" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'eval_loss': 3.0407938957214355, 'eval_runtime': 2.3837, 'eval_samples_per_second': 2.098, 'eval_steps_per_second': 0.42, 'epoch': 56.47}\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - " \n", - " 89%|████████▊ | 310/350 [1:00:22<07:34, 11.37s/it]" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'eval_loss': 3.0404062271118164, 'eval_runtime': 2.3948, 'eval_samples_per_second': 2.088, 'eval_steps_per_second': 0.418, 'epoch': 58.35}\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - " \n", - " 91%|█████████▏| 320/350 [1:02:17<05:38, 11.27s/it]" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'eval_loss': 3.0399832725524902, 'eval_runtime': 2.3929, 'eval_samples_per_second': 2.089, 'eval_steps_per_second': 0.418, 'epoch': 60.24}\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - " \n", - " 94%|█████████▍| 330/350 [1:04:12<03:43, 11.20s/it]" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'eval_loss': 3.039731740951538, 'eval_runtime': 2.3855, 'eval_samples_per_second': 2.096, 'eval_steps_per_second': 0.419, 'epoch': 62.12}\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - " \n", - " 97%|█████████▋| 340/350 [1:06:07<01:51, 11.19s/it]" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'eval_loss': 3.0396060943603516, 'eval_runtime': 2.3904, 'eval_samples_per_second': 2.092, 'eval_steps_per_second': 0.418, 'epoch': 64.0}\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - " \n", - "100%|██████████| 350/350 [1:08:03<00:00, 11.35s/it]" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'eval_loss': 3.039623260498047, 'eval_runtime': 2.3877, 'eval_samples_per_second': 2.094, 'eval_steps_per_second': 0.419, 'epoch': 65.88}\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "The intermediate checkpoints of PEFT may not be saved correctly, consider using a custom callback to save adapter_model.bin in corresponding saving folders. Check some examples here: https://github.com/huggingface/peft/issues/96\n", - "100%|██████████| 350/350 [1:08:12<00:00, 11.69s/it]\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'train_runtime': 4092.112, 'train_samples_per_second': 23.264, 'train_steps_per_second': 0.086, 'train_loss': 3.2515819876534597, 'epoch': 65.88}\n" - ] - } - ], + "outputs": [], "source": [ "trainer.train()\n", "\n", @@ -1415,109 +627,9 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "model merge succeeded\n" - ] - }, - { - "data": { - "text/plain": [ - "LlamaForCausalLM(\n", - " (model): LlamaModel(\n", - " (embed_tokens): Embedding(55296, 4096, padding_idx=0)\n", - " (layers): ModuleList(\n", - " (0-3): 4 x LlamaDecoderLayer(\n", - " (self_attn): LlamaAttention(\n", - " (q_proj): lora.Linear(\n", - " (base_layer): Linear (4096 -> 4096)\n", - " (lora_dropout): ModuleDict(\n", - " (default): Dropout(p=0.1, inplace=False)\n", - " )\n", - " (lora_A): ModuleDict(\n", - " (default): Linear (4096 -> 8)\n", - " )\n", - " (lora_B): ModuleDict(\n", - " (default): Linear (8 -> 4096)\n", - " )\n", - " (lora_embedding_A): ParameterDict()\n", - " (lora_embedding_B): ParameterDict()\n", - " (lora_magnitude_vector): ModuleDict()\n", - " )\n", - " (k_proj): lora.Linear(\n", - " (base_layer): Linear (4096 -> 4096)\n", - " (lora_dropout): ModuleDict(\n", - " (default): Dropout(p=0.1, inplace=False)\n", - " )\n", - " (lora_A): ModuleDict(\n", - " (default): Linear (4096 -> 8)\n", - " )\n", - " (lora_B): ModuleDict(\n", - " (default): Linear (8 -> 4096)\n", - " )\n", - " (lora_embedding_A): ParameterDict()\n", - " (lora_embedding_B): ParameterDict()\n", - " (lora_magnitude_vector): ModuleDict()\n", - " )\n", - " (v_proj): lora.Linear(\n", - " (base_layer): Linear (4096 -> 4096)\n", - " (lora_dropout): ModuleDict(\n", - " (default): Dropout(p=0.1, inplace=False)\n", - " )\n", - " (lora_A): ModuleDict(\n", - " (default): Linear (4096 -> 8)\n", - " )\n", - " (lora_B): ModuleDict(\n", - " (default): Linear (8 -> 4096)\n", - " )\n", - " (lora_embedding_A): ParameterDict()\n", - " (lora_embedding_B): ParameterDict()\n", - " (lora_magnitude_vector): ModuleDict()\n", - " )\n", - " (o_proj): lora.Linear(\n", - " (base_layer): Linear (4096 -> 4096)\n", - " (lora_dropout): ModuleDict(\n", - " (default): Dropout(p=0.1, inplace=False)\n", - " )\n", - " (lora_A): ModuleDict(\n", - " (default): Linear (4096 -> 8)\n", - " )\n", - " (lora_B): ModuleDict(\n", - " (default): Linear (8 -> 4096)\n", - " )\n", - " (lora_embedding_A): ParameterDict()\n", - " (lora_embedding_B): ParameterDict()\n", - " (lora_magnitude_vector): ModuleDict()\n", - " )\n", - " (rotary_emb): LlamaRotaryEmbedding()\n", - " )\n", - " (mlp): LlamaMLP(\n", - " (gate_proj): Linear (4096 -> 11008)\n", - " (up_proj): Linear (4096 -> 11008)\n", - " (down_proj): Linear (11008 -> 4096)\n", - " (act_fn): SiLU()\n", - " )\n", - " (input_layernorm): LlamaRMSNorm((4096,), eps=1e-05)\n", - " (post_attention_layernorm): LlamaRMSNorm((4096,), eps=1e-05)\n", - " )\n", - " )\n", - " (norm): LlamaRMSNorm((4096,), eps=1e-05)\n", - " (rotary_emb): LlamaRotaryEmbedding()\n", - " )\n", - " (lm_head): Linear (4096 -> 55296)\n", - ")" - ] - }, - "execution_count": 18, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "#将 LoRA微调后的参数加载到预训练模型中\n", "from mindnlp.peft import PeftModel\n", @@ -1536,7 +648,7 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -1570,30 +682,9 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "/home/jiangna1/miniconda3/envs/ms39/lib/python3.9/site-packages/mindnlp/transformers/generation/configuration_utils.py:557: UserWarning: `do_sample` is set to `False`. However, `temperature` is set to `0.2` -- this flag is only used in sample-based generation modes. You should set `do_sample=True` or unset `temperature`.\n", - " warnings.warn(\n", - "/home/jiangna1/miniconda3/envs/ms39/lib/python3.9/site-packages/mindnlp/transformers/generation/configuration_utils.py:562: UserWarning: `do_sample` is set to `False`. However, `top_p` is set to `0.9` -- this flag is only used in sample-based generation modes. You should set `do_sample=True` or unset `top_p`.\n", - " warnings.warn(\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "User: 如何保持清醒?\n", - "LLAMA: 以下是用户和助手之间的问答。\n", - "问:如何保持清醒?\n", - "答:在你睡觉的时候,你的大脑会一直处于兴奋状态中;当你醒来时,它就会继续工作了。所以如果你的睡眠时间很短的话,你就不会感到太疲劳或昏沉。你可以通过使用一些药物来帮助恢复精力、提高警觉度以及降低血压等方法使自己进入深度睡眠的状态。此外,你还可以通过服用维生素B6片剂或者吃富含蛋白质的食物等方式让自己重新振作起来。\n" - ] - } - ], + "outputs": [], "source": [ "question = \"如何保持清醒?\"\n", "response = generate_response(question, model, tokenizer)\n", diff --git a/01.LLM_Theory_Course/01.Industry_Model_Introduction/02.Partner_Innovation_Model_Sharing/01.CodeGeeX/Review.md b/01.LLM_Theory_Course/01.Industry_Model_Introduction/02.Partner_Innovation_Model_Sharing/01.CodeGeeX/Review.md index a4b8883..2d5fce9 100644 --- a/01.LLM_Theory_Course/01.Industry_Model_Introduction/02.Partner_Innovation_Model_Sharing/01.CodeGeeX/Review.md +++ b/01.LLM_Theory_Course/01.Industry_Model_Introduction/02.Partner_Innovation_Model_Sharing/01.CodeGeeX/Review.md @@ -70,11 +70,11 @@ 2. 目前的基准从多任务及多语言两个方面对模型进行评价 - 多任务 - + 通过不同应用场景进行评价,多使用CodeBLEU/BLEU评价相似性 - 多语言 - + 在不同编程语言下评价代码正确性,如HumanEval(仅支持Python)、MultiPL-E(支持16种语言,但为自动翻译并不支持多任务) 3. HumanEval-X:新的多语言代码生成基准 diff --git a/01.LLM_Theory_Course/02.Technical_Topic_Introduction/01.Prompt_Tuning/roberta_sequence_classification.ipynb b/01.LLM_Theory_Course/02.Technical_Topic_Introduction/01.Prompt_Tuning/roberta_sequence_classification.ipynb index 75c4c9e..25e1ce7 100644 --- a/01.LLM_Theory_Course/02.Technical_Topic_Introduction/01.Prompt_Tuning/roberta_sequence_classification.ipynb +++ b/01.LLM_Theory_Course/02.Technical_Topic_Introduction/01.Prompt_Tuning/roberta_sequence_classification.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "markdown", - "id": "7a2ac91c", + "id": "0", "metadata": {}, "source": [ "# 基于MindNLP的Roberta模型Prompt Tuning" @@ -10,7 +10,7 @@ }, { "cell_type": "markdown", - "id": "324424c6", + "id": "1", "metadata": {}, "source": [ "安装mindspore, mindnlp及其他依赖" @@ -18,66 +18,27 @@ }, { "cell_type": "code", - "execution_count": 1, - "id": "cd3f2df1-da30-4009-8b33-80df52be80c7", + "execution_count": null, + "id": "2", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple\n", - "Collecting mindspore==2.4.1\n", - " Downloading https://ms-release.obs.cn-north-4.myhuaweicloud.com/2.4.1/MindSpore/unified/aarch64/mindspore-2.4.1-cp39-cp39-linux_aarch64.whl (335.5 MB)\n", - "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m335.5/335.5 MB\u001b[0m \u001b[31m6.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m\n", - "\u001b[?25hRequirement already satisfied: numpy<2.0.0,>=1.20.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from mindspore==2.4.1) (1.26.1)\n", - "Requirement already satisfied: protobuf>=3.13.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from mindspore==2.4.1) (3.20.3)\n", - "Requirement already satisfied: asttokens>=2.0.4 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from mindspore==2.4.1) (2.4.1)\n", - "Requirement already satisfied: pillow>=6.2.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from mindspore==2.4.1) (9.0.1)\n", - "Requirement already satisfied: scipy>=1.5.4 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from mindspore==2.4.1) (1.11.3)\n", - "Requirement already satisfied: packaging>=20.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from mindspore==2.4.1) (23.2)\n", - "Requirement already satisfied: psutil>=5.6.1 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from mindspore==2.4.1) (5.9.5)\n", - "Requirement already satisfied: astunparse>=1.6.3 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from mindspore==2.4.1) (1.6.3)\n", - "Collecting safetensors>=0.4.0 (from mindspore==2.4.1)\n", - " Downloading https://pypi.tuna.tsinghua.edu.cn/packages/08/94/7760694760f1e5001bd62c93155b8b7ccb652d1f4d0161d1e72b5bf9581a/safetensors-0.4.5-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (442 kB)\n", - "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m442.4/442.4 kB\u001b[0m \u001b[31m39.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", - "\u001b[?25hRequirement already satisfied: six>=1.12.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from asttokens>=2.0.4->mindspore==2.4.1) (1.16.0)\n", - "Requirement already satisfied: wheel<1.0,>=0.23.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from astunparse>=1.6.3->mindspore==2.4.1) (0.41.2)\n", - "\u001b[33mDEPRECATION: moxing-framework 2.1.16.2ae09d45 has a non-standard version number. pip 24.0 will enforce this behaviour change. A possible replacement is to upgrade to a newer version of moxing-framework or contact the author to suggest that they release a version with a conforming version number. Discussion can be found at https://github.com/pypa/pip/issues/12063\u001b[0m\u001b[33m\n", - "\u001b[0mInstalling collected packages: safetensors, mindspore\n", - " Attempting uninstall: mindspore\n", - " Found existing installation: mindspore 2.3.0\n", - " Uninstalling mindspore-2.3.0:\n", - " Successfully uninstalled mindspore-2.3.0\n", - "Successfully installed mindspore-2.4.1 safetensors-0.4.5\n" - ] - } - ], + "outputs": [], "source": [ "!pip install https://ms-release.obs.cn-north-4.myhuaweicloud.com/2.4.1/MindSpore/unified/aarch64/mindspore-2.4.1-cp39-cp39-linux_aarch64.whl --trusted-host ms-release.obs.cn-north-4.myhuaweicloud.com -i https://pypi.tuna.tsinghua.edu.cn/simple" ] }, { "cell_type": "code", - "execution_count": 14, - "id": "d8b0ba09", + "execution_count": null, + "id": "3", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "env: HF_ENDPOINT=https://hf-mirror.com\n" - ] - } - ], + "outputs": [], "source": [ "%env HF_ENDPOINT=https://hf-mirror.com" ] }, { "cell_type": "markdown", - "id": "5b0e977f", + "id": "4", "metadata": {}, "source": [ "## 模型与数据集加载\n", @@ -87,8 +48,8 @@ }, { "cell_type": "code", - "execution_count": 15, - "id": "ef577ba3", + "execution_count": null, + "id": "5", "metadata": {}, "outputs": [], "source": [ @@ -115,8 +76,8 @@ }, { "cell_type": "code", - "execution_count": 16, - "id": "af061f0b", + "execution_count": null, + "id": "6", "metadata": {}, "outputs": [], "source": [ @@ -130,7 +91,7 @@ }, { "cell_type": "markdown", - "id": "f949e9cb", + "id": "7", "metadata": {}, "source": [ "prompt tuning配置,任务类型选为\"SEQ_CLS\", 即序列分类。" @@ -138,8 +99,8 @@ }, { "cell_type": "code", - "execution_count": 17, - "id": "4e9663be", + "execution_count": null, + "id": "8", "metadata": {}, "outputs": [], "source": [ @@ -151,7 +112,7 @@ }, { "cell_type": "markdown", - "id": "3dc55fc7", + "id": "9", "metadata": {}, "source": [ "加载tokenizer。如模型为GPT、OPT或BLOOM类模型,从序列左侧添加padding,其他情况下从序列右侧添加padding。" @@ -159,19 +120,10 @@ }, { "cell_type": "code", - "execution_count": 18, - "id": "871ebbae", + "execution_count": null, + "id": "10", "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "/home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages/mindnlp/transformers/tokenization_utils_base.py:1526: FutureWarning: `clean_up_tokenization_spaces` was not set. It will be set to `True` by default. This behavior will be depracted, and will be then set to `False` by default. \n", - " warnings.warn(\n" - ] - } - ], + "outputs": [], "source": [ "# load tokenizer\n", "if any(k in model_name_or_path for k in (\"gpt\", \"opt\", \"bloom\")):\n", @@ -186,18 +138,10 @@ }, { "cell_type": "code", - "execution_count": 19, - "id": "79ef5257", + "execution_count": null, + "id": "11", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'sentence1': Tensor(shape=[], dtype=String, value= 'Amrozi accused his brother , whom he called \" the witness \" , of deliberately distorting his evidence .'), 'sentence2': Tensor(shape=[], dtype=String, value= 'Referring to him as only \" the witness \" , Amrozi accused his brother of deliberately distorting his evidence .'), 'label': Tensor(shape=[], dtype=Int64, value= 1), 'idx': Tensor(shape=[], dtype=Int64, value= 0)}\n" - ] - } - ], + "outputs": [], "source": [ "datasets = load_dataset(\"glue\", task)\n", "print(next(datasets['train'].create_dict_iterator()))" @@ -205,8 +149,8 @@ }, { "cell_type": "code", - "execution_count": 20, - "id": "151943cb", + "execution_count": null, + "id": "12", "metadata": {}, "outputs": [], "source": [ @@ -233,57 +177,19 @@ }, { "cell_type": "code", - "execution_count": 21, - "id": "a99c4ab6", + "execution_count": null, + "id": "13", "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "Asking to truncate to max_length but no maximum length is provided and the model has no predefined maximum length. Default to no truncation.\n", - "Asking to truncate to max_length but no maximum length is provided and the model has no predefined maximum length. Default to no truncation.\n", - "Asking to truncate to max_length but no maximum length is provided and the model has no predefined maximum length. Default to no truncation.\n", - "Asking to truncate to max_length but no maximum length is provided and the model has no predefined maximum length. Default to no truncation.\n", - "Asking to truncate to max_length but no maximum length is provided and the model has no predefined maximum length. Default to no truncation.\n", - "Asking to truncate to max_length but no maximum length is provided and the model has no predefined maximum length. Default to no truncation.\n", - "Asking to truncate to max_length but no maximum length is provided and the model has no predefined maximum length. Default to no truncation.\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "{'input_ids': Tensor(shape=[32, 70], dtype=Int64, value=\n", - "[[ 0, 10127, 1001 ... 1, 1, 1],\n", - " [ 0, 975, 26802 ... 1, 1, 1],\n", - " [ 0, 1213, 56 ... 1, 1, 1],\n", - " ...\n", - " [ 0, 133, 1154 ... 1, 1, 1],\n", - " [ 0, 12667, 8423 ... 1, 1, 1],\n", - " [ 0, 32478, 1033 ... 1, 1, 1]]), 'attention_mask': Tensor(shape=[32, 70], dtype=Int64, value=\n", - "[[1, 1, 1 ... 0, 0, 0],\n", - " [1, 1, 1 ... 0, 0, 0],\n", - " [1, 1, 1 ... 0, 0, 0],\n", - " ...\n", - " [1, 1, 1 ... 0, 0, 0],\n", - " [1, 1, 1 ... 0, 0, 0],\n", - " [1, 1, 1 ... 0, 0, 0]]), 'labels': Tensor(shape=[32], dtype=Int64, value= [1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 1, 1, 0, 1, \n", - " 1, 1, 0, 0, 1, 1, 1, 0])}\n" - ] - } - ], + "outputs": [], "source": [ "print(next(train_dataset.create_dict_iterator()))" ] }, { "cell_type": "code", - "execution_count": 22, - "id": "9dc17398", - "metadata": { - "scrolled": true - }, + "execution_count": null, + "id": "14", + "metadata": {}, "outputs": [], "source": [ "metric = evaluate.load(\"glue\", task)" @@ -291,7 +197,7 @@ }, { "cell_type": "markdown", - "id": "9034b5b2", + "id": "15", "metadata": {}, "source": [ "加载模型并打印微调参数量,可以看到仅有不到0.6%的参数参与了微调。\n", @@ -308,26 +214,10 @@ }, { "cell_type": "code", - "execution_count": 23, - "id": "f929a616", + "execution_count": null, + "id": "16", "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "Some weights of RobertaForSequenceClassification were not initialized from the model checkpoint at AI-ModelScope/roberta-large and are newly initialized: ['classifier.dense.bias', 'classifier.dense.weight', 'classifier.out_proj.bias', 'classifier.out_proj.weight']\n", - "You should probably TRAIN this model on a down-stream task to be able to use it for predictions and inference.\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "trainable params: 1,061,890 || all params: 356,423,684 || trainable%: 0.2979291353713745\n" - ] - } - ], + "outputs": [], "source": [ "# load model\n", "model = AutoModelForSequenceClassification.from_pretrained(model_name_or_path, return_dict=True, mirror=\"modelscope\")\n", @@ -338,7 +228,7 @@ }, { "cell_type": "markdown", - "id": "6fe629f6", + "id": "17", "metadata": {}, "source": [ "## 模型微调(prompt tuning)" @@ -346,7 +236,7 @@ }, { "cell_type": "markdown", - "id": "855ae5a5", + "id": "18", "metadata": {}, "source": [ "指定优化器和学习率调整策略" @@ -354,8 +244,8 @@ }, { "cell_type": "code", - "execution_count": 24, - "id": "3c7ee704", + "execution_count": null, + "id": "19", "metadata": {}, "outputs": [], "source": [ @@ -371,7 +261,7 @@ }, { "cell_type": "markdown", - "id": "c4f5b68a", + "id": "20", "metadata": {}, "source": [ "打印参与微调的模型参数" @@ -379,41 +269,10 @@ }, { "cell_type": "code", - "execution_count": 25, - "id": "a0d2bff6", + "execution_count": null, + "id": "21", "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "(Tensor(shape=[1024, 1024], dtype=Float32, value=\n", - " [[-1.36615150e-02, 4.08777148e-02, 2.55590724e-03 ... 3.47721018e-02, 9.83245391e-03, 3.02866008e-02],\n", - " [-1.82124749e-02, -1.49800153e-02, -7.02886097e-03 ... 2.07055025e-02, 3.45048914e-03, -3.01328991e-02],\n", - " [-6.06489694e-03, 6.34483900e-03, 1.55880465e-03 ... 3.41698825e-02, -7.40761030e-03, 3.69770750e-02],\n", - " ...\n", - " [-4.91964221e-02, 1.94903351e-02, 2.51724524e-03 ... 3.08064763e-02, -7.55657675e-04, -8.02899338e-03],\n", - " [-2.02472787e-03, -2.46642623e-02, -7.02362158e-04 ... 2.86021479e-03, 8.27849377e-03, 9.28967725e-03],\n", - " [-2.06481982e-02, 2.20393538e-02, 3.17191752e-03 ... -2.68367468e-03, -4.67487238e-02, 9.09192720e-04]]),\n", - " Tensor(shape=[1024], dtype=Float32, value= [ 0.00000000e+00, 0.00000000e+00, 0.00000000e+00 ... 0.00000000e+00, 0.00000000e+00, 0.00000000e+00]),\n", - " Tensor(shape=[2, 1024], dtype=Float32, value=\n", - " [[ 8.87530856e-03, 2.81313114e-04, 3.74777764e-02 ... -2.02168617e-02, 4.23110556e-03, -3.84111144e-02],\n", - " [ 3.84113006e-03, -1.38288038e-02, 1.98907983e-02 ... -3.23316827e-02, -3.48059200e-02, 7.11114611e-04]]),\n", - " Tensor(shape=[2], dtype=Float32, value= [ 0.00000000e+00, 0.00000000e+00]),\n", - " Tensor(shape=[10, 1024], dtype=Float32, value=\n", - " [[-1.75136819e-01, 6.45715892e-02, 1.14947283e+00 ... 8.42640877e-01, 6.34459913e-01, 9.26455021e-01],\n", - " [ 7.65107423e-02, 5.32130003e-01, -2.12189722e+00 ... 1.34316778e+00, 4.83163930e-02, -2.11086214e-01],\n", - " [-7.30758488e-01, -8.77783835e-01, -5.94429135e-01 ... -2.58468151e-01, -2.85294857e-02, -2.18536639e+00],\n", - " ...\n", - " [ 4.13678169e-01, -1.15315497e+00, 8.49422574e-01 ... 2.54201055e-01, -1.30300558e+00, 2.13208008e+00],\n", - " [ 5.60092032e-01, -8.55898261e-01, -7.30682373e-01 ... -1.04416716e+00, -1.10600793e+00, 4.29843873e-01],\n", - " [-1.94377673e+00, 4.45314497e-02, -4.56895113e-01 ... 1.88079858e+00, -6.05825901e-01, -3.19380850e-01]]))" - ] - }, - "execution_count": 25, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "# print name of trainable parameters\n", "model.trainable_params()" @@ -421,7 +280,7 @@ }, { "cell_type": "markdown", - "id": "b61576ae", + "id": "22", "metadata": {}, "source": [ "按照如下步骤定义训练逻辑:\n", @@ -434,93 +293,10 @@ }, { "cell_type": "code", - "execution_count": 26, - "id": "0667ebea", + "execution_count": null, + "id": "23", "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "100%|██████████| 115/115 [00:26<00:00, 4.38it/s]\n", - "100%|██████████| 13/13 [00:01<00:00, 7.83it/s]\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "epoch 0: {'accuracy': 0.6985294117647058, 'f1': 0.8183161004431314}\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "100%|██████████| 115/115 [00:26<00:00, 4.42it/s]\n", - "100%|██████████| 13/13 [00:01<00:00, 7.78it/s]\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "epoch 1: {'accuracy': 0.7009803921568627, 'f1': 0.8195266272189349}\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "100%|██████████| 115/115 [00:26<00:00, 4.38it/s]\n", - "100%|██████████| 13/13 [00:01<00:00, 7.76it/s]\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "epoch 2: {'accuracy': 0.7083333333333334, 'f1': 0.8231797919762258}\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "100%|██████████| 115/115 [00:26<00:00, 4.39it/s]\n", - "100%|██████████| 13/13 [00:01<00:00, 8.15it/s]\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "epoch 3: {'accuracy': 0.7009803921568627, 'f1': 0.8195266272189349}\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "100%|██████████| 115/115 [00:27<00:00, 4.21it/s]\n", - "100%|██████████| 13/13 [00:01<00:00, 8.02it/s]" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "epoch 4: {'accuracy': 0.7009803921568627, 'f1': 0.8195266272189349}\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "\n" - ] - } - ], + "outputs": [], "source": [ "from mindnlp.core import value_and_grad\n", "def forward_fn(**batch):\n", @@ -557,7 +333,7 @@ { "cell_type": "code", "execution_count": null, - "id": "4de28f75", + "id": "24", "metadata": {}, "outputs": [], "source": [] @@ -565,7 +341,7 @@ { "cell_type": "code", "execution_count": null, - "id": "7cb41077-b027-4c0f-87ed-380cd816d2f4", + "id": "25", "metadata": {}, "outputs": [], "source": [] diff --git a/01.LLM_Theory_Course/02.Technical_Topic_Introduction/05.Text_Generation_Decoding/text_generation_decoding.ipynb b/01.LLM_Theory_Course/02.Technical_Topic_Introduction/05.Text_Generation_Decoding/text_generation_decoding.ipynb index 22921f5..bcf33e0 100644 --- a/01.LLM_Theory_Course/02.Technical_Topic_Introduction/05.Text_Generation_Decoding/text_generation_decoding.ipynb +++ b/01.LLM_Theory_Course/02.Technical_Topic_Introduction/05.Text_Generation_Decoding/text_generation_decoding.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "markdown", - "id": "70943fc4", + "id": "0", "metadata": {}, "source": [ "## __文本解码原理\\-\\-以MindNLP为例__\n", @@ -26,7 +26,7 @@ }, { "cell_type": "markdown", - "id": "39212dbd", + "id": "1", "metadata": {}, "source": [ "__Greedy search__\n", @@ -43,7 +43,7 @@ }, { "cell_type": "markdown", - "id": "f1b3ea92", + "id": "2", "metadata": {}, "source": [ "__环境准备__" @@ -52,7 +52,7 @@ { "cell_type": "code", "execution_count": null, - "id": "5c56827b", + "id": "3", "metadata": {}, "outputs": [], "source": [ @@ -64,8 +64,8 @@ }, { "cell_type": "code", - "execution_count": 8, - "id": "c40cdb84", + "execution_count": null, + "id": "4", "metadata": {}, "outputs": [], "source": [ @@ -96,118 +96,10 @@ }, { "cell_type": "code", - "execution_count": 1, - "id": "5593606f", + "execution_count": null, + "id": "5", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "\u001b[33mWARNING: Skipping mindspore-gpu as it is not installed.\u001b[0m\n", - "\u001b[33mWARNING: Skipping mindvision as it is not installed.\u001b[0m\n", - "\u001b[33mWARNING: Skipping mindinsight as it is not installed.\u001b[0m\n", - "Looking in indexes: http://pip.modelarts.private.com:8888/repository/pypi/simple\n", - "Processing ./mindnlp-0.4.1-py3-none-any.whl\n", - "Requirement already satisfied: pytest==7.2.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from mindnlp==0.4.1) (7.2.0)\n", - "Requirement already satisfied: evaluate in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from mindnlp==0.4.1) (0.4.3)\n", - "Requirement already satisfied: regex in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from mindnlp==0.4.1) (2024.7.24)\n", - "Requirement already satisfied: safetensors in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from mindnlp==0.4.1) (0.4.5)\n", - "Requirement already satisfied: pyctcdecode in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from mindnlp==0.4.1) (0.5.0)\n", - "Requirement already satisfied: tokenizers==0.19.1 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from mindnlp==0.4.1) (0.19.1)\n", - "Requirement already satisfied: datasets in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from mindnlp==0.4.1) (3.1.0)\n", - "Requirement already satisfied: sentencepiece in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from mindnlp==0.4.1) (0.2.0)\n", - "Requirement already satisfied: mindspore>=2.2.14 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from mindnlp==0.4.1) (2.4.0)\n", - "Requirement already satisfied: requests in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from mindnlp==0.4.1) (2.32.3)\n", - "Requirement already satisfied: pillow>=10.0.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from mindnlp==0.4.1) (10.0.1)\n", - "Requirement already satisfied: tqdm in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from mindnlp==0.4.1) (4.65.0)\n", - "Requirement already satisfied: addict in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from mindnlp==0.4.1) (2.4.0)\n", - "Requirement already satisfied: ml-dtypes in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from mindnlp==0.4.1) (0.4.0)\n", - "Requirement already satisfied: tomli>=1.0.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from pytest==7.2.0->mindnlp==0.4.1) (2.0.1)\n", - "Requirement already satisfied: exceptiongroup>=1.0.0rc8 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from pytest==7.2.0->mindnlp==0.4.1) (1.2.2)\n", - "Requirement already satisfied: iniconfig in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from pytest==7.2.0->mindnlp==0.4.1) (2.0.0)\n", - "Requirement already satisfied: pluggy<2.0,>=0.12 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from pytest==7.2.0->mindnlp==0.4.1) (1.5.0)\n", - "Requirement already satisfied: attrs>=19.2.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from pytest==7.2.0->mindnlp==0.4.1) (23.2.0)\n", - "Requirement already satisfied: packaging in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from pytest==7.2.0->mindnlp==0.4.1) (24.1)\n", - "Requirement already satisfied: huggingface-hub<1.0,>=0.16.4 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from tokenizers==0.19.1->mindnlp==0.4.1) (0.24.2)\n", - "Requirement already satisfied: pyyaml>=5.1 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from huggingface-hub<1.0,>=0.16.4->tokenizers==0.19.1->mindnlp==0.4.1) (6.0.1)\n", - "Requirement already satisfied: typing-extensions>=3.7.4.3 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from huggingface-hub<1.0,>=0.16.4->tokenizers==0.19.1->mindnlp==0.4.1) (4.12.2)\n", - "Requirement already satisfied: filelock in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from huggingface-hub<1.0,>=0.16.4->tokenizers==0.19.1->mindnlp==0.4.1) (3.15.4)\n", - "Requirement already satisfied: fsspec>=2023.5.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from huggingface-hub<1.0,>=0.16.4->tokenizers==0.19.1->mindnlp==0.4.1) (2024.6.1)\n", - "Requirement already satisfied: asttokens>=2.0.4 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from mindspore>=2.2.14->mindnlp==0.4.1) (2.4.1)\n", - "Requirement already satisfied: psutil>=5.6.1 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from mindspore>=2.2.14->mindnlp==0.4.1) (5.9.5)\n", - "Requirement already satisfied: numpy<2.0.0,>=1.20.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from mindspore>=2.2.14->mindnlp==0.4.1) (1.22.0)\n", - "Requirement already satisfied: scipy>=1.5.4 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from mindspore>=2.2.14->mindnlp==0.4.1) (1.10.1)\n", - "Requirement already satisfied: protobuf>=3.13.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from mindspore>=2.2.14->mindnlp==0.4.1) (3.20.2)\n", - "Requirement already satisfied: astunparse>=1.6.3 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from mindspore>=2.2.14->mindnlp==0.4.1) (1.6.3)\n", - "Requirement already satisfied: six>=1.12.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from asttokens>=2.0.4->mindspore>=2.2.14->mindnlp==0.4.1) (1.16.0)\n", - "Requirement already satisfied: wheel<1.0,>=0.23.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from astunparse>=1.6.3->mindspore>=2.2.14->mindnlp==0.4.1) (0.38.4)\n", - "Requirement already satisfied: multiprocess<0.70.17 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from datasets->mindnlp==0.4.1) (0.70.16)\n", - "Collecting tqdm\n", - " Downloading http://pip.modelarts.private.com:8888/repository/pypi/packages/tqdm/4.67.1/tqdm-4.67.1-py3-none-any.whl (78 kB)\n", - "\u001b[K |████████████████████████████████| 78 kB 39.9 MB/s eta 0:00:01\n", - "\u001b[?25hRequirement already satisfied: pandas in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from datasets->mindnlp==0.4.1) (1.3.5)\n", - "Requirement already satisfied: xxhash in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from datasets->mindnlp==0.4.1) (3.5.0)\n", - "Requirement already satisfied: aiohttp in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from datasets->mindnlp==0.4.1) (3.11.9)\n", - "Requirement already satisfied: pyarrow>=15.0.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from datasets->mindnlp==0.4.1) (18.1.0)\n", - "Requirement already satisfied: dill<0.3.9,>=0.3.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from datasets->mindnlp==0.4.1) (0.3.8)\n", - "Requirement already satisfied: async-timeout<6.0,>=4.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from aiohttp->datasets->mindnlp==0.4.1) (5.0.1)\n", - "Requirement already satisfied: propcache>=0.2.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from aiohttp->datasets->mindnlp==0.4.1) (0.2.1)\n", - "Requirement already satisfied: aiosignal>=1.1.2 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from aiohttp->datasets->mindnlp==0.4.1) (1.3.1)\n", - "Requirement already satisfied: yarl<2.0,>=1.17.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from aiohttp->datasets->mindnlp==0.4.1) (1.18.3)\n", - "Requirement already satisfied: multidict<7.0,>=4.5 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from aiohttp->datasets->mindnlp==0.4.1) (6.1.0)\n", - "Requirement already satisfied: aiohappyeyeballs>=2.3.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from aiohttp->datasets->mindnlp==0.4.1) (2.4.4)\n", - "Requirement already satisfied: frozenlist>=1.1.1 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from aiohttp->datasets->mindnlp==0.4.1) (1.5.0)\n", - "Requirement already satisfied: idna<4,>=2.5 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from requests->mindnlp==0.4.1) (2.10)\n", - "Requirement already satisfied: charset-normalizer<4,>=2 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from requests->mindnlp==0.4.1) (2.0.12)\n", - "Requirement already satisfied: urllib3<3,>=1.21.1 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from requests->mindnlp==0.4.1) (1.26.7)\n", - "Requirement already satisfied: certifi>=2017.4.17 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from requests->mindnlp==0.4.1) (2024.7.4)\n", - "Requirement already satisfied: python-dateutil>=2.7.3 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from pandas->datasets->mindnlp==0.4.1) (2.9.0.post0)\n", - "Requirement already satisfied: pytz>=2017.3 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from pandas->datasets->mindnlp==0.4.1) (2024.1)\n", - "Requirement already satisfied: pygtrie<3.0,>=2.1 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from pyctcdecode->mindnlp==0.4.1) (2.5.0)\n", - "Requirement already satisfied: hypothesis<7,>=6.14 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from pyctcdecode->mindnlp==0.4.1) (6.122.1)\n", - "Requirement already satisfied: sortedcontainers<3.0.0,>=2.1.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from hypothesis<7,>=6.14->pyctcdecode->mindnlp==0.4.1) (2.4.0)\n", - "Installing collected packages: tqdm, mindnlp\n", - " Attempting uninstall: tqdm\n", - " Found existing installation: tqdm 4.65.0\n", - " Uninstalling tqdm-4.65.0:\n", - " Successfully uninstalled tqdm-4.65.0\n", - " Attempting uninstall: mindnlp\n", - " Found existing installation: mindnlp 0.3.0\n", - " Uninstalling mindnlp-0.3.0:\n", - " Successfully uninstalled mindnlp-0.3.0\n", - "\u001b[31mERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.\n", - "modelarts 1.4.28 requires lxml==5.1.0, but you have lxml 4.9.3 which is incompatible.\n", - "modelarts 1.4.28 requires matplotlib==3.5.2, but you have matplotlib 3.5.1 which is incompatible.\n", - "modelarts 1.4.28 requires prettytable<=3.7.0, but you have prettytable 3.10.2 which is incompatible.\n", - "modelarts 1.4.28 requires requests==2.31.0, but you have requests 2.32.3 which is incompatible.\n", - "modelarts 1.4.28 requires tqdm<=4.66.1, but you have tqdm 4.67.1 which is incompatible.\n", - "modelarts 1.4.28 requires typing-extensions==4.7.1, but you have typing-extensions 4.12.2 which is incompatible.\n", - "modelarts 1.4.28 requires urllib3==1.26.18, but you have urllib3 1.26.7 which is incompatible.\u001b[0m\n", - "Successfully installed mindnlp-0.4.1 tqdm-4.67.1\n", - "\u001b[33mWARNING: You are using pip version 21.0.1; however, version 24.3.1 is available.\n", - "You should consider upgrading via the '/home/ma-user/anaconda3/envs/MindSpore/bin/python3.9 -m pip install --upgrade pip' command.\u001b[0m\n", - "env: no_proxy='a.test.com,127.0.0.1,2.2.2.2'\n", - "Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple\n", - "Collecting mindspore==2.4.0\n", - " Using cached https://ms-release.obs.cn-north-4.myhuaweicloud.com/2.4.0/MindSpore/unified/aarch64/mindspore-2.4.0-cp39-cp39-linux_aarch64.whl (333.7 MB)\n", - "Requirement already satisfied: protobuf>=3.13.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from mindspore==2.4.0) (3.20.2)\n", - "Requirement already satisfied: psutil>=5.6.1 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from mindspore==2.4.0) (5.9.5)\n", - "Requirement already satisfied: astunparse>=1.6.3 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from mindspore==2.4.0) (1.6.3)\n", - "Requirement already satisfied: numpy<2.0.0,>=1.20.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from mindspore==2.4.0) (1.22.0)\n", - "Requirement already satisfied: scipy>=1.5.4 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from mindspore==2.4.0) (1.10.1)\n", - "Requirement already satisfied: pillow>=6.2.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from mindspore==2.4.0) (10.0.1)\n", - "Requirement already satisfied: asttokens>=2.0.4 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from mindspore==2.4.0) (2.4.1)\n", - "Requirement already satisfied: safetensors>=0.4.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from mindspore==2.4.0) (0.4.5)\n", - "Requirement already satisfied: packaging>=20.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from mindspore==2.4.0) (24.1)\n", - "Requirement already satisfied: six>=1.12.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from asttokens>=2.0.4->mindspore==2.4.0) (1.16.0)\n", - "Requirement already satisfied: wheel<1.0,>=0.23.0 in /home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages (from astunparse>=1.6.3->mindspore==2.4.0) (0.38.4)\n", - "\u001b[33mWARNING: You are using pip version 21.0.1; however, version 24.3.1 is available.\n", - "You should consider upgrading via the '/home/ma-user/anaconda3/envs/MindSpore/bin/python -m pip install --upgrade pip' command.\u001b[0m\n", - "Note: you may need to restart the kernel to use updated packages.\n" - ] - } - ], + "outputs": [], "source": [ "#安装mindspore2.4\n", "!pip uninstall mindspore-gpu -y\n", @@ -220,95 +112,10 @@ }, { "cell_type": "code", - "execution_count": 1, - "id": "54e990b4", + "execution_count": null, + "id": "6", "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "[WARNING] GE_ADPT(36162,ffff9d7f40b0,python):2024-12-03-21:20:47.447.323 [mindspore/ccsrc/utils/dlopen_macro.h:163] DlsymAscend] Dynamically load symbol aclmdlBundleGetModelId failed, result = /usr/local/Ascend/ascend-toolkit/latest/lib64/libascendcl.so: undefined symbol: aclmdlBundleGetModelId\n", - "[WARNING] GE_ADPT(36162,ffff9d7f40b0,python):2024-12-03-21:20:47.447.394 [mindspore/ccsrc/utils/dlopen_macro.h:163] DlsymAscend] Dynamically load symbol aclmdlBundleLoadFromMem failed, result = /usr/local/Ascend/ascend-toolkit/latest/lib64/libascendcl.so: undefined symbol: aclmdlBundleLoadFromMem\n", - "[WARNING] GE_ADPT(36162,ffff9d7f40b0,python):2024-12-03-21:20:47.447.413 [mindspore/ccsrc/utils/dlopen_macro.h:163] DlsymAscend] Dynamically load symbol aclmdlBundleUnload failed, result = /usr/local/Ascend/ascend-toolkit/latest/lib64/libascendcl.so: undefined symbol: aclmdlBundleUnload\n", - "[WARNING] GE_ADPT(36162,ffff9d7f40b0,python):2024-12-03-21:20:47.447.594 [mindspore/ccsrc/utils/dlopen_macro.h:163] DlsymAscend] Dynamically load symbol aclrtGetMemUceInfo failed, result = /usr/local/Ascend/ascend-toolkit/latest/lib64/libascendcl.so: undefined symbol: aclrtGetMemUceInfo\n", - "[WARNING] GE_ADPT(36162,ffff9d7f40b0,python):2024-12-03-21:20:47.447.611 [mindspore/ccsrc/utils/dlopen_macro.h:163] DlsymAscend] Dynamically load symbol aclrtDeviceTaskAbort failed, result = /usr/local/Ascend/ascend-toolkit/latest/lib64/libascendcl.so: undefined symbol: aclrtDeviceTaskAbort\n", - "[WARNING] GE_ADPT(36162,ffff9d7f40b0,python):2024-12-03-21:20:47.447.627 [mindspore/ccsrc/utils/dlopen_macro.h:163] DlsymAscend] Dynamically load symbol aclrtMemUceRepair failed, result = /usr/local/Ascend/ascend-toolkit/latest/lib64/libascendcl.so: undefined symbol: aclrtMemUceRepair\n", - "[WARNING] GE_ADPT(36162,ffff9d7f40b0,python):2024-12-03-21:20:47.449.575 [mindspore/ccsrc/utils/dlopen_macro.h:163] DlsymAscend] Dynamically load symbol acltdtCleanChannel failed, result = /usr/local/Ascend/ascend-toolkit/latest/lib64/libacl_tdt_channel.so: undefined symbol: acltdtCleanChannel\n", - "[WARNING] ME(36162:281473324105904,MainProcess):2024-12-03-21:20:47.589.499 [mindspore/run_check/_check_version.py:396] Can not find the tbe operator implementation(need by mindspore-ascend). Please check whether the Environment Variable PYTHONPATH is set. For details, refer to the installation guidelines: https://www.mindspore.cn/install\n", - "/home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages/numpy/core/getlimits.py:499: UserWarning: The value of the smallest subnormal for type is zero.\n", - " setattr(self, word, getattr(machar, word).flat[0])\n", - "/home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages/numpy/core/getlimits.py:89: UserWarning: The value of the smallest subnormal for type is zero.\n", - " return self._float_to_str(self.smallest_subnormal)\n", - "/home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages/numpy/core/getlimits.py:499: UserWarning: The value of the smallest subnormal for type is zero.\n", - " setattr(self, word, getattr(machar, word).flat[0])\n", - "/home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages/numpy/core/getlimits.py:89: UserWarning: The value of the smallest subnormal for type is zero.\n", - " return self._float_to_str(self.smallest_subnormal)\n", - "Building prefix dict from the default dictionary ...\n", - "Loading model from cache /tmp/jieba.cache\n", - "Loading model cost 1.288 seconds.\n", - "Prefix dict has been built successfully.\n", - "/home/ma-user/anaconda3/envs/MindSpore/lib/python3.9/site-packages/mindnlp/transformers/tokenization_utils_base.py:1526: FutureWarning: `clean_up_tokenization_spaces` was not set. It will be set to `True` by default. This behavior will be depracted, and will be then set to `False` by default. \n", - " warnings.warn(\n" - ] - }, - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "6716298ddb8449b38bfaef38c9ca1860", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - " 1%|1 | 7.61M/523M [00:00=1.20.0 (from mindspore==2.3.1)\n", - " Downloading https://pypi.tuna.tsinghua.edu.cn/packages/54/30/c2a907b9443cf42b90c17ad10c1e8fa801975f01cb9764f3f8eb8aea638b/numpy-1.26.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (18.2 MB)\n", - "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m18.2/18.2 MB\u001b[0m \u001b[31m17.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m\n", - "\u001b[?25hCollecting protobuf>=3.13.0 (from mindspore==2.3.1)\n", - " Downloading https://pypi.tuna.tsinghua.edu.cn/packages/23/08/a1ce0415a115c2b703bfa798f06f0e43ca91dbe29d6180bf86a9287b15e2/protobuf-5.28.2-cp38-abi3-manylinux2014_x86_64.whl (316 kB)\n", - "Requirement already satisfied: asttokens>=2.0.4 in /home/ma-user/anaconda3/envs/python-3.9.0/lib/python3.9/site-packages (from mindspore==2.3.1) (2.4.1)\n", - "Collecting pillow>=6.2.0 (from mindspore==2.3.1)\n", - " Downloading https://pypi.tuna.tsinghua.edu.cn/packages/32/3f/c02268d0c6fb6b3958bdda673c17b315c821d97df29ae6969f20fb49388a/pillow-10.4.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.4 MB)\n", - "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m4.4/4.4 MB\u001b[0m \u001b[31m8.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0ma \u001b[36m0:00:01\u001b[0m\n", - "\u001b[?25hCollecting scipy>=1.5.4 (from mindspore==2.3.1)\n", - " Downloading https://pypi.tuna.tsinghua.edu.cn/packages/35/f5/d0ad1a96f80962ba65e2ce1de6a1e59edecd1f0a7b55990ed208848012e0/scipy-1.13.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (38.6 MB)\n", - "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m38.6/38.6 MB\u001b[0m \u001b[31m6.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m\n", - "\u001b[?25hRequirement already satisfied: packaging>=20.0 in /home/ma-user/anaconda3/envs/python-3.9.0/lib/python3.9/site-packages (from mindspore==2.3.1) (24.1)\n", - "Requirement already satisfied: psutil>=5.6.1 in /home/ma-user/anaconda3/envs/python-3.9.0/lib/python3.9/site-packages (from mindspore==2.3.1) (6.0.0)\n", - "Collecting astunparse>=1.6.3 (from mindspore==2.3.1)\n", - " Downloading https://pypi.tuna.tsinghua.edu.cn/packages/2b/03/13dde6512ad7b4557eb792fbcf0c653af6076b81e5941d36ec61f7ce6028/astunparse-1.6.3-py2.py3-none-any.whl (12 kB)\n", - "Requirement already satisfied: six>=1.12.0 in /home/ma-user/anaconda3/envs/python-3.9.0/lib/python3.9/site-packages (from asttokens>=2.0.4->mindspore==2.3.1) (1.16.0)\n", - "Requirement already satisfied: wheel<1.0,>=0.23.0 in /home/ma-user/anaconda3/envs/python-3.9.0/lib/python3.9/site-packages (from astunparse>=1.6.3->mindspore==2.3.1) (0.44.0)\n", - "Installing collected packages: protobuf, pillow, numpy, astunparse, scipy, mindspore\n", - "Successfully installed astunparse-1.6.3 mindspore-2.3.1 numpy-1.26.4 pillow-10.4.0 protobuf-5.28.2 scipy-1.13.1\n" - ] - } - ], + "outputs": [], "source": [ "!pip install https://ms-release.obs.cn-north-4.myhuaweicloud.com/2.3.1/MindSpore/unified/x86_64/mindspore-2.3.1-cp39-cp39-linux_x86_64.whl --trusted-host ms-release.obs.cn-north-4.myhuaweicloud.com -i https://pypi.tuna.tsinghua.edu.cn/simple" ] }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "metadata": { - "scrolled": true, "tags": [] }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Looking in indexes: http://repo.myhuaweicloud.com/repository/pypi/simple\n", - "Collecting mindnlp==0.4.0\n", - " Downloading https://repo.mindspore.cn/mindspore-lab/mindnlp/newest/any/mindnlp-0.4.0-py3-none-any.whl (8.2 MB)\n", - "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m8.2/8.2 MB\u001b[0m \u001b[31m30.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0ma \u001b[36m0:00:01\u001b[0m\n", - "\u001b[?25hRequirement already satisfied: mindspore>=2.2.14 in /home/ma-user/anaconda3/envs/python-3.9.0/lib/python3.9/site-packages (from mindnlp==0.4.0) (2.3.1)\n", - "Collecting tqdm (from mindnlp==0.4.0)\n", - " Downloading http://repo.myhuaweicloud.com/repository/pypi/packages/48/5d/acf5905c36149bbaec41ccf7f2b68814647347b72075ac0b1fe3022fdc73/tqdm-4.66.5-py3-none-any.whl (78 kB)\n", - "Collecting requests (from mindnlp==0.4.0)\n", - " Downloading http://repo.myhuaweicloud.com/repository/pypi/packages/f9/9b/335f9764261e915ed497fcdeb11df5dfd6f7bf257d4a6a2a686d80da4d54/requests-2.32.3-py3-none-any.whl (64 kB)\n", - "Collecting datasets (from mindnlp==0.4.0)\n", - " Downloading http://repo.myhuaweicloud.com/repository/pypi/packages/a5/52/45dab187f03d48c765b94db0464f5c10431756e47ae4cc6a8029a7d57a36/datasets-3.0.0-py3-none-any.whl (474 kB)\n", - "Collecting evaluate (from mindnlp==0.4.0)\n", - " Downloading http://repo.myhuaweicloud.com/repository/pypi/packages/a2/e7/cbca9e2d2590eb9b5aa8f7ebabe1beb1498f9462d2ecede5c9fd9735faaf/evaluate-0.4.3-py3-none-any.whl (84 kB)\n", - "Collecting tokenizers==0.19.1 (from mindnlp==0.4.0)\n", - " Downloading http://repo.myhuaweicloud.com/repository/pypi/packages/0f/cb/8fc733c8f251bac1e5c4ae52458c353b3faa98f41d734c226cad3783da03/tokenizers-0.19.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.6 MB)\n", - "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m3.6/3.6 MB\u001b[0m \u001b[31m34.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", - "\u001b[?25hCollecting safetensors (from mindnlp==0.4.0)\n", - " Downloading http://repo.myhuaweicloud.com/repository/pypi/packages/5d/80/81ba44fc82afbf5ca553913ac49460e325dc5cf00c317b34c14d43ebd76b/safetensors-0.4.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (436 kB)\n", - "Collecting sentencepiece (from mindnlp==0.4.0)\n", - " Downloading http://repo.myhuaweicloud.com/repository/pypi/packages/5f/01/c95e42eb86282b2c79305d3e0b0ca5a743f85a61262bb7130999c70b9374/sentencepiece-0.2.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB)\n", - "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.3/1.3 MB\u001b[0m \u001b[31m52.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", - "\u001b[?25hCollecting regex (from mindnlp==0.4.0)\n", - " Downloading http://repo.myhuaweicloud.com/repository/pypi/packages/01/e6/a7256c99c312b68f01cfd4f8eae6e770906fffb3832ecb66f35ca5b86b96/regex-2024.9.11-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (781 kB)\n", - "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m782.0/782.0 kB\u001b[0m \u001b[31m37.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", - "\u001b[?25hCollecting addict (from mindnlp==0.4.0)\n", - " Downloading http://repo.myhuaweicloud.com/repository/pypi/packages/6a/00/b08f23b7d7e1e14ce01419a467b583edbb93c6cdb8654e54a9cc579cd61f/addict-2.4.0-py3-none-any.whl (3.8 kB)\n", - "Collecting ml-dtypes (from mindnlp==0.4.0)\n", - " Downloading http://repo.myhuaweicloud.com/repository/pypi/packages/a8/6f/49effaafbc24c7665bcea42cacb22e7198bbab5b473d908c5900c6bb6a59/ml_dtypes-0.5.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.5 MB)\n", - "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m4.5/4.5 MB\u001b[0m \u001b[31m44.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", - "\u001b[?25hCollecting pyctcdecode (from mindnlp==0.4.0)\n", - " Downloading http://repo.myhuaweicloud.com/repository/pypi/packages/a5/8a/93e2118411ae5e861d4f4ce65578c62e85d0f1d9cb389bd63bd57130604e/pyctcdecode-0.5.0-py2.py3-none-any.whl (39 kB)\n", - "Collecting jieba (from mindnlp==0.4.0)\n", - " Downloading http://repo.myhuaweicloud.com/repository/pypi/packages/c6/cb/18eeb235f833b726522d7ebed54f2278ce28ba9438e3135ab0278d9792a2/jieba-0.42.1.tar.gz (19.2 MB)\n", - "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m19.2/19.2 MB\u001b[0m \u001b[31m87.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m\n", - "\u001b[?25h Preparing metadata (setup.py) ... \u001b[?25ldone\n", - "\u001b[?25hCollecting pytest==7.2.0 (from mindnlp==0.4.0)\n", - " Downloading http://repo.myhuaweicloud.com/repository/pypi/packages/67/68/a5eb36c3a8540594b6035e6cdae40c1ef1b6a2bfacbecc3d1a544583c078/pytest-7.2.0-py3-none-any.whl (316 kB)\n", - "Collecting attrs>=19.2.0 (from pytest==7.2.0->mindnlp==0.4.0)\n", - " Downloading http://repo.myhuaweicloud.com/repository/pypi/packages/6a/21/5b6702a7f963e95456c0de2d495f67bf5fd62840ac655dc451586d23d39a/attrs-24.2.0-py3-none-any.whl (63 kB)\n", - "Collecting iniconfig (from pytest==7.2.0->mindnlp==0.4.0)\n", - " Downloading http://repo.myhuaweicloud.com/repository/pypi/packages/ef/a6/62565a6e1cf69e10f5727360368e451d4b7f58beeac6173dc9db836a5b46/iniconfig-2.0.0-py3-none-any.whl (5.9 kB)\n", - "Requirement already satisfied: packaging in /home/ma-user/anaconda3/envs/python-3.9.0/lib/python3.9/site-packages (from pytest==7.2.0->mindnlp==0.4.0) (24.1)\n", - "Collecting pluggy<2.0,>=0.12 (from pytest==7.2.0->mindnlp==0.4.0)\n", - " Downloading http://repo.myhuaweicloud.com/repository/pypi/packages/88/5f/e351af9a41f866ac3f1fac4ca0613908d9a41741cfcf2228f4ad853b697d/pluggy-1.5.0-py3-none-any.whl (20 kB)\n", - "Requirement already satisfied: exceptiongroup>=1.0.0rc8 in /home/ma-user/anaconda3/envs/python-3.9.0/lib/python3.9/site-packages (from pytest==7.2.0->mindnlp==0.4.0) (1.2.2)\n", - "Collecting tomli>=1.0.0 (from pytest==7.2.0->mindnlp==0.4.0)\n", - " Downloading http://repo.myhuaweicloud.com/repository/pypi/packages/97/75/10a9ebee3fd790d20926a90a2547f0bf78f371b2f13aa822c759680ca7b9/tomli-2.0.1-py3-none-any.whl (12 kB)\n", - "Collecting huggingface-hub<1.0,>=0.16.4 (from tokenizers==0.19.1->mindnlp==0.4.0)\n", - " Downloading http://repo.myhuaweicloud.com/repository/pypi/packages/d5/ce/1f8e61cd63175cc2e79233b954b1c4e85363c788fb3a1fa23c87a25c9b81/huggingface_hub-0.25.0-py3-none-any.whl (436 kB)\n", - "Requirement already satisfied: numpy<2.0.0,>=1.20.0 in /home/ma-user/anaconda3/envs/python-3.9.0/lib/python3.9/site-packages (from mindspore>=2.2.14->mindnlp==0.4.0) (1.26.4)\n", - "Requirement already satisfied: protobuf>=3.13.0 in /home/ma-user/anaconda3/envs/python-3.9.0/lib/python3.9/site-packages (from mindspore>=2.2.14->mindnlp==0.4.0) (5.28.2)\n", - "Requirement already satisfied: asttokens>=2.0.4 in /home/ma-user/anaconda3/envs/python-3.9.0/lib/python3.9/site-packages (from mindspore>=2.2.14->mindnlp==0.4.0) (2.4.1)\n", - "Requirement already satisfied: pillow>=6.2.0 in /home/ma-user/anaconda3/envs/python-3.9.0/lib/python3.9/site-packages (from mindspore>=2.2.14->mindnlp==0.4.0) (10.4.0)\n", - "Requirement already satisfied: scipy>=1.5.4 in /home/ma-user/anaconda3/envs/python-3.9.0/lib/python3.9/site-packages (from mindspore>=2.2.14->mindnlp==0.4.0) (1.13.1)\n", - "Requirement already satisfied: psutil>=5.6.1 in /home/ma-user/anaconda3/envs/python-3.9.0/lib/python3.9/site-packages (from mindspore>=2.2.14->mindnlp==0.4.0) (6.0.0)\n", - "Requirement already satisfied: astunparse>=1.6.3 in /home/ma-user/anaconda3/envs/python-3.9.0/lib/python3.9/site-packages (from mindspore>=2.2.14->mindnlp==0.4.0) (1.6.3)\n", - "Collecting filelock (from datasets->mindnlp==0.4.0)\n", - " Downloading http://repo.myhuaweicloud.com/repository/pypi/packages/b9/f8/feced7779d755758a52d1f6635d990b8d98dc0a29fa568bbe0625f18fdf3/filelock-3.16.1-py3-none-any.whl (16 kB)\n", - "Collecting pyarrow>=15.0.0 (from datasets->mindnlp==0.4.0)\n", - " Downloading http://repo.myhuaweicloud.com/repository/pypi/packages/af/61/bcd9b58e38ead6ad42b9ed00da33a3f862bc1d445e3d3164799c25550ac2/pyarrow-17.0.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (39.9 MB)\n", - "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m39.9/39.9 MB\u001b[0m \u001b[31m101.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0ma \u001b[36m0:00:01\u001b[0m\n", - "\u001b[?25hCollecting dill<0.3.9,>=0.3.0 (from datasets->mindnlp==0.4.0)\n", - " Downloading http://repo.myhuaweicloud.com/repository/pypi/packages/c9/7a/cef76fd8438a42f96db64ddaa85280485a9c395e7df3db8158cfec1eee34/dill-0.3.8-py3-none-any.whl (116 kB)\n", - "Collecting pandas (from datasets->mindnlp==0.4.0)\n", - " Downloading http://repo.myhuaweicloud.com/repository/pypi/packages/bb/30/f6f1f1ac36250f50c421b1b6af08c35e5a8b5a84385ef928625336b93e6f/pandas-2.2.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (13.1 MB)\n", - "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m13.1/13.1 MB\u001b[0m \u001b[31m58.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m\n", - "\u001b[?25hCollecting xxhash (from datasets->mindnlp==0.4.0)\n", - " Downloading http://repo.myhuaweicloud.com/repository/pypi/packages/b4/b4/332647451ed7d2c021294b7c1e9c144dbb5586b1fb214ad4f5a404642835/xxhash-3.5.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (193 kB)\n", - "Collecting multiprocess (from datasets->mindnlp==0.4.0)\n", - " Downloading http://repo.myhuaweicloud.com/repository/pypi/packages/da/d9/f7f9379981e39b8c2511c9e0326d212accacb82f12fbfdc1aa2ce2a7b2b6/multiprocess-0.70.16-py39-none-any.whl (133 kB)\n", - "Collecting fsspec<=2024.6.1,>=2023.1.0 (from fsspec[http]<=2024.6.1,>=2023.1.0->datasets->mindnlp==0.4.0)\n", - " Downloading http://repo.myhuaweicloud.com/repository/pypi/packages/5e/44/73bea497ac69bafde2ee4269292fa3b41f1198f4bb7bbaaabde30ad29d4a/fsspec-2024.6.1-py3-none-any.whl (177 kB)\n", - "Collecting aiohttp (from datasets->mindnlp==0.4.0)\n", - " Downloading http://repo.myhuaweicloud.com/repository/pypi/packages/23/69/200bf165b56c17854d54975f894de10dababc4d0226c07600c9abc679e7e/aiohttp-3.10.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB)\n", - "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.2/1.2 MB\u001b[0m \u001b[31m51.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", - "\u001b[?25hCollecting pyyaml>=5.1 (from datasets->mindnlp==0.4.0)\n", - " Downloading http://repo.myhuaweicloud.com/repository/pypi/packages/3d/32/e7bd8535d22ea2874cef6a81021ba019474ace0d13a4819c2a4bce79bd6a/PyYAML-6.0.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (737 kB)\n", - "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m737.4/737.4 kB\u001b[0m \u001b[31m33.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", - "\u001b[?25hCollecting charset-normalizer<4,>=2 (from requests->mindnlp==0.4.0)\n", - " Downloading http://repo.myhuaweicloud.com/repository/pypi/packages/98/69/5d8751b4b670d623aa7a47bef061d69c279e9f922f6705147983aa76c3ce/charset_normalizer-3.3.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (142 kB)\n", - "Collecting idna<4,>=2.5 (from requests->mindnlp==0.4.0)\n", - " Downloading http://repo.myhuaweicloud.com/repository/pypi/packages/76/c6/c88e154df9c4e1a2a66ccf0005a88dfb2650c1dffb6f5ce603dfbd452ce3/idna-3.10-py3-none-any.whl (70 kB)\n", - "Collecting urllib3<3,>=1.21.1 (from requests->mindnlp==0.4.0)\n", - " Downloading http://repo.myhuaweicloud.com/repository/pypi/packages/ce/d9/5f4c13cecde62396b0d3fe530a50ccea91e7dfc1ccf0e09c228841bb5ba8/urllib3-2.2.3-py3-none-any.whl (126 kB)\n", - "Collecting certifi>=2017.4.17 (from requests->mindnlp==0.4.0)\n", - " Downloading http://repo.myhuaweicloud.com/repository/pypi/packages/12/90/3c9ff0512038035f59d279fddeb79f5f1eccd8859f06d6163c58798b9487/certifi-2024.8.30-py3-none-any.whl (167 kB)\n", - "Collecting pygtrie<3.0,>=2.1 (from pyctcdecode->mindnlp==0.4.0)\n", - " Downloading http://repo.myhuaweicloud.com/repository/pypi/packages/ec/cd/bd196b2cf014afb1009de8b0f05ecd54011d881944e62763f3c1b1e8ef37/pygtrie-2.5.0-py3-none-any.whl (25 kB)\n", - "Collecting hypothesis<7,>=6.14 (from pyctcdecode->mindnlp==0.4.0)\n", - " Downloading http://repo.myhuaweicloud.com/repository/pypi/packages/5f/25/f1fb5b3ec58ed3c6014385672d4298e2f0c7291bfcd9ffd06627a641470d/hypothesis-6.112.1-py3-none-any.whl (467 kB)\n", - "Requirement already satisfied: six>=1.12.0 in /home/ma-user/anaconda3/envs/python-3.9.0/lib/python3.9/site-packages (from asttokens>=2.0.4->mindspore>=2.2.14->mindnlp==0.4.0) (1.16.0)\n", - "Requirement already satisfied: wheel<1.0,>=0.23.0 in /home/ma-user/anaconda3/envs/python-3.9.0/lib/python3.9/site-packages (from astunparse>=1.6.3->mindspore>=2.2.14->mindnlp==0.4.0) (0.44.0)\n", - "Collecting aiohappyeyeballs>=2.3.0 (from aiohttp->datasets->mindnlp==0.4.0)\n", - " Downloading http://repo.myhuaweicloud.com/repository/pypi/packages/18/b6/58ea188899950d759a837f9a58b2aee1d1a380ea4d6211ce9b1823748851/aiohappyeyeballs-2.4.0-py3-none-any.whl (12 kB)\n", - "Collecting aiosignal>=1.1.2 (from aiohttp->datasets->mindnlp==0.4.0)\n", - " Downloading http://repo.myhuaweicloud.com/repository/pypi/packages/76/ac/a7305707cb852b7e16ff80eaf5692309bde30e2b1100a1fcacdc8f731d97/aiosignal-1.3.1-py3-none-any.whl (7.6 kB)\n", - "Collecting frozenlist>=1.1.1 (from aiohttp->datasets->mindnlp==0.4.0)\n", - " Downloading http://repo.myhuaweicloud.com/repository/pypi/packages/70/b0/6f1ebdabfb604e39a0f84428986b89ab55f246b64cddaa495f2c953e1f6b/frozenlist-1.4.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (240 kB)\n", - "Collecting multidict<7.0,>=4.5 (from aiohttp->datasets->mindnlp==0.4.0)\n", - " Downloading http://repo.myhuaweicloud.com/repository/pypi/packages/5e/41/0d0fb18c1ad574f807196f5f3d99164edf9de3e169a58c6dc2d6ed5742b9/multidict-6.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (124 kB)\n", - "Collecting yarl<2.0,>=1.0 (from aiohttp->datasets->mindnlp==0.4.0)\n", - " Downloading http://repo.myhuaweicloud.com/repository/pypi/packages/ff/be/78953a3d5154b974af49ce367f1a8d4751ababdf26a66ae607b4ae625d99/yarl-1.11.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (453 kB)\n", - "Collecting async-timeout<5.0,>=4.0 (from aiohttp->datasets->mindnlp==0.4.0)\n", - " Downloading http://repo.myhuaweicloud.com/repository/pypi/packages/a7/fa/e01228c2938de91d47b307831c62ab9e4001e747789d0b05baf779a6488c/async_timeout-4.0.3-py3-none-any.whl (5.7 kB)\n", - "Requirement already satisfied: typing-extensions>=3.7.4.3 in /home/ma-user/anaconda3/envs/python-3.9.0/lib/python3.9/site-packages (from huggingface-hub<1.0,>=0.16.4->tokenizers==0.19.1->mindnlp==0.4.0) (4.12.2)\n", - "Collecting sortedcontainers<3.0.0,>=2.1.0 (from hypothesis<7,>=6.14->pyctcdecode->mindnlp==0.4.0)\n", - " Downloading http://repo.myhuaweicloud.com/repository/pypi/packages/32/46/9cb0e58b2deb7f82b84065f37f3bffeb12413f947f9388e4cac22c4621ce/sortedcontainers-2.4.0-py2.py3-none-any.whl (29 kB)\n", - "Requirement already satisfied: python-dateutil>=2.8.2 in /home/ma-user/anaconda3/envs/python-3.9.0/lib/python3.9/site-packages (from pandas->datasets->mindnlp==0.4.0) (2.9.0.post0)\n", - "Collecting pytz>=2020.1 (from pandas->datasets->mindnlp==0.4.0)\n", - " Downloading http://repo.myhuaweicloud.com/repository/pypi/packages/11/c3/005fcca25ce078d2cc29fd559379817424e94885510568bc1bc53d7d5846/pytz-2024.2-py2.py3-none-any.whl (508 kB)\n", - "Collecting tzdata>=2022.7 (from pandas->datasets->mindnlp==0.4.0)\n", - " Downloading http://repo.myhuaweicloud.com/repository/pypi/packages/65/58/f9c9e6be752e9fcb8b6a0ee9fb87e6e7a1f6bcab2cdc73f02bb7ba91ada0/tzdata-2024.1-py2.py3-none-any.whl (345 kB)\n", - "Building wheels for collected packages: jieba\n", - " Building wheel for jieba (setup.py) ... \u001b[?25ldone\n", - "\u001b[?25h Created wheel for jieba: filename=jieba-0.42.1-py3-none-any.whl size=19314458 sha256=de190811901ea689a37a0ecc8e410ef914b6b76740894df9b47c2bdbfd51decc\n", - " Stored in directory: /home/ma-user/.cache/pip/wheels/2d/22/9e/9af7e8c2773513ac75905acfb75073922bcc1aa176f730a0c9\n", - "Successfully built jieba\n", - "Installing collected packages: sortedcontainers, sentencepiece, pytz, pygtrie, jieba, addict, xxhash, urllib3, tzdata, tqdm, tomli, safetensors, regex, pyyaml, pyarrow, pluggy, multidict, ml-dtypes, iniconfig, idna, fsspec, frozenlist, filelock, dill, charset-normalizer, certifi, attrs, async-timeout, aiohappyeyeballs, yarl, requests, pytest, pandas, multiprocess, hypothesis, aiosignal, pyctcdecode, huggingface-hub, aiohttp, tokenizers, datasets, evaluate, mindnlp\n", - "Successfully installed addict-2.4.0 aiohappyeyeballs-2.4.0 aiohttp-3.10.5 aiosignal-1.3.1 async-timeout-4.0.3 attrs-24.2.0 certifi-2024.8.30 charset-normalizer-3.3.2 datasets-3.0.0 dill-0.3.8 evaluate-0.4.3 filelock-3.16.1 frozenlist-1.4.1 fsspec-2024.6.1 huggingface-hub-0.25.0 hypothesis-6.112.1 idna-3.10 iniconfig-2.0.0 jieba-0.42.1 mindnlp-0.4.0 ml-dtypes-0.5.0 multidict-6.1.0 multiprocess-0.70.16 pandas-2.2.2 pluggy-1.5.0 pyarrow-17.0.0 pyctcdecode-0.5.0 pygtrie-2.5.0 pytest-7.2.0 pytz-2024.2 pyyaml-6.0.2 regex-2024.9.11 requests-2.32.3 safetensors-0.4.5 sentencepiece-0.2.0 sortedcontainers-2.4.0 tokenizers-0.19.1 tomli-2.0.1 tqdm-4.66.5 tzdata-2024.1 urllib3-2.2.3 xxhash-3.5.0 yarl-1.11.1\n" - ] - } - ], + "outputs": [], "source": [ "#安装mindnlp的daily包,待正式发布后可改为直接安装mindnlp包\n", "!pip install https://repo.mindspore.cn/mindspore-lab/mindnlp/newest/any/mindnlp-0.4.0-py3-none-any.whl\n", @@ -260,52 +102,18 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Name: mindspore\n", - "Version: 2.3.1\n", - "Summary: MindSpore is a new open source deep learning training/inference framework that could be used for mobile, edge and cloud scenarios.\n", - "Home-page: https://www.mindspore.cn\n", - "Author: The MindSpore Authors\n", - "Author-email: contact@mindspore.cn\n", - "License: Apache 2.0\n", - "Location: /home/ma-user/anaconda3/envs/python-3.9.0/lib/python3.9/site-packages\n", - "Requires: asttokens, astunparse, numpy, packaging, pillow, protobuf, psutil, scipy\n", - "Required-by: mindnlp\n" - ] - } - ], + "outputs": [], "source": [ "!pip show mindspore" ] }, { "cell_type": "code", - "execution_count": 2, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Name: mindnlp\n", - "Version: 0.4.0\n", - "Summary: An open source natural language processing research tool box. Git version: [sha1]:2fb76bf, [branch]: (HEAD, origin/master, origin/HEAD, master)\n", - "Home-page: https://github.com/mindlab-ai/mindnlp/tree/master/\n", - "Author: MindSpore Team\n", - "Author-email: \n", - "License: Apache 2.0\n", - "Location: /home/ma-user/anaconda3/envs/python-3.9.0/lib/python3.9/site-packages\n", - "Requires: addict, datasets, evaluate, jieba, mindspore, ml-dtypes, pyctcdecode, pytest, regex, requests, safetensors, sentencepiece, tokenizers, tqdm\n", - "Required-by: \n" - ] - } - ], + "outputs": [], "source": [ "!pip show mindnlp" ] @@ -330,45 +138,18 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "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", - " 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.753 seconds.\n", - "Prefix dict has been built successfully.\n" - ] - } - ], + "outputs": [], "source": [ "from mindnlp.dataset import load_dataset" ] }, { "cell_type": "code", - "execution_count": 29, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "Repo card metadata block was not found. Setting CardData to empty.\n", - "Downloading data: 100%|██████████| 1.14M/1.14M [00:00<00:00, 1.45MB/s]\n", - "Downloading data: 100%|██████████| 127k/127k [00:00<00:00, 131kB/s] \n", - "Downloading data: 100%|██████████| 533k/533k [00:00<00:00, 666kB/s] \n", - "Generating train split: 3668 examples [00:00, 176571.87 examples/s]\n", - "Generating validation split: 408 examples [00:00, 48980.37 examples/s]\n", - "Generating test split: 1725 examples [00:00, 153982.47 examples/s]\n" - ] - } - ], + "outputs": [], "source": [ "mrpc_dict = load_dataset(\"SetFit/mrpc\") # 如果本地未下载会先下载,若已下载则会直接加载\n", "mrpc_train = mrpc_dict['train']\n", @@ -378,19 +159,9 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "train: 3668 samples\n", - "validation: 408 samples\n", - "test: 1725 samples\n" - ] - } - ], + "outputs": [], "source": [ "# 打印每个数据集的样本数量\n", "for k,v in mrpc_dict.items():\n", @@ -399,21 +170,9 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "text1: Amrozi accused his brother , whom he called \" the witness \" , of deliberately distorting his evidence .\n", - "text2: Referring to him as only \" the witness \" , Amrozi accused his brother of deliberately distorting his evidence .\n", - "label: 1\n", - "idx: 0\n", - "label_text: equivalent\n" - ] - } - ], + "outputs": [], "source": [ "# 打印原数据集的样本格式及其内容\n", "for dataDict in mrpc_train.create_dict_iterator():\n", @@ -424,7 +183,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -483,7 +242,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -522,7 +281,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -606,7 +365,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -649,27 +408,9 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "100%|██████████| 26.0/26.0 [00:00<00:00, 134kB/s]\n", - "0.99MB [00:00, 3.22MB/s]\n", - "446kB [00:00, 1.77MB/s]\n", - "1.29MB [00:00, 4.27MB/s]\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "3\n" - ] - } - ], + "outputs": [], "source": [ "from mindnlp.transformers import GPT2Tokenizer\n", "\n", @@ -686,7 +427,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -706,7 +447,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -718,7 +459,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -730,20 +471,9 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "['input_ids', 'attention_mask', 'token_type_ids', 'lens', 'labels']" - ] - }, - "execution_count": 12, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "train_dataloader.get_col_names() # 数据集样本的列名" ] @@ -764,7 +494,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -787,40 +517,18 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "100%|██████████| 523M/523M [00:32<00:00, 16.7MB/s] \n", - "100%|██████████| 124/124 [00:00<00:00, 365kB/s]\n", - "The following parameters in models are missing parameter:\n", - "['score.weight']\n" - ] - } - ], + "outputs": [], "source": [ "model = GPT2ForSequenceClassification.from_pretrained(\"gpt2\", num_labels = 2)" ] }, { "cell_type": "code", - "execution_count": 16, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "Embedding" - ] - }, - "execution_count": 16, - "metadata": {}, - "output_type": "execute_result" - } - ], + "outputs": [], "source": [ "model.config.pad_token_id = tokenizer.pad_token_id\n", "model.resize_token_embeddings(model.config.vocab_size + num_added_toks)" @@ -835,7 +543,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -845,17 +553,9 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "trainable params: 296,448 || all params: 124,737,792 || trainable%: 0.23765692437461133\n" - ] - } - ], + "outputs": [], "source": [ "if args.is_lora:\n", " # build peft model\n", @@ -867,7 +567,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -878,7 +578,7 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": null, "metadata": {}, "outputs": [], "source": [ @@ -901,107 +601,18 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "The train will start from the checkpoint saved in '.mindnlp/peft_model/mrpc_IA3'.\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "Epoch 0: 100%|██████████| 459/459 [03:05<00:00, 2.47it/s, loss=0.6872016] \n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Checkpoint: 'gpt2_mrpc_finetune_epoch_0.ckpt' has been saved in epoch: 0.\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "Evaluate: 100%|██████████| 51/51 [00:07<00:00, 7.18it/s]\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Evaluate Score: {'Accuracy': 0.6838235294117647}\n", - "---------------Best Model: 'gpt2_mrpc_finetune_best.ckpt' has been saved in epoch: 0.---------------\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "Epoch 1: 100%|██████████| 459/459 [03:04<00:00, 2.49it/s, loss=0.6677042] \n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Checkpoint: 'gpt2_mrpc_finetune_epoch_1.ckpt' has been saved in epoch: 1.\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "Evaluate: 100%|██████████| 51/51 [00:07<00:00, 7.21it/s]\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Evaluate Score: {'Accuracy': 0.6838235294117647}\n", - "Loading best model from '.mindnlp/peft_model/mrpc_IA3' with '['Accuracy']': [0.6838235294117647]...\n", - "---------------The model is already load the best model from 'gpt2_mrpc_finetune_best.ckpt'.---------------\n" - ] - } - ], + "outputs": [], "source": [ "trainer.run(tgt_columns=\"labels\")" ] }, { "cell_type": "code", - "execution_count": 23, + "execution_count": null, "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "Evaluate: 100%|██████████| 216/216 [00:30<00:00, 7.13it/s]" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "Evaluate Score: {'Accuracy': 0.664927536231884}\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "\n" - ] - } - ], + "outputs": [], "source": [ "evaluator = Evaluator(network=model, eval_dataset=test_dataloader, metrics=metric)\n", "evaluator.run(tgt_columns=\"labels\")" diff --git a/README.md b/README.md index cb05d1f..7159a1e 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ ### 课程特色 + - ***探究前沿***:解读技术热点,解构热点模型 - ***应用实践***:理论实践相结合,手把手指导开发 - ***专家解读***:多领域专家,多元解读 @@ -15,18 +16,17 @@ - 新增MindSpore Transformers大模型系列课程 - 新增MindSpore兼容式训练系列课程 - 新增MindSpore大模型推理系列课程 - -### 课程介绍 本**系列课程**理论结合实践深入剖析大模型理论、训练、推理中的关键技术,介绍经典模型的结构设计与创新技术、MindSpore原生大模型训练套件、兼容式大模型训练套件、MindSpore大模型推理套件,课程体系主要包含以下内容: | 课程序号 | 课程名称 | 课程简介 | 视频 | 课件及代码 | |:----:|:---------------------------:|:---------------------------------------------------------------------------------------------------------------------------------------|:----:|:---------------------------------------------------------------------------------------------------:| -| 01 | 大模型理论课程 | 由浅入深地逐步深入大模型技术,以模型为主线介绍经典模型的结构、训练、推理中的创新技术。 | [link](https://www.bilibili.com/video/BV1xs4y1M72q/?spm_id_from=333.999.0.0&vd_source=eb3a45e6eb4dccc5795f97586b78f429) | [link](./01.Industry_Model_Introduction/01.Classic_Model_Technical_Analysis/01.BERT/) | -| 02 | MindSpore Transformers大模型课程 | 基于MindSpore Transformers大模型套件,详细讲解了从环境搭建、预训练、微调至推理部署的大模型全流程开发使用方法,详细讲解了大模型开发迁移、精度对比、性能调优的内容。助力开发者基于MindSpore Transformers进行大模型高阶开发与调优。 | [link](https://www.bilibili.com/video/BV1Gh411w7HC/?spm_id_from=333.999.0.0&vd_source=eb3a45e6eb4dccc5795f97586b78f429) | [link](./01.Industry_Model_Introduction/01.Classic_Model_Technical_Analysis/02.GPT/) | -| 03 | MindSpore兼容式大模型训练课程 | 围绕大模型预训练、微调、强化学习等场景,介绍了基于MindSpeed-Core-MS套件的全流程开发过程,使得学员能够了解MindSpeed-Core-MS相关概念、特性和开发流程,并初步具备在不同场景下大模型训练的能力。 | [link](xxx) |[link](xxx)| -| 04 | MindSpore大模型推理课程 | xxxxx | [link](xxx) |[link](xxx)| +| 01 | 大模型理论课程 | 由浅入深地逐步深入大模型技术,以模型为主线介绍经典模型的结构、训练、推理中的创新技术。 | [link](https://www.bilibili.com/video/BV1xs4y1M72q/?spm_id_from=333.999.0.0&vd_source=eb3a45e6eb4dccc5795f97586b78f429) | [link](./01.Industry_Model_Introduction/01.Classic_Model_Technical_Analysis/01.BERT/) | +| 02 | MindSpore Transformers大模型课程 | 基于MindSpore Transformers大模型套件,详细讲解了从环境搭建、预训练、微调至推理部署的大模型全流程开发使用方法,详细讲解了大模型开发迁移、精度对比、性能调优的内容。助力开发者基于MindSpore Transformers进行大模型高阶开发与调优。 | [link](https://www.bilibili.com/video/BV1Gh411w7HC/?spm_id_from=333.999.0.0&vd_source=eb3a45e6eb4dccc5795f97586b78f429) | [link](./01.Industry_Model_Introduction/01.Classic_Model_Technical_Analysis/02.GPT/) | +| 03 | MindSpore兼容式大模型训练课程 | 围绕大模型预训练、微调、强化学习等场景,介绍了基于MindSpeed-Core-MS套件的全流程开发过程,使得学员能够了解MindSpeed-Core-MS相关概念、特性和开发流程,并初步具备在不同场景下大模型训练的能力。 | [link](xxx) |[link](xxx)| +| 04 | MindSpore大模型推理课程 | xxxxx | [link](xxx) |[link](xxx)| + ## 贡献与反馈 欢迎各位开发者通过 [Issue](https://github.com/mindspore-lab/step_into_llm/issues) 提交建议或 bug 反馈,也可直接发起 [PR](https://github.com/mindspore-lab/step_into_llm/pulls) 进行Bug修复或代码贡献(提交前请参考提交规范,由Committer @username 完成评审合入),你的每一份参与都能让本项目更加完善。 @@ -43,4 +43,4 @@ - \ No newline at end of file +