From 84a40d5df741e3d5e6cf83caf1e5fd25407aa998 Mon Sep 17 00:00:00 2001
From: Hyesoo Kim <100982596+duper203@users.noreply.github.com>
Date: Tue, 1 Oct 2024 08:00:26 -0700
Subject: [PATCH 1/5] Update 03_hallucinations.ipynb : solar pro model
---
Solar-Fullstack-LLM-101/03_hallucinations.ipynb | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Solar-Fullstack-LLM-101/03_hallucinations.ipynb b/Solar-Fullstack-LLM-101/03_hallucinations.ipynb
index e6ec25d..d223769 100644
--- a/Solar-Fullstack-LLM-101/03_hallucinations.ipynb
+++ b/Solar-Fullstack-LLM-101/03_hallucinations.ipynb
@@ -88,7 +88,7 @@
"from langchain_core.prompts import PromptTemplate\n",
"from langchain_upstage import ChatUpstage\n",
"\n",
- "llm = ChatUpstage()\n",
+ "llm = ChatUpstage(model=\"solar-pro\")\n",
"prompt_template = PromptTemplate.from_template(\n",
" \"\"\"\n",
"Q: What is DUS developed from Upstage?\n",
@@ -121,7 +121,7 @@
"from langchain_core.prompts import PromptTemplate\n",
"from langchain_upstage import ChatUpstage\n",
"\n",
- "llm = ChatUpstage()\n",
+ "llm = ChatUpstage(model=\"solar-pro\")\n",
"prompt_template = PromptTemplate.from_template(\n",
" \"\"\"\n",
"Q: What is DUS developed from Google?\n",
From 61936fb2646524b0d70081c9d0130bcaf478a578 Mon Sep 17 00:00:00 2001
From: Hyesoo Kim <100982596+duper203@users.noreply.github.com>
Date: Wed, 2 Oct 2024 10:38:05 -0700
Subject: [PATCH 2/5] Created using Colab
---
.../03_hallucinations.ipynb | 395 ++++++++++--------
1 file changed, 216 insertions(+), 179 deletions(-)
diff --git a/Solar-Fullstack-LLM-101/03_hallucinations.ipynb b/Solar-Fullstack-LLM-101/03_hallucinations.ipynb
index d223769..4c185ca 100644
--- a/Solar-Fullstack-LLM-101/03_hallucinations.ipynb
+++ b/Solar-Fullstack-LLM-101/03_hallucinations.ipynb
@@ -1,186 +1,223 @@
{
- "cells": [
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "\n",
- "
\n",
- ""
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "# 03. Hallucinations\n",
- "## Overview \n",
- "In this exercise, we will explore the concept of hallucinations in large language models using the Solar framework. Hallucinations refer to instances where the model generates information that is not based on the input data or is factually incorrect. This notebook will help you understand why hallucinations occur and how to mitigate them to ensure the reliability and accuracy of the model's outputs.\n",
- " \n",
- "## Purpose of the Exercise\n",
- "The purpose of this exercise is to identify and address the issue of hallucinations in language models. By the end of this tutorial, users will be able to recognize hallucinations, understand their causes, and apply strategies to minimize their occurrence, thereby improving the trustworthiness and usability of the Solar LLM.\n"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 5,
- "metadata": {},
- "outputs": [],
- "source": [
- "! pip3 install -qU langchain-upstage python-dotenv"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 7,
- "metadata": {},
- "outputs": [],
- "source": [
- "# @title set API key\n",
- "from pprint import pprint\n",
- "import os\n",
- "\n",
- "import warnings\n",
- "\n",
- "warnings.filterwarnings(\"ignore\")\n",
- "\n",
- "from IPython import get_ipython\n",
- "\n",
- "upstage_api_key_env_name = \"UPSTAGE_API_KEY\"\n",
- "\n",
- "\n",
- "def load_env():\n",
- " if \"google.colab\" in str(get_ipython()):\n",
- " # Running in Google Colab\n",
- " from google.colab import userdata\n",
- "\n",
- " upstage_api_key = userdata.get(upstage_api_key_env_name)\n",
- " return os.environ.setdefault(\"UPSTAGE_API_KEY\", upstage_api_key)\n",
- " else:\n",
- " # Running in local Jupyter Notebook\n",
- " from dotenv import load_dotenv\n",
- "\n",
- " load_dotenv()\n",
- " return os.environ.get(upstage_api_key_env_name)\n",
- "\n",
- "\n",
- "UPSTAGE_API_KEY = load_env()"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 8,
- "metadata": {},
- "outputs": [
+ "cells": [
{
- "data": {
- "text/plain": [
- "'DUS (Distributed Universal Services) is a software platform that is developed from Upstage. Upstage is a cloud-based platform that provides a range of services, including video conferencing, collaboration tools, and communication services. DUS is an extension of Upstage that provides a more comprehensive set of services, including distributed computing, storage, and networking services. DUS is designed to be a flexible and scalable platform that can be used to build and deploy a wide range of applications and services.'"
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "DFAyDWd_So7F"
+ },
+ "source": [
+ "\n",
+ "
\n",
+ ""
]
- },
- "execution_count": 8,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "from langchain_core.output_parsers import StrOutputParser\n",
- "from langchain_core.prompts import PromptTemplate\n",
- "from langchain_upstage import ChatUpstage\n",
- "\n",
- "llm = ChatUpstage(model=\"solar-pro\")\n",
- "prompt_template = PromptTemplate.from_template(\n",
- " \"\"\"\n",
- "Q: What is DUS developed from Upstage?\n",
- "\n",
- "A:\n",
- "\"\"\"\n",
- ")\n",
- "chain = prompt_template | llm | StrOutputParser()\n",
- "chain.invoke({})"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 19,
- "metadata": {},
- "outputs": [
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "QR6QI343So7G"
+ },
+ "source": [
+ "# 03. Hallucinations\n",
+ "## Overview \n",
+ "In this exercise, we will explore the concept of hallucinations in large language models using the Solar framework. Hallucinations refer to instances where the model generates information that is not based on the input data or is factually incorrect. This notebook will help you understand why hallucinations occur and how to mitigate them to ensure the reliability and accuracy of the model's outputs.\n",
+ "\n",
+ "## Purpose of the Exercise\n",
+ "The purpose of this exercise is to identify and address the issue of hallucinations in language models. By the end of this tutorial, users will be able to recognize hallucinations, understand their causes, and apply strategies to minimize their occurrence, thereby improving the trustworthiness and usability of the Solar LLM.\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "id": "82Q8QyidSo7H"
+ },
+ "outputs": [],
+ "source": [
+ "! pip3 install -qU langchain-upstage python-dotenv"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "metadata": {
+ "id": "BVVji6UCSo7H"
+ },
+ "outputs": [],
+ "source": [
+ "# @title set API key\n",
+ "from pprint import pprint\n",
+ "import os\n",
+ "\n",
+ "import warnings\n",
+ "\n",
+ "warnings.filterwarnings(\"ignore\")\n",
+ "\n",
+ "from IPython import get_ipython\n",
+ "\n",
+ "upstage_api_key_env_name = \"UPSTAGE_API_KEY\"\n",
+ "\n",
+ "\n",
+ "def load_env():\n",
+ " if \"google.colab\" in str(get_ipython()):\n",
+ " # Running in Google Colab\n",
+ " from google.colab import userdata\n",
+ "\n",
+ " upstage_api_key = userdata.get(upstage_api_key_env_name)\n",
+ " return os.environ.setdefault(\"UPSTAGE_API_KEY\", upstage_api_key)\n",
+ " else:\n",
+ " # Running in local Jupyter Notebook\n",
+ " from dotenv import load_dotenv\n",
+ "\n",
+ " load_dotenv()\n",
+ " return os.environ.get(upstage_api_key_env_name)\n",
+ "\n",
+ "\n",
+ "UPSTAGE_API_KEY = load_env()"
+ ]
+ },
{
- "data": {
- "text/plain": [
- "'DUS is a tool developed from Google that allows developers to test and debug their applications. It stands for \"Debugging and Profiling for Android Studio.\" DUS provides a set of features that help developers identify and fix issues in their applications, such as memory leaks, performance bottlenecks, and other issues that can affect the overall quality of the application.\\n\\nDUS was developed by Google as a part of the Android Studio IDE, which is a popular development environment for building Android applications. It is designed to work seamlessly with Android Studio, providing developers with a comprehensive set of tools and features to help them build high-quality applications.\\n\\nOne of the key features of DUS is its ability to provide real-time feedback and insights into the performance of an application. Developers can use DUS to monitor the memory usage, CPU usage, and network activity of their applications, and identify any issues that may be affecting the performance of the application.\\n\\nDUS also provides a range of debugging tools, such as breakpoints, watchpoints, and step-through debugging, which allow developers to identify and fix issues in their code. Additionally, DUS provides a range of profiling tools, such as memory profiling, CPU profiling, and network profiling, which allow developers to identify and optimize the performance of their applications.\\n\\nOverall, DUS is a powerful tool developed by Google that provides developers with a comprehensive set of tools and features to help them build high-quality Android applications.'"
+ "cell_type": "code",
+ "execution_count": 9,
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 70
+ },
+ "id": "z7vXj-gwSo7H",
+ "outputId": "b56144e8-00db-4edc-9271-e76fb86931a7"
+ },
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "\"DUS, or Document Understanding Service, is an AI solution developed by Upstage that specializes in processing, analyzing, and extracting information from various types of documents. It's designed to help businesses automate and streamline their document-driven workflows.\""
+ ],
+ "application/vnd.google.colaboratory.intrinsic+json": {
+ "type": "string"
+ }
+ },
+ "metadata": {},
+ "execution_count": 9
+ }
+ ],
+ "source": [
+ "from langchain_core.output_parsers import StrOutputParser\n",
+ "from langchain_core.prompts import PromptTemplate\n",
+ "from langchain_upstage import ChatUpstage\n",
+ "\n",
+ "llm = ChatUpstage(model=\"solar-pro\")\n",
+ "prompt_template = PromptTemplate.from_template(\n",
+ " \"\"\"\n",
+ "Q: What is DUS developed from Upstage?\n",
+ "\n",
+ "A:\n",
+ "\"\"\"\n",
+ ")\n",
+ "chain = prompt_template | llm | StrOutputParser()\n",
+ "chain.invoke({})"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 10,
+ "metadata": {
+ "colab": {
+ "base_uri": "https://localhost:8080/",
+ "height": 52
+ },
+ "id": "nh8EkSEySo7I",
+ "outputId": "ff336620-b3c3-4af0-d390-d4fd09a4d038"
+ },
+ "outputs": [
+ {
+ "output_type": "execute_result",
+ "data": {
+ "text/plain": [
+ "\"DUS stands for Duplex Unified Server. It's a software product developed by Google to enable their AI assistant, Google Duplex, to make phone calls on behalf of users. This can be useful for tasks like scheduling appointments or making reservations.\""
+ ],
+ "application/vnd.google.colaboratory.intrinsic+json": {
+ "type": "string"
+ }
+ },
+ "metadata": {},
+ "execution_count": 10
+ }
+ ],
+ "source": [
+ "from langchain_core.output_parsers import StrOutputParser\n",
+ "from langchain_core.prompts import PromptTemplate\n",
+ "from langchain_upstage import ChatUpstage\n",
+ "\n",
+ "llm = ChatUpstage(model=\"solar-pro\")\n",
+ "prompt_template = PromptTemplate.from_template(\n",
+ " \"\"\"\n",
+ "Q: What is DUS developed from Google?\n",
+ "\n",
+ "A:\n",
+ "\"\"\"\n",
+ ")\n",
+ "chain = prompt_template | llm | StrOutputParser()\n",
+ "chain.invoke({})"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "Zk7ncsGUSo7I"
+ },
+ "source": [
+ ""
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "Wy0tBDUQSo7I"
+ },
+ "source": [
+ "## Next Token Prediction\n",
+ "They are designed to generate the next words. It's also very difficult to know what we don't know.\n",
+ "\n",
+ "\n",
+ "\n",
+ "Image from https://jalammar.github.io/illustrated-gpt2/"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {
+ "id": "FXAqMmrTSo7I"
+ },
+ "source": [
+ "# Excercise\n",
+ "\n",
+ "Think of ways to prevent Large Language Models (LLMs) from generating incorrect information."
]
- },
- "execution_count": 19,
- "metadata": {},
- "output_type": "execute_result"
}
- ],
- "source": [
- "from langchain_core.output_parsers import StrOutputParser\n",
- "from langchain_core.prompts import PromptTemplate\n",
- "from langchain_upstage import ChatUpstage\n",
- "\n",
- "llm = ChatUpstage(model=\"solar-pro\")\n",
- "prompt_template = PromptTemplate.from_template(\n",
- " \"\"\"\n",
- "Q: What is DUS developed from Google?\n",
- "\n",
- "A:\n",
- "\"\"\"\n",
- ")\n",
- "chain = prompt_template | llm | StrOutputParser()\n",
- "chain.invoke({})"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- ""
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "## Next Token Prediction\n",
- "They are designed to generate the next words. It's also very difficult to know what we don't know.\n",
- "\n",
- "\n",
- "\n",
- "Image from https://jalammar.github.io/illustrated-gpt2/"
- ]
- },
- {
- "cell_type": "markdown",
- "metadata": {},
- "source": [
- "# Excercise \n",
- "\n",
- "Think of ways to prevent Large Language Models (LLMs) from generating incorrect information."
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3 (ipykernel)",
- "language": "python",
- "name": "python3"
+ ],
+ "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.10.10"
+ },
+ "colab": {
+ "provenance": []
+ }
},
- "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.10.10"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 4
-}
+ "nbformat": 4,
+ "nbformat_minor": 0
+}
\ No newline at end of file
From f74d5c9cd1bfce0bde3f8760f78d0a5c56586bd2 Mon Sep 17 00:00:00 2001
From: Hyesoo Kim <100982596+duper203@users.noreply.github.com>
Date: Fri, 4 Oct 2024 10:15:55 -0700
Subject: [PATCH 3/5] Update 03_hallucinations.ipynb : api key
---
.../03_hallucinations.ipynb | 55 ++++++++-----------
1 file changed, 24 insertions(+), 31 deletions(-)
diff --git a/Solar-Fullstack-LLM-101/03_hallucinations.ipynb b/Solar-Fullstack-LLM-101/03_hallucinations.ipynb
index 4c185ca..973191b 100644
--- a/Solar-Fullstack-LLM-101/03_hallucinations.ipynb
+++ b/Solar-Fullstack-LLM-101/03_hallucinations.ipynb
@@ -44,36 +44,29 @@
},
"outputs": [],
"source": [
- "# @title set API key\n",
- "from pprint import pprint\n",
- "import os\n",
- "\n",
- "import warnings\n",
- "\n",
- "warnings.filterwarnings(\"ignore\")\n",
- "\n",
- "from IPython import get_ipython\n",
- "\n",
- "upstage_api_key_env_name = \"UPSTAGE_API_KEY\"\n",
- "\n",
- "\n",
- "def load_env():\n",
- " if \"google.colab\" in str(get_ipython()):\n",
- " # Running in Google Colab\n",
- " from google.colab import userdata\n",
- "\n",
- " upstage_api_key = userdata.get(upstage_api_key_env_name)\n",
- " return os.environ.setdefault(\"UPSTAGE_API_KEY\", upstage_api_key)\n",
- " else:\n",
- " # Running in local Jupyter Notebook\n",
- " from dotenv import load_dotenv\n",
- "\n",
- " load_dotenv()\n",
- " return os.environ.get(upstage_api_key_env_name)\n",
- "\n",
- "\n",
- "UPSTAGE_API_KEY = load_env()"
- ]
+ "# @title set API key\n",
+ "from pprint import pprint\n",
+ "import os\n",
+ "\n",
+ "import warnings\n",
+ "\n",
+ "warnings.filterwarnings(\"ignore\")\n",
+ "\n",
+ "if \"google.colab\" in str(get_ipython()):\n",
+ " # Running in Google Colab. Please set the UPSTAGE_API_KEY in the Colab Secrets\n",
+ " from google.colab import userdata\n",
+ "\n",
+ " os.environ[\"UPSTAGE_API_KEY\"] = userdata.get(\"UPSTAGE_API_KEY\")\n",
+ "else:\n",
+ " # Running locally. Please set the UPSTAGE_API_KEY in the .env file\n",
+ " from dotenv import load_dotenv\n",
+ "\n",
+ " load_dotenv()\n",
+ "\n",
+ "assert (\n",
+ " \"UPSTAGE_API_KEY\" in os.environ\n",
+ "), \"Please set the UPSTAGE_API_KEY environment variable\""
+ ]
},
{
"cell_type": "code",
@@ -220,4 +213,4 @@
},
"nbformat": 4,
"nbformat_minor": 0
-}
\ No newline at end of file
+}
From 2fbd60768ab765ec07e97ce8bd1b7a39e1afb672 Mon Sep 17 00:00:00 2001
From: Hyesoo Kim <100982596+duper203@users.noreply.github.com>
Date: Fri, 4 Oct 2024 14:45:50 -0700
Subject: [PATCH 4/5] api key
---
.../03_hallucinations.ipynb | 136 ++++++++++--------
1 file changed, 74 insertions(+), 62 deletions(-)
diff --git a/Solar-Fullstack-LLM-101/03_hallucinations.ipynb b/Solar-Fullstack-LLM-101/03_hallucinations.ipynb
index 973191b..efe2ea5 100644
--- a/Solar-Fullstack-LLM-101/03_hallucinations.ipynb
+++ b/Solar-Fullstack-LLM-101/03_hallucinations.ipynb
@@ -3,7 +3,7 @@
{
"cell_type": "markdown",
"metadata": {
- "id": "DFAyDWd_So7F"
+ "id": "p8iN9XbOfH07"
},
"source": [
"\n",
@@ -14,7 +14,7 @@
{
"cell_type": "markdown",
"metadata": {
- "id": "QR6QI343So7G"
+ "id": "SrfSiQmqfH08"
},
"source": [
"# 03. Hallucinations\n",
@@ -29,69 +29,88 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
- "id": "82Q8QyidSo7H"
+ "id": "xeVWQHpyfH09"
},
"outputs": [],
"source": [
"! pip3 install -qU langchain-upstage python-dotenv"
]
},
+ {
+ "cell_type": "markdown",
+ "source": [
+ "## UPSTAGE_API_KEY\n",
+ "To obtain your Upstage API key, follow these steps:\n",
+ "\n",
+ "1. Visit the Upstage AI console at .\n",
+ "2. Sign up for an account if you don't already have one.\n",
+ "3. Log in to your account.\n",
+ "4. Navigate to the API key section.\n",
+ "5. Generate your API key.\n",
+ "6. Copy the key and save it securely.\n",
+ "\n",
+ ""
+ ],
+ "metadata": {
+ "id": "FAQEALbMfdhG"
+ }
+ },
{
"cell_type": "code",
- "execution_count": 2,
+ "execution_count": null,
"metadata": {
- "id": "BVVji6UCSo7H"
+ "id": "SzI4bGqLfH0-"
},
"outputs": [],
"source": [
- "# @title set API key\n",
- "from pprint import pprint\n",
- "import os\n",
- "\n",
- "import warnings\n",
- "\n",
- "warnings.filterwarnings(\"ignore\")\n",
- "\n",
- "if \"google.colab\" in str(get_ipython()):\n",
- " # Running in Google Colab. Please set the UPSTAGE_API_KEY in the Colab Secrets\n",
- " from google.colab import userdata\n",
- "\n",
- " os.environ[\"UPSTAGE_API_KEY\"] = userdata.get(\"UPSTAGE_API_KEY\")\n",
- "else:\n",
- " # Running locally. Please set the UPSTAGE_API_KEY in the .env file\n",
- " from dotenv import load_dotenv\n",
- "\n",
- " load_dotenv()\n",
- "\n",
- "assert (\n",
- " \"UPSTAGE_API_KEY\" in os.environ\n",
- "), \"Please set the UPSTAGE_API_KEY environment variable\""
- ]
+ "# @title set API key\n",
+ "from pprint import pprint\n",
+ "import os\n",
+ "\n",
+ "import warnings\n",
+ "\n",
+ "warnings.filterwarnings(\"ignore\")\n",
+ "\n",
+ "from IPython import get_ipython\n",
+ "\n",
+ "upstage_api_key_env_name = \"UPSTAGE_API_KEY\"\n",
+ "\n",
+ "\n",
+ "def load_env():\n",
+ " if \"google.colab\" in str(get_ipython()):\n",
+ " # Running in Google Colab\n",
+ " from google.colab import userdata\n",
+ "\n",
+ " upstage_api_key = userdata.get(upstage_api_key_env_name)\n",
+ " return os.environ.setdefault(\"UPSTAGE_API_KEY\", upstage_api_key)\n",
+ " else:\n",
+ " # Running in local Jupyter Notebook\n",
+ " from dotenv import load_dotenv\n",
+ "\n",
+ " load_dotenv()\n",
+ " return os.environ.get(upstage_api_key_env_name)\n",
+ "\n",
+ "\n",
+ "UPSTAGE_API_KEY = load_env()"
+ ]
},
{
"cell_type": "code",
- "execution_count": 9,
+ "execution_count": null,
"metadata": {
- "colab": {
- "base_uri": "https://localhost:8080/",
- "height": 70
- },
- "id": "z7vXj-gwSo7H",
- "outputId": "b56144e8-00db-4edc-9271-e76fb86931a7"
+ "id": "zK6mcZ05fH0-",
+ "outputId": "c870f792-6c5f-4f79-9e26-9c1f10def711"
},
"outputs": [
{
- "output_type": "execute_result",
"data": {
"text/plain": [
- "\"DUS, or Document Understanding Service, is an AI solution developed by Upstage that specializes in processing, analyzing, and extracting information from various types of documents. It's designed to help businesses automate and streamline their document-driven workflows.\""
- ],
- "application/vnd.google.colaboratory.intrinsic+json": {
- "type": "string"
- }
+ "'DUS (Distributed Universal Services) is a software platform that is developed from Upstage. Upstage is a cloud-based platform that provides a range of services, including video conferencing, collaboration tools, and communication services. DUS is an extension of Upstage that provides a more comprehensive set of services, including distributed computing, storage, and networking services. DUS is designed to be a flexible and scalable platform that can be used to build and deploy a wide range of applications and services.'"
+ ]
},
+ "execution_count": 8,
"metadata": {},
- "execution_count": 9
+ "output_type": "execute_result"
}
],
"source": [
@@ -99,7 +118,7 @@
"from langchain_core.prompts import PromptTemplate\n",
"from langchain_upstage import ChatUpstage\n",
"\n",
- "llm = ChatUpstage(model=\"solar-pro\")\n",
+ "llm = ChatUpstage()\n",
"prompt_template = PromptTemplate.from_template(\n",
" \"\"\"\n",
"Q: What is DUS developed from Upstage?\n",
@@ -113,28 +132,21 @@
},
{
"cell_type": "code",
- "execution_count": 10,
+ "execution_count": null,
"metadata": {
- "colab": {
- "base_uri": "https://localhost:8080/",
- "height": 52
- },
- "id": "nh8EkSEySo7I",
- "outputId": "ff336620-b3c3-4af0-d390-d4fd09a4d038"
+ "id": "jzQZiCrZfH0_",
+ "outputId": "3dff60c6-21be-4379-a68b-c7ef0572e5d2"
},
"outputs": [
{
- "output_type": "execute_result",
"data": {
"text/plain": [
- "\"DUS stands for Duplex Unified Server. It's a software product developed by Google to enable their AI assistant, Google Duplex, to make phone calls on behalf of users. This can be useful for tasks like scheduling appointments or making reservations.\""
- ],
- "application/vnd.google.colaboratory.intrinsic+json": {
- "type": "string"
- }
+ "'DUS is a tool developed from Google that allows developers to test and debug their applications. It stands for \"Debugging and Profiling for Android Studio.\" DUS provides a set of features that help developers identify and fix issues in their applications, such as memory leaks, performance bottlenecks, and other issues that can affect the overall quality of the application.\\n\\nDUS was developed by Google as a part of the Android Studio IDE, which is a popular development environment for building Android applications. It is designed to work seamlessly with Android Studio, providing developers with a comprehensive set of tools and features to help them build high-quality applications.\\n\\nOne of the key features of DUS is its ability to provide real-time feedback and insights into the performance of an application. Developers can use DUS to monitor the memory usage, CPU usage, and network activity of their applications, and identify any issues that may be affecting the performance of the application.\\n\\nDUS also provides a range of debugging tools, such as breakpoints, watchpoints, and step-through debugging, which allow developers to identify and fix issues in their code. Additionally, DUS provides a range of profiling tools, such as memory profiling, CPU profiling, and network profiling, which allow developers to identify and optimize the performance of their applications.\\n\\nOverall, DUS is a powerful tool developed by Google that provides developers with a comprehensive set of tools and features to help them build high-quality Android applications.'"
+ ]
},
+ "execution_count": 19,
"metadata": {},
- "execution_count": 10
+ "output_type": "execute_result"
}
],
"source": [
@@ -142,7 +154,7 @@
"from langchain_core.prompts import PromptTemplate\n",
"from langchain_upstage import ChatUpstage\n",
"\n",
- "llm = ChatUpstage(model=\"solar-pro\")\n",
+ "llm = ChatUpstage()\n",
"prompt_template = PromptTemplate.from_template(\n",
" \"\"\"\n",
"Q: What is DUS developed from Google?\n",
@@ -157,7 +169,7 @@
{
"cell_type": "markdown",
"metadata": {
- "id": "Zk7ncsGUSo7I"
+ "id": "jDkiEUQffH1A"
},
"source": [
""
@@ -166,7 +178,7 @@
{
"cell_type": "markdown",
"metadata": {
- "id": "Wy0tBDUQSo7I"
+ "id": "93ZXabfhfH1A"
},
"source": [
"## Next Token Prediction\n",
@@ -180,7 +192,7 @@
{
"cell_type": "markdown",
"metadata": {
- "id": "FXAqMmrTSo7I"
+ "id": "7lX5KQy_fH1A"
},
"source": [
"# Excercise\n",
@@ -213,4 +225,4 @@
},
"nbformat": 4,
"nbformat_minor": 0
-}
+}
\ No newline at end of file
From b8a30b9531875410d8d3127922e4bace8e2435b5 Mon Sep 17 00:00:00 2001
From: Hyesoo Kim <100982596+duper203@users.noreply.github.com>
Date: Mon, 7 Oct 2024 09:52:27 -0700
Subject: [PATCH 5/5] Update 03_hallucinations.ipynb : env setting
---
.../03_hallucinations.ipynb | 55 ++++++++-----------
1 file changed, 24 insertions(+), 31 deletions(-)
diff --git a/Solar-Fullstack-LLM-101/03_hallucinations.ipynb b/Solar-Fullstack-LLM-101/03_hallucinations.ipynb
index efe2ea5..089fe39 100644
--- a/Solar-Fullstack-LLM-101/03_hallucinations.ipynb
+++ b/Solar-Fullstack-LLM-101/03_hallucinations.ipynb
@@ -63,36 +63,29 @@
},
"outputs": [],
"source": [
- "# @title set API key\n",
- "from pprint import pprint\n",
- "import os\n",
- "\n",
- "import warnings\n",
- "\n",
- "warnings.filterwarnings(\"ignore\")\n",
- "\n",
- "from IPython import get_ipython\n",
- "\n",
- "upstage_api_key_env_name = \"UPSTAGE_API_KEY\"\n",
- "\n",
- "\n",
- "def load_env():\n",
- " if \"google.colab\" in str(get_ipython()):\n",
- " # Running in Google Colab\n",
- " from google.colab import userdata\n",
- "\n",
- " upstage_api_key = userdata.get(upstage_api_key_env_name)\n",
- " return os.environ.setdefault(\"UPSTAGE_API_KEY\", upstage_api_key)\n",
- " else:\n",
- " # Running in local Jupyter Notebook\n",
- " from dotenv import load_dotenv\n",
- "\n",
- " load_dotenv()\n",
- " return os.environ.get(upstage_api_key_env_name)\n",
- "\n",
- "\n",
- "UPSTAGE_API_KEY = load_env()"
- ]
+ "# @title set API key\n",
+ "from pprint import pprint\n",
+ "import os\n",
+ "\n",
+ "import warnings\n",
+ "\n",
+ "warnings.filterwarnings(\"ignore\")\n",
+ "\n",
+ "if \"google.colab\" in str(get_ipython()):\n",
+ " # Running in Google Colab. Please set the UPSTAGE_API_KEY in the Colab Secrets\n",
+ " from google.colab import userdata\n",
+ "\n",
+ " os.environ[\"UPSTAGE_API_KEY\"] = userdata.get(\"UPSTAGE_API_KEY\")\n",
+ "else:\n",
+ " # Running locally. Please set the UPSTAGE_API_KEY in the .env file\n",
+ " from dotenv import load_dotenv\n",
+ "\n",
+ " load_dotenv()\n",
+ "\n",
+ "assert (\n",
+ " \"UPSTAGE_API_KEY\" in os.environ\n",
+ "), \"Please set the UPSTAGE_API_KEY environment variable\""
+ ]
},
{
"cell_type": "code",
@@ -225,4 +218,4 @@
},
"nbformat": 4,
"nbformat_minor": 0
-}
\ No newline at end of file
+}