Files
rag/Local-RAG.ipynb

2206 lines
175 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{
"cells": [
{
"cell_type": "code",
"execution_count": 2,
"id": "dab6db2a-e284-4660-b431-ed2f1d643c1a",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Requirement already satisfied: pypdf in /usr/local/lib/python3.10/dist-packages (5.1.0)\n",
"Requirement already satisfied: typing_extensions>=4.0 in /usr/local/lib/python3.10/dist-packages (from pypdf) (4.12.2)\n",
"\u001b[33mWARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv\u001b[0m\u001b[33m\n",
"\u001b[0m\n",
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m23.3.1\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m24.3.1\u001b[0m\n",
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpython -m pip install --upgrade pip\u001b[0m\n",
"Requirement already satisfied: llama-index in /usr/local/lib/python3.10/dist-packages (0.12.11)\n",
"Requirement already satisfied: llama-index-agent-openai<0.5.0,>=0.4.0 in /usr/local/lib/python3.10/dist-packages (from llama-index) (0.4.2)\n",
"Requirement already satisfied: llama-index-cli<0.5.0,>=0.4.0 in /usr/local/lib/python3.10/dist-packages (from llama-index) (0.4.0)\n",
"Requirement already satisfied: llama-index-core<0.13.0,>=0.12.11 in /usr/local/lib/python3.10/dist-packages (from llama-index) (0.12.11)\n",
"Requirement already satisfied: llama-index-embeddings-openai<0.4.0,>=0.3.0 in /usr/local/lib/python3.10/dist-packages (from llama-index) (0.3.1)\n",
"Requirement already satisfied: llama-index-indices-managed-llama-cloud>=0.4.0 in /usr/local/lib/python3.10/dist-packages (from llama-index) (0.6.3)\n",
"Requirement already satisfied: llama-index-llms-openai<0.4.0,>=0.3.0 in /usr/local/lib/python3.10/dist-packages (from llama-index) (0.3.13)\n",
"Requirement already satisfied: llama-index-multi-modal-llms-openai<0.5.0,>=0.4.0 in /usr/local/lib/python3.10/dist-packages (from llama-index) (0.4.2)\n",
"Requirement already satisfied: llama-index-program-openai<0.4.0,>=0.3.0 in /usr/local/lib/python3.10/dist-packages (from llama-index) (0.3.1)\n",
"Requirement already satisfied: llama-index-question-gen-openai<0.4.0,>=0.3.0 in /usr/local/lib/python3.10/dist-packages (from llama-index) (0.3.0)\n",
"Requirement already satisfied: llama-index-readers-file<0.5.0,>=0.4.0 in /usr/local/lib/python3.10/dist-packages (from llama-index) (0.4.3)\n",
"Requirement already satisfied: llama-index-readers-llama-parse>=0.4.0 in /usr/local/lib/python3.10/dist-packages (from llama-index) (0.4.0)\n",
"Requirement already satisfied: nltk>3.8.1 in /usr/local/lib/python3.10/dist-packages (from llama-index) (3.9.1)\n",
"Requirement already satisfied: openai>=1.14.0 in /usr/local/lib/python3.10/dist-packages (from llama-index-agent-openai<0.5.0,>=0.4.0->llama-index) (1.59.7)\n",
"Requirement already satisfied: PyYAML>=6.0.1 in /usr/local/lib/python3.10/dist-packages (from llama-index-core<0.13.0,>=0.12.11->llama-index) (6.0.1)\n",
"Requirement already satisfied: SQLAlchemy>=1.4.49 in /usr/local/lib/python3.10/dist-packages (from SQLAlchemy[asyncio]>=1.4.49->llama-index-core<0.13.0,>=0.12.11->llama-index) (2.0.36)\n",
"Requirement already satisfied: aiohttp<4.0.0,>=3.8.6 in /usr/local/lib/python3.10/dist-packages (from llama-index-core<0.13.0,>=0.12.11->llama-index) (3.10.10)\n",
"Requirement already satisfied: dataclasses-json in /usr/local/lib/python3.10/dist-packages (from llama-index-core<0.13.0,>=0.12.11->llama-index) (0.6.7)\n",
"Requirement already satisfied: deprecated>=1.2.9.3 in /usr/local/lib/python3.10/dist-packages (from llama-index-core<0.13.0,>=0.12.11->llama-index) (1.2.15)\n",
"Requirement already satisfied: dirtyjson<2.0.0,>=1.0.8 in /usr/local/lib/python3.10/dist-packages (from llama-index-core<0.13.0,>=0.12.11->llama-index) (1.0.8)\n",
"Requirement already satisfied: filetype<2.0.0,>=1.2.0 in /usr/local/lib/python3.10/dist-packages (from llama-index-core<0.13.0,>=0.12.11->llama-index) (1.2.0)\n",
"Requirement already satisfied: fsspec>=2023.5.0 in /usr/local/lib/python3.10/dist-packages (from llama-index-core<0.13.0,>=0.12.11->llama-index) (2024.9.0)\n",
"Requirement already satisfied: httpx in /usr/local/lib/python3.10/dist-packages (from llama-index-core<0.13.0,>=0.12.11->llama-index) (0.27.2)\n",
"Requirement already satisfied: nest-asyncio<2.0.0,>=1.5.8 in /usr/local/lib/python3.10/dist-packages (from llama-index-core<0.13.0,>=0.12.11->llama-index) (1.5.8)\n",
"Requirement already satisfied: networkx>=3.0 in /usr/local/lib/python3.10/dist-packages (from llama-index-core<0.13.0,>=0.12.11->llama-index) (3.0)\n",
"Requirement already satisfied: numpy in /usr/local/lib/python3.10/dist-packages (from llama-index-core<0.13.0,>=0.12.11->llama-index) (1.24.1)\n",
"Requirement already satisfied: pillow>=9.0.0 in /usr/local/lib/python3.10/dist-packages (from llama-index-core<0.13.0,>=0.12.11->llama-index) (11.1.0)\n",
"Requirement already satisfied: pydantic>=2.8.0 in /usr/local/lib/python3.10/dist-packages (from llama-index-core<0.13.0,>=0.12.11->llama-index) (2.9.2)\n",
"Requirement already satisfied: requests>=2.31.0 in /usr/local/lib/python3.10/dist-packages (from llama-index-core<0.13.0,>=0.12.11->llama-index) (2.32.3)\n",
"Requirement already satisfied: tenacity!=8.4.0,<10.0.0,>=8.2.0 in /usr/local/lib/python3.10/dist-packages (from llama-index-core<0.13.0,>=0.12.11->llama-index) (9.0.0)\n",
"Requirement already satisfied: tiktoken>=0.3.3 in /usr/local/lib/python3.10/dist-packages (from llama-index-core<0.13.0,>=0.12.11->llama-index) (0.8.0)\n",
"Requirement already satisfied: tqdm<5.0.0,>=4.66.1 in /usr/local/lib/python3.10/dist-packages (from llama-index-core<0.13.0,>=0.12.11->llama-index) (4.67.0)\n",
"Requirement already satisfied: typing-extensions>=4.5.0 in /usr/local/lib/python3.10/dist-packages (from llama-index-core<0.13.0,>=0.12.11->llama-index) (4.12.2)\n",
"Requirement already satisfied: typing-inspect>=0.8.0 in /usr/local/lib/python3.10/dist-packages (from llama-index-core<0.13.0,>=0.12.11->llama-index) (0.9.0)\n",
"Requirement already satisfied: wrapt in /usr/local/lib/python3.10/dist-packages (from llama-index-core<0.13.0,>=0.12.11->llama-index) (1.17.0)\n",
"Requirement already satisfied: llama-cloud>=0.1.5 in /usr/local/lib/python3.10/dist-packages (from llama-index-indices-managed-llama-cloud>=0.4.0->llama-index) (0.1.9)\n",
"Requirement already satisfied: beautifulsoup4<5.0.0,>=4.12.3 in /usr/local/lib/python3.10/dist-packages (from llama-index-readers-file<0.5.0,>=0.4.0->llama-index) (4.12.3)\n",
"Requirement already satisfied: pandas in /usr/local/lib/python3.10/dist-packages (from llama-index-readers-file<0.5.0,>=0.4.0->llama-index) (2.0.3)\n",
"Requirement already satisfied: pypdf<6.0.0,>=5.1.0 in /usr/local/lib/python3.10/dist-packages (from llama-index-readers-file<0.5.0,>=0.4.0->llama-index) (5.1.0)\n",
"Requirement already satisfied: striprtf<0.0.27,>=0.0.26 in /usr/local/lib/python3.10/dist-packages (from llama-index-readers-file<0.5.0,>=0.4.0->llama-index) (0.0.26)\n",
"Requirement already satisfied: llama-parse>=0.5.0 in /usr/local/lib/python3.10/dist-packages (from llama-index-readers-llama-parse>=0.4.0->llama-index) (0.5.19)\n",
"Requirement already satisfied: click in /usr/local/lib/python3.10/dist-packages (from nltk>3.8.1->llama-index) (8.1.7)\n",
"Requirement already satisfied: joblib in /usr/local/lib/python3.10/dist-packages (from nltk>3.8.1->llama-index) (1.4.2)\n",
"Requirement already satisfied: regex>=2021.8.3 in /usr/local/lib/python3.10/dist-packages (from nltk>3.8.1->llama-index) (2024.11.6)\n",
"Requirement already satisfied: aiohappyeyeballs>=2.3.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core<0.13.0,>=0.12.11->llama-index) (2.4.3)\n",
"Requirement already satisfied: aiosignal>=1.1.2 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core<0.13.0,>=0.12.11->llama-index) (1.3.1)\n",
"Requirement already satisfied: attrs>=17.3.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core<0.13.0,>=0.12.11->llama-index) (23.1.0)\n",
"Requirement already satisfied: frozenlist>=1.1.1 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core<0.13.0,>=0.12.11->llama-index) (1.5.0)\n",
"Requirement already satisfied: multidict<7.0,>=4.5 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core<0.13.0,>=0.12.11->llama-index) (6.1.0)\n",
"Requirement already satisfied: yarl<2.0,>=1.12.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core<0.13.0,>=0.12.11->llama-index) (1.17.1)\n",
"Requirement already satisfied: async-timeout<5.0,>=4.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core<0.13.0,>=0.12.11->llama-index) (4.0.3)\n",
"Requirement already satisfied: soupsieve>1.2 in /usr/local/lib/python3.10/dist-packages (from beautifulsoup4<5.0.0,>=4.12.3->llama-index-readers-file<0.5.0,>=0.4.0->llama-index) (2.5)\n",
"Requirement already satisfied: certifi<2025.0.0,>=2024.7.4 in /usr/local/lib/python3.10/dist-packages (from llama-cloud>=0.1.5->llama-index-indices-managed-llama-cloud>=0.4.0->llama-index) (2024.12.14)\n",
"Requirement already satisfied: anyio in /usr/local/lib/python3.10/dist-packages (from httpx->llama-index-core<0.13.0,>=0.12.11->llama-index) (4.0.0)\n",
"Requirement already satisfied: httpcore==1.* in /usr/local/lib/python3.10/dist-packages (from httpx->llama-index-core<0.13.0,>=0.12.11->llama-index) (1.0.7)\n",
"Requirement already satisfied: idna in /usr/local/lib/python3.10/dist-packages (from httpx->llama-index-core<0.13.0,>=0.12.11->llama-index) (3.4)\n",
"Requirement already satisfied: sniffio in /usr/local/lib/python3.10/dist-packages (from httpx->llama-index-core<0.13.0,>=0.12.11->llama-index) (1.3.0)\n",
"Requirement already satisfied: h11<0.15,>=0.13 in /usr/local/lib/python3.10/dist-packages (from httpcore==1.*->httpx->llama-index-core<0.13.0,>=0.12.11->llama-index) (0.14.0)\n",
"Requirement already satisfied: distro<2,>=1.7.0 in /usr/lib/python3/dist-packages (from openai>=1.14.0->llama-index-agent-openai<0.5.0,>=0.4.0->llama-index) (1.7.0)\n",
"Requirement already satisfied: jiter<1,>=0.4.0 in /usr/local/lib/python3.10/dist-packages (from openai>=1.14.0->llama-index-agent-openai<0.5.0,>=0.4.0->llama-index) (0.7.1)\n",
"Requirement already satisfied: annotated-types>=0.6.0 in /usr/local/lib/python3.10/dist-packages (from pydantic>=2.8.0->llama-index-core<0.13.0,>=0.12.11->llama-index) (0.7.0)\n",
"Requirement already satisfied: pydantic-core==2.23.4 in /usr/local/lib/python3.10/dist-packages (from pydantic>=2.8.0->llama-index-core<0.13.0,>=0.12.11->llama-index) (2.23.4)\n",
"Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests>=2.31.0->llama-index-core<0.13.0,>=0.12.11->llama-index) (2.1.1)\n",
"Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests>=2.31.0->llama-index-core<0.13.0,>=0.12.11->llama-index) (1.26.13)\n",
"Requirement already satisfied: greenlet!=0.4.17 in /usr/local/lib/python3.10/dist-packages (from SQLAlchemy>=1.4.49->SQLAlchemy[asyncio]>=1.4.49->llama-index-core<0.13.0,>=0.12.11->llama-index) (3.1.1)\n",
"Requirement already satisfied: mypy-extensions>=0.3.0 in /usr/local/lib/python3.10/dist-packages (from typing-inspect>=0.8.0->llama-index-core<0.13.0,>=0.12.11->llama-index) (1.0.0)\n",
"Requirement already satisfied: marshmallow<4.0.0,>=3.18.0 in /usr/local/lib/python3.10/dist-packages (from dataclasses-json->llama-index-core<0.13.0,>=0.12.11->llama-index) (3.23.2)\n",
"Requirement already satisfied: python-dateutil>=2.8.2 in /usr/local/lib/python3.10/dist-packages (from pandas->llama-index-readers-file<0.5.0,>=0.4.0->llama-index) (2.8.2)\n",
"Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.10/dist-packages (from pandas->llama-index-readers-file<0.5.0,>=0.4.0->llama-index) (2024.2)\n",
"Requirement already satisfied: tzdata>=2022.1 in /usr/local/lib/python3.10/dist-packages (from pandas->llama-index-readers-file<0.5.0,>=0.4.0->llama-index) (2024.2)\n",
"Requirement already satisfied: exceptiongroup>=1.0.2 in /usr/local/lib/python3.10/dist-packages (from anyio->httpx->llama-index-core<0.13.0,>=0.12.11->llama-index) (1.1.3)\n",
"Requirement already satisfied: packaging>=17.0 in /usr/local/lib/python3.10/dist-packages (from marshmallow<4.0.0,>=3.18.0->dataclasses-json->llama-index-core<0.13.0,>=0.12.11->llama-index) (23.2)\n",
"Requirement already satisfied: six>=1.5 in /usr/lib/python3/dist-packages (from python-dateutil>=2.8.2->pandas->llama-index-readers-file<0.5.0,>=0.4.0->llama-index) (1.16.0)\n",
"Requirement already satisfied: propcache>=0.2.0 in /usr/local/lib/python3.10/dist-packages (from yarl<2.0,>=1.12.0->aiohttp<4.0.0,>=3.8.6->llama-index-core<0.13.0,>=0.12.11->llama-index) (0.2.0)\n",
"\u001b[33mWARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv\u001b[0m\u001b[33m\n",
"\u001b[0m\n",
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m23.3.1\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m24.3.1\u001b[0m\n",
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpython -m pip install --upgrade pip\u001b[0m\n",
"Collecting faiss-cpu\n",
" Downloading faiss_cpu-1.9.0.post1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (4.4 kB)\n",
"Collecting numpy<3.0,>=1.25.0 (from faiss-cpu)\n",
" Downloading numpy-2.2.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (62 kB)\n",
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m62.0/62.0 kB\u001b[0m \u001b[31m988.6 kB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m \u001b[36m0:00:01\u001b[0m\n",
"\u001b[?25hRequirement already satisfied: packaging in /usr/local/lib/python3.10/dist-packages (from faiss-cpu) (23.2)\n",
"Downloading faiss_cpu-1.9.0.post1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (27.5 MB)\n",
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m27.5/27.5 MB\u001b[0m \u001b[31m38.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m\n",
"\u001b[?25hDownloading numpy-2.2.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (16.4 MB)\n",
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m16.4/16.4 MB\u001b[0m \u001b[31m36.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m\n",
"\u001b[?25hInstalling collected packages: numpy, faiss-cpu\n",
" Attempting uninstall: numpy\n",
" Found existing installation: numpy 1.24.1\n",
" Uninstalling numpy-1.24.1:\n",
" Successfully uninstalled numpy-1.24.1\n",
"\u001b[31mERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.\n",
"catboost 1.2.7 requires numpy<2.0,>=1.16.0, but you have numpy 2.2.1 which is incompatible.\n",
"langchain 0.3.14 requires numpy<2,>=1.22.4; python_version < \"3.12\", but you have numpy 2.2.1 which is incompatible.\n",
"langchain-community 0.3.14 requires numpy<2,>=1.22.4; python_version < \"3.12\", but you have numpy 2.2.1 which is incompatible.\n",
"numba 0.60.0 requires numpy<2.1,>=1.22, but you have numpy 2.2.1 which is incompatible.\n",
"raid-bench 0.0.9 requires numpy<1.26.0,>=1.24.0, but you have numpy 2.2.1 which is incompatible.\n",
"scikit-learn 1.3.2 requires numpy<2.0,>=1.17.3, but you have numpy 2.2.1 which is incompatible.\n",
"torchvision 0.16.0+cu118 requires torch==2.1.0, but you have torch 2.5.1 which is incompatible.\n",
"unsloth-zoo 2024.11.8 requires protobuf<4.0.0, but you have protobuf 5.29.3 which is incompatible.\u001b[0m\u001b[31m\n",
"\u001b[0mSuccessfully installed faiss-cpu-1.9.0.post1 numpy-2.2.1\n",
"\u001b[33mWARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv\u001b[0m\u001b[33m\n",
"\u001b[0m\n",
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m23.3.1\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m24.3.1\u001b[0m\n",
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpython -m pip install --upgrade pip\u001b[0m\n",
"Requirement already satisfied: python-dotenv in /usr/local/lib/python3.10/dist-packages (1.0.1)\n",
"\u001b[33mWARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv\u001b[0m\u001b[33m\n",
"\u001b[0m\n",
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m23.3.1\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m24.3.1\u001b[0m\n",
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpython -m pip install --upgrade pip\u001b[0m\n",
"Requirement already satisfied: langchain_community in /usr/local/lib/python3.10/dist-packages (0.3.14)\n",
"Requirement already satisfied: PyYAML>=5.3 in /usr/local/lib/python3.10/dist-packages (from langchain_community) (6.0.1)\n",
"Requirement already satisfied: SQLAlchemy<3,>=1.4 in /usr/local/lib/python3.10/dist-packages (from langchain_community) (2.0.36)\n",
"Requirement already satisfied: aiohttp<4.0.0,>=3.8.3 in /usr/local/lib/python3.10/dist-packages (from langchain_community) (3.10.10)\n",
"Requirement already satisfied: dataclasses-json<0.7,>=0.5.7 in /usr/local/lib/python3.10/dist-packages (from langchain_community) (0.6.7)\n",
"Requirement already satisfied: httpx-sse<0.5.0,>=0.4.0 in /usr/local/lib/python3.10/dist-packages (from langchain_community) (0.4.0)\n",
"Requirement already satisfied: langchain<0.4.0,>=0.3.14 in /usr/local/lib/python3.10/dist-packages (from langchain_community) (0.3.14)\n",
"Requirement already satisfied: langchain-core<0.4.0,>=0.3.29 in /usr/local/lib/python3.10/dist-packages (from langchain_community) (0.3.30)\n",
"Requirement already satisfied: langsmith<0.3,>=0.1.125 in /usr/local/lib/python3.10/dist-packages (from langchain_community) (0.2.11)\n",
"Collecting numpy<2,>=1.22.4 (from langchain_community)\n",
" Downloading numpy-1.26.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (61 kB)\n",
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m61.0/61.0 kB\u001b[0m \u001b[31m921.6 kB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0ma \u001b[36m0:00:01\u001b[0m\n",
"\u001b[?25hRequirement already satisfied: pydantic-settings<3.0.0,>=2.4.0 in /usr/local/lib/python3.10/dist-packages (from langchain_community) (2.6.1)\n",
"Requirement already satisfied: requests<3,>=2 in /usr/local/lib/python3.10/dist-packages (from langchain_community) (2.32.3)\n",
"Requirement already satisfied: tenacity!=8.4.0,<10,>=8.1.0 in /usr/local/lib/python3.10/dist-packages (from langchain_community) (9.0.0)\n",
"Requirement already satisfied: aiohappyeyeballs>=2.3.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4.0.0,>=3.8.3->langchain_community) (2.4.3)\n",
"Requirement already satisfied: aiosignal>=1.1.2 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4.0.0,>=3.8.3->langchain_community) (1.3.1)\n",
"Requirement already satisfied: attrs>=17.3.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4.0.0,>=3.8.3->langchain_community) (23.1.0)\n",
"Requirement already satisfied: frozenlist>=1.1.1 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4.0.0,>=3.8.3->langchain_community) (1.5.0)\n",
"Requirement already satisfied: multidict<7.0,>=4.5 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4.0.0,>=3.8.3->langchain_community) (6.1.0)\n",
"Requirement already satisfied: yarl<2.0,>=1.12.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4.0.0,>=3.8.3->langchain_community) (1.17.1)\n",
"Requirement already satisfied: async-timeout<5.0,>=4.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4.0.0,>=3.8.3->langchain_community) (4.0.3)\n",
"Requirement already satisfied: marshmallow<4.0.0,>=3.18.0 in /usr/local/lib/python3.10/dist-packages (from dataclasses-json<0.7,>=0.5.7->langchain_community) (3.23.2)\n",
"Requirement already satisfied: typing-inspect<1,>=0.4.0 in /usr/local/lib/python3.10/dist-packages (from dataclasses-json<0.7,>=0.5.7->langchain_community) (0.9.0)\n",
"Requirement already satisfied: langchain-text-splitters<0.4.0,>=0.3.3 in /usr/local/lib/python3.10/dist-packages (from langchain<0.4.0,>=0.3.14->langchain_community) (0.3.5)\n",
"Requirement already satisfied: pydantic<3.0.0,>=2.7.4 in /usr/local/lib/python3.10/dist-packages (from langchain<0.4.0,>=0.3.14->langchain_community) (2.9.2)\n",
"Requirement already satisfied: jsonpatch<2.0,>=1.33 in /usr/local/lib/python3.10/dist-packages (from langchain-core<0.4.0,>=0.3.29->langchain_community) (1.33)\n",
"Requirement already satisfied: packaging<25,>=23.2 in /usr/local/lib/python3.10/dist-packages (from langchain-core<0.4.0,>=0.3.29->langchain_community) (23.2)\n",
"Requirement already satisfied: typing-extensions>=4.7 in /usr/local/lib/python3.10/dist-packages (from langchain-core<0.4.0,>=0.3.29->langchain_community) (4.12.2)\n",
"Requirement already satisfied: httpx<1,>=0.23.0 in /usr/local/lib/python3.10/dist-packages (from langsmith<0.3,>=0.1.125->langchain_community) (0.27.2)\n",
"Requirement already satisfied: orjson<4.0.0,>=3.9.14 in /usr/local/lib/python3.10/dist-packages (from langsmith<0.3,>=0.1.125->langchain_community) (3.10.11)\n",
"Requirement already satisfied: requests-toolbelt<2.0.0,>=1.0.0 in /usr/local/lib/python3.10/dist-packages (from langsmith<0.3,>=0.1.125->langchain_community) (1.0.0)\n",
"Requirement already satisfied: python-dotenv>=0.21.0 in /usr/local/lib/python3.10/dist-packages (from pydantic-settings<3.0.0,>=2.4.0->langchain_community) (1.0.1)\n",
"Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests<3,>=2->langchain_community) (2.1.1)\n",
"Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests<3,>=2->langchain_community) (3.4)\n",
"Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests<3,>=2->langchain_community) (1.26.13)\n",
"Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests<3,>=2->langchain_community) (2024.12.14)\n",
"Requirement already satisfied: greenlet!=0.4.17 in /usr/local/lib/python3.10/dist-packages (from SQLAlchemy<3,>=1.4->langchain_community) (3.1.1)\n",
"Requirement already satisfied: anyio in /usr/local/lib/python3.10/dist-packages (from httpx<1,>=0.23.0->langsmith<0.3,>=0.1.125->langchain_community) (4.0.0)\n",
"Requirement already satisfied: httpcore==1.* in /usr/local/lib/python3.10/dist-packages (from httpx<1,>=0.23.0->langsmith<0.3,>=0.1.125->langchain_community) (1.0.7)\n",
"Requirement already satisfied: sniffio in /usr/local/lib/python3.10/dist-packages (from httpx<1,>=0.23.0->langsmith<0.3,>=0.1.125->langchain_community) (1.3.0)\n",
"Requirement already satisfied: h11<0.15,>=0.13 in /usr/local/lib/python3.10/dist-packages (from httpcore==1.*->httpx<1,>=0.23.0->langsmith<0.3,>=0.1.125->langchain_community) (0.14.0)\n",
"Requirement already satisfied: jsonpointer>=1.9 in /usr/local/lib/python3.10/dist-packages (from jsonpatch<2.0,>=1.33->langchain-core<0.4.0,>=0.3.29->langchain_community) (2.4)\n",
"Requirement already satisfied: annotated-types>=0.6.0 in /usr/local/lib/python3.10/dist-packages (from pydantic<3.0.0,>=2.7.4->langchain<0.4.0,>=0.3.14->langchain_community) (0.7.0)\n",
"Requirement already satisfied: pydantic-core==2.23.4 in /usr/local/lib/python3.10/dist-packages (from pydantic<3.0.0,>=2.7.4->langchain<0.4.0,>=0.3.14->langchain_community) (2.23.4)\n",
"Requirement already satisfied: mypy-extensions>=0.3.0 in /usr/local/lib/python3.10/dist-packages (from typing-inspect<1,>=0.4.0->dataclasses-json<0.7,>=0.5.7->langchain_community) (1.0.0)\n",
"Requirement already satisfied: propcache>=0.2.0 in /usr/local/lib/python3.10/dist-packages (from yarl<2.0,>=1.12.0->aiohttp<4.0.0,>=3.8.3->langchain_community) (0.2.0)\n",
"Requirement already satisfied: exceptiongroup>=1.0.2 in /usr/local/lib/python3.10/dist-packages (from anyio->httpx<1,>=0.23.0->langsmith<0.3,>=0.1.125->langchain_community) (1.1.3)\n",
"Downloading numpy-1.26.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (18.2 MB)\n",
"\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m18.2/18.2 MB\u001b[0m \u001b[31m40.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m00:01\u001b[0m00:01\u001b[0m\n",
"\u001b[?25hInstalling collected packages: numpy\n",
" Attempting uninstall: numpy\n",
" Found existing installation: numpy 2.2.1\n",
" Uninstalling numpy-2.2.1:\n",
" Successfully uninstalled numpy-2.2.1\n",
"\u001b[31mERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.\n",
"raid-bench 0.0.9 requires numpy<1.26.0,>=1.24.0, but you have numpy 1.26.4 which is incompatible.\n",
"torchvision 0.16.0+cu118 requires torch==2.1.0, but you have torch 2.5.1 which is incompatible.\n",
"unsloth-zoo 2024.11.8 requires protobuf<4.0.0, but you have protobuf 5.29.3 which is incompatible.\u001b[0m\u001b[31m\n",
"\u001b[0mSuccessfully installed numpy-1.26.4\n",
"\u001b[33mWARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv\u001b[0m\u001b[33m\n",
"\u001b[0m\n",
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m23.3.1\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m24.3.1\u001b[0m\n",
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpython -m pip install --upgrade pip\u001b[0m\n"
]
}
],
"source": [
"# Required installations:\n",
"!pip install pypdf\n",
"!pip install llama-index\n",
"!pip install faiss-cpu\n",
"!pip install python-dotenv\n",
"!pip install langchain_community"
]
},
{
"cell_type": "code",
"execution_count": 20,
"id": "248774c6-1e39-48b3-8a35-d8b02a2d1c27",
"metadata": {},
"outputs": [],
"source": [
"import os\n",
"from typing import List\n",
"import faiss\n",
"import numpy as np\n",
"from datetime import datetime\n",
"from sentence_transformers import SentenceTransformer\n",
"from langchain_community.llms import Ollama\n",
"from langchain_community.document_loaders import DirectoryLoader, PyPDFLoader\n",
"from langchain.text_splitter import RecursiveCharacterTextSplitter\n",
"from llama_index.core import SimpleDirectoryReader\n",
"from llama_index.core.node_parser import SimpleFileNodeParser\n",
"from llama_index.core.node_parser import SimpleNodeParser\n",
"from llama_index.core import Document"
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "9ae9820a-819e-4d5b-be44-0fb85e21dec2",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Requirement already satisfied: llama-index in /usr/local/lib/python3.10/dist-packages (0.12.11)\n",
"Requirement already satisfied: llama-index-core in /usr/local/lib/python3.10/dist-packages (0.12.11)\n",
"Requirement already satisfied: llama-index-agent-openai<0.5.0,>=0.4.0 in /usr/local/lib/python3.10/dist-packages (from llama-index) (0.4.2)\n",
"Requirement already satisfied: llama-index-cli<0.5.0,>=0.4.0 in /usr/local/lib/python3.10/dist-packages (from llama-index) (0.4.0)\n",
"Requirement already satisfied: llama-index-embeddings-openai<0.4.0,>=0.3.0 in /usr/local/lib/python3.10/dist-packages (from llama-index) (0.3.1)\n",
"Requirement already satisfied: llama-index-indices-managed-llama-cloud>=0.4.0 in /usr/local/lib/python3.10/dist-packages (from llama-index) (0.6.3)\n",
"Requirement already satisfied: llama-index-llms-openai<0.4.0,>=0.3.0 in /usr/local/lib/python3.10/dist-packages (from llama-index) (0.3.13)\n",
"Requirement already satisfied: llama-index-multi-modal-llms-openai<0.5.0,>=0.4.0 in /usr/local/lib/python3.10/dist-packages (from llama-index) (0.4.2)\n",
"Requirement already satisfied: llama-index-program-openai<0.4.0,>=0.3.0 in /usr/local/lib/python3.10/dist-packages (from llama-index) (0.3.1)\n",
"Requirement already satisfied: llama-index-question-gen-openai<0.4.0,>=0.3.0 in /usr/local/lib/python3.10/dist-packages (from llama-index) (0.3.0)\n",
"Requirement already satisfied: llama-index-readers-file<0.5.0,>=0.4.0 in /usr/local/lib/python3.10/dist-packages (from llama-index) (0.4.3)\n",
"Requirement already satisfied: llama-index-readers-llama-parse>=0.4.0 in /usr/local/lib/python3.10/dist-packages (from llama-index) (0.4.0)\n",
"Requirement already satisfied: nltk>3.8.1 in /usr/local/lib/python3.10/dist-packages (from llama-index) (3.9.1)\n",
"Requirement already satisfied: PyYAML>=6.0.1 in /usr/local/lib/python3.10/dist-packages (from llama-index-core) (6.0.1)\n",
"Requirement already satisfied: SQLAlchemy>=1.4.49 in /usr/local/lib/python3.10/dist-packages (from SQLAlchemy[asyncio]>=1.4.49->llama-index-core) (2.0.36)\n",
"Requirement already satisfied: aiohttp<4.0.0,>=3.8.6 in /usr/local/lib/python3.10/dist-packages (from llama-index-core) (3.10.10)\n",
"Requirement already satisfied: dataclasses-json in /usr/local/lib/python3.10/dist-packages (from llama-index-core) (0.6.7)\n",
"Requirement already satisfied: deprecated>=1.2.9.3 in /usr/local/lib/python3.10/dist-packages (from llama-index-core) (1.2.15)\n",
"Requirement already satisfied: dirtyjson<2.0.0,>=1.0.8 in /usr/local/lib/python3.10/dist-packages (from llama-index-core) (1.0.8)\n",
"Requirement already satisfied: filetype<2.0.0,>=1.2.0 in /usr/local/lib/python3.10/dist-packages (from llama-index-core) (1.2.0)\n",
"Requirement already satisfied: fsspec>=2023.5.0 in /usr/local/lib/python3.10/dist-packages (from llama-index-core) (2024.9.0)\n",
"Requirement already satisfied: httpx in /usr/local/lib/python3.10/dist-packages (from llama-index-core) (0.27.2)\n",
"Requirement already satisfied: nest-asyncio<2.0.0,>=1.5.8 in /usr/local/lib/python3.10/dist-packages (from llama-index-core) (1.5.8)\n",
"Requirement already satisfied: networkx>=3.0 in /usr/local/lib/python3.10/dist-packages (from llama-index-core) (3.0)\n",
"Requirement already satisfied: numpy in /usr/local/lib/python3.10/dist-packages (from llama-index-core) (1.26.4)\n",
"Requirement already satisfied: pillow>=9.0.0 in /usr/local/lib/python3.10/dist-packages (from llama-index-core) (11.1.0)\n",
"Requirement already satisfied: pydantic>=2.8.0 in /usr/local/lib/python3.10/dist-packages (from llama-index-core) (2.9.2)\n",
"Requirement already satisfied: requests>=2.31.0 in /usr/local/lib/python3.10/dist-packages (from llama-index-core) (2.32.3)\n",
"Requirement already satisfied: tenacity!=8.4.0,<10.0.0,>=8.2.0 in /usr/local/lib/python3.10/dist-packages (from llama-index-core) (9.0.0)\n",
"Requirement already satisfied: tiktoken>=0.3.3 in /usr/local/lib/python3.10/dist-packages (from llama-index-core) (0.8.0)\n",
"Requirement already satisfied: tqdm<5.0.0,>=4.66.1 in /usr/local/lib/python3.10/dist-packages (from llama-index-core) (4.67.0)\n",
"Requirement already satisfied: typing-extensions>=4.5.0 in /usr/local/lib/python3.10/dist-packages (from llama-index-core) (4.12.2)\n",
"Requirement already satisfied: typing-inspect>=0.8.0 in /usr/local/lib/python3.10/dist-packages (from llama-index-core) (0.9.0)\n",
"Requirement already satisfied: wrapt in /usr/local/lib/python3.10/dist-packages (from llama-index-core) (1.17.0)\n",
"Requirement already satisfied: aiohappyeyeballs>=2.3.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core) (2.4.3)\n",
"Requirement already satisfied: aiosignal>=1.1.2 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core) (1.3.1)\n",
"Requirement already satisfied: attrs>=17.3.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core) (23.1.0)\n",
"Requirement already satisfied: frozenlist>=1.1.1 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core) (1.5.0)\n",
"Requirement already satisfied: multidict<7.0,>=4.5 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core) (6.1.0)\n",
"Requirement already satisfied: yarl<2.0,>=1.12.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core) (1.17.1)\n",
"Requirement already satisfied: async-timeout<5.0,>=4.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core) (4.0.3)\n",
"Requirement already satisfied: openai>=1.14.0 in /usr/local/lib/python3.10/dist-packages (from llama-index-agent-openai<0.5.0,>=0.4.0->llama-index) (1.59.7)\n",
"Requirement already satisfied: llama-cloud>=0.1.5 in /usr/local/lib/python3.10/dist-packages (from llama-index-indices-managed-llama-cloud>=0.4.0->llama-index) (0.1.9)\n",
"Requirement already satisfied: beautifulsoup4<5.0.0,>=4.12.3 in /usr/local/lib/python3.10/dist-packages (from llama-index-readers-file<0.5.0,>=0.4.0->llama-index) (4.12.3)\n",
"Requirement already satisfied: pandas in /usr/local/lib/python3.10/dist-packages (from llama-index-readers-file<0.5.0,>=0.4.0->llama-index) (2.0.3)\n",
"Requirement already satisfied: pypdf<6.0.0,>=5.1.0 in /usr/local/lib/python3.10/dist-packages (from llama-index-readers-file<0.5.0,>=0.4.0->llama-index) (5.1.0)\n",
"Requirement already satisfied: striprtf<0.0.27,>=0.0.26 in /usr/local/lib/python3.10/dist-packages (from llama-index-readers-file<0.5.0,>=0.4.0->llama-index) (0.0.26)\n",
"Requirement already satisfied: llama-parse>=0.5.0 in /usr/local/lib/python3.10/dist-packages (from llama-index-readers-llama-parse>=0.4.0->llama-index) (0.5.19)\n",
"Requirement already satisfied: click in /usr/local/lib/python3.10/dist-packages (from nltk>3.8.1->llama-index) (8.1.7)\n",
"Requirement already satisfied: joblib in /usr/local/lib/python3.10/dist-packages (from nltk>3.8.1->llama-index) (1.4.2)\n",
"Requirement already satisfied: regex>=2021.8.3 in /usr/local/lib/python3.10/dist-packages (from nltk>3.8.1->llama-index) (2024.11.6)\n",
"Requirement already satisfied: annotated-types>=0.6.0 in /usr/local/lib/python3.10/dist-packages (from pydantic>=2.8.0->llama-index-core) (0.7.0)\n",
"Requirement already satisfied: pydantic-core==2.23.4 in /usr/local/lib/python3.10/dist-packages (from pydantic>=2.8.0->llama-index-core) (2.23.4)\n",
"Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests>=2.31.0->llama-index-core) (2.1.1)\n",
"Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests>=2.31.0->llama-index-core) (3.4)\n",
"Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests>=2.31.0->llama-index-core) (1.26.13)\n",
"Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests>=2.31.0->llama-index-core) (2024.12.14)\n",
"Requirement already satisfied: greenlet!=0.4.17 in /usr/local/lib/python3.10/dist-packages (from SQLAlchemy>=1.4.49->SQLAlchemy[asyncio]>=1.4.49->llama-index-core) (3.1.1)\n",
"Requirement already satisfied: mypy-extensions>=0.3.0 in /usr/local/lib/python3.10/dist-packages (from typing-inspect>=0.8.0->llama-index-core) (1.0.0)\n",
"Requirement already satisfied: marshmallow<4.0.0,>=3.18.0 in /usr/local/lib/python3.10/dist-packages (from dataclasses-json->llama-index-core) (3.23.2)\n",
"Requirement already satisfied: anyio in /usr/local/lib/python3.10/dist-packages (from httpx->llama-index-core) (4.0.0)\n",
"Requirement already satisfied: httpcore==1.* in /usr/local/lib/python3.10/dist-packages (from httpx->llama-index-core) (1.0.7)\n",
"Requirement already satisfied: sniffio in /usr/local/lib/python3.10/dist-packages (from httpx->llama-index-core) (1.3.0)\n",
"Requirement already satisfied: h11<0.15,>=0.13 in /usr/local/lib/python3.10/dist-packages (from httpcore==1.*->httpx->llama-index-core) (0.14.0)\n",
"Requirement already satisfied: soupsieve>1.2 in /usr/local/lib/python3.10/dist-packages (from beautifulsoup4<5.0.0,>=4.12.3->llama-index-readers-file<0.5.0,>=0.4.0->llama-index) (2.5)\n",
"Requirement already satisfied: packaging>=17.0 in /usr/local/lib/python3.10/dist-packages (from marshmallow<4.0.0,>=3.18.0->dataclasses-json->llama-index-core) (23.2)\n",
"Requirement already satisfied: distro<2,>=1.7.0 in /usr/lib/python3/dist-packages (from openai>=1.14.0->llama-index-agent-openai<0.5.0,>=0.4.0->llama-index) (1.7.0)\n",
"Requirement already satisfied: jiter<1,>=0.4.0 in /usr/local/lib/python3.10/dist-packages (from openai>=1.14.0->llama-index-agent-openai<0.5.0,>=0.4.0->llama-index) (0.7.1)\n",
"Requirement already satisfied: exceptiongroup>=1.0.2 in /usr/local/lib/python3.10/dist-packages (from anyio->httpx->llama-index-core) (1.1.3)\n",
"Requirement already satisfied: propcache>=0.2.0 in /usr/local/lib/python3.10/dist-packages (from yarl<2.0,>=1.12.0->aiohttp<4.0.0,>=3.8.6->llama-index-core) (0.2.0)\n",
"Requirement already satisfied: python-dateutil>=2.8.2 in /usr/local/lib/python3.10/dist-packages (from pandas->llama-index-readers-file<0.5.0,>=0.4.0->llama-index) (2.8.2)\n",
"Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.10/dist-packages (from pandas->llama-index-readers-file<0.5.0,>=0.4.0->llama-index) (2024.2)\n",
"Requirement already satisfied: tzdata>=2022.1 in /usr/local/lib/python3.10/dist-packages (from pandas->llama-index-readers-file<0.5.0,>=0.4.0->llama-index) (2024.2)\n",
"Requirement already satisfied: six>=1.5 in /usr/lib/python3/dist-packages (from python-dateutil>=2.8.2->pandas->llama-index-readers-file<0.5.0,>=0.4.0->llama-index) (1.16.0)\n",
"\u001b[33mWARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv\u001b[0m\u001b[33m\n",
"\u001b[0m\n",
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m23.3.1\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m24.3.1\u001b[0m\n",
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpython -m pip install --upgrade pip\u001b[0m\n"
]
}
],
"source": [
"!pip install -U llama-index llama-index-core"
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "95c8503a-cc9f-4c35-a0f6-216dfee1844d",
"metadata": {},
"outputs": [],
"source": [
"from llama_index.core import download_loader"
]
},
{
"cell_type": "code",
"execution_count": 32,
"id": "ffe58842-1825-4ca3-9a88-997b674f2e1f",
"metadata": {},
"outputs": [],
"source": [
"class DocumentProcessor:\n",
" def __init__(self, directory_path: str):\n",
" self.directory_path = directory_path\n",
" \n",
" def load_pdfs_langchain(self) -> List[str]:\n",
" \"\"\"Load PDFs using LangChain's DirectoryLoader\"\"\"\n",
" loader = DirectoryLoader(\n",
" self.directory_path,\n",
" glob=\"**/*.pdf\",\n",
" loader_cls=PyPDFLoader\n",
" )\n",
" documents = loader.load()\n",
" \n",
" # Split documents into chunks\n",
" text_splitter = RecursiveCharacterTextSplitter(\n",
" chunk_size=1000,\n",
" chunk_overlap=200,\n",
" length_function=len,\n",
" )\n",
" \n",
" splits = text_splitter.split_documents(documents)\n",
" return [split.page_content for split in splits]\n",
" \n",
" def load_pdfs_llamaindex(self) -> List[str]:\n",
" \"\"\"Load PDFs using LlamaIndex\"\"\"\n",
" PDFReader = download_loader(\"PDFReader\")\n",
" loader = SimpleDirectoryReader(\n",
" self.directory_path,\n",
" file_extractor={\n",
" \".pdf\": PDFReader()\n",
" }\n",
" )\n",
" documents = loader.load_data()\n",
" \n",
" # Parse into nodes\n",
" parser = SimpleNodeParser.from_defaults(\n",
" chunk_size=1000,\n",
" chunk_overlap=200\n",
" )\n",
" nodes = parser.get_nodes_from_documents(documents)\n",
" \n",
" return [node.text for node in nodes]"
]
},
{
"cell_type": "code",
"execution_count": 33,
"id": "36e720d6-4fb4-4076-8320-20b9d9710096",
"metadata": {},
"outputs": [],
"source": [
"class EmbeddingModel:\n",
" def __init__(self):\n",
" self.model = SentenceTransformer('all-MiniLM-L6-v2')\n",
" \n",
" def get_embeddings(self, texts: List[str]) -> np.ndarray:\n",
" embeddings = self.model.encode(texts)\n",
" return embeddings\n"
]
},
{
"cell_type": "code",
"execution_count": 34,
"id": "705eac53-6651-4352-87c3-47a8a76dfb92",
"metadata": {},
"outputs": [],
"source": [
"class VectorStore:\n",
" def __init__(self, dimension: int):\n",
" self.index = faiss.IndexFlatL2(dimension)\n",
" self.texts = []\n",
" \n",
" def add_texts(self, texts: List[str], embeddings: np.ndarray):\n",
" self.texts.extend(texts)\n",
" self.index.add(embeddings.astype('float32'))\n",
" \n",
" def similarity_search(self, query_embedding: np.ndarray, k: int = 3):\n",
" distances, indices = self.index.search(query_embedding.reshape(1, -1).astype('float32'), k)\n",
" return [(self.texts[i], distances[0][idx]) for idx, i in enumerate(indices[0])]"
]
},
{
"cell_type": "code",
"execution_count": 35,
"id": "83b189f4-ed4d-46f8-a5de-cc0cfbf122de",
"metadata": {},
"outputs": [],
"source": [
"class RAGPipeline:\n",
" def __init__(self, pdf_directory: str):\n",
" self.embedding_model = EmbeddingModel()\n",
" self.vector_store = VectorStore(dimension=384)\n",
" self.llm = Ollama(model=\"gemma2:9b\")\n",
" self.doc_processor = DocumentProcessor(pdf_directory)\n",
" \n",
" def load_and_index_documents(self, use_llamaindex: bool = True):\n",
" \"\"\"Load PDFs and index them in the vector store\"\"\"\n",
" print(\"Loading and processing documents...\")\n",
" \n",
" # Load documents using either LlamaIndex or LangChain\n",
" if use_llamaindex:\n",
" documents = self.doc_processor.load_pdfs_llamaindex()\n",
" else:\n",
" documents = self.doc_processor.load_pdfs_langchain()\n",
" \n",
" print(f\"Loaded {len(documents)} text chunks\")\n",
" \n",
" # Get embeddings and add to vector store\n",
" print(\"Creating embeddings and indexing documents...\")\n",
" embeddings = self.embedding_model.get_embeddings(documents)\n",
" self.vector_store.add_texts(documents, embeddings)\n",
" print(\"Indexing complete!\")\n",
" \n",
" def query(self, question: str, k: int = 3):\n",
" # Get question embedding\n",
" question_embedding = self.embedding_model.get_embeddings([question])\n",
" \n",
" # Retrieve relevant documents\n",
" relevant_docs = self.vector_store.similarity_search(question_embedding, k)\n",
" \n",
" # Create prompt with context and metadata\n",
" context = \"\\n\".join([doc[0] for doc in relevant_docs])\n",
" \n",
" prompt = f\"\"\"Given the context below, answer the question. If you cannot answer based on the context, say \"I cannot answer based on the given context.\"\n",
"\n",
" Context:\n",
" {context}\n",
" \n",
" Question: {question}\n",
" \n",
" Please provide a detailed answer based on the context provided above.\n",
" \n",
" Current Time (UTC): {datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S')}\n",
" \n",
" Answer:\"\"\"\n",
" \n",
" # Generate answer using Ollama\n",
" response = self.llm.invoke(prompt)\n",
" return response,context"
]
},
{
"cell_type": "code",
"execution_count": 27,
"id": "f03fca20-9c23-497f-9250-8677efb8bc63",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Loading and processing documents...\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"/tmp/ipykernel_880667/3826327294.py:26: DeprecationWarning: Call to deprecated function (or staticmethod) download_loader. (`download_loader()` is deprecated. Please install tool using pip install directly instead.)\n",
" PDFReader = download_loader(\"PDFReader\")\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Requirement already satisfied: llama-index-readers-file in /usr/local/lib/python3.10/dist-packages (0.4.3)\n",
"Requirement already satisfied: beautifulsoup4<5.0.0,>=4.12.3 in /usr/local/lib/python3.10/dist-packages (from llama-index-readers-file) (4.12.3)\n",
"Requirement already satisfied: llama-index-core<0.13.0,>=0.12.0 in /usr/local/lib/python3.10/dist-packages (from llama-index-readers-file) (0.12.11)\n",
"Requirement already satisfied: pandas in /usr/local/lib/python3.10/dist-packages (from llama-index-readers-file) (2.0.3)\n",
"Requirement already satisfied: pypdf<6.0.0,>=5.1.0 in /usr/local/lib/python3.10/dist-packages (from llama-index-readers-file) (5.1.0)\n",
"Requirement already satisfied: striprtf<0.0.27,>=0.0.26 in /usr/local/lib/python3.10/dist-packages (from llama-index-readers-file) (0.0.26)\n",
"Requirement already satisfied: soupsieve>1.2 in /usr/local/lib/python3.10/dist-packages (from beautifulsoup4<5.0.0,>=4.12.3->llama-index-readers-file) (2.5)\n",
"Requirement already satisfied: PyYAML>=6.0.1 in /usr/local/lib/python3.10/dist-packages (from llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (6.0.1)\n",
"Requirement already satisfied: SQLAlchemy>=1.4.49 in /usr/local/lib/python3.10/dist-packages (from SQLAlchemy[asyncio]>=1.4.49->llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (2.0.36)\n",
"Requirement already satisfied: aiohttp<4.0.0,>=3.8.6 in /usr/local/lib/python3.10/dist-packages (from llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (3.10.10)\n",
"Requirement already satisfied: dataclasses-json in /usr/local/lib/python3.10/dist-packages (from llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (0.6.7)\n",
"Requirement already satisfied: deprecated>=1.2.9.3 in /usr/local/lib/python3.10/dist-packages (from llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (1.2.15)\n",
"Requirement already satisfied: dirtyjson<2.0.0,>=1.0.8 in /usr/local/lib/python3.10/dist-packages (from llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (1.0.8)\n",
"Requirement already satisfied: filetype<2.0.0,>=1.2.0 in /usr/local/lib/python3.10/dist-packages (from llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (1.2.0)\n",
"Requirement already satisfied: fsspec>=2023.5.0 in /usr/local/lib/python3.10/dist-packages (from llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (2024.9.0)\n",
"Requirement already satisfied: httpx in /usr/local/lib/python3.10/dist-packages (from llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (0.27.2)\n",
"Requirement already satisfied: nest-asyncio<2.0.0,>=1.5.8 in /usr/local/lib/python3.10/dist-packages (from llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (1.5.8)\n",
"Requirement already satisfied: networkx>=3.0 in /usr/local/lib/python3.10/dist-packages (from llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (3.0)\n",
"Requirement already satisfied: nltk>3.8.1 in /usr/local/lib/python3.10/dist-packages (from llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (3.9.1)\n",
"Requirement already satisfied: numpy in /usr/local/lib/python3.10/dist-packages (from llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (1.26.4)\n",
"Requirement already satisfied: pillow>=9.0.0 in /usr/local/lib/python3.10/dist-packages (from llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (11.1.0)\n",
"Requirement already satisfied: pydantic>=2.8.0 in /usr/local/lib/python3.10/dist-packages (from llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (2.9.2)\n",
"Requirement already satisfied: requests>=2.31.0 in /usr/local/lib/python3.10/dist-packages (from llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (2.32.3)\n",
"Requirement already satisfied: tenacity!=8.4.0,<10.0.0,>=8.2.0 in /usr/local/lib/python3.10/dist-packages (from llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (9.0.0)\n",
"Requirement already satisfied: tiktoken>=0.3.3 in /usr/local/lib/python3.10/dist-packages (from llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (0.8.0)\n",
"Requirement already satisfied: tqdm<5.0.0,>=4.66.1 in /usr/local/lib/python3.10/dist-packages (from llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (4.67.0)\n",
"Requirement already satisfied: typing-extensions>=4.5.0 in /usr/local/lib/python3.10/dist-packages (from llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (4.12.2)\n",
"Requirement already satisfied: typing-inspect>=0.8.0 in /usr/local/lib/python3.10/dist-packages (from llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (0.9.0)\n",
"Requirement already satisfied: wrapt in /usr/local/lib/python3.10/dist-packages (from llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (1.17.0)\n",
"Requirement already satisfied: python-dateutil>=2.8.2 in /usr/local/lib/python3.10/dist-packages (from pandas->llama-index-readers-file) (2.8.2)\n",
"Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.10/dist-packages (from pandas->llama-index-readers-file) (2024.2)\n",
"Requirement already satisfied: tzdata>=2022.1 in /usr/local/lib/python3.10/dist-packages (from pandas->llama-index-readers-file) (2024.2)\n",
"Requirement already satisfied: aiohappyeyeballs>=2.3.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (2.4.3)\n",
"Requirement already satisfied: aiosignal>=1.1.2 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (1.3.1)\n",
"Requirement already satisfied: attrs>=17.3.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (23.1.0)\n",
"Requirement already satisfied: frozenlist>=1.1.1 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (1.5.0)\n",
"Requirement already satisfied: multidict<7.0,>=4.5 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (6.1.0)\n",
"Requirement already satisfied: yarl<2.0,>=1.12.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (1.17.1)\n",
"Requirement already satisfied: async-timeout<5.0,>=4.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (4.0.3)\n",
"Requirement already satisfied: click in /usr/local/lib/python3.10/dist-packages (from nltk>3.8.1->llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (8.1.7)\n",
"Requirement already satisfied: joblib in /usr/local/lib/python3.10/dist-packages (from nltk>3.8.1->llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (1.4.2)\n",
"Requirement already satisfied: regex>=2021.8.3 in /usr/local/lib/python3.10/dist-packages (from nltk>3.8.1->llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (2024.11.6)\n",
"Requirement already satisfied: annotated-types>=0.6.0 in /usr/local/lib/python3.10/dist-packages (from pydantic>=2.8.0->llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (0.7.0)\n",
"Requirement already satisfied: pydantic-core==2.23.4 in /usr/local/lib/python3.10/dist-packages (from pydantic>=2.8.0->llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (2.23.4)\n",
"Requirement already satisfied: six>=1.5 in /usr/lib/python3/dist-packages (from python-dateutil>=2.8.2->pandas->llama-index-readers-file) (1.16.0)\n",
"Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests>=2.31.0->llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (2.1.1)\n",
"Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests>=2.31.0->llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (3.4)\n",
"Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests>=2.31.0->llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (1.26.13)\n",
"Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests>=2.31.0->llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (2024.12.14)\n",
"Requirement already satisfied: greenlet!=0.4.17 in /usr/local/lib/python3.10/dist-packages (from SQLAlchemy>=1.4.49->SQLAlchemy[asyncio]>=1.4.49->llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (3.1.1)\n",
"Requirement already satisfied: mypy-extensions>=0.3.0 in /usr/local/lib/python3.10/dist-packages (from typing-inspect>=0.8.0->llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (1.0.0)\n",
"Requirement already satisfied: marshmallow<4.0.0,>=3.18.0 in /usr/local/lib/python3.10/dist-packages (from dataclasses-json->llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (3.23.2)\n",
"Requirement already satisfied: anyio in /usr/local/lib/python3.10/dist-packages (from httpx->llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (4.0.0)\n",
"Requirement already satisfied: httpcore==1.* in /usr/local/lib/python3.10/dist-packages (from httpx->llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (1.0.7)\n",
"Requirement already satisfied: sniffio in /usr/local/lib/python3.10/dist-packages (from httpx->llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (1.3.0)\n",
"Requirement already satisfied: h11<0.15,>=0.13 in /usr/local/lib/python3.10/dist-packages (from httpcore==1.*->httpx->llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (0.14.0)\n",
"Requirement already satisfied: packaging>=17.0 in /usr/local/lib/python3.10/dist-packages (from marshmallow<4.0.0,>=3.18.0->dataclasses-json->llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (23.2)\n",
"Requirement already satisfied: propcache>=0.2.0 in /usr/local/lib/python3.10/dist-packages (from yarl<2.0,>=1.12.0->aiohttp<4.0.0,>=3.8.6->llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (0.2.0)\n",
"Requirement already satisfied: exceptiongroup>=1.0.2 in /usr/local/lib/python3.10/dist-packages (from anyio->httpx->llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (1.1.3)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\u001b[33mWARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv\u001b[0m\u001b[33m\n",
"\u001b[0m\n",
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m23.3.1\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m24.3.1\u001b[0m\n",
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpython -m pip install --upgrade pip\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Loaded 15 text chunks\n",
"Creating embeddings and indexing documents...\n",
"Indexing complete!\n",
"\n",
"Question: What are the main topics covered in the documents?\n",
"Answer: The provided text consists of two distinct sets of references, each focusing on different topics. \n",
"\n",
"**Set 1:** This set focuses on the topic of cell phone usage for children, particularly tweens (ages 8-12). The sources discuss:\n",
"\n",
"* **Appropriate age for a child to have a cell phone:** Various experts and surveys are cited to present arguments for and against giving younger children access to phones.\n",
"* **Benefits of cell phone use for children:** This includes increased independence, safety in emergencies, and communication with parents.\n",
"* **Potential concerns surrounding cell phone use:** While the provided text doesn't explicitly list concerns, it implies potential issues by focusing on responsible use and setting guidelines.\n",
"\n",
"**Set 2:** This set explores the topic of parenting classes and their effectiveness. The sources delve into:\n",
"\n",
"* **Different types of parenting programs:** The references highlight various approaches and methodologies used in these programs.\n",
"* **Benefits of attending parenting classes:** This includes improved child behavior, enhanced parent-child relationships, and increased knowledge about effective parenting techniques.\n",
"* **Effectiveness of parenting classes:** Studies and research findings are cited to assess the impact of parenting programs on child development and family dynamics. \n",
"\n",
"\n",
"Let me know if you have any other questions or need further clarification!\n",
"--------------------------------------------------------------------------------\n",
"\n",
"Question: Can you summarize the key points from the documents?\n",
"Answer: The provided text focuses on two main topics:\n",
"\n",
"**1. The Ideal Age for Children to Have Cell Phones:**\n",
"\n",
"* **Argument for Earlier Adoption:** Deborah Pendergast, representing a telecommunications company, argues that age 10 is appropriate for children to have cell phones. She cites a 2012 survey by the National Consumers League showing almost 60% of children ages 8-12 already possess phones. \n",
"* **Benefits Highlighted:** Pendergast emphasizes the benefits of cell phone ownership for both parents and children: increased independence for kids (e.g., walking home safely), and a sense of security for parents who can easily contact their children. She uses a scenario of a parent stuck in traffic to illustrate how cell phones can provide reassurance and communication in unexpected situations.\n",
"* **Counterarguments Not Presented:** The text primarily presents Pendergast's viewpoint without including opposing arguments regarding potential risks or drawbacks associated with early cell phone use.\n",
"\n",
"**2. Parenting Classes:** \n",
"\n",
"* **General Discussion:** While the focus is primarily on cell phones, the text also includes a section about parenting classes. It lists various articles and studies exploring the effectiveness of such programs.\n",
"* **Lack of Specific Conclusions:** This section lacks a clear summary or conclusion regarding whether parenting classes are beneficial. It simply presents diverse viewpoints and resources related to the topic.\n",
"\n",
"\n",
"\n",
"**In Summary:** The provided text advocates for an earlier age for cell phone adoption, citing benefits like increased independence and parental security. It briefly touches upon parenting classes but doesn't reach a definitive conclusion about their effectiveness. \n",
"\n",
"--------------------------------------------------------------------------------\n"
]
}
],
"source": [
"pdf_directory = \"/workspace/lipsync/dataset\" # Replace with your PDF folder path\n",
"\n",
"# Initialize RAG pipeline\n",
"rag = RAGPipeline(pdf_directory)\n",
"\n",
"# Load and index documents (choose either LlamaIndex or LangChain)\n",
"rag.load_and_index_documents(use_llamaindex=True) # Set to False to use LangChain\n",
"\n",
"# Example queries\n",
"questions = [\n",
" \"What are the main topics covered in the documents?\",\n",
" \"Can you summarize the key points from the documents?\",\n",
" # Add your own questions here\n",
"]\n",
"\n",
"for question in questions:\n",
" print(f\"\\nQuestion: {question}\")\n",
" answer = rag.query(question)\n",
" print(f\"Answer: {answer}\")\n",
" print(\"-\" * 80)"
]
},
{
"cell_type": "code",
"execution_count": 36,
"id": "8f1affde-c380-478b-93cb-fa318af241d0",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Loading and processing documents...\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"/tmp/ipykernel_880667/3826327294.py:26: DeprecationWarning: Call to deprecated function (or staticmethod) download_loader. (`download_loader()` is deprecated. Please install tool using pip install directly instead.)\n",
" PDFReader = download_loader(\"PDFReader\")\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Requirement already satisfied: llama-index-readers-file in /usr/local/lib/python3.10/dist-packages (0.4.3)\n",
"Requirement already satisfied: beautifulsoup4<5.0.0,>=4.12.3 in /usr/local/lib/python3.10/dist-packages (from llama-index-readers-file) (4.12.3)\n",
"Requirement already satisfied: llama-index-core<0.13.0,>=0.12.0 in /usr/local/lib/python3.10/dist-packages (from llama-index-readers-file) (0.12.11)\n",
"Requirement already satisfied: pandas in /usr/local/lib/python3.10/dist-packages (from llama-index-readers-file) (2.0.3)\n",
"Requirement already satisfied: pypdf<6.0.0,>=5.1.0 in /usr/local/lib/python3.10/dist-packages (from llama-index-readers-file) (5.1.0)\n",
"Requirement already satisfied: striprtf<0.0.27,>=0.0.26 in /usr/local/lib/python3.10/dist-packages (from llama-index-readers-file) (0.0.26)\n",
"Requirement already satisfied: soupsieve>1.2 in /usr/local/lib/python3.10/dist-packages (from beautifulsoup4<5.0.0,>=4.12.3->llama-index-readers-file) (2.5)\n",
"Requirement already satisfied: PyYAML>=6.0.1 in /usr/local/lib/python3.10/dist-packages (from llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (6.0.1)\n",
"Requirement already satisfied: SQLAlchemy>=1.4.49 in /usr/local/lib/python3.10/dist-packages (from SQLAlchemy[asyncio]>=1.4.49->llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (2.0.36)\n",
"Requirement already satisfied: aiohttp<4.0.0,>=3.8.6 in /usr/local/lib/python3.10/dist-packages (from llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (3.10.10)\n",
"Requirement already satisfied: dataclasses-json in /usr/local/lib/python3.10/dist-packages (from llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (0.6.7)\n",
"Requirement already satisfied: deprecated>=1.2.9.3 in /usr/local/lib/python3.10/dist-packages (from llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (1.2.15)\n",
"Requirement already satisfied: dirtyjson<2.0.0,>=1.0.8 in /usr/local/lib/python3.10/dist-packages (from llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (1.0.8)\n",
"Requirement already satisfied: filetype<2.0.0,>=1.2.0 in /usr/local/lib/python3.10/dist-packages (from llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (1.2.0)\n",
"Requirement already satisfied: fsspec>=2023.5.0 in /usr/local/lib/python3.10/dist-packages (from llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (2024.9.0)\n",
"Requirement already satisfied: httpx in /usr/local/lib/python3.10/dist-packages (from llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (0.27.2)\n",
"Requirement already satisfied: nest-asyncio<2.0.0,>=1.5.8 in /usr/local/lib/python3.10/dist-packages (from llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (1.5.8)\n",
"Requirement already satisfied: networkx>=3.0 in /usr/local/lib/python3.10/dist-packages (from llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (3.0)\n",
"Requirement already satisfied: nltk>3.8.1 in /usr/local/lib/python3.10/dist-packages (from llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (3.9.1)\n",
"Requirement already satisfied: numpy in /usr/local/lib/python3.10/dist-packages (from llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (1.26.4)\n",
"Requirement already satisfied: pillow>=9.0.0 in /usr/local/lib/python3.10/dist-packages (from llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (11.1.0)\n",
"Requirement already satisfied: pydantic>=2.8.0 in /usr/local/lib/python3.10/dist-packages (from llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (2.9.2)\n",
"Requirement already satisfied: requests>=2.31.0 in /usr/local/lib/python3.10/dist-packages (from llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (2.32.3)\n",
"Requirement already satisfied: tenacity!=8.4.0,<10.0.0,>=8.2.0 in /usr/local/lib/python3.10/dist-packages (from llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (9.0.0)\n",
"Requirement already satisfied: tiktoken>=0.3.3 in /usr/local/lib/python3.10/dist-packages (from llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (0.8.0)\n",
"Requirement already satisfied: tqdm<5.0.0,>=4.66.1 in /usr/local/lib/python3.10/dist-packages (from llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (4.67.0)\n",
"Requirement already satisfied: typing-extensions>=4.5.0 in /usr/local/lib/python3.10/dist-packages (from llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (4.12.2)\n",
"Requirement already satisfied: typing-inspect>=0.8.0 in /usr/local/lib/python3.10/dist-packages (from llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (0.9.0)\n",
"Requirement already satisfied: wrapt in /usr/local/lib/python3.10/dist-packages (from llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (1.17.0)\n",
"Requirement already satisfied: python-dateutil>=2.8.2 in /usr/local/lib/python3.10/dist-packages (from pandas->llama-index-readers-file) (2.8.2)\n",
"Requirement already satisfied: pytz>=2020.1 in /usr/local/lib/python3.10/dist-packages (from pandas->llama-index-readers-file) (2024.2)\n",
"Requirement already satisfied: tzdata>=2022.1 in /usr/local/lib/python3.10/dist-packages (from pandas->llama-index-readers-file) (2024.2)\n",
"Requirement already satisfied: aiohappyeyeballs>=2.3.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (2.4.3)\n",
"Requirement already satisfied: aiosignal>=1.1.2 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (1.3.1)\n",
"Requirement already satisfied: attrs>=17.3.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (23.1.0)\n",
"Requirement already satisfied: frozenlist>=1.1.1 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (1.5.0)\n",
"Requirement already satisfied: multidict<7.0,>=4.5 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (6.1.0)\n",
"Requirement already satisfied: yarl<2.0,>=1.12.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (1.17.1)\n",
"Requirement already satisfied: async-timeout<5.0,>=4.0 in /usr/local/lib/python3.10/dist-packages (from aiohttp<4.0.0,>=3.8.6->llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (4.0.3)\n",
"Requirement already satisfied: click in /usr/local/lib/python3.10/dist-packages (from nltk>3.8.1->llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (8.1.7)\n",
"Requirement already satisfied: joblib in /usr/local/lib/python3.10/dist-packages (from nltk>3.8.1->llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (1.4.2)\n",
"Requirement already satisfied: regex>=2021.8.3 in /usr/local/lib/python3.10/dist-packages (from nltk>3.8.1->llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (2024.11.6)\n",
"Requirement already satisfied: annotated-types>=0.6.0 in /usr/local/lib/python3.10/dist-packages (from pydantic>=2.8.0->llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (0.7.0)\n",
"Requirement already satisfied: pydantic-core==2.23.4 in /usr/local/lib/python3.10/dist-packages (from pydantic>=2.8.0->llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (2.23.4)\n",
"Requirement already satisfied: six>=1.5 in /usr/lib/python3/dist-packages (from python-dateutil>=2.8.2->pandas->llama-index-readers-file) (1.16.0)\n",
"Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests>=2.31.0->llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (2.1.1)\n",
"Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests>=2.31.0->llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (3.4)\n",
"Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests>=2.31.0->llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (1.26.13)\n",
"Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests>=2.31.0->llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (2024.12.14)\n",
"Requirement already satisfied: greenlet!=0.4.17 in /usr/local/lib/python3.10/dist-packages (from SQLAlchemy>=1.4.49->SQLAlchemy[asyncio]>=1.4.49->llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (3.1.1)\n",
"Requirement already satisfied: mypy-extensions>=0.3.0 in /usr/local/lib/python3.10/dist-packages (from typing-inspect>=0.8.0->llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (1.0.0)\n",
"Requirement already satisfied: marshmallow<4.0.0,>=3.18.0 in /usr/local/lib/python3.10/dist-packages (from dataclasses-json->llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (3.23.2)\n",
"Requirement already satisfied: anyio in /usr/local/lib/python3.10/dist-packages (from httpx->llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (4.0.0)\n",
"Requirement already satisfied: httpcore==1.* in /usr/local/lib/python3.10/dist-packages (from httpx->llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (1.0.7)\n",
"Requirement already satisfied: sniffio in /usr/local/lib/python3.10/dist-packages (from httpx->llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (1.3.0)\n",
"Requirement already satisfied: h11<0.15,>=0.13 in /usr/local/lib/python3.10/dist-packages (from httpcore==1.*->httpx->llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (0.14.0)\n",
"Requirement already satisfied: packaging>=17.0 in /usr/local/lib/python3.10/dist-packages (from marshmallow<4.0.0,>=3.18.0->dataclasses-json->llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (23.2)\n",
"Requirement already satisfied: propcache>=0.2.0 in /usr/local/lib/python3.10/dist-packages (from yarl<2.0,>=1.12.0->aiohttp<4.0.0,>=3.8.6->llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (0.2.0)\n",
"Requirement already satisfied: exceptiongroup>=1.0.2 in /usr/local/lib/python3.10/dist-packages (from anyio->httpx->llama-index-core<0.13.0,>=0.12.0->llama-index-readers-file) (1.1.3)\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\u001b[33mWARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv\u001b[0m\u001b[33m\n",
"\u001b[0m\n",
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip is available: \u001b[0m\u001b[31;49m23.3.1\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m24.3.1\u001b[0m\n",
"\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpython -m pip install --upgrade pip\u001b[0m\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Loaded 15 text chunks\n",
"Creating embeddings and indexing documents...\n",
"Indexing complete!\n"
]
}
],
"source": [
"pdf_directory = \"/workspace/lipsync/dataset\" # Replace with your PDF folder path\n",
"\n",
"# Initialize RAG pipeline\n",
"rag = RAGPipeline(pdf_directory)\n",
"\n",
"# Load and index documents (choose either LlamaIndex or LangChain)\n",
"rag.load_and_index_documents(use_llamaindex=True) # Set to False to use LangChain"
]
},
{
"cell_type": "code",
"execution_count": 37,
"id": "b029d85e-0635-4b7f-9e0e-cafb51c04018",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"Question: How may word limitations in writing?\n",
"Answer: The context highlights how word limitations can negatively impact student performance on the GED® Reasoning Through Language Arts test, specifically in the Extended Response (ER) section. \n",
"\n",
"Here's a breakdown based on the provided information:\n",
"\n",
"* **Length Requirement:** ER prompts often require 4-7 paragraphs of 3-7 sentences each, totaling 300 to 500 words. This substantial length allows students to thoroughly develop their arguments, provide ample evidence, and demonstrate critical thinking skills.\n",
"* **Negative Consequences of Short Responses:** The text explicitly states that failing to meet the word count can hurt a student's performance. This implies that shorter responses may:\n",
" * **Lack Depth:** Insufficient words prevent students from fully exploring an argument, leaving it underdeveloped and unconvincing.\n",
" * **Insufficient Evidence:** Students might not have room to incorporate enough specific examples and details from the sources to effectively support their claims. \n",
" * **Show Inadequate Analysis:** Word limitations can hinder a student's ability to analyze complex information and formulate sophisticated interpretations.\n",
"\n",
"In essence, the GED® test emphasizes the importance of comprehensive written communication. Word limitations force students to prioritize their ideas carefully and communicate them concisely while ensuring sufficient depth and support for their arguments. \n",
"\n",
"\n",
"Let me know if you have any other questions about the GED® or this specific text passage!\n",
"Context: GED.com \n",
"GED® and GED Testing Service® are registered trademarks of the American Council on Education. They may not be used or reproduced without the express written permission \n",
"of ACE or GED Testing Service. The GED® and GED Testing Service® brands are administered by GED Testing Service LLC under license from the American Council on \n",
"Education. Copyright © 2019 GED Testing Service LLC. All rights reserved. \n",
"Sample Extended Response Passages and \n",
"Prompts for Classroom Practice - RLA \n",
"Help your students get ready for the extended responses on the GED® test Reasoning \n",
"Through Language Arts test by practicing with these sample prompts and source \n",
"materials in the classroom. \n",
"Fully answering an ER prompt often requires 4 to 7 paragraphs of 3 to 7 sentences \n",
"each that can quickly add up to 300 to 500 words of writing! A response that is \n",
"significantly shorter could put your students in danger of scoring a 0 just for not showing \n",
"enough of their writing skills. \n",
"Passage #1 - Are Tweens Ready for Cell Phones? \n",
"Extended Response Stimulus Materials: \n",
"Source Material #1 \n",
"Speech: “Tweens” Are Ready for Cell Phones by Deborah Pendergast \n",
"“Safer Kids Summit” \n",
"Thank you for inviting me to the first “Safer Kids Summit.” We are here to discuss ways \n",
"to keep our children safe in an increasingly complex world. Todays focus is on \n",
"technology— specifically on the ideal age to give kids their own cell phones. As a \n",
"representative of a large telecommunications company, I receive many inquiries from \n",
"parents on this topic, and this is what I tell them: It depends on the child, of course, but \n",
"in general, age 10 is just about right. \n",
"A 2012 survey by the National Consumers League backs me up. The survey found that \n",
"almost 60 percent of children ages 8 to 12 already have cell phones. These “tweens” \n",
"can contact their parents at any time, and vice versa, giving the kids a sense of \n",
"empowerment and their parents a feeling of security. Caroline Knorr, of the group \n",
"Common Sense Media, says, \"We want our kids to be independent, to be able to walk \n",
"home from school and play at the playground without us. We want them to have that \n",
"old-fashioned, fun experience of being on their own, and cell phones can help with that.” \n",
"Picture the following scenario: You told your fourth-grader that you would pick her up \n",
"after school, but you are stuck in traffic. She is waiting for you …and waiting, and \n",
"waiting. But if you both have cell phones, you can call her to let her know you are \n",
"delayed, and she can go back inside the school, where there are adults around. You \n",
"both breathe a sigh of relief.\n",
"GED.com 7 \n",
"Passage #3 Parenting Education \n",
"Extended Response Stimulus Materials: \n",
"Source Material #1 \n",
"Guest Column: Parenting Education Should Be Mandatory \n",
"Kai Fernandez, APRN \n",
"The Freeport Times \n",
"As a nurse practitioner in a pediatric office, I had to complete extensive training and \n",
"obtain a license before I could examine my first toddler. Many jobs, from barber to pilot, \n",
"involve specific training. But for the most important job —\n",
" raising children to be \n",
"responsible adults —no training is required, and children and society suffer the results \n",
"of this lack of knowledge. The time has come to correct this situation. Before they can \n",
"be discharged from the hospital, first-time parents should be required to take parenting \n",
"classes. \n",
"Just as we equip new drivers with a learners permit and instruction, we must also equip \n",
"new parents with the skills they need. While some people might believe that this is the \n",
"“nanny state” stepping on the rights of individuals, I am not suggesting that there is only \n",
"one “correct” style of parenting. But there is basic information about infants and children \n",
"that every parent should be required to know, including nutrition, health and safety, and \n",
"stages of child development. Knowing how to safely bathe a baby, for example, would \n",
"prevent many tragedies. Understanding that babies are crying to communicate, not to \n",
"be “naughty,” helps parents adjust their expectations and their behavior. \n",
"And parent education works. According to the Centers for Disease Control, for example, \n",
"the “Safe To Sleep” campaign has reduced the number of deaths from Sudden Infant \n",
"Death Syndrome by fifty percent since 1994 just by teaching parents to put babies to \n",
"bed on their backs. Conversely, uninformed parenting hurts not only children, but the \n",
"rest of us as well. A study by the Department of Education in England found that \n",
"children whose parents use harsh or inconsistent discipline are more likely to have poor \n",
"attention spans, low levels of literacy, and anti-social behavior. \n",
"In cultures where extended families are the rule, raising children is a group effort. But in \n",
"the modern world, new parents are on their own. It is our obligation as a society to make \n",
"sure they have the skills to do their best in this challenging job. Making parenting \n",
"classes mandatory is a step towards this goal. \n",
"Source Material #2 \n",
"Guest Column: Leave New Parents Alone \n",
"Sophie Thomas \n",
"The Freeport Times \n",
"I am writing in response to the op-ed essay by Kai Fernandez advocating mandatory \n",
"parenting classes for new parents. As the mother of three, I speak with experience \n",
"about raising children, and I strongly object to the idea that a random instructor knows\n",
"GED.com 2 \n",
"Psychologists tell us that the period between ages 10 and 12 is one of growing \n",
"independence. It is a time to teach children about responsibility, and to give them \n",
"opportunities to earn our trust. Providing a 10-year-old with a cell phone offers an ideal \n",
"way to achieve these goals and gives parents peace of mind as well. \n",
"Source Material #2 \n",
"Speech: Wait Until They Are Older by Linda Sidner \n",
"“Safer Kids Summit” \n",
"Good morning! I come to this topic as a parent and a veteran teacher of so-called \n",
"“tweens.” I love kids this age for their curiosity and energy, but those same qualities can \n",
"lead to trouble if not overseen by adults. Thats why giving children their own phones \n",
"actually makes them less safe, not more. I believe that the best age for a cell phone is \n",
"16, the point at which we consider kids grown-up enough to learn to drive —\n",
" and even \n",
"then, parents must set firm limits on phone use! \n",
"Why are tweens with phones less safe? For one thing, parents may be lulled into a false \n",
"sense of security if their kids have phones. They may become careless about knowing \n",
"where their child is and who he is with, thinking, “I can always reach him on his phone.” \n",
"For another, cell phones give children access to all the frightening, dangerous, and \n",
"inappropriate sites on the Internet, with no parent nearby to monitor this activity. \n",
"But perhaps the most worrisome aspect of giving cell phones to children is the rise in \n",
"“cyberbullying” or “text bullying.” Text bullying means using a cell phone to send cruel, \n",
"embarrassing, or false text messages to or about someone. In one study, researcher \n",
"Elizabeth Englander found that by middle school, over 90% of children report that they \n",
"use their cell phones to text or go onto the Internet. She also found that in grades 3 \n",
"through 5, between 14 and 19 percent of children reported being victims of \n",
"cyberbullying. What if its your child on the receiving end of this cruelty? Or, perhaps \n",
"worse, what if your child is the bully? Children of this age are simply not mature enough \n",
"to handle this technology, and we shouldnt expect them to be. Its our job as adults to \n",
"protect them. Thats why I say: Its better to wait. \n",
"Extended Response Prompt: \n",
"Analyze the arguments presented in the two speeches. \n",
"In your response, develop an argument in which you explain how one position is better \n",
"supported than the other. Incorporate relevant and specific evidence from both sources \n",
"to support your argument. \n",
"Remember, the better-argued position is not necessarily the position with which you \n",
"agree. This task should take approximately 45 minutes to complete.\n",
"--------------------------------------------------------------------------------\n"
]
}
],
"source": [
"question = \"How may word limitations in writing?\"\n",
"print(f\"\\nQuestion: {question}\")\n",
"answer,context = rag.query(question)\n",
"print(f\"Answer: {answer}\")\n",
"print(f\"Context: {context}\")\n",
"print(\"-\" * 80)"
]
},
{
"cell_type": "code",
"execution_count": 39,
"id": "9d1013d6-2b1c-4d43-8880-1447e3e7f65d",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"Question: How much time will be provided for each task?\n",
"Answer: I cannot answer how much time will be provided for each task based on the context given. The text you provided discusses topics like game-based learning and e-learning strategies, but it doesn't mention anything about specific tasks or allotted timeframes. \n",
"\n",
"--------------------------------------------------------------------------------\n",
"Context: GED.com 11 \n",
"Source Material #2 \n",
"From: Honoria Bell \n",
"Sent: Tuesday, September 25 \n",
"To: Justine Timmons, CEO \n",
"CC: Employees of Niagara Equipment Corp. \n",
"Subject: Workplace Internet Use \n",
"Dear Ms. Timmons, \n",
"We, the undersigned employees of Niagara Equipment Corp., urge management to \n",
"reconsider the installation of Internet-filtering software. While we recognize that it is in \n",
"all our interests to promote productivity and a positive workplace environment, we \n",
"believe that blocking our free access to the Internet is the wrong way to go about this. \n",
"First, there is more to that Salary.com statistic that you cite than meets the eye. Most of \n",
"the “cyberslackers” in that survey surf the Internet for only one hour per week. This is \n",
"comparable to taking a walk to the water cooler or chatting about last nights game with \n",
"a colleague. According to author Laura Vanderkam, “no one can get through a whole \n",
"workday without taking a break.” In fact, one 2009 study found that workers who could \n",
"occasionally check the Internet were happier at work than those who could not. Another \n",
"study, this one from the National University of Singapore, found that Web-surfing \n",
"refreshed employees, actually making them more productive, not less. \n",
"Second, one important function of the Internet is as a communication tool, just like the \n",
"telephone. Just as workers are permitted to make brief personal calls at work, so should \n",
"they be allowed to use the Internet for the same purpose. \n",
"Third, we believe that the best way to grow as a business and protect the company from \n",
"lawsuits is to hire responsible employees and then demonstrate your trust in them. \n",
"Instead of treating us like children, why not establish clear guidelines concerning \n",
"Internet use? All employees can understand the reasons that offensive websites are off \n",
"limits. \n",
"Finally, installing an Internet filter may create resentment and tempt some employees to \n",
"find ways around the filters. It is an unnecessary solution in search of a problem. \n",
"Thank you for your attention. \n",
"Honoria Bell, Chief Designer and the undersigned 53 employees\n",
"GED.com \n",
"GED® and GED Testing Service® are registered trademarks of the American Council on Education. They may not be used or reproduced without the express written permission \n",
"of ACE or GED Testing Service. The GED® and GED Testing Service® brands are administered by GED Testing Service LLC under license from the American Council on \n",
"Education. Copyright © 2019 GED Testing Service LLC. All rights reserved. \n",
"Sample Extended Response Passages and \n",
"Prompts for Classroom Practice - RLA \n",
"Help your students get ready for the extended responses on the GED® test Reasoning \n",
"Through Language Arts test by practicing with these sample prompts and source \n",
"materials in the classroom. \n",
"Fully answering an ER prompt often requires 4 to 7 paragraphs of 3 to 7 sentences \n",
"each that can quickly add up to 300 to 500 words of writing! A response that is \n",
"significantly shorter could put your students in danger of scoring a 0 just for not showing \n",
"enough of their writing skills. \n",
"Passage #1 - Are Tweens Ready for Cell Phones? \n",
"Extended Response Stimulus Materials: \n",
"Source Material #1 \n",
"Speech: “Tweens” Are Ready for Cell Phones by Deborah Pendergast \n",
"“Safer Kids Summit” \n",
"Thank you for inviting me to the first “Safer Kids Summit.” We are here to discuss ways \n",
"to keep our children safe in an increasingly complex world. Todays focus is on \n",
"technology— specifically on the ideal age to give kids their own cell phones. As a \n",
"representative of a large telecommunications company, I receive many inquiries from \n",
"parents on this topic, and this is what I tell them: It depends on the child, of course, but \n",
"in general, age 10 is just about right. \n",
"A 2012 survey by the National Consumers League backs me up. The survey found that \n",
"almost 60 percent of children ages 8 to 12 already have cell phones. These “tweens” \n",
"can contact their parents at any time, and vice versa, giving the kids a sense of \n",
"empowerment and their parents a feeling of security. Caroline Knorr, of the group \n",
"Common Sense Media, says, \"We want our kids to be independent, to be able to walk \n",
"home from school and play at the playground without us. We want them to have that \n",
"old-fashioned, fun experience of being on their own, and cell phones can help with that.” \n",
"Picture the following scenario: You told your fourth-grader that you would pick her up \n",
"after school, but you are stuck in traffic. She is waiting for you …and waiting, and \n",
"waiting. But if you both have cell phones, you can call her to let her know you are \n",
"delayed, and she can go back inside the school, where there are adults around. You \n",
"both breathe a sigh of relief.\n",
"GED.com 6 \n",
"References \n",
" Arth, B. (2011, September) The business impact of next-generation e-learning.\n",
"http://wwwimages.adobe.com/content/dam/Adobe/en/products/adobeconnect/pdfs/elearning/0921\n",
"11-rr-nextgen-elearning-ba-ctcrevised-vendor.pdf\n",
" Bhasin, K. (2014, January 7) Gamification, game-based learning, serious games: Any difference?\n",
"Retrieved from http://www.learningsolutionsmag.com/articles/1337/gamification-game-based-\n",
"learning-serious-games-any-difference\n",
" Cavalli, E. (2011, June 8) New demographic show gamers are getting older. The Escapist.\n",
"Retrieved from http://www.escapistmagazine.com/news/view/110837-New-Demographics-Show-\n",
"Gamers-Are-Getting-Older\n",
" Donovan, L. (2012, December) The use of serious games in the corporate sector. Retreived from\n",
"http://www.learnovatecentre.org/wp-\n",
"content/uploads/2013/06/Use_of_Serious_Games_in_the_Corporate_Sector_PRINT_FINAL.pdf\n",
" Harwell, D. (2014, October 17) More women play video games than boys and other surprising\n",
"facts lost in the mess of gamergate. The Washington Post. Retrieved from\n",
"http://www.washingtonpost.com/blogs/the-switch/wp/2014/10/17/more-women-play-video-games-\n",
"than-boys-and-other-surprising-facts-lost-in-the-mess-of-gamergate/\n",
" Koller, V., Harvey, S., & Magnotta, M. (n.d.) Technology-based learning strategies. Retrieved\n",
"from http://www.doleta.gov/reports/papers/tbl_paper_final.pdf\n",
" More than just a game: Video games are behind the latest fad in management. (2012, November\n",
"10) The Economist. Retrieved from http://www.economist.com/news/business/21565926-video-\n",
"games-are-behind-latest-fad-management-more-just-game \n",
" New Media Institute. (n.d.) Game-based learning: what it is, why it works, and where its going.\n",
" Retrieved from http://www.newmedia.org/game-based-learning--what-it-is-why-it- \n",
"works-and-where-its-going.html\n",
" Outcomes of game-based learning: Research roundup (2013, May 20) Retrieved from\n",
"http://journalistsresource.org/studies/society/education/outcomes-of-game-based-learning-\n",
"research-roundup#\n",
" Squire, K.D. (2008, November 2) Performance Improvement Quarterly, 21 (2)\n",
"7-36 Retrieved from http://www.performancexpress.org/wp-content/uploads /2011/11/Video-\n",
"Game%96Based-Learning.pdf\n",
" The Rapid E-Learning Blog. (2010, February 2) Why e-learning is so effective. Retrieved from\n",
"http://www.articulate.com/rapid-elearning/why-e-learning-is-so-effective/\n",
" True Office. (n.d.) Digital games revolutionizing workplace learning? Retrieved from\n",
"http://www.trueoffice.com/wpcontent/uploads/2014/04/TRU\n",
"--------------------------------------------------------------------------------\n"
]
}
],
"source": [
"question = \"How much time will be provided for each task?\"\n",
"print(f\"\\nQuestion: {question}\")\n",
"answer,context = rag.query(question)\n",
"print(f\"Answer: {answer}\")\n",
"print(\"-\" * 80)\n",
"print(f\"Context: {context}\")\n",
"print(\"-\" * 80)"
]
},
{
"cell_type": "code",
"execution_count": 42,
"id": "a76583e4-4986-4f27-a57a-80f3797596f1",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"Question: Who is Solomon Robles?\n",
"Answer: Based on the provided text, Solomon Robles is an Ed.D., Professor of Education at Winborne College. \n",
"\n",
"He authored the article \"Game-based Learning Is Merely a Fad\" published in the *Workplace Training Journal*. In his article, he argues against the effectiveness of game-based learning, comparing it to previous eLearning trends that ultimately failed. \n",
"\n",
"--------------------------------------------------------------------------------\n",
"Context: GED.com 4 \n",
"Passage #2 Game-Based Learning \n",
"Extended Response Stimulus Materials: \n",
"Source Material #1 \n",
"Game-based Learning Is Merely a Fad \n",
"Solomon Robles, Ed.D., Professor of Education at Winborne College \n",
"Workplace Training Journal \n",
"Electronic learning, or “eLearning,” was sold to many CEOs as the wave of the \n",
"corporate future. Theres no need to hire human beings to train staff, managers were \n",
"told. All the information you require can be accessed online —\n",
" at a reduced cost for the \n",
"company, and more flexible scheduling for employees. It sounded too good to be true \n",
"— and it was. As one writer noted, “most eLearning is nothing more than online lectures \n",
"or course notes.” To teach skills beyond basic facts, the person-to-person method is still \n",
"more effective than any form of electronic learning. \n",
"And yet, along comes the next eLearning fad: “gamification,” which means using video \n",
"games to teach. Video-game-based learning is already widely used in schools, and has \n",
"spread to corporations as a tool for training workers and motivating customers. This \n",
"approach is even used in the military. But does it work? \n",
"Most research on game-based learning has looked at schools. Results have been \n",
"inconsistent but not especially encouraging. One 2013 study found that “students who \n",
"completed the gamified experience got better scores in practical assignments and in \n",
"overall score, but … performed poorly on written assignments and participated less \n",
"during class activities.” This makes sense: If youre playing video games, you are not \n",
"developing the so-called “soft skills” —\n",
"also known as “people skills” that are \n",
"necessary for success in any job. In a traditional classroom, on the other hand, students \n",
"can ask questions and engage with the teacher and with other learners. \n",
"In the workplace, game-based learning is yet another wedge driven between younger \n",
"employees, who might applaud gamification, and older workers, who may now feel \n",
"obsolete. Whats more, the prestigious magazine The Economist points out that “many \n",
"of the aspects of gamification that do work are merely old ideas in trendy new clothes.” \n",
"For example, the points and other rewards that are selling features of video games are \n",
"just online versions of sales contests or “employee of the month” perks. Like other \n",
"trends, game-based learning is likely to fade away as the next new teaching fad \n",
"appears on the horizon. \n",
"Source Material #2 \n",
"Game-based Learning: An Effective Training Strategy \n",
"Janette Morgan, Ph.D., Professor of Business, Saratoga State University \n",
"Innovative Trends in the Workplace \n",
"Already a multi-billion-dollar business, game-based learning in the corporate world \n",
"continues to grow at a steady pace, and is here to stay. Executives are smart —\n",
" they\n",
"GED.com 5 \n",
"are not going to waste resources on training methods that dont work. Lets look at some \n",
"of the advantages of “gamifying” workplace training. \n",
"First, many people are “gamers” in their non-work lives, so playing video games is \n",
"something they are already comfortable with and enjoy. This makes game-based \n",
"learning in the workplace more attractive and motivating than traditional instruction. And \n",
"according to the Entertainment Software Association, despite the image of video-game \n",
"players as teenaged boys, “the average gamer is now 37 years old.” Further challenging \n",
"the stereotype, nearly half of gamers are girls or women. Even 29 percent of those over \n",
"age 50 are getting into the video-game habit. Teenagers and young men, in fact, make \n",
"up only 15 percent of the over 190 million video-game users in the United States. \n",
"Evidence supporting the effectiveness of game-based learning is starting to emerge. \n",
"Researchers point out that video games have “compelling storylines, attainable \n",
"challenges, rewards, recognition and control,” all of which stimulate learners. A 2012 \n",
"report on game-based learning notes that “there is research evidence demonstrating \n",
"positive impact on higher order skills such as decision making and problem solving.” \n",
"The report adds that using video games can also reduce training time, an advantage for \n",
"both managers and employees. \n",
"Finally, unlike one-time training in a classroom, game-based learning is infinitely \n",
"repeatable. If employees miss something or need more practice, they can always start \n",
"the game again, using the feedback provided by the game to gauge their progress. This \n",
"leads to a sense of accomplishment and creates a supportive learning environment, \n",
"which is what we all want in an education strategy. \n",
"Extended Response Prompt: \n",
"Analyze the arguments presented in the two journal articles. \n",
"In your response, develop an argument in which you explain how one position is better \n",
"supported than the other. Incorporate relevant and specific evidence from both sources \n",
"to support your argument. \n",
"Remember, the better-argued position is not necessarily the position with which you \n",
"agree. This task should take approximately 45 minutes to complete.\n",
"GED.com 12 \n",
"Extended Response Prompt: \n",
"References \n",
" Bowers, T. (2002, October 22) Hostile work environment: A managers legal liability. Tech\n",
"Republic. Retrieved from http://www.techrepublic.com/article/hostile-work-environment-a-\n",
"managers-legal-liability/\n",
" Cain, A. & OBrien, K. (n.d.) Facebook status update: Employer is…sued: How internet\n",
"harassment could lead to a change in status. Retrieved from http://www.lmblaw.com/media/in-\n",
"the-news/articles/internet-harassment\n",
" Ho, Mimi. (2000, June 12) Internet surfing at the workplace. CIO. Retrieved from\n",
"http://www.cio.com/article/2439254/security0/internet-surfing-at-the-workplace.html\n",
" Odysseas, M. (2013, December 13) How relevant is internet filtering in the workplace? Retrieved\n",
"from http://www.smallbusiness.co.uk/blog/2447732/how-relevant-is-internet-filtering-in-the-\n",
"workplace.thtml\n",
" Platt, J. (2012, November 26) Cyberslacking actually boosts workplace productivity. Mother\n",
"Nature Network. Retrieved from http://www.mnn.com/green-\n",
"tech/computers/stories/cyberslacking-actually-boosts-workplace-productivity\n",
" Signal, M. (n.d.) Pros and cons of internet filtering in schools. eHow. Retrieved from\n",
"http://www.ehow.com/info_8005986_pros-cons-internet-filtering.html\n",
" Whitty, M. (2004) Should filtering software be utilised in the workplace? Australian employees\n",
"attitudes towards internet usage and surveillance of the internet in the workplace. Surveillance\n",
"and Society 2 (1): 39-54 Retrieved from http://www.surveillance-and-\n",
"society.org/articles2%281%29/filtering.pdf\n",
"Analyze the arguments presented in the two emails. \n",
"In your response, develop an argument in which you explain how one position is better \n",
"supported than the other. Incorporate relevant and specific evidence from both sources \n",
"to support your argument. \n",
"Remember, the better-argued position is not necessarily the position with which you \n",
"agree. This task should take approximately 45 minutes to complete.\n",
"--------------------------------------------------------------------------------\n"
]
}
],
"source": [
"question = \"Who is Solomon Robles?\"\n",
"print(f\"\\nQuestion: {question}\")\n",
"answer,context = rag.query(question)\n",
"print(f\"Answer: {answer}\")\n",
"print(\"-\" * 80)\n",
"print(f\"Context: {context}\")\n",
"print(\"-\" * 80)"
]
},
{
"cell_type": "code",
"execution_count": 46,
"id": "9f23f39a-9dfe-4aca-982c-d02854b28e1d",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"Question: Who is Kai Fernandez?\n",
"Answer: The provided text does not contain information about an individual named Kai Fernandez. Therefore, I cannot answer your question based on the context given. \n",
"\n",
"\n",
"Let me know if you have any other questions about the provided texts! \n",
"\n",
"--------------------------------------------------------------------------------\n",
"Context: GED.com 15 \n",
"References \n",
" Appelbaum, B. (2014, August 5) Does hosting the olympics actually pay off? The New York\n",
"Times Magazine. Retrieved from http://www.nytimes.com/2014/08/10/magazine/does-hosting-\n",
"the-olympics-actually-pay-off.html?_r=0\n",
" Cloherty, S. (2014, February 21) The pros and cons of hosting the olympics. The Milton Measure.\n",
"Retrieved from http://miltonmeasure.org/2014/02/the-pros-and-cons-of-hosting-the-olympics/\n",
" Fowler, G.A. & Meichtry, S. (2008, July 6) China counts the cost of hosting the olympics. The\n",
"Wall Street Journal. Retrieved from http://www.wsj.com/articles/\n",
"SB121614671139755287\n",
" Not all Brazilians overjoyed by world cup. (2014, June 12) PBS Newshour Extra. Retrieved from\n",
"http://www.pbs.org/newshour/extra/daily_videos/not-all-brazilians-overjoyed- by-world-cup/\n",
" Pettinger, T. (2012, January 24) Advantages of hosting a major event. Economics Help.\n",
"Retrieved from http://www.economicshelp.org/blog/4909/economics/advantages- of-hosting-a-\n",
"major-event/\n",
" Weissman, J. (2012, July 31) Empty nest: Beijings olympic stadium is a vacant museum piece.\n",
"The Atlantic. http://www.theatlantic.com/business/archive/2012/07/empty-nest-beijings- olympic-\n",
"stadium-is-a-vacant-museum-piece/260522/\n",
" Wihbey, J. (2014, February 3) Economic and cultural benefits of the olympics: Research roundup.\n",
"Journalists Resource. Retrieved from\n",
"http://journalistsresource.org/studies/society/culture/economic-and-cultural-benefits-of-the-\n",
"olympics-research-roundup\n",
" Yates, B. (2010, November) Major events: Good economics and exposure to the world.\n",
"Technology Innovation Management Review. Retrieved from http://timreview.ca/article/393\n",
" Zimbalist, A. (2012, July 23) 3 reasons why hosting the olympics is a losers game. The Atlantic.\n",
"Retrieved from http://www.theatlantic.com/business/archive/2012/07/3-reasons-why-hosting- the-\n",
"olympics-is-a-losers-game/260111/\n",
"GED.com 5 \n",
"are not going to waste resources on training methods that dont work. Lets look at some \n",
"of the advantages of “gamifying” workplace training. \n",
"First, many people are “gamers” in their non-work lives, so playing video games is \n",
"something they are already comfortable with and enjoy. This makes game-based \n",
"learning in the workplace more attractive and motivating than traditional instruction. And \n",
"according to the Entertainment Software Association, despite the image of video-game \n",
"players as teenaged boys, “the average gamer is now 37 years old.” Further challenging \n",
"the stereotype, nearly half of gamers are girls or women. Even 29 percent of those over \n",
"age 50 are getting into the video-game habit. Teenagers and young men, in fact, make \n",
"up only 15 percent of the over 190 million video-game users in the United States. \n",
"Evidence supporting the effectiveness of game-based learning is starting to emerge. \n",
"Researchers point out that video games have “compelling storylines, attainable \n",
"challenges, rewards, recognition and control,” all of which stimulate learners. A 2012 \n",
"report on game-based learning notes that “there is research evidence demonstrating \n",
"positive impact on higher order skills such as decision making and problem solving.” \n",
"The report adds that using video games can also reduce training time, an advantage for \n",
"both managers and employees. \n",
"Finally, unlike one-time training in a classroom, game-based learning is infinitely \n",
"repeatable. If employees miss something or need more practice, they can always start \n",
"the game again, using the feedback provided by the game to gauge their progress. This \n",
"leads to a sense of accomplishment and creates a supportive learning environment, \n",
"which is what we all want in an education strategy. \n",
"Extended Response Prompt: \n",
"Analyze the arguments presented in the two journal articles. \n",
"In your response, develop an argument in which you explain how one position is better \n",
"supported than the other. Incorporate relevant and specific evidence from both sources \n",
"to support your argument. \n",
"Remember, the better-argued position is not necessarily the position with which you \n",
"agree. This task should take approximately 45 minutes to complete.\n",
"GED.com 12 \n",
"Extended Response Prompt: \n",
"References \n",
" Bowers, T. (2002, October 22) Hostile work environment: A managers legal liability. Tech\n",
"Republic. Retrieved from http://www.techrepublic.com/article/hostile-work-environment-a-\n",
"managers-legal-liability/\n",
" Cain, A. & OBrien, K. (n.d.) Facebook status update: Employer is…sued: How internet\n",
"harassment could lead to a change in status. Retrieved from http://www.lmblaw.com/media/in-\n",
"the-news/articles/internet-harassment\n",
" Ho, Mimi. (2000, June 12) Internet surfing at the workplace. CIO. Retrieved from\n",
"http://www.cio.com/article/2439254/security0/internet-surfing-at-the-workplace.html\n",
" Odysseas, M. (2013, December 13) How relevant is internet filtering in the workplace? Retrieved\n",
"from http://www.smallbusiness.co.uk/blog/2447732/how-relevant-is-internet-filtering-in-the-\n",
"workplace.thtml\n",
" Platt, J. (2012, November 26) Cyberslacking actually boosts workplace productivity. Mother\n",
"Nature Network. Retrieved from http://www.mnn.com/green-\n",
"tech/computers/stories/cyberslacking-actually-boosts-workplace-productivity\n",
" Signal, M. (n.d.) Pros and cons of internet filtering in schools. eHow. Retrieved from\n",
"http://www.ehow.com/info_8005986_pros-cons-internet-filtering.html\n",
" Whitty, M. (2004) Should filtering software be utilised in the workplace? Australian employees\n",
"attitudes towards internet usage and surveillance of the internet in the workplace. Surveillance\n",
"and Society 2 (1): 39-54 Retrieved from http://www.surveillance-and-\n",
"society.org/articles2%281%29/filtering.pdf\n",
"Analyze the arguments presented in the two emails. \n",
"In your response, develop an argument in which you explain how one position is better \n",
"supported than the other. Incorporate relevant and specific evidence from both sources \n",
"to support your argument. \n",
"Remember, the better-argued position is not necessarily the position with which you \n",
"agree. This task should take approximately 45 minutes to complete.\n",
"--------------------------------------------------------------------------------\n"
]
}
],
"source": [
"question = \"Who is Kai Fernandez?\"\n",
"print(f\"\\nQuestion: {question}\")\n",
"answer,context = rag.query(question)\n",
"print(f\"Answer: {answer}\")\n",
"print(\"-\" * 80)\n",
"print(f\"Context: {context}\")\n",
"print(\"-\" * 80)"
]
},
{
"cell_type": "code",
"execution_count": 48,
"id": "a4dcc360-e10e-474c-84fb-6b62f8ec760e",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"Question: What is discussed about Parenting Education?\n",
"Answer: The provided text discusses parenting education from two opposing viewpoints. \n",
"\n",
"**Kai Fernandez, in \"Parenting Education Should Be Mandatory,\" argues for mandatory parenting classes.** He believes that just as other professions require training and licensing, raising children should also involve formal education. He cites examples like the \"Safe To Sleep\" campaign demonstrating the effectiveness of such programs in reducing SIDS deaths. Fernandez also points to studies showing that uninformed parenting can lead to negative outcomes for children, impacting their attention span, literacy, and social behavior. He contends that mandatory classes would equip parents with essential knowledge about child development, nutrition, safety, and communication, ultimately benefiting both children and society.\n",
"\n",
"**Sophie Thomas, in \"Leave New Parents Alone,\" opposes mandatory parenting classes.** She argues against government intervention in family life, emphasizing the freedom of choice and individual responsibility. Thomas suggests existing resources like books, online information, family support networks, and voluntary classes provide ample opportunities for learning. She raises concerns about the financial burden and potential enforcement issues associated with mandatory classes. Thomas believes parents have successfully raised children for centuries without government mandates and finds the idea of forced parenting education an unnecessary intrusion.\n",
"\n",
"\n",
"The debate centers around the balance between individual freedom and societal well-being. Fernandez champions the potential benefits of structured learning, while Thomas emphasizes parental autonomy and existing support systems. \n",
"\n",
"--------------------------------------------------------------------------------\n",
"Context: GED.com 9 \n",
"References \n",
" Fetsch, R.J. & Collins, C.L. (2012, August) A review and critique of 16 major parent education\n",
"programs. Journal of Extension. Retrieved from http://www.joe.org/joe/2012august/a8.php\n",
" Gentleman, A. (2012, March 30) Do we need parenting classes? The Guardian. Retrieved from\n",
"http://www.theguardian.com/lifeandstyle/2012/mar/31/do-we-need-parenting-classes\n",
" Greenwood, B. (n.d.) The effectiveness of parenting classes. Retrieved from\n",
"http://everydaylife.globalpost.com/effectiveness-parenting-classes-5089.html\n",
" Maffei, M. (2013, September 2) Should parenting require a license? Retrieved from\n",
"http://www.sheknows.com/parenting/articles/1009213/should-parenting-require-a-license\n",
" Page, A. (2010, January 8) Ultimate guide to parenting classes. HowStuffWorks.com. Retrieved\n",
"from http://lifestyle.howstuffworks.com/family/parenting/parenting-tips/parenting- \n",
"classes3.htm\n",
" Paton, G. (2012, February 26) Children with negative parents twice as likely to misbehave.\n",
" The Telegraph. Retrieved from http://www.telegraph.co.uk/education/\n",
"educationnews/9106818/Children-with-negative-parents-twice-as-likely-to-misbehave.html\n",
" Schreiber, T. (2011, September 26) Parenting 101: The benefits of parenting classes. Parent\n",
"Map. Retrieved from https://www.parentmap.com/article/benefits-of-parenting-classes\n",
" Should all parents be required to attend parenting classes? (n.d.) Retrieved from\n",
"http://www.debate.org/opinions/should-all-parents-be-required-to-attend-parenting-classes\n",
" UK Department for Education (2012, December 20) Which type of parenting programme best\n",
"improves child behaviour and reading? Retrieved from\n",
"https://www.gov.uk/government/publications/which-type-of-parenting-programme-best-improves-\n",
"child-behaviour-and-reading-the-helping-children-achieve-trial\n",
" What Works Wisconsin (n.d.) Cooperative extension Family living programs. Retrieved from\n",
"http://whatworks.uwex.edu/attachment/factsheet_4parentinged.pdf\n",
"GED.com 7 \n",
"Passage #3 Parenting Education \n",
"Extended Response Stimulus Materials: \n",
"Source Material #1 \n",
"Guest Column: Parenting Education Should Be Mandatory \n",
"Kai Fernandez, APRN \n",
"The Freeport Times \n",
"As a nurse practitioner in a pediatric office, I had to complete extensive training and \n",
"obtain a license before I could examine my first toddler. Many jobs, from barber to pilot, \n",
"involve specific training. But for the most important job —\n",
" raising children to be \n",
"responsible adults —no training is required, and children and society suffer the results \n",
"of this lack of knowledge. The time has come to correct this situation. Before they can \n",
"be discharged from the hospital, first-time parents should be required to take parenting \n",
"classes. \n",
"Just as we equip new drivers with a learners permit and instruction, we must also equip \n",
"new parents with the skills they need. While some people might believe that this is the \n",
"“nanny state” stepping on the rights of individuals, I am not suggesting that there is only \n",
"one “correct” style of parenting. But there is basic information about infants and children \n",
"that every parent should be required to know, including nutrition, health and safety, and \n",
"stages of child development. Knowing how to safely bathe a baby, for example, would \n",
"prevent many tragedies. Understanding that babies are crying to communicate, not to \n",
"be “naughty,” helps parents adjust their expectations and their behavior. \n",
"And parent education works. According to the Centers for Disease Control, for example, \n",
"the “Safe To Sleep” campaign has reduced the number of deaths from Sudden Infant \n",
"Death Syndrome by fifty percent since 1994 just by teaching parents to put babies to \n",
"bed on their backs. Conversely, uninformed parenting hurts not only children, but the \n",
"rest of us as well. A study by the Department of Education in England found that \n",
"children whose parents use harsh or inconsistent discipline are more likely to have poor \n",
"attention spans, low levels of literacy, and anti-social behavior. \n",
"In cultures where extended families are the rule, raising children is a group effort. But in \n",
"the modern world, new parents are on their own. It is our obligation as a society to make \n",
"sure they have the skills to do their best in this challenging job. Making parenting \n",
"classes mandatory is a step towards this goal. \n",
"Source Material #2 \n",
"Guest Column: Leave New Parents Alone \n",
"Sophie Thomas \n",
"The Freeport Times \n",
"I am writing in response to the op-ed essay by Kai Fernandez advocating mandatory \n",
"parenting classes for new parents. As the mother of three, I speak with experience \n",
"about raising children, and I strongly object to the idea that a random instructor knows\n",
"GED.com 8 \n",
"my family and my circumstances better than I do. Just like New York Citys efforts to \n",
"ban the sale of large sodas, a law requiring parents to take parenting classes is yet \n",
"another example of some government bureaucrat determining what is best for the rest \n",
"of us. Freedom of choice is a fundamental American value; forcing all parents to learn \n",
"the same information about children conflicts with this basic right. \n",
"While it is true that there are many challenges facing new parents, there are also many \n",
"ways to learn how to handle these challenges. There are shelves full of parenting books \n",
"in every bookstore; enter the word “parenting” in the search box on any Web browser, \n",
"and millions of resources will pop up. Then there are family members and friends to turn \n",
"to for advice, as well as good old trial and error. Hospitals, community centers, and \n",
"houses of worship also offer a variety of parenting classes —\n",
" but the important point is \n",
"that these are voluntary. \n",
"There are also the problems of funding and enforcing this proposal. Would parents have \n",
"to pay for the classes themselves? This could pose a financial burden for many people. \n",
"And what if parents refused to take the classes? Would they be fined? Arrested? \n",
"Even if these practical aspects of mandatory parenting classes could be worked out, \n",
"however, the issue of government intrusion into family lives makes it a non-starter. After \n",
"all, parents have been raising children for millions of years without the governments \n",
"help. \n",
"Extended Response Prompt: \n",
"Analyze the arguments presented in the two guest columns. \n",
"In your response, develop an argument in which you explain how one position is better \n",
"supported than the other. Incorporate relevant and specific evidence from both sources \n",
"to support your argument. \n",
"Remember, the better-argued position is not necessarily the position with which you \n",
"agree. This task should take approximately 45 minutes to complete.\n",
"--------------------------------------------------------------------------------\n"
]
}
],
"source": [
"question = \"What is discussed about Parenting Education?\"\n",
"print(f\"\\nQuestion: {question}\")\n",
"answer,context = rag.query(question)\n",
"print(f\"Answer: {answer}\")\n",
"print(\"-\" * 80)\n",
"print(f\"Context: {context}\")\n",
"print(\"-\" * 80)"
]
},
{
"cell_type": "code",
"execution_count": 49,
"id": "b442cf59-ff68-4873-839c-928453ff3d35",
"metadata": {},
"outputs": [],
"source": [
"## Use llama3:8b model"
]
},
{
"cell_type": "code",
"execution_count": 50,
"id": "331ef762-d9b2-4006-93d5-baafdf0f4cdd",
"metadata": {},
"outputs": [],
"source": [
"class RAGPipeline:\n",
" def __init__(self, pdf_directory: str):\n",
" self.embedding_model = EmbeddingModel()\n",
" self.vector_store = VectorStore(dimension=384)\n",
" self.llm = Ollama(model=\"llama3:8b\")\n",
" self.doc_processor = DocumentProcessor(pdf_directory)\n",
" \n",
" def load_and_index_documents(self, use_llamaindex: bool = True):\n",
" \"\"\"Load PDFs and index them in the vector store\"\"\"\n",
" print(\"Loading and processing documents...\")\n",
" \n",
" # Load documents using either LlamaIndex or LangChain\n",
" if use_llamaindex:\n",
" documents = self.doc_processor.load_pdfs_llamaindex()\n",
" else:\n",
" documents = self.doc_processor.load_pdfs_langchain()\n",
" \n",
" print(f\"Loaded {len(documents)} text chunks\")\n",
" \n",
" # Get embeddings and add to vector store\n",
" print(\"Creating embeddings and indexing documents...\")\n",
" embeddings = self.embedding_model.get_embeddings(documents)\n",
" self.vector_store.add_texts(documents, embeddings)\n",
" print(\"Indexing complete!\")\n",
" \n",
" def query(self, question: str, k: int = 3):\n",
" # Get question embedding\n",
" question_embedding = self.embedding_model.get_embeddings([question])\n",
" \n",
" # Retrieve relevant documents\n",
" relevant_docs = self.vector_store.similarity_search(question_embedding, k)\n",
" \n",
" # Create prompt with context and metadata\n",
" context = \"\\n\".join([doc[0] for doc in relevant_docs])\n",
" \n",
" prompt = f\"\"\"Given the context below, answer the question. If you cannot answer based on the context, say \"I cannot answer based on the given context.\"\n",
"\n",
" Context:\n",
" {context}\n",
" \n",
" Question: {question}\n",
" \n",
" Please provide a detailed answer based on the context provided above.\n",
" \n",
" Current Time (UTC): {datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S')}\n",
" \n",
" Answer:\"\"\"\n",
" \n",
" # Generate answer using Ollama\n",
" response = self.llm.invoke(prompt)\n",
" return response,context"
]
},
{
"cell_type": "code",
"execution_count": 51,
"id": "ba58c6eb-b47c-4efd-afd2-cab9e8a4bd30",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"Question: How many word limitations in writing?\n",
"Answer: The text states that \"A response that is significantly shorter could put your students in danger of scoring a 0 just for not showing enough of their writing skills\". It also mentions that \"Fully answering an ER prompt often requires 4 to 7 paragraphs of 3 to 7 sentences each that can quickly add up to 300 to 500 words of writing!\".\n",
"\n",
"Therefore, while there isn't a strict word limit given, it is clear that responses need to be substantial and detailed, aiming for **between 300 to 500 words**. Anything significantly shorter than this risks not demonstrating enough understanding and analysis. \n",
"\n",
"\n",
"\n",
"--------------------------------------------------------------------------------\n",
"Context: GED.com \n",
"GED® and GED Testing Service® are registered trademarks of the American Council on Education. They may not be used or reproduced without the express written permission \n",
"of ACE or GED Testing Service. The GED® and GED Testing Service® brands are administered by GED Testing Service LLC under license from the American Council on \n",
"Education. Copyright © 2019 GED Testing Service LLC. All rights reserved. \n",
"Sample Extended Response Passages and \n",
"Prompts for Classroom Practice - RLA \n",
"Help your students get ready for the extended responses on the GED® test Reasoning \n",
"Through Language Arts test by practicing with these sample prompts and source \n",
"materials in the classroom. \n",
"Fully answering an ER prompt often requires 4 to 7 paragraphs of 3 to 7 sentences \n",
"each that can quickly add up to 300 to 500 words of writing! A response that is \n",
"significantly shorter could put your students in danger of scoring a 0 just for not showing \n",
"enough of their writing skills. \n",
"Passage #1 - Are Tweens Ready for Cell Phones? \n",
"Extended Response Stimulus Materials: \n",
"Source Material #1 \n",
"Speech: “Tweens” Are Ready for Cell Phones by Deborah Pendergast \n",
"“Safer Kids Summit” \n",
"Thank you for inviting me to the first “Safer Kids Summit.” We are here to discuss ways \n",
"to keep our children safe in an increasingly complex world. Todays focus is on \n",
"technology— specifically on the ideal age to give kids their own cell phones. As a \n",
"representative of a large telecommunications company, I receive many inquiries from \n",
"parents on this topic, and this is what I tell them: It depends on the child, of course, but \n",
"in general, age 10 is just about right. \n",
"A 2012 survey by the National Consumers League backs me up. The survey found that \n",
"almost 60 percent of children ages 8 to 12 already have cell phones. These “tweens” \n",
"can contact their parents at any time, and vice versa, giving the kids a sense of \n",
"empowerment and their parents a feeling of security. Caroline Knorr, of the group \n",
"Common Sense Media, says, \"We want our kids to be independent, to be able to walk \n",
"home from school and play at the playground without us. We want them to have that \n",
"old-fashioned, fun experience of being on their own, and cell phones can help with that.” \n",
"Picture the following scenario: You told your fourth-grader that you would pick her up \n",
"after school, but you are stuck in traffic. She is waiting for you …and waiting, and \n",
"waiting. But if you both have cell phones, you can call her to let her know you are \n",
"delayed, and she can go back inside the school, where there are adults around. You \n",
"both breathe a sigh of relief.\n",
"GED.com 7 \n",
"Passage #3 Parenting Education \n",
"Extended Response Stimulus Materials: \n",
"Source Material #1 \n",
"Guest Column: Parenting Education Should Be Mandatory \n",
"Kai Fernandez, APRN \n",
"The Freeport Times \n",
"As a nurse practitioner in a pediatric office, I had to complete extensive training and \n",
"obtain a license before I could examine my first toddler. Many jobs, from barber to pilot, \n",
"involve specific training. But for the most important job —\n",
" raising children to be \n",
"responsible adults —no training is required, and children and society suffer the results \n",
"of this lack of knowledge. The time has come to correct this situation. Before they can \n",
"be discharged from the hospital, first-time parents should be required to take parenting \n",
"classes. \n",
"Just as we equip new drivers with a learners permit and instruction, we must also equip \n",
"new parents with the skills they need. While some people might believe that this is the \n",
"“nanny state” stepping on the rights of individuals, I am not suggesting that there is only \n",
"one “correct” style of parenting. But there is basic information about infants and children \n",
"that every parent should be required to know, including nutrition, health and safety, and \n",
"stages of child development. Knowing how to safely bathe a baby, for example, would \n",
"prevent many tragedies. Understanding that babies are crying to communicate, not to \n",
"be “naughty,” helps parents adjust their expectations and their behavior. \n",
"And parent education works. According to the Centers for Disease Control, for example, \n",
"the “Safe To Sleep” campaign has reduced the number of deaths from Sudden Infant \n",
"Death Syndrome by fifty percent since 1994 just by teaching parents to put babies to \n",
"bed on their backs. Conversely, uninformed parenting hurts not only children, but the \n",
"rest of us as well. A study by the Department of Education in England found that \n",
"children whose parents use harsh or inconsistent discipline are more likely to have poor \n",
"attention spans, low levels of literacy, and anti-social behavior. \n",
"In cultures where extended families are the rule, raising children is a group effort. But in \n",
"the modern world, new parents are on their own. It is our obligation as a society to make \n",
"sure they have the skills to do their best in this challenging job. Making parenting \n",
"classes mandatory is a step towards this goal. \n",
"Source Material #2 \n",
"Guest Column: Leave New Parents Alone \n",
"Sophie Thomas \n",
"The Freeport Times \n",
"I am writing in response to the op-ed essay by Kai Fernandez advocating mandatory \n",
"parenting classes for new parents. As the mother of three, I speak with experience \n",
"about raising children, and I strongly object to the idea that a random instructor knows\n",
"GED.com 2 \n",
"Psychologists tell us that the period between ages 10 and 12 is one of growing \n",
"independence. It is a time to teach children about responsibility, and to give them \n",
"opportunities to earn our trust. Providing a 10-year-old with a cell phone offers an ideal \n",
"way to achieve these goals and gives parents peace of mind as well. \n",
"Source Material #2 \n",
"Speech: Wait Until They Are Older by Linda Sidner \n",
"“Safer Kids Summit” \n",
"Good morning! I come to this topic as a parent and a veteran teacher of so-called \n",
"“tweens.” I love kids this age for their curiosity and energy, but those same qualities can \n",
"lead to trouble if not overseen by adults. Thats why giving children their own phones \n",
"actually makes them less safe, not more. I believe that the best age for a cell phone is \n",
"16, the point at which we consider kids grown-up enough to learn to drive —\n",
" and even \n",
"then, parents must set firm limits on phone use! \n",
"Why are tweens with phones less safe? For one thing, parents may be lulled into a false \n",
"sense of security if their kids have phones. They may become careless about knowing \n",
"where their child is and who he is with, thinking, “I can always reach him on his phone.” \n",
"For another, cell phones give children access to all the frightening, dangerous, and \n",
"inappropriate sites on the Internet, with no parent nearby to monitor this activity. \n",
"But perhaps the most worrisome aspect of giving cell phones to children is the rise in \n",
"“cyberbullying” or “text bullying.” Text bullying means using a cell phone to send cruel, \n",
"embarrassing, or false text messages to or about someone. In one study, researcher \n",
"Elizabeth Englander found that by middle school, over 90% of children report that they \n",
"use their cell phones to text or go onto the Internet. She also found that in grades 3 \n",
"through 5, between 14 and 19 percent of children reported being victims of \n",
"cyberbullying. What if its your child on the receiving end of this cruelty? Or, perhaps \n",
"worse, what if your child is the bully? Children of this age are simply not mature enough \n",
"to handle this technology, and we shouldnt expect them to be. Its our job as adults to \n",
"protect them. Thats why I say: Its better to wait. \n",
"Extended Response Prompt: \n",
"Analyze the arguments presented in the two speeches. \n",
"In your response, develop an argument in which you explain how one position is better \n",
"supported than the other. Incorporate relevant and specific evidence from both sources \n",
"to support your argument. \n",
"Remember, the better-argued position is not necessarily the position with which you \n",
"agree. This task should take approximately 45 minutes to complete.\n",
"--------------------------------------------------------------------------------\n"
]
}
],
"source": [
"question = \"How many word limitations in writing?\"\n",
"print(f\"\\nQuestion: {question}\")\n",
"answer,context = rag.query(question)\n",
"print(f\"Answer: {answer}\")\n",
"print(\"-\" * 80)\n",
"print(f\"Context: {context}\")\n",
"print(\"-\" * 80)"
]
},
{
"cell_type": "code",
"execution_count": 52,
"id": "2f218001-2427-4820-9a1b-72d2a049ab11",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"Question: How much time will be provided for each task?\n",
"Answer: I cannot answer your question about how much time will be provided for each task. The text you provided is about learning strategies, video games in education, and e-learning. There is no mention of specific tasks or allotted timeframes. \n",
"\n",
"--------------------------------------------------------------------------------\n",
"Context: GED.com 11 \n",
"Source Material #2 \n",
"From: Honoria Bell \n",
"Sent: Tuesday, September 25 \n",
"To: Justine Timmons, CEO \n",
"CC: Employees of Niagara Equipment Corp. \n",
"Subject: Workplace Internet Use \n",
"Dear Ms. Timmons, \n",
"We, the undersigned employees of Niagara Equipment Corp., urge management to \n",
"reconsider the installation of Internet-filtering software. While we recognize that it is in \n",
"all our interests to promote productivity and a positive workplace environment, we \n",
"believe that blocking our free access to the Internet is the wrong way to go about this. \n",
"First, there is more to that Salary.com statistic that you cite than meets the eye. Most of \n",
"the “cyberslackers” in that survey surf the Internet for only one hour per week. This is \n",
"comparable to taking a walk to the water cooler or chatting about last nights game with \n",
"a colleague. According to author Laura Vanderkam, “no one can get through a whole \n",
"workday without taking a break.” In fact, one 2009 study found that workers who could \n",
"occasionally check the Internet were happier at work than those who could not. Another \n",
"study, this one from the National University of Singapore, found that Web-surfing \n",
"refreshed employees, actually making them more productive, not less. \n",
"Second, one important function of the Internet is as a communication tool, just like the \n",
"telephone. Just as workers are permitted to make brief personal calls at work, so should \n",
"they be allowed to use the Internet for the same purpose. \n",
"Third, we believe that the best way to grow as a business and protect the company from \n",
"lawsuits is to hire responsible employees and then demonstrate your trust in them. \n",
"Instead of treating us like children, why not establish clear guidelines concerning \n",
"Internet use? All employees can understand the reasons that offensive websites are off \n",
"limits. \n",
"Finally, installing an Internet filter may create resentment and tempt some employees to \n",
"find ways around the filters. It is an unnecessary solution in search of a problem. \n",
"Thank you for your attention. \n",
"Honoria Bell, Chief Designer and the undersigned 53 employees\n",
"GED.com \n",
"GED® and GED Testing Service® are registered trademarks of the American Council on Education. They may not be used or reproduced without the express written permission \n",
"of ACE or GED Testing Service. The GED® and GED Testing Service® brands are administered by GED Testing Service LLC under license from the American Council on \n",
"Education. Copyright © 2019 GED Testing Service LLC. All rights reserved. \n",
"Sample Extended Response Passages and \n",
"Prompts for Classroom Practice - RLA \n",
"Help your students get ready for the extended responses on the GED® test Reasoning \n",
"Through Language Arts test by practicing with these sample prompts and source \n",
"materials in the classroom. \n",
"Fully answering an ER prompt often requires 4 to 7 paragraphs of 3 to 7 sentences \n",
"each that can quickly add up to 300 to 500 words of writing! A response that is \n",
"significantly shorter could put your students in danger of scoring a 0 just for not showing \n",
"enough of their writing skills. \n",
"Passage #1 - Are Tweens Ready for Cell Phones? \n",
"Extended Response Stimulus Materials: \n",
"Source Material #1 \n",
"Speech: “Tweens” Are Ready for Cell Phones by Deborah Pendergast \n",
"“Safer Kids Summit” \n",
"Thank you for inviting me to the first “Safer Kids Summit.” We are here to discuss ways \n",
"to keep our children safe in an increasingly complex world. Todays focus is on \n",
"technology— specifically on the ideal age to give kids their own cell phones. As a \n",
"representative of a large telecommunications company, I receive many inquiries from \n",
"parents on this topic, and this is what I tell them: It depends on the child, of course, but \n",
"in general, age 10 is just about right. \n",
"A 2012 survey by the National Consumers League backs me up. The survey found that \n",
"almost 60 percent of children ages 8 to 12 already have cell phones. These “tweens” \n",
"can contact their parents at any time, and vice versa, giving the kids a sense of \n",
"empowerment and their parents a feeling of security. Caroline Knorr, of the group \n",
"Common Sense Media, says, \"We want our kids to be independent, to be able to walk \n",
"home from school and play at the playground without us. We want them to have that \n",
"old-fashioned, fun experience of being on their own, and cell phones can help with that.” \n",
"Picture the following scenario: You told your fourth-grader that you would pick her up \n",
"after school, but you are stuck in traffic. She is waiting for you …and waiting, and \n",
"waiting. But if you both have cell phones, you can call her to let her know you are \n",
"delayed, and she can go back inside the school, where there are adults around. You \n",
"both breathe a sigh of relief.\n",
"GED.com 6 \n",
"References \n",
" Arth, B. (2011, September) The business impact of next-generation e-learning.\n",
"http://wwwimages.adobe.com/content/dam/Adobe/en/products/adobeconnect/pdfs/elearning/0921\n",
"11-rr-nextgen-elearning-ba-ctcrevised-vendor.pdf\n",
" Bhasin, K. (2014, January 7) Gamification, game-based learning, serious games: Any difference?\n",
"Retrieved from http://www.learningsolutionsmag.com/articles/1337/gamification-game-based-\n",
"learning-serious-games-any-difference\n",
" Cavalli, E. (2011, June 8) New demographic show gamers are getting older. The Escapist.\n",
"Retrieved from http://www.escapistmagazine.com/news/view/110837-New-Demographics-Show-\n",
"Gamers-Are-Getting-Older\n",
" Donovan, L. (2012, December) The use of serious games in the corporate sector. Retreived from\n",
"http://www.learnovatecentre.org/wp-\n",
"content/uploads/2013/06/Use_of_Serious_Games_in_the_Corporate_Sector_PRINT_FINAL.pdf\n",
" Harwell, D. (2014, October 17) More women play video games than boys and other surprising\n",
"facts lost in the mess of gamergate. The Washington Post. Retrieved from\n",
"http://www.washingtonpost.com/blogs/the-switch/wp/2014/10/17/more-women-play-video-games-\n",
"than-boys-and-other-surprising-facts-lost-in-the-mess-of-gamergate/\n",
" Koller, V., Harvey, S., & Magnotta, M. (n.d.) Technology-based learning strategies. Retrieved\n",
"from http://www.doleta.gov/reports/papers/tbl_paper_final.pdf\n",
" More than just a game: Video games are behind the latest fad in management. (2012, November\n",
"10) The Economist. Retrieved from http://www.economist.com/news/business/21565926-video-\n",
"games-are-behind-latest-fad-management-more-just-game \n",
" New Media Institute. (n.d.) Game-based learning: what it is, why it works, and where its going.\n",
" Retrieved from http://www.newmedia.org/game-based-learning--what-it-is-why-it- \n",
"works-and-where-its-going.html\n",
" Outcomes of game-based learning: Research roundup (2013, May 20) Retrieved from\n",
"http://journalistsresource.org/studies/society/education/outcomes-of-game-based-learning-\n",
"research-roundup#\n",
" Squire, K.D. (2008, November 2) Performance Improvement Quarterly, 21 (2)\n",
"7-36 Retrieved from http://www.performancexpress.org/wp-content/uploads /2011/11/Video-\n",
"Game%96Based-Learning.pdf\n",
" The Rapid E-Learning Blog. (2010, February 2) Why e-learning is so effective. Retrieved from\n",
"http://www.articulate.com/rapid-elearning/why-e-learning-is-so-effective/\n",
" True Office. (n.d.) Digital games revolutionizing workplace learning? Retrieved from\n",
"http://www.trueoffice.com/wpcontent/uploads/2014/04/TRU\n",
"--------------------------------------------------------------------------------\n"
]
}
],
"source": [
"question = \"How much time will be provided for each task?\"\n",
"print(f\"\\nQuestion: {question}\")\n",
"answer,context = rag.query(question)\n",
"print(f\"Answer: {answer}\")\n",
"print(\"-\" * 80)\n",
"print(f\"Context: {context}\")\n",
"print(\"-\" * 80)"
]
},
{
"cell_type": "code",
"execution_count": 53,
"id": "bbfba2a8-5bcf-43d5-b1d2-21dbe21f1862",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"Question: Who is Solomon Robles?\n",
"Answer: Solomon Robles is an Ed.D., Professor of Education at Winborne College. \n",
"\n",
"He wrote the article \"Game-based Learning Is Merely a Fad\" for *Workplace Training Journal*. In his article, he argues against the effectiveness of game-based learning, comparing it to previous eLearning trends that ultimately failed. He cites research that shows mixed results for game-based learning in schools and points out its potential drawbacks, such as hindering the development of \"soft skills\" and creating a divide between generations of workers. \n",
"\n",
"--------------------------------------------------------------------------------\n",
"Context: GED.com 4 \n",
"Passage #2 Game-Based Learning \n",
"Extended Response Stimulus Materials: \n",
"Source Material #1 \n",
"Game-based Learning Is Merely a Fad \n",
"Solomon Robles, Ed.D., Professor of Education at Winborne College \n",
"Workplace Training Journal \n",
"Electronic learning, or “eLearning,” was sold to many CEOs as the wave of the \n",
"corporate future. Theres no need to hire human beings to train staff, managers were \n",
"told. All the information you require can be accessed online —\n",
" at a reduced cost for the \n",
"company, and more flexible scheduling for employees. It sounded too good to be true \n",
"— and it was. As one writer noted, “most eLearning is nothing more than online lectures \n",
"or course notes.” To teach skills beyond basic facts, the person-to-person method is still \n",
"more effective than any form of electronic learning. \n",
"And yet, along comes the next eLearning fad: “gamification,” which means using video \n",
"games to teach. Video-game-based learning is already widely used in schools, and has \n",
"spread to corporations as a tool for training workers and motivating customers. This \n",
"approach is even used in the military. But does it work? \n",
"Most research on game-based learning has looked at schools. Results have been \n",
"inconsistent but not especially encouraging. One 2013 study found that “students who \n",
"completed the gamified experience got better scores in practical assignments and in \n",
"overall score, but … performed poorly on written assignments and participated less \n",
"during class activities.” This makes sense: If youre playing video games, you are not \n",
"developing the so-called “soft skills” —\n",
"also known as “people skills” that are \n",
"necessary for success in any job. In a traditional classroom, on the other hand, students \n",
"can ask questions and engage with the teacher and with other learners. \n",
"In the workplace, game-based learning is yet another wedge driven between younger \n",
"employees, who might applaud gamification, and older workers, who may now feel \n",
"obsolete. Whats more, the prestigious magazine The Economist points out that “many \n",
"of the aspects of gamification that do work are merely old ideas in trendy new clothes.” \n",
"For example, the points and other rewards that are selling features of video games are \n",
"just online versions of sales contests or “employee of the month” perks. Like other \n",
"trends, game-based learning is likely to fade away as the next new teaching fad \n",
"appears on the horizon. \n",
"Source Material #2 \n",
"Game-based Learning: An Effective Training Strategy \n",
"Janette Morgan, Ph.D., Professor of Business, Saratoga State University \n",
"Innovative Trends in the Workplace \n",
"Already a multi-billion-dollar business, game-based learning in the corporate world \n",
"continues to grow at a steady pace, and is here to stay. Executives are smart —\n",
" they\n",
"GED.com 5 \n",
"are not going to waste resources on training methods that dont work. Lets look at some \n",
"of the advantages of “gamifying” workplace training. \n",
"First, many people are “gamers” in their non-work lives, so playing video games is \n",
"something they are already comfortable with and enjoy. This makes game-based \n",
"learning in the workplace more attractive and motivating than traditional instruction. And \n",
"according to the Entertainment Software Association, despite the image of video-game \n",
"players as teenaged boys, “the average gamer is now 37 years old.” Further challenging \n",
"the stereotype, nearly half of gamers are girls or women. Even 29 percent of those over \n",
"age 50 are getting into the video-game habit. Teenagers and young men, in fact, make \n",
"up only 15 percent of the over 190 million video-game users in the United States. \n",
"Evidence supporting the effectiveness of game-based learning is starting to emerge. \n",
"Researchers point out that video games have “compelling storylines, attainable \n",
"challenges, rewards, recognition and control,” all of which stimulate learners. A 2012 \n",
"report on game-based learning notes that “there is research evidence demonstrating \n",
"positive impact on higher order skills such as decision making and problem solving.” \n",
"The report adds that using video games can also reduce training time, an advantage for \n",
"both managers and employees. \n",
"Finally, unlike one-time training in a classroom, game-based learning is infinitely \n",
"repeatable. If employees miss something or need more practice, they can always start \n",
"the game again, using the feedback provided by the game to gauge their progress. This \n",
"leads to a sense of accomplishment and creates a supportive learning environment, \n",
"which is what we all want in an education strategy. \n",
"Extended Response Prompt: \n",
"Analyze the arguments presented in the two journal articles. \n",
"In your response, develop an argument in which you explain how one position is better \n",
"supported than the other. Incorporate relevant and specific evidence from both sources \n",
"to support your argument. \n",
"Remember, the better-argued position is not necessarily the position with which you \n",
"agree. This task should take approximately 45 minutes to complete.\n",
"GED.com 12 \n",
"Extended Response Prompt: \n",
"References \n",
" Bowers, T. (2002, October 22) Hostile work environment: A managers legal liability. Tech\n",
"Republic. Retrieved from http://www.techrepublic.com/article/hostile-work-environment-a-\n",
"managers-legal-liability/\n",
" Cain, A. & OBrien, K. (n.d.) Facebook status update: Employer is…sued: How internet\n",
"harassment could lead to a change in status. Retrieved from http://www.lmblaw.com/media/in-\n",
"the-news/articles/internet-harassment\n",
" Ho, Mimi. (2000, June 12) Internet surfing at the workplace. CIO. Retrieved from\n",
"http://www.cio.com/article/2439254/security0/internet-surfing-at-the-workplace.html\n",
" Odysseas, M. (2013, December 13) How relevant is internet filtering in the workplace? Retrieved\n",
"from http://www.smallbusiness.co.uk/blog/2447732/how-relevant-is-internet-filtering-in-the-\n",
"workplace.thtml\n",
" Platt, J. (2012, November 26) Cyberslacking actually boosts workplace productivity. Mother\n",
"Nature Network. Retrieved from http://www.mnn.com/green-\n",
"tech/computers/stories/cyberslacking-actually-boosts-workplace-productivity\n",
" Signal, M. (n.d.) Pros and cons of internet filtering in schools. eHow. Retrieved from\n",
"http://www.ehow.com/info_8005986_pros-cons-internet-filtering.html\n",
" Whitty, M. (2004) Should filtering software be utilised in the workplace? Australian employees\n",
"attitudes towards internet usage and surveillance of the internet in the workplace. Surveillance\n",
"and Society 2 (1): 39-54 Retrieved from http://www.surveillance-and-\n",
"society.org/articles2%281%29/filtering.pdf\n",
"Analyze the arguments presented in the two emails. \n",
"In your response, develop an argument in which you explain how one position is better \n",
"supported than the other. Incorporate relevant and specific evidence from both sources \n",
"to support your argument. \n",
"Remember, the better-argued position is not necessarily the position with which you \n",
"agree. This task should take approximately 45 minutes to complete.\n",
"--------------------------------------------------------------------------------\n"
]
}
],
"source": [
"question = \"Who is Solomon Robles?\"\n",
"print(f\"\\nQuestion: {question}\")\n",
"answer,context = rag.query(question)\n",
"print(f\"Answer: {answer}\")\n",
"print(\"-\" * 80)\n",
"print(f\"Context: {context}\")\n",
"print(\"-\" * 80)"
]
},
{
"cell_type": "code",
"execution_count": 54,
"id": "c22b7dac-33d4-4c36-a2f6-07eb52bc2fd6",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"Question: Who is Kai Fernandez?\n",
"Answer: The provided text does not contain any information about Kai Fernandez. Therefore, I cannot answer who Kai Fernandez is based on the context given. \n",
"\n",
"\n",
"\n",
"--------------------------------------------------------------------------------\n",
"Context: GED.com 15 \n",
"References \n",
" Appelbaum, B. (2014, August 5) Does hosting the olympics actually pay off? The New York\n",
"Times Magazine. Retrieved from http://www.nytimes.com/2014/08/10/magazine/does-hosting-\n",
"the-olympics-actually-pay-off.html?_r=0\n",
" Cloherty, S. (2014, February 21) The pros and cons of hosting the olympics. The Milton Measure.\n",
"Retrieved from http://miltonmeasure.org/2014/02/the-pros-and-cons-of-hosting-the-olympics/\n",
" Fowler, G.A. & Meichtry, S. (2008, July 6) China counts the cost of hosting the olympics. The\n",
"Wall Street Journal. Retrieved from http://www.wsj.com/articles/\n",
"SB121614671139755287\n",
" Not all Brazilians overjoyed by world cup. (2014, June 12) PBS Newshour Extra. Retrieved from\n",
"http://www.pbs.org/newshour/extra/daily_videos/not-all-brazilians-overjoyed- by-world-cup/\n",
" Pettinger, T. (2012, January 24) Advantages of hosting a major event. Economics Help.\n",
"Retrieved from http://www.economicshelp.org/blog/4909/economics/advantages- of-hosting-a-\n",
"major-event/\n",
" Weissman, J. (2012, July 31) Empty nest: Beijings olympic stadium is a vacant museum piece.\n",
"The Atlantic. http://www.theatlantic.com/business/archive/2012/07/empty-nest-beijings- olympic-\n",
"stadium-is-a-vacant-museum-piece/260522/\n",
" Wihbey, J. (2014, February 3) Economic and cultural benefits of the olympics: Research roundup.\n",
"Journalists Resource. Retrieved from\n",
"http://journalistsresource.org/studies/society/culture/economic-and-cultural-benefits-of-the-\n",
"olympics-research-roundup\n",
" Yates, B. (2010, November) Major events: Good economics and exposure to the world.\n",
"Technology Innovation Management Review. Retrieved from http://timreview.ca/article/393\n",
" Zimbalist, A. (2012, July 23) 3 reasons why hosting the olympics is a losers game. The Atlantic.\n",
"Retrieved from http://www.theatlantic.com/business/archive/2012/07/3-reasons-why-hosting- the-\n",
"olympics-is-a-losers-game/260111/\n",
"GED.com 5 \n",
"are not going to waste resources on training methods that dont work. Lets look at some \n",
"of the advantages of “gamifying” workplace training. \n",
"First, many people are “gamers” in their non-work lives, so playing video games is \n",
"something they are already comfortable with and enjoy. This makes game-based \n",
"learning in the workplace more attractive and motivating than traditional instruction. And \n",
"according to the Entertainment Software Association, despite the image of video-game \n",
"players as teenaged boys, “the average gamer is now 37 years old.” Further challenging \n",
"the stereotype, nearly half of gamers are girls or women. Even 29 percent of those over \n",
"age 50 are getting into the video-game habit. Teenagers and young men, in fact, make \n",
"up only 15 percent of the over 190 million video-game users in the United States. \n",
"Evidence supporting the effectiveness of game-based learning is starting to emerge. \n",
"Researchers point out that video games have “compelling storylines, attainable \n",
"challenges, rewards, recognition and control,” all of which stimulate learners. A 2012 \n",
"report on game-based learning notes that “there is research evidence demonstrating \n",
"positive impact on higher order skills such as decision making and problem solving.” \n",
"The report adds that using video games can also reduce training time, an advantage for \n",
"both managers and employees. \n",
"Finally, unlike one-time training in a classroom, game-based learning is infinitely \n",
"repeatable. If employees miss something or need more practice, they can always start \n",
"the game again, using the feedback provided by the game to gauge their progress. This \n",
"leads to a sense of accomplishment and creates a supportive learning environment, \n",
"which is what we all want in an education strategy. \n",
"Extended Response Prompt: \n",
"Analyze the arguments presented in the two journal articles. \n",
"In your response, develop an argument in which you explain how one position is better \n",
"supported than the other. Incorporate relevant and specific evidence from both sources \n",
"to support your argument. \n",
"Remember, the better-argued position is not necessarily the position with which you \n",
"agree. This task should take approximately 45 minutes to complete.\n",
"GED.com 12 \n",
"Extended Response Prompt: \n",
"References \n",
" Bowers, T. (2002, October 22) Hostile work environment: A managers legal liability. Tech\n",
"Republic. Retrieved from http://www.techrepublic.com/article/hostile-work-environment-a-\n",
"managers-legal-liability/\n",
" Cain, A. & OBrien, K. (n.d.) Facebook status update: Employer is…sued: How internet\n",
"harassment could lead to a change in status. Retrieved from http://www.lmblaw.com/media/in-\n",
"the-news/articles/internet-harassment\n",
" Ho, Mimi. (2000, June 12) Internet surfing at the workplace. CIO. Retrieved from\n",
"http://www.cio.com/article/2439254/security0/internet-surfing-at-the-workplace.html\n",
" Odysseas, M. (2013, December 13) How relevant is internet filtering in the workplace? Retrieved\n",
"from http://www.smallbusiness.co.uk/blog/2447732/how-relevant-is-internet-filtering-in-the-\n",
"workplace.thtml\n",
" Platt, J. (2012, November 26) Cyberslacking actually boosts workplace productivity. Mother\n",
"Nature Network. Retrieved from http://www.mnn.com/green-\n",
"tech/computers/stories/cyberslacking-actually-boosts-workplace-productivity\n",
" Signal, M. (n.d.) Pros and cons of internet filtering in schools. eHow. Retrieved from\n",
"http://www.ehow.com/info_8005986_pros-cons-internet-filtering.html\n",
" Whitty, M. (2004) Should filtering software be utilised in the workplace? Australian employees\n",
"attitudes towards internet usage and surveillance of the internet in the workplace. Surveillance\n",
"and Society 2 (1): 39-54 Retrieved from http://www.surveillance-and-\n",
"society.org/articles2%281%29/filtering.pdf\n",
"Analyze the arguments presented in the two emails. \n",
"In your response, develop an argument in which you explain how one position is better \n",
"supported than the other. Incorporate relevant and specific evidence from both sources \n",
"to support your argument. \n",
"Remember, the better-argued position is not necessarily the position with which you \n",
"agree. This task should take approximately 45 minutes to complete.\n",
"--------------------------------------------------------------------------------\n"
]
}
],
"source": [
"question = \"Who is Kai Fernandez?\"\n",
"print(f\"\\nQuestion: {question}\")\n",
"answer,context = rag.query(question)\n",
"print(f\"Answer: {answer}\")\n",
"print(\"-\" * 80)\n",
"print(f\"Context: {context}\")\n",
"print(\"-\" * 80)"
]
},
{
"cell_type": "code",
"execution_count": 55,
"id": "69c1b9aa-d159-43cd-a14b-ec49bf20d878",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"Question: What is discussed about Parenting Education?\n",
"Answer: The provided text delves into the debate surrounding mandatory parenting classes. \n",
"\n",
"**Here's a breakdown of the discussion points:**\n",
"\n",
"* **Arguments for Mandatory Parenting Classes:**\n",
" * **Essential Skill:** Kai Fernandez, in his guest column, argues that raising children is the most important job and deserves proper training, akin to other professions requiring licenses or certifications. \n",
" * **Preventing Harm:** He emphasizes the potential benefits of education in areas like infant safety (reducing SIDS), understanding child development, and managing behavioral issues. He cites the \"Safe To Sleep\" campaign's success in reducing SIDS deaths as evidence.\n",
" * **Societal Benefit:** Fernandez suggests that informed parenting leads to better child outcomes, including improved attention spans, literacy, and reduced antisocial behavior, ultimately benefiting society as a whole.\n",
"\n",
"* **Arguments Against Mandatory Parenting Classes:** \n",
" * **Government Overreach:** Sophie Thomas opposes the idea as an infringement on parental rights and personal freedom. She compares it to government-imposed restrictions like banning large sodas, arguing that individuals should have the autonomy to choose their parenting methods.\n",
" * **Existing Resources:** Thomas points out the abundance of existing resources for parents, including books, online information, family support, and voluntary classes offered by various institutions. \n",
" * **Practical Challenges:** She raises concerns about the financial burden on families who might be required to pay for classes and questions the feasibility of enforcing mandatory participation.\n",
"\n",
"**In essence, the debate centers around the balance between individual freedom and societal responsibility when it comes to parenting.** While both sides acknowledge the importance of effective parenting, they differ significantly in their views on the role of government intervention.\n",
"\n",
"\n",
"Let me know if you'd like me to analyze which argument is more persuasive based on the evidence presented! \n",
"\n",
"--------------------------------------------------------------------------------\n",
"Context: GED.com 9 \n",
"References \n",
" Fetsch, R.J. & Collins, C.L. (2012, August) A review and critique of 16 major parent education\n",
"programs. Journal of Extension. Retrieved from http://www.joe.org/joe/2012august/a8.php\n",
" Gentleman, A. (2012, March 30) Do we need parenting classes? The Guardian. Retrieved from\n",
"http://www.theguardian.com/lifeandstyle/2012/mar/31/do-we-need-parenting-classes\n",
" Greenwood, B. (n.d.) The effectiveness of parenting classes. Retrieved from\n",
"http://everydaylife.globalpost.com/effectiveness-parenting-classes-5089.html\n",
" Maffei, M. (2013, September 2) Should parenting require a license? Retrieved from\n",
"http://www.sheknows.com/parenting/articles/1009213/should-parenting-require-a-license\n",
" Page, A. (2010, January 8) Ultimate guide to parenting classes. HowStuffWorks.com. Retrieved\n",
"from http://lifestyle.howstuffworks.com/family/parenting/parenting-tips/parenting- \n",
"classes3.htm\n",
" Paton, G. (2012, February 26) Children with negative parents twice as likely to misbehave.\n",
" The Telegraph. Retrieved from http://www.telegraph.co.uk/education/\n",
"educationnews/9106818/Children-with-negative-parents-twice-as-likely-to-misbehave.html\n",
" Schreiber, T. (2011, September 26) Parenting 101: The benefits of parenting classes. Parent\n",
"Map. Retrieved from https://www.parentmap.com/article/benefits-of-parenting-classes\n",
" Should all parents be required to attend parenting classes? (n.d.) Retrieved from\n",
"http://www.debate.org/opinions/should-all-parents-be-required-to-attend-parenting-classes\n",
" UK Department for Education (2012, December 20) Which type of parenting programme best\n",
"improves child behaviour and reading? Retrieved from\n",
"https://www.gov.uk/government/publications/which-type-of-parenting-programme-best-improves-\n",
"child-behaviour-and-reading-the-helping-children-achieve-trial\n",
" What Works Wisconsin (n.d.) Cooperative extension Family living programs. Retrieved from\n",
"http://whatworks.uwex.edu/attachment/factsheet_4parentinged.pdf\n",
"GED.com 7 \n",
"Passage #3 Parenting Education \n",
"Extended Response Stimulus Materials: \n",
"Source Material #1 \n",
"Guest Column: Parenting Education Should Be Mandatory \n",
"Kai Fernandez, APRN \n",
"The Freeport Times \n",
"As a nurse practitioner in a pediatric office, I had to complete extensive training and \n",
"obtain a license before I could examine my first toddler. Many jobs, from barber to pilot, \n",
"involve specific training. But for the most important job —\n",
" raising children to be \n",
"responsible adults —no training is required, and children and society suffer the results \n",
"of this lack of knowledge. The time has come to correct this situation. Before they can \n",
"be discharged from the hospital, first-time parents should be required to take parenting \n",
"classes. \n",
"Just as we equip new drivers with a learners permit and instruction, we must also equip \n",
"new parents with the skills they need. While some people might believe that this is the \n",
"“nanny state” stepping on the rights of individuals, I am not suggesting that there is only \n",
"one “correct” style of parenting. But there is basic information about infants and children \n",
"that every parent should be required to know, including nutrition, health and safety, and \n",
"stages of child development. Knowing how to safely bathe a baby, for example, would \n",
"prevent many tragedies. Understanding that babies are crying to communicate, not to \n",
"be “naughty,” helps parents adjust their expectations and their behavior. \n",
"And parent education works. According to the Centers for Disease Control, for example, \n",
"the “Safe To Sleep” campaign has reduced the number of deaths from Sudden Infant \n",
"Death Syndrome by fifty percent since 1994 just by teaching parents to put babies to \n",
"bed on their backs. Conversely, uninformed parenting hurts not only children, but the \n",
"rest of us as well. A study by the Department of Education in England found that \n",
"children whose parents use harsh or inconsistent discipline are more likely to have poor \n",
"attention spans, low levels of literacy, and anti-social behavior. \n",
"In cultures where extended families are the rule, raising children is a group effort. But in \n",
"the modern world, new parents are on their own. It is our obligation as a society to make \n",
"sure they have the skills to do their best in this challenging job. Making parenting \n",
"classes mandatory is a step towards this goal. \n",
"Source Material #2 \n",
"Guest Column: Leave New Parents Alone \n",
"Sophie Thomas \n",
"The Freeport Times \n",
"I am writing in response to the op-ed essay by Kai Fernandez advocating mandatory \n",
"parenting classes for new parents. As the mother of three, I speak with experience \n",
"about raising children, and I strongly object to the idea that a random instructor knows\n",
"GED.com 8 \n",
"my family and my circumstances better than I do. Just like New York Citys efforts to \n",
"ban the sale of large sodas, a law requiring parents to take parenting classes is yet \n",
"another example of some government bureaucrat determining what is best for the rest \n",
"of us. Freedom of choice is a fundamental American value; forcing all parents to learn \n",
"the same information about children conflicts with this basic right. \n",
"While it is true that there are many challenges facing new parents, there are also many \n",
"ways to learn how to handle these challenges. There are shelves full of parenting books \n",
"in every bookstore; enter the word “parenting” in the search box on any Web browser, \n",
"and millions of resources will pop up. Then there are family members and friends to turn \n",
"to for advice, as well as good old trial and error. Hospitals, community centers, and \n",
"houses of worship also offer a variety of parenting classes —\n",
" but the important point is \n",
"that these are voluntary. \n",
"There are also the problems of funding and enforcing this proposal. Would parents have \n",
"to pay for the classes themselves? This could pose a financial burden for many people. \n",
"And what if parents refused to take the classes? Would they be fined? Arrested? \n",
"Even if these practical aspects of mandatory parenting classes could be worked out, \n",
"however, the issue of government intrusion into family lives makes it a non-starter. After \n",
"all, parents have been raising children for millions of years without the governments \n",
"help. \n",
"Extended Response Prompt: \n",
"Analyze the arguments presented in the two guest columns. \n",
"In your response, develop an argument in which you explain how one position is better \n",
"supported than the other. Incorporate relevant and specific evidence from both sources \n",
"to support your argument. \n",
"Remember, the better-argued position is not necessarily the position with which you \n",
"agree. This task should take approximately 45 minutes to complete.\n",
"--------------------------------------------------------------------------------\n"
]
}
],
"source": [
"question = \"What is discussed about Parenting Education?\"\n",
"print(f\"\\nQuestion: {question}\")\n",
"answer,context = rag.query(question)\n",
"print(f\"Answer: {answer}\")\n",
"print(\"-\" * 80)\n",
"print(f\"Context: {context}\")\n",
"print(\"-\" * 80)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "fcc1109e-2c6a-4f3d-8f1b-86474da9f796",
"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.10.12"
}
},
"nbformat": 4,
"nbformat_minor": 5
}