diff --git "a/\343\200\220\345\274\200\346\272\220\345\256\236\344\271\240\343\200\221RWKV\350\257\276\347\250\213\350\265\204\346\226\231\346\233\264\346\226\260/RWKV.pptx" "b/\343\200\220\345\274\200\346\272\220\345\256\236\344\271\240\343\200\221RWKV\350\257\276\347\250\213\350\265\204\346\226\231\346\233\264\346\226\260/RWKV.pptx" new file mode 100644 index 0000000000000000000000000000000000000000..315ca3abd8d9515d4fc22a923b8303747b4ad888 Binary files /dev/null and "b/\343\200\220\345\274\200\346\272\220\345\256\236\344\271\240\343\200\221RWKV\350\257\276\347\250\213\350\265\204\346\226\231\346\233\264\346\226\260/RWKV.pptx" differ diff --git "a/\343\200\220\345\274\200\346\272\220\345\256\236\344\271\240\343\200\221RWKV\350\257\276\347\250\213\350\265\204\346\226\231\346\233\264\346\226\260/run_rwkv.ipynb" "b/\343\200\220\345\274\200\346\272\220\345\256\236\344\271\240\343\200\221RWKV\350\257\276\347\250\213\350\265\204\346\226\231\346\233\264\346\226\260/run_rwkv.ipynb" new file mode 100644 index 0000000000000000000000000000000000000000..ba9994b6a013a39247e4d9e8fcb55beb6aa2aed9 --- /dev/null +++ "b/\343\200\220\345\274\200\346\272\220\345\256\236\344\271\240\343\200\221RWKV\350\257\276\347\250\213\350\265\204\346\226\231\346\233\264\346\226\260/run_rwkv.ipynb" @@ -0,0 +1,352 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "56a97ac0", + "metadata": {}, + "source": [ + "环境安装 \n" + ] + }, + { + "cell_type": "markdown", + "id": "a7e595f1", + "metadata": {}, + "source": [ + " python 3.9.0 \n", + " mindspore 2.2.14 \n", + " mindnlp 0.4daily " + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "f9b08a2d-26ac-4028-9eb7-87cb1d12d7d1", + "metadata": {}, + "outputs": [], + "source": [ + "%%capture captured_output\n", + "!/home/ma-user/anaconda3/bin/conda create -n python-3.9.0 python=3.9.0 -y --override-channels --channel https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main\n", + "!/home/ma-user/anaconda3/envs/python-3.9.0/bin/pip install ipykernel" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "fff10db6-08d5-4105-8874-353ac2ffca7d", + "metadata": {}, + "outputs": [], + "source": [ + "import json\n", + "import os\n", + "\n", + "data = {\n", + " \"display_name\": \"python-3.9.0\",\n", + " \"env\": {\n", + " \"PATH\": \"/home/ma-user/anaconda3/envs/python-3.9.0/bin:/home/ma-user/anaconda3/envs/python-3.7.10/bin:/modelarts/authoring/notebook-conda/bin:/opt/conda/bin:/usr/local/nvidia/bin:/usr/local/cuda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/ma-user/modelarts/ma-cli/bin:/home/ma-user/modelarts/ma-cli/bin\"\n", + " },\n", + " \"language\": \"python\",\n", + " \"argv\": [\n", + " \"/home/ma-user/anaconda3/envs/python-3.9.0/bin/python\",\n", + " \"-m\",\n", + " \"ipykernel\",\n", + " \"-f\",\n", + " \"{connection_file}\"\n", + " ]\n", + "}\n", + "\n", + "if not os.path.exists(\"/home/ma-user/anaconda3/share/jupyter/kernels/python-3.9.0/\"):\n", + " os.mkdir(\"/home/ma-user/anaconda3/share/jupyter/kernels/python-3.9.0/\")\n", + "\n", + "with open('/home/ma-user/anaconda3/share/jupyter/kernels/python-3.9.0/kernel.json', 'w') as f:\n", + " json.dump(data, f, indent=4)" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "id": "da946ffb-f044-4877-ac13-e15de024dd49", + "metadata": {}, + "outputs": [], + "source": [ + "%%capture captured_output\n", + "\n", + "!pip install https://ms-release.obs.cn-north-4.myhuaweicloud.com/2.2.14/MindSpore/unified/x86_64/mindspore-2.2.14-cp39-cp39-linux_x86_64.whl --trusted-host ms-release.obs.cn-north-4.myhuaweicloud.com -i https://pypi.tuna.tsinghua.edu.cn/simple\n", + "# 0.4 daily 网址:https://repo.mindspore.cn/mindspore-lab/mindnlp/newest/any/\n", + "!pip install mindnlp-0.4.0-py3-none-any.whl\n", + "!pip install ipywidgets -i https://pypi.tuna.tsinghua.edu.cn/simple" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "f300d660-4cbe-4c87-8c6f-cafbab7f1c27", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "env: HF_ENDPOINT=https://hf-mirror.com\n" + ] + } + ], + "source": [ + "%env HF_ENDPOINT=https://hf-mirror.com" + ] + }, + { + "cell_type": "markdown", + "id": "72e5ecd2", + "metadata": {}, + "source": [ + "示例测试运行" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "93231ee6-5fbd-4ed8-b0a2-a222f16b5327", + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "Building prefix dict from the default dictionary ...\n", + "Dumping model to file cache /tmp/jieba.cache\n", + "Loading model cost 0.782 seconds.\n", + "Prefix dict has been built successfully.\n" + ] + } + ], + "source": [ + "import mindspore\n", + "from mindnlp.transformers import RwkvForCausalLM, AutoTokenizer" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "f490cd8a-948e-4c1d-bb6e-8223e3389402", + "metadata": {}, + "outputs": [], + "source": [ + "expected_output = \"Hello my name is Jasmine and I am a newbie to the\"" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "c14a2b61-cb45-4c5a-bd15-03f8d88abc91", + "metadata": {}, + "outputs": [], + "source": [ + "model_id = \"RWKV/rwkv-4-169m-pile\"" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "id": "f80ccca8-f659-470f-8870-435ad29acf2b", + "metadata": {}, + "outputs": [ + { + "data": { + "application/vnd.jupyter.widget-view+json": { + "model_id": "6bd7d8931181452394ff4a60811ede70", + "version_major": 2, + "version_minor": 0 + }, + "text/plain": [ + " 0%| | 0.00/264 [00:00