{ "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