{ "cells": [ { "cell_type": "markdown", "id": "531467a2-5160-4073-a990-0d81d574b014", "metadata": {}, "source": [ "## (1) Load model" ] }, { "cell_type": "code", "execution_count": 1, "id": "621ebeea-475a-4917-af01-22b1ec948075", "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": "code", "execution_count": 3, "id": "cac008ac-d314-4ebe-a3d4-f9454d7e3614", "metadata": { "scrolled": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple\n", "Collecting einops\n", " Downloading https://pypi.tuna.tsinghua.edu.cn/packages/44/5a/f0b9ad6c0a9017e62d4735daaeb11ba3b6c009d69a26141b258cd37b5588/einops-0.8.0-py3-none-any.whl (43 kB)\n", "\u001b[2K \u001b[38;2;114;156;31m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m43.2/43.2 kB\u001b[0m \u001b[31m395.8 kB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0mm eta \u001b[36m-:--:--\u001b[0m\n", "\u001b[?25hInstalling collected packages: einops\n", "Successfully installed einops-0.8.0\n", "Note: you may need to restart the kernel to use updated packages.\n" ] } ], "source": [ "%pip install einops" ] }, { "cell_type": "code", "execution_count": 4, "id": "d9337043-4e7a-4b20-9d89-6c6257245334", "metadata": {}, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "570f0993fa46465d8866e3190fde4a0e", "version_major": 2, "version_minor": 0 }, "text/plain": [ "config.json: 0%| | 0.00/200 [00:00Q:\n", "\n", "Error creating an EntityManager instance in JavaEE 7\n", "\n", "This is\n" ] } ], "source": [ "print(generate(model, tokenizer, 'The meaning of life is '))" ] }, { "cell_type": "code", "execution_count": 11, "id": "2b189e6e-6a96-4770-88cf-7c5de22cb321", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "def reverse_string(text, result):\n", " # find the position of the start of the string.\n", " start = text.index(text[0:-1])\n", " # find the position where the string begins changing.\n", " end = text.index\n" ] } ], "source": [ "print(generate(model, tokenizer, 'def reverse_string('))" ] }, { "cell_type": "raw", "id": "be40cccb-e0e3-40ca-ac87-90249f1bbe3f", "metadata": {}, "source": [ "我感觉mamba速度还是赶rwkv差了不少,340m参数的模型,不及rwkv-1b6参数量的模型快" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.5" } }, "nbformat": 4, "nbformat_minor": 5 }