|
@@ -1,728 +0,0 @@
|
|
|
-{
|
|
|
- "cells": [
|
|
|
- {
|
|
|
- "cell_type": "code",
|
|
|
- "execution_count": 3,
|
|
|
- "id": "0fccdeda-60db-4ac0-bbb0-98d4d5577a40",
|
|
|
- "metadata": {},
|
|
|
- "outputs": [],
|
|
|
- "source": [
|
|
|
- "#!pip install replicate"
|
|
|
- ]
|
|
|
- },
|
|
|
- {
|
|
|
- "cell_type": "code",
|
|
|
- "execution_count": 18,
|
|
|
- "id": "69395317-ad78-47b6-a533-2e8a01313e82",
|
|
|
- "metadata": {},
|
|
|
- "outputs": [],
|
|
|
- "source": [
|
|
|
- "SYSTEMP_PROMPT = \"\"\"\n",
|
|
|
- "You are the most skilled podcast writer, you have won multiple podcast awards for your writing.\n",
|
|
|
- " \n",
|
|
|
- "Your job is to write word by word, even \"umm, hmmm, right\" interruptions by the second speaker based on the PDF upload. Keep it extremely engaging, the speakers can get derailed now and then but should discuss the topic. \n",
|
|
|
- "\n",
|
|
|
- "Remember Speaker 2 is new to the topic and the conversation should always have realistic anecdotes and analogies sprinkled throughout. The questions should have real world example follow ups etc\n",
|
|
|
- "\n",
|
|
|
- "Speaker 1: Leads the conversation and teaches the speaker 2, gives incredible anecdotes and analogies when explaining. Is a captivating teacher that gives great anecdotes\n",
|
|
|
- "\n",
|
|
|
- "Speaker 2: Keeps the conversation on track by asking follow up questions. Gets super excited or confused when asking questions. Is a curious mindset that asks very interesting confirmation questions\n",
|
|
|
- "\n",
|
|
|
- "Make sure the tangents speaker 2 provides are quite wild or interesting. \n",
|
|
|
- "\n",
|
|
|
- "Ensure there are interruptions during explanations or there are \"hmm\" and \"umm\" injected throughout from the second speaker. \n",
|
|
|
- "\n",
|
|
|
- "It should be a real podcast with every fine nuance documented in as much detail as possible. Welcome the listeners with a super fun overview and keep it really catchy and almost borderline click bait\n",
|
|
|
- "\"\"\""
|
|
|
- ]
|
|
|
- },
|
|
|
- {
|
|
|
- "cell_type": "code",
|
|
|
- "execution_count": 19,
|
|
|
- "id": "08c30139-ff2f-4203-8194-d1b5c50acac5",
|
|
|
- "metadata": {},
|
|
|
- "outputs": [],
|
|
|
- "source": [
|
|
|
- "DEFAULT_MODEL = \"meta-llama/Llama-3.1-70B-Instruct\""
|
|
|
- ]
|
|
|
- },
|
|
|
- {
|
|
|
- "cell_type": "code",
|
|
|
- "execution_count": 20,
|
|
|
- "id": "1641060a-d86d-4137-bbbc-ab05cbb1a888",
|
|
|
- "metadata": {},
|
|
|
- "outputs": [],
|
|
|
- "source": [
|
|
|
- "# Import necessary libraries\n",
|
|
|
- "import torch\n",
|
|
|
- "from accelerate import Accelerator\n",
|
|
|
- "from transformers import AutoModelForCausalLM, AutoTokenizer\n",
|
|
|
- "\n",
|
|
|
- "from tqdm.notebook import tqdm\n",
|
|
|
- "import warnings\n",
|
|
|
- "\n",
|
|
|
- "warnings.filterwarnings('ignore')"
|
|
|
- ]
|
|
|
- },
|
|
|
- {
|
|
|
- "cell_type": "code",
|
|
|
- "execution_count": 21,
|
|
|
- "id": "522fbf7f-8c00-412c-90c7-5cfe2fc94e4c",
|
|
|
- "metadata": {},
|
|
|
- "outputs": [],
|
|
|
- "source": [
|
|
|
- "def read_file_to_string(filename):\n",
|
|
|
- " try:\n",
|
|
|
- " with open(filename, 'r') as file:\n",
|
|
|
- " content = file.read()\n",
|
|
|
- " return content\n",
|
|
|
- " except FileNotFoundError:\n",
|
|
|
- " print(f\"Error: File '{filename}' not found.\")\n",
|
|
|
- " return None\n",
|
|
|
- " except IOError:\n",
|
|
|
- " print(f\"Error: Could not read file '{filename}'.\")\n",
|
|
|
- " return None"
|
|
|
- ]
|
|
|
- },
|
|
|
- {
|
|
|
- "cell_type": "code",
|
|
|
- "execution_count": 26,
|
|
|
- "id": "8119803c-18f9-47cb-b719-2b34ccc5cc41",
|
|
|
- "metadata": {},
|
|
|
- "outputs": [],
|
|
|
- "source": [
|
|
|
- "INPUT_PROMPT = read_file_to_string('./clean_extracted_text.txt')"
|
|
|
- ]
|
|
|
- },
|
|
|
- {
|
|
|
- "cell_type": "code",
|
|
|
- "execution_count": 27,
|
|
|
- "id": "d895ed4f-1f3e-48b4-b7e2-b51d214fd6fb",
|
|
|
- "metadata": {},
|
|
|
- "outputs": [],
|
|
|
- "source": [
|
|
|
- "conversation = [\n",
|
|
|
- " {\"role\": \"system\", \"content\": SYSTEMP_PROMPT},\n",
|
|
|
- " {\"role\": \"user\", \"content\": INPUT_PROMPT},\n",
|
|
|
- " ]"
|
|
|
- ]
|
|
|
- },
|
|
|
- {
|
|
|
- "cell_type": "code",
|
|
|
- "execution_count": 25,
|
|
|
- "id": "e9753245-dfd8-4eb4-b1f4-219723884d9f",
|
|
|
- "metadata": {},
|
|
|
- "outputs": [
|
|
|
- {
|
|
|
- "data": {
|
|
|
- "application/vnd.jupyter.widget-view+json": {
|
|
|
- "model_id": "3ee94e15d1a04e88a6f5ebff149e2e98",
|
|
|
- "version_major": 2,
|
|
|
- "version_minor": 0
|
|
|
- },
|
|
|
- "text/plain": [
|
|
|
- "config.json: 0%| | 0.00/855 [00:00<?, ?B/s]"
|
|
|
- ]
|
|
|
- },
|
|
|
- "metadata": {},
|
|
|
- "output_type": "display_data"
|
|
|
- },
|
|
|
- {
|
|
|
- "data": {
|
|
|
- "application/vnd.jupyter.widget-view+json": {
|
|
|
- "model_id": "8522222de2eb4877a6a2087cc05ad130",
|
|
|
- "version_major": 2,
|
|
|
- "version_minor": 0
|
|
|
- },
|
|
|
- "text/plain": [
|
|
|
- "model.safetensors.index.json: 0%| | 0.00/59.6k [00:00<?, ?B/s]"
|
|
|
- ]
|
|
|
- },
|
|
|
- "metadata": {},
|
|
|
- "output_type": "display_data"
|
|
|
- },
|
|
|
- {
|
|
|
- "data": {
|
|
|
- "application/vnd.jupyter.widget-view+json": {
|
|
|
- "model_id": "0852ae52bfef44c1bc487e7f0951826f",
|
|
|
- "version_major": 2,
|
|
|
- "version_minor": 0
|
|
|
- },
|
|
|
- "text/plain": [
|
|
|
- "Downloading shards: 0%| | 0/30 [00:00<?, ?it/s]"
|
|
|
- ]
|
|
|
- },
|
|
|
- "metadata": {},
|
|
|
- "output_type": "display_data"
|
|
|
- },
|
|
|
- {
|
|
|
- "data": {
|
|
|
- "application/vnd.jupyter.widget-view+json": {
|
|
|
- "model_id": "337fe09b152d4d8fb90a579a7b22554d",
|
|
|
- "version_major": 2,
|
|
|
- "version_minor": 0
|
|
|
- },
|
|
|
- "text/plain": [
|
|
|
- "model-00001-of-00030.safetensors: 0%| | 0.00/4.58G [00:00<?, ?B/s]"
|
|
|
- ]
|
|
|
- },
|
|
|
- "metadata": {},
|
|
|
- "output_type": "display_data"
|
|
|
- },
|
|
|
- {
|
|
|
- "data": {
|
|
|
- "application/vnd.jupyter.widget-view+json": {
|
|
|
- "model_id": "9dd0369f649247d89714134fca62deea",
|
|
|
- "version_major": 2,
|
|
|
- "version_minor": 0
|
|
|
- },
|
|
|
- "text/plain": [
|
|
|
- "model-00002-of-00030.safetensors: 0%| | 0.00/4.66G [00:00<?, ?B/s]"
|
|
|
- ]
|
|
|
- },
|
|
|
- "metadata": {},
|
|
|
- "output_type": "display_data"
|
|
|
- },
|
|
|
- {
|
|
|
- "data": {
|
|
|
- "application/vnd.jupyter.widget-view+json": {
|
|
|
- "model_id": "2e428d6b4af540d7b6eea54e6595f55c",
|
|
|
- "version_major": 2,
|
|
|
- "version_minor": 0
|
|
|
- },
|
|
|
- "text/plain": [
|
|
|
- "model-00003-of-00030.safetensors: 0%| | 0.00/5.00G [00:00<?, ?B/s]"
|
|
|
- ]
|
|
|
- },
|
|
|
- "metadata": {},
|
|
|
- "output_type": "display_data"
|
|
|
- },
|
|
|
- {
|
|
|
- "data": {
|
|
|
- "application/vnd.jupyter.widget-view+json": {
|
|
|
- "model_id": "d2a2b3878e014d269d80509cc4e4edec",
|
|
|
- "version_major": 2,
|
|
|
- "version_minor": 0
|
|
|
- },
|
|
|
- "text/plain": [
|
|
|
- "model-00004-of-00030.safetensors: 0%| | 0.00/4.97G [00:00<?, ?B/s]"
|
|
|
- ]
|
|
|
- },
|
|
|
- "metadata": {},
|
|
|
- "output_type": "display_data"
|
|
|
- },
|
|
|
- {
|
|
|
- "data": {
|
|
|
- "application/vnd.jupyter.widget-view+json": {
|
|
|
- "model_id": "8b5a80f517e64d1d9e10cefa72a44a5f",
|
|
|
- "version_major": 2,
|
|
|
- "version_minor": 0
|
|
|
- },
|
|
|
- "text/plain": [
|
|
|
- "model-00005-of-00030.safetensors: 0%| | 0.00/4.66G [00:00<?, ?B/s]"
|
|
|
- ]
|
|
|
- },
|
|
|
- "metadata": {},
|
|
|
- "output_type": "display_data"
|
|
|
- },
|
|
|
- {
|
|
|
- "data": {
|
|
|
- "application/vnd.jupyter.widget-view+json": {
|
|
|
- "model_id": "42f21ca77fe340228f5e58ca0a479750",
|
|
|
- "version_major": 2,
|
|
|
- "version_minor": 0
|
|
|
- },
|
|
|
- "text/plain": [
|
|
|
- "model-00006-of-00030.safetensors: 0%| | 0.00/4.66G [00:00<?, ?B/s]"
|
|
|
- ]
|
|
|
- },
|
|
|
- "metadata": {},
|
|
|
- "output_type": "display_data"
|
|
|
- },
|
|
|
- {
|
|
|
- "data": {
|
|
|
- "application/vnd.jupyter.widget-view+json": {
|
|
|
- "model_id": "b35ef602eed74020b44c06f8c3f829b6",
|
|
|
- "version_major": 2,
|
|
|
- "version_minor": 0
|
|
|
- },
|
|
|
- "text/plain": [
|
|
|
- "model-00007-of-00030.safetensors: 0%| | 0.00/4.66G [00:00<?, ?B/s]"
|
|
|
- ]
|
|
|
- },
|
|
|
- "metadata": {},
|
|
|
- "output_type": "display_data"
|
|
|
- },
|
|
|
- {
|
|
|
- "data": {
|
|
|
- "application/vnd.jupyter.widget-view+json": {
|
|
|
- "model_id": "3f94a8721bf44c61aefd38975c8ed29e",
|
|
|
- "version_major": 2,
|
|
|
- "version_minor": 0
|
|
|
- },
|
|
|
- "text/plain": [
|
|
|
- "model-00008-of-00030.safetensors: 0%| | 0.00/5.00G [00:00<?, ?B/s]"
|
|
|
- ]
|
|
|
- },
|
|
|
- "metadata": {},
|
|
|
- "output_type": "display_data"
|
|
|
- },
|
|
|
- {
|
|
|
- "data": {
|
|
|
- "application/vnd.jupyter.widget-view+json": {
|
|
|
- "model_id": "8abe061e491a40cdb3c42bf07a73c645",
|
|
|
- "version_major": 2,
|
|
|
- "version_minor": 0
|
|
|
- },
|
|
|
- "text/plain": [
|
|
|
- "model-00009-of-00030.safetensors: 0%| | 0.00/4.97G [00:00<?, ?B/s]"
|
|
|
- ]
|
|
|
- },
|
|
|
- "metadata": {},
|
|
|
- "output_type": "display_data"
|
|
|
- },
|
|
|
- {
|
|
|
- "data": {
|
|
|
- "application/vnd.jupyter.widget-view+json": {
|
|
|
- "model_id": "b473d57e0fe64cc9a77b3516fdbfed70",
|
|
|
- "version_major": 2,
|
|
|
- "version_minor": 0
|
|
|
- },
|
|
|
- "text/plain": [
|
|
|
- "model-00010-of-00030.safetensors: 0%| | 0.00/4.66G [00:00<?, ?B/s]"
|
|
|
- ]
|
|
|
- },
|
|
|
- "metadata": {},
|
|
|
- "output_type": "display_data"
|
|
|
- },
|
|
|
- {
|
|
|
- "data": {
|
|
|
- "application/vnd.jupyter.widget-view+json": {
|
|
|
- "model_id": "e3c0a69348074c62a1a2275fb261daf4",
|
|
|
- "version_major": 2,
|
|
|
- "version_minor": 0
|
|
|
- },
|
|
|
- "text/plain": [
|
|
|
- "model-00011-of-00030.safetensors: 0%| | 0.00/4.66G [00:00<?, ?B/s]"
|
|
|
- ]
|
|
|
- },
|
|
|
- "metadata": {},
|
|
|
- "output_type": "display_data"
|
|
|
- },
|
|
|
- {
|
|
|
- "data": {
|
|
|
- "application/vnd.jupyter.widget-view+json": {
|
|
|
- "model_id": "a1980c5050dd4756975bce80e3a9ec06",
|
|
|
- "version_major": 2,
|
|
|
- "version_minor": 0
|
|
|
- },
|
|
|
- "text/plain": [
|
|
|
- "model-00012-of-00030.safetensors: 0%| | 0.00/4.66G [00:00<?, ?B/s]"
|
|
|
- ]
|
|
|
- },
|
|
|
- "metadata": {},
|
|
|
- "output_type": "display_data"
|
|
|
- },
|
|
|
- {
|
|
|
- "data": {
|
|
|
- "application/vnd.jupyter.widget-view+json": {
|
|
|
- "model_id": "1893e6e54598498f8a8765614d93bfe5",
|
|
|
- "version_major": 2,
|
|
|
- "version_minor": 0
|
|
|
- },
|
|
|
- "text/plain": [
|
|
|
- "model-00013-of-00030.safetensors: 0%| | 0.00/5.00G [00:00<?, ?B/s]"
|
|
|
- ]
|
|
|
- },
|
|
|
- "metadata": {},
|
|
|
- "output_type": "display_data"
|
|
|
- },
|
|
|
- {
|
|
|
- "data": {
|
|
|
- "application/vnd.jupyter.widget-view+json": {
|
|
|
- "model_id": "1ca56f17fa3b4c9ca25aaf998c0fcf34",
|
|
|
- "version_major": 2,
|
|
|
- "version_minor": 0
|
|
|
- },
|
|
|
- "text/plain": [
|
|
|
- "model-00014-of-00030.safetensors: 0%| | 0.00/4.97G [00:00<?, ?B/s]"
|
|
|
- ]
|
|
|
- },
|
|
|
- "metadata": {},
|
|
|
- "output_type": "display_data"
|
|
|
- },
|
|
|
- {
|
|
|
- "data": {
|
|
|
- "application/vnd.jupyter.widget-view+json": {
|
|
|
- "model_id": "82e40953ca7849069d2c6abf48f7da05",
|
|
|
- "version_major": 2,
|
|
|
- "version_minor": 0
|
|
|
- },
|
|
|
- "text/plain": [
|
|
|
- "model-00015-of-00030.safetensors: 0%| | 0.00/4.66G [00:00<?, ?B/s]"
|
|
|
- ]
|
|
|
- },
|
|
|
- "metadata": {},
|
|
|
- "output_type": "display_data"
|
|
|
- },
|
|
|
- {
|
|
|
- "data": {
|
|
|
- "application/vnd.jupyter.widget-view+json": {
|
|
|
- "model_id": "abada8dbafd14afcb725e7d5e82636d0",
|
|
|
- "version_major": 2,
|
|
|
- "version_minor": 0
|
|
|
- },
|
|
|
- "text/plain": [
|
|
|
- "model-00016-of-00030.safetensors: 0%| | 0.00/4.66G [00:00<?, ?B/s]"
|
|
|
- ]
|
|
|
- },
|
|
|
- "metadata": {},
|
|
|
- "output_type": "display_data"
|
|
|
- },
|
|
|
- {
|
|
|
- "data": {
|
|
|
- "application/vnd.jupyter.widget-view+json": {
|
|
|
- "model_id": "1418a6bc716d4ede964bee4d5e08ad6c",
|
|
|
- "version_major": 2,
|
|
|
- "version_minor": 0
|
|
|
- },
|
|
|
- "text/plain": [
|
|
|
- "model-00017-of-00030.safetensors: 0%| | 0.00/4.66G [00:00<?, ?B/s]"
|
|
|
- ]
|
|
|
- },
|
|
|
- "metadata": {},
|
|
|
- "output_type": "display_data"
|
|
|
- },
|
|
|
- {
|
|
|
- "data": {
|
|
|
- "application/vnd.jupyter.widget-view+json": {
|
|
|
- "model_id": "cc5968b03fa64c17bcaa0b83ecd193cc",
|
|
|
- "version_major": 2,
|
|
|
- "version_minor": 0
|
|
|
- },
|
|
|
- "text/plain": [
|
|
|
- "model-00018-of-00030.safetensors: 0%| | 0.00/5.00G [00:00<?, ?B/s]"
|
|
|
- ]
|
|
|
- },
|
|
|
- "metadata": {},
|
|
|
- "output_type": "display_data"
|
|
|
- },
|
|
|
- {
|
|
|
- "data": {
|
|
|
- "application/vnd.jupyter.widget-view+json": {
|
|
|
- "model_id": "03cf0008853a413fbefdb7469f4238d7",
|
|
|
- "version_major": 2,
|
|
|
- "version_minor": 0
|
|
|
- },
|
|
|
- "text/plain": [
|
|
|
- "model-00019-of-00030.safetensors: 0%| | 0.00/4.97G [00:00<?, ?B/s]"
|
|
|
- ]
|
|
|
- },
|
|
|
- "metadata": {},
|
|
|
- "output_type": "display_data"
|
|
|
- },
|
|
|
- {
|
|
|
- "data": {
|
|
|
- "application/vnd.jupyter.widget-view+json": {
|
|
|
- "model_id": "3477ef3422434df49e633fb46b7bd7b1",
|
|
|
- "version_major": 2,
|
|
|
- "version_minor": 0
|
|
|
- },
|
|
|
- "text/plain": [
|
|
|
- "model-00020-of-00030.safetensors: 0%| | 0.00/4.66G [00:00<?, ?B/s]"
|
|
|
- ]
|
|
|
- },
|
|
|
- "metadata": {},
|
|
|
- "output_type": "display_data"
|
|
|
- },
|
|
|
- {
|
|
|
- "data": {
|
|
|
- "application/vnd.jupyter.widget-view+json": {
|
|
|
- "model_id": "28d2912323bf4f1cb29883655494f56e",
|
|
|
- "version_major": 2,
|
|
|
- "version_minor": 0
|
|
|
- },
|
|
|
- "text/plain": [
|
|
|
- "model-00021-of-00030.safetensors: 0%| | 0.00/4.66G [00:00<?, ?B/s]"
|
|
|
- ]
|
|
|
- },
|
|
|
- "metadata": {},
|
|
|
- "output_type": "display_data"
|
|
|
- },
|
|
|
- {
|
|
|
- "data": {
|
|
|
- "application/vnd.jupyter.widget-view+json": {
|
|
|
- "model_id": "04cf278b908f470797c3d23072ec96b5",
|
|
|
- "version_major": 2,
|
|
|
- "version_minor": 0
|
|
|
- },
|
|
|
- "text/plain": [
|
|
|
- "model-00022-of-00030.safetensors: 0%| | 0.00/4.66G [00:00<?, ?B/s]"
|
|
|
- ]
|
|
|
- },
|
|
|
- "metadata": {},
|
|
|
- "output_type": "display_data"
|
|
|
- },
|
|
|
- {
|
|
|
- "data": {
|
|
|
- "application/vnd.jupyter.widget-view+json": {
|
|
|
- "model_id": "242b1b426d8043c89ab2068f65fd22d2",
|
|
|
- "version_major": 2,
|
|
|
- "version_minor": 0
|
|
|
- },
|
|
|
- "text/plain": [
|
|
|
- "model-00023-of-00030.safetensors: 0%| | 0.00/5.00G [00:00<?, ?B/s]"
|
|
|
- ]
|
|
|
- },
|
|
|
- "metadata": {},
|
|
|
- "output_type": "display_data"
|
|
|
- },
|
|
|
- {
|
|
|
- "data": {
|
|
|
- "application/vnd.jupyter.widget-view+json": {
|
|
|
- "model_id": "068e90118c17466c998732d2e9262c01",
|
|
|
- "version_major": 2,
|
|
|
- "version_minor": 0
|
|
|
- },
|
|
|
- "text/plain": [
|
|
|
- "model-00024-of-00030.safetensors: 0%| | 0.00/4.97G [00:00<?, ?B/s]"
|
|
|
- ]
|
|
|
- },
|
|
|
- "metadata": {},
|
|
|
- "output_type": "display_data"
|
|
|
- },
|
|
|
- {
|
|
|
- "data": {
|
|
|
- "application/vnd.jupyter.widget-view+json": {
|
|
|
- "model_id": "7edb872c32a54b87b7d332380e52609f",
|
|
|
- "version_major": 2,
|
|
|
- "version_minor": 0
|
|
|
- },
|
|
|
- "text/plain": [
|
|
|
- "model-00025-of-00030.safetensors: 0%| | 0.00/4.66G [00:00<?, ?B/s]"
|
|
|
- ]
|
|
|
- },
|
|
|
- "metadata": {},
|
|
|
- "output_type": "display_data"
|
|
|
- },
|
|
|
- {
|
|
|
- "data": {
|
|
|
- "application/vnd.jupyter.widget-view+json": {
|
|
|
- "model_id": "6ae0395a5a2c427c99be982f1e4219ee",
|
|
|
- "version_major": 2,
|
|
|
- "version_minor": 0
|
|
|
- },
|
|
|
- "text/plain": [
|
|
|
- "model-00026-of-00030.safetensors: 0%| | 0.00/4.66G [00:00<?, ?B/s]"
|
|
|
- ]
|
|
|
- },
|
|
|
- "metadata": {},
|
|
|
- "output_type": "display_data"
|
|
|
- },
|
|
|
- {
|
|
|
- "data": {
|
|
|
- "application/vnd.jupyter.widget-view+json": {
|
|
|
- "model_id": "b61147d350de4664bb4b9503fff64c24",
|
|
|
- "version_major": 2,
|
|
|
- "version_minor": 0
|
|
|
- },
|
|
|
- "text/plain": [
|
|
|
- "model-00027-of-00030.safetensors: 0%| | 0.00/4.66G [00:00<?, ?B/s]"
|
|
|
- ]
|
|
|
- },
|
|
|
- "metadata": {},
|
|
|
- "output_type": "display_data"
|
|
|
- },
|
|
|
- {
|
|
|
- "data": {
|
|
|
- "application/vnd.jupyter.widget-view+json": {
|
|
|
- "model_id": "3ce42250ba79420ea919d13ad810aeef",
|
|
|
- "version_major": 2,
|
|
|
- "version_minor": 0
|
|
|
- },
|
|
|
- "text/plain": [
|
|
|
- "model-00028-of-00030.safetensors: 0%| | 0.00/5.00G [00:00<?, ?B/s]"
|
|
|
- ]
|
|
|
- },
|
|
|
- "metadata": {},
|
|
|
- "output_type": "display_data"
|
|
|
- },
|
|
|
- {
|
|
|
- "data": {
|
|
|
- "application/vnd.jupyter.widget-view+json": {
|
|
|
- "model_id": "53255416182b4eefbc8bed8c10ba7fe2",
|
|
|
- "version_major": 2,
|
|
|
- "version_minor": 0
|
|
|
- },
|
|
|
- "text/plain": [
|
|
|
- "model-00029-of-00030.safetensors: 0%| | 0.00/4.97G [00:00<?, ?B/s]"
|
|
|
- ]
|
|
|
- },
|
|
|
- "metadata": {},
|
|
|
- "output_type": "display_data"
|
|
|
- },
|
|
|
- {
|
|
|
- "data": {
|
|
|
- "application/vnd.jupyter.widget-view+json": {
|
|
|
- "model_id": "ebf8e0ed2f4d4d64964643723e70b745",
|
|
|
- "version_major": 2,
|
|
|
- "version_minor": 0
|
|
|
- },
|
|
|
- "text/plain": [
|
|
|
- "model-00030-of-00030.safetensors: 0%| | 0.00/2.10G [00:00<?, ?B/s]"
|
|
|
- ]
|
|
|
- },
|
|
|
- "metadata": {},
|
|
|
- "output_type": "display_data"
|
|
|
- },
|
|
|
- {
|
|
|
- "data": {
|
|
|
- "application/vnd.jupyter.widget-view+json": {
|
|
|
- "model_id": "5491aa5c1fc44bfab0265439207d4c2d",
|
|
|
- "version_major": 2,
|
|
|
- "version_minor": 0
|
|
|
- },
|
|
|
- "text/plain": [
|
|
|
- "Loading checkpoint shards: 0%| | 0/30 [00:00<?, ?it/s]"
|
|
|
- ]
|
|
|
- },
|
|
|
- "metadata": {},
|
|
|
- "output_type": "display_data"
|
|
|
- },
|
|
|
- {
|
|
|
- "data": {
|
|
|
- "application/vnd.jupyter.widget-view+json": {
|
|
|
- "model_id": "ce6476509463415e9d4218aee9ff9d49",
|
|
|
- "version_major": 2,
|
|
|
- "version_minor": 0
|
|
|
- },
|
|
|
- "text/plain": [
|
|
|
- "generation_config.json: 0%| | 0.00/183 [00:00<?, ?B/s]"
|
|
|
- ]
|
|
|
- },
|
|
|
- "metadata": {},
|
|
|
- "output_type": "display_data"
|
|
|
- },
|
|
|
- {
|
|
|
- "data": {
|
|
|
- "application/vnd.jupyter.widget-view+json": {
|
|
|
- "model_id": "449bf99c0da248c99594d903482a967a",
|
|
|
- "version_major": 2,
|
|
|
- "version_minor": 0
|
|
|
- },
|
|
|
- "text/plain": [
|
|
|
- "tokenizer_config.json: 0%| | 0.00/55.4k [00:00<?, ?B/s]"
|
|
|
- ]
|
|
|
- },
|
|
|
- "metadata": {},
|
|
|
- "output_type": "display_data"
|
|
|
- },
|
|
|
- {
|
|
|
- "data": {
|
|
|
- "application/vnd.jupyter.widget-view+json": {
|
|
|
- "model_id": "a9d4713519db420d85391c8e8f7d9628",
|
|
|
- "version_major": 2,
|
|
|
- "version_minor": 0
|
|
|
- },
|
|
|
- "text/plain": [
|
|
|
- "tokenizer.json: 0%| | 0.00/9.09M [00:00<?, ?B/s]"
|
|
|
- ]
|
|
|
- },
|
|
|
- "metadata": {},
|
|
|
- "output_type": "display_data"
|
|
|
- },
|
|
|
- {
|
|
|
- "data": {
|
|
|
- "application/vnd.jupyter.widget-view+json": {
|
|
|
- "model_id": "d24adab709fc44d58cf9e952c2fd7f63",
|
|
|
- "version_major": 2,
|
|
|
- "version_minor": 0
|
|
|
- },
|
|
|
- "text/plain": [
|
|
|
- "special_tokens_map.json: 0%| | 0.00/296 [00:00<?, ?B/s]"
|
|
|
- ]
|
|
|
- },
|
|
|
- "metadata": {},
|
|
|
- "output_type": "display_data"
|
|
|
- }
|
|
|
- ],
|
|
|
- "source": [
|
|
|
- "accelerator = Accelerator()\n",
|
|
|
- "model = AutoModelForCausalLM.from_pretrained(\n",
|
|
|
- " DEFAULT_MODEL,\n",
|
|
|
- " torch_dtype=torch.bfloat16,\n",
|
|
|
- " use_safetensors=True,\n",
|
|
|
- " device_map=\"auto\",\n",
|
|
|
- ")\n",
|
|
|
- "tokenizer = AutoTokenizer.from_pretrained(DEFAULT_MODEL, use_safetensors=True)\n",
|
|
|
- "model, tokenizer = accelerator.prepare(model, tokenizer)"
|
|
|
- ]
|
|
|
- },
|
|
|
- {
|
|
|
- "cell_type": "code",
|
|
|
- "execution_count": 29,
|
|
|
- "id": "662b3567-1fe4-4744-a673-e0f871f4fe9a",
|
|
|
- "metadata": {},
|
|
|
- "outputs": [],
|
|
|
- "source": [
|
|
|
- "prompt = tokenizer.apply_chat_template(conversation, tokenize=False)\n",
|
|
|
- "inputs = tokenizer(prompt, return_tensors=\"pt\")"
|
|
|
- ]
|
|
|
- },
|
|
|
- {
|
|
|
- "cell_type": "code",
|
|
|
- "execution_count": null,
|
|
|
- "id": "13c51b1c-af72-4a30-99e2-e559b052aaeb",
|
|
|
- "metadata": {},
|
|
|
- "outputs": [
|
|
|
- {
|
|
|
- "name": "stderr",
|
|
|
- "output_type": "stream",
|
|
|
- "text": [
|
|
|
- "Setting `pad_token_id` to `eos_token_id`:128001 for open-end generation.\n"
|
|
|
- ]
|
|
|
- }
|
|
|
- ],
|
|
|
- "source": [
|
|
|
- "with torch.no_grad():\n",
|
|
|
- " output = model.generate(\n",
|
|
|
- " **inputs,\n",
|
|
|
- " temperature=0.7,\n",
|
|
|
- " top_p=0.9,\n",
|
|
|
- " max_new_tokens=8126\n",
|
|
|
- " )\n",
|
|
|
- "\n",
|
|
|
- "output = tokenizer.decode(output[0], skip_special_tokens=True)[len(prompt):].strip()"
|
|
|
- ]
|
|
|
- },
|
|
|
- {
|
|
|
- "cell_type": "code",
|
|
|
- "execution_count": null,
|
|
|
- "id": "41c83f2a-d0dc-4962-8fe7-cd187a8cb006",
|
|
|
- "metadata": {},
|
|
|
- "outputs": [],
|
|
|
- "source": []
|
|
|
- }
|
|
|
- ],
|
|
|
- "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.10"
|
|
|
- }
|
|
|
- },
|
|
|
- "nbformat": 4,
|
|
|
- "nbformat_minor": 5
|
|
|
-}
|