{ "cells": [ { "cell_type": "markdown", "metadata": { "id": "L3jJhdKW5Oeo" }, "source": [ "# **If you are using Colab for free, we highly recommend you active the T4 GPU hardware accelerator. Our models are designed to run with at least 16GB of RAM, activating T4 will grant the notebook 16GB of GDDR6 RAM as opposed to the 13GB Colab gives automatically.**\n", "# **To active T4:**\n", "# **1. click on the \"Runtime\" tab**\n", "# **2. click on \"Change runtime type\"**\n", "# **3. select T4 GPU under Hardware Accelerator**\n", "# **NOTE: there is a weekly usage limit on using T4 for free**\n" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "lxFs5ZL5O2jZ", "outputId": "ee864ee3-5de8-4bf7-8327-935258471852" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Collecting llmware\n", " Downloading llmware-0.3.0-py3-none-any.whl (56.0 MB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m56.0/56.0 MB\u001b[0m \u001b[31m12.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hCollecting boto3>=1.24.53 (from llmware)\n", " Downloading boto3-1.34.120-py3-none-any.whl (139 kB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m139.3/139.3 kB\u001b[0m \u001b[31m2.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hRequirement already satisfied: huggingface-hub>=0.19.4 in /usr/local/lib/python3.10/dist-packages (from llmware) (0.23.2)\n", "Requirement already satisfied: numpy>=1.23.2 in /usr/local/lib/python3.10/dist-packages (from llmware) (1.25.2)\n", "Collecting pymongo>=4.7.0 (from llmware)\n", " Downloading pymongo-4.7.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (669 kB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m669.1/669.1 kB\u001b[0m \u001b[31m17.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hRequirement already satisfied: tokenizers>=0.15.0 in /usr/local/lib/python3.10/dist-packages (from llmware) (0.19.1)\n", "Collecting psycopg-binary==3.1.17 (from llmware)\n", " Downloading psycopg_binary-3.1.17-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.3 MB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m3.3/3.3 MB\u001b[0m \u001b[31m22.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hCollecting psycopg==3.1.17 (from llmware)\n", " Downloading psycopg-3.1.17-py3-none-any.whl (178 kB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m178.0/178.0 kB\u001b[0m \u001b[31m12.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hCollecting pgvector==0.2.4 (from llmware)\n", " Downloading pgvector-0.2.4-py2.py3-none-any.whl (9.6 kB)\n", "Collecting colorama==0.4.6 (from llmware)\n", " Downloading colorama-0.4.6-py2.py3-none-any.whl (25 kB)\n", "Requirement already satisfied: librosa>=0.10.0 in /usr/local/lib/python3.10/dist-packages (from llmware) (0.10.2.post1)\n", "Requirement already satisfied: typing-extensions>=4.1 in /usr/local/lib/python3.10/dist-packages (from psycopg==3.1.17->llmware) (4.12.1)\n", "Collecting botocore<1.35.0,>=1.34.120 (from boto3>=1.24.53->llmware)\n", " Downloading botocore-1.34.120-py3-none-any.whl (12.3 MB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m12.3/12.3 MB\u001b[0m \u001b[31m49.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hCollecting jmespath<2.0.0,>=0.7.1 (from boto3>=1.24.53->llmware)\n", " Downloading jmespath-1.0.1-py3-none-any.whl (20 kB)\n", "Collecting s3transfer<0.11.0,>=0.10.0 (from boto3>=1.24.53->llmware)\n", " Downloading s3transfer-0.10.1-py3-none-any.whl (82 kB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m82.2/82.2 kB\u001b[0m \u001b[31m7.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hRequirement already satisfied: filelock in /usr/local/lib/python3.10/dist-packages (from huggingface-hub>=0.19.4->llmware) (3.14.0)\n", "Requirement already satisfied: fsspec>=2023.5.0 in /usr/local/lib/python3.10/dist-packages (from huggingface-hub>=0.19.4->llmware) (2023.6.0)\n", "Requirement already satisfied: packaging>=20.9 in /usr/local/lib/python3.10/dist-packages (from huggingface-hub>=0.19.4->llmware) (24.0)\n", "Requirement already satisfied: pyyaml>=5.1 in /usr/local/lib/python3.10/dist-packages (from huggingface-hub>=0.19.4->llmware) (6.0.1)\n", "Requirement already satisfied: requests in /usr/local/lib/python3.10/dist-packages (from huggingface-hub>=0.19.4->llmware) (2.31.0)\n", "Requirement already satisfied: tqdm>=4.42.1 in /usr/local/lib/python3.10/dist-packages (from huggingface-hub>=0.19.4->llmware) (4.66.4)\n", "Requirement already satisfied: audioread>=2.1.9 in /usr/local/lib/python3.10/dist-packages (from librosa>=0.10.0->llmware) (3.0.1)\n", "Requirement already satisfied: scipy>=1.2.0 in /usr/local/lib/python3.10/dist-packages (from librosa>=0.10.0->llmware) (1.11.4)\n", "Requirement already satisfied: scikit-learn>=0.20.0 in /usr/local/lib/python3.10/dist-packages (from librosa>=0.10.0->llmware) (1.2.2)\n", "Requirement already satisfied: joblib>=0.14 in /usr/local/lib/python3.10/dist-packages (from librosa>=0.10.0->llmware) (1.4.2)\n", "Requirement already satisfied: decorator>=4.3.0 in /usr/local/lib/python3.10/dist-packages (from librosa>=0.10.0->llmware) (4.4.2)\n", "Requirement already satisfied: numba>=0.51.0 in /usr/local/lib/python3.10/dist-packages (from librosa>=0.10.0->llmware) (0.58.1)\n", "Requirement already satisfied: soundfile>=0.12.1 in /usr/local/lib/python3.10/dist-packages (from librosa>=0.10.0->llmware) (0.12.1)\n", "Requirement already satisfied: pooch>=1.1 in /usr/local/lib/python3.10/dist-packages (from librosa>=0.10.0->llmware) (1.8.1)\n", "Requirement already satisfied: soxr>=0.3.2 in /usr/local/lib/python3.10/dist-packages (from librosa>=0.10.0->llmware) (0.3.7)\n", "Requirement already satisfied: lazy-loader>=0.1 in /usr/local/lib/python3.10/dist-packages (from librosa>=0.10.0->llmware) (0.4)\n", "Requirement already satisfied: msgpack>=1.0 in /usr/local/lib/python3.10/dist-packages (from librosa>=0.10.0->llmware) (1.0.8)\n", "Collecting dnspython<3.0.0,>=1.16.0 (from pymongo>=4.7.0->llmware)\n", " Downloading dnspython-2.6.1-py3-none-any.whl (307 kB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m307.7/307.7 kB\u001b[0m \u001b[31m22.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hRequirement already satisfied: python-dateutil<3.0.0,>=2.1 in /usr/local/lib/python3.10/dist-packages (from botocore<1.35.0,>=1.34.120->boto3>=1.24.53->llmware) (2.8.2)\n", "Requirement already satisfied: urllib3!=2.2.0,<3,>=1.25.4 in /usr/local/lib/python3.10/dist-packages (from botocore<1.35.0,>=1.34.120->boto3>=1.24.53->llmware) (2.0.7)\n", "Requirement already satisfied: llvmlite<0.42,>=0.41.0dev0 in /usr/local/lib/python3.10/dist-packages (from numba>=0.51.0->librosa>=0.10.0->llmware) (0.41.1)\n", "Requirement already satisfied: platformdirs>=2.5.0 in /usr/local/lib/python3.10/dist-packages (from pooch>=1.1->librosa>=0.10.0->llmware) (4.2.2)\n", "Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests->huggingface-hub>=0.19.4->llmware) (3.3.2)\n", "Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests->huggingface-hub>=0.19.4->llmware) (3.7)\n", "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests->huggingface-hub>=0.19.4->llmware) (2024.6.2)\n", "Requirement already satisfied: threadpoolctl>=2.0.0 in /usr/local/lib/python3.10/dist-packages (from scikit-learn>=0.20.0->librosa>=0.10.0->llmware) (3.5.0)\n", "Requirement already satisfied: cffi>=1.0 in /usr/local/lib/python3.10/dist-packages (from soundfile>=0.12.1->librosa>=0.10.0->llmware) (1.16.0)\n", "Requirement already satisfied: pycparser in /usr/local/lib/python3.10/dist-packages (from cffi>=1.0->soundfile>=0.12.1->librosa>=0.10.0->llmware) (2.22)\n", "Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.10/dist-packages (from python-dateutil<3.0.0,>=2.1->botocore<1.35.0,>=1.34.120->boto3>=1.24.53->llmware) (1.16.0)\n", "Installing collected packages: psycopg-binary, psycopg, pgvector, jmespath, dnspython, colorama, pymongo, botocore, s3transfer, boto3, llmware\n", "Successfully installed boto3-1.34.120 botocore-1.34.120 colorama-0.4.6 dnspython-2.6.1 jmespath-1.0.1 llmware-0.3.0 pgvector-0.2.4 psycopg-3.1.17 psycopg-binary-3.1.17 pymongo-4.7.3 s3transfer-0.10.1\n", "Collecting wikipedia-api\n", " Downloading Wikipedia_API-0.6.0-py3-none-any.whl (14 kB)\n", "Requirement already satisfied: requests in /usr/local/lib/python3.10/dist-packages (from wikipedia-api) (2.31.0)\n", "Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests->wikipedia-api) (3.3.2)\n", "Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests->wikipedia-api) (3.7)\n", "Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests->wikipedia-api) (2.0.7)\n", "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests->wikipedia-api) (2024.6.2)\n", "Installing collected packages: wikipedia-api\n", "Successfully installed wikipedia-api-0.6.0\n" ] } ], "source": [ "!pip install llmware\n", "!pip install wikipedia-api" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "-kgUJQnhO9wY" }, "outputs": [], "source": [ "from llmware.agents import LLMfx\n", "from llmware.parsers import WikiParser" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "PA4O0nmHPGm0" }, "outputs": [], "source": [ "text = (\"The new Miko Marks album is one of the best I have ever heard in a number of years. \"\n", " \"She is definitely an artist worth exploring further.\")" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 611, "referenced_widgets": [ "b5ba93edf3694b91b6c022357bc63c5f", "3ad08a5184024a61867f53cd60967b8a", "4610da9b45a14e37a5d22437b6c80af1", "da05759d64dd4fde96f2571ab57c10d7", "a3b4c3736ec44e05b0408a77328afc46", "2f422e29743147d589f78e88a5023584", "04a584f3e21e437392ea4e1f2e454256", "7e3bc21eddef4a3e9711034215666fc1", "e78047ec9ef14fe0b33d559b7d1a98c1", "7a3edae3026743adaa4dfc750652e612", "a285f26081e54e5485d6ba816dccab04", "3d75de815f1d4b0ba7f45ba62bd0fee0", "98fd25c941ed4cc48b64265f9b02e21d", "0b4e656fbf75456087a719a1f5cfe7f9", "912f9795761d477b80183838f87798c3", "d62e6155e43143d384c97fa637800900", "27e955a826c44c4f888f94fd8d214342", "d84ecb5ba26d42fca5c0a71f3557ec77", "11f553b8d131488e918823421766447f", "af317516d22447efb596af73d29ed7f3", "1b767e77b41b4b2a95cea950a91140e9", "1aae4ab030be4d19bab991a878e260ae", "38399b2088e54e29b6fe46d61cfe375e", "2dd4eae5448c4c0f8c4210941b32fe02", "c51a57f4bf0645efbfb294f9c2560a58", "f7af4381065f44f08497189171e5fa32", "93ea85bd3d5f4a559c10411360aeb9f0", "4e1dcfb6582741febec7ad363e39cec1", "2cf7635b38d5497eb537461c45fc172e", "019e216bc5474a5ba5e4bc7028b83f8f", "38ee479136694284ba995e82fe9c2c97", "0227bbda2303417282d010d7df429eb4", "2775aacd793e4d26bb4ebb4570aa79cd", "a7a23c114b8e4275bfd18872e8347cc7", "7ce0ea72f4614748aa436eb323388ca7", "44917c6036de44fcb5ca9bc468964caf", "de6808042e2c49f991a66ee27bb66b05", "c36923294558418cab03cb76147602fd", "206fd63bc81c40648b38e2f716275c95", "0e8834fb34e34e189a80265a23b04a0a", "722725fd61d54b70b7124d46988ff309", "a1ebc53841d14cd1a2fb40e7b2a28f28", "179c1a00853d45859b1200c7385deadd", "3a0d0a8cf1b24aeb95ef6b3df3a67bad", "cb53876e1e9941c1be09b31acc33022c", "e559393bb20441ac99f79e7b665e6466", "0784e58f828141d38104fb7c8b6d37fa", "3941ca3615e349f9abc379840d7ad5d7", "66fa1a4bfe684b3296e9733209a3e755", "1f26676cf8a0472d82edf15e1605fd07", "90bccb0588ac4dbfb1c6ebff10663214", "a9075f2798d94525861de0c205b67ad0", "edf56f8ea6044bf7a4c782e767216299", "40ae101d8d824a4d9a45cc7eb2f4d23d", "666ecaec0c19436eba7ffb801316707a", "c5e77bad53e64c398568b55814c805b0", "87f4f58671ad419c998dce7641f63ae7", "7b3eb01c9d0e4e51b12ec860020a5c9c", "d52782db557244b6a1a0987cbe11afbe", "9417ecffee87490b98a0515b9c90152f", "4de8ad290b3f4ad88ae9dd82bd2db17b", "6f81e12919f74ecfa091f0a70920ea1b", "5ea39357b9ca4d439469d4b0fdb7dc06", "693871dab6e84a78a709fa5f64a62631", "3f10128eefff4dbc91af23ca3b644fb8", "737f4afd766d44b192db1cb921504334" ] }, "id": "Ue0d-BL8PmpT", "outputId": "3f4803eb-9371-4905-d6ac-ad69affae2c8" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "update: Launching LLMfx process\n", "step - \t1 - \tcreating object - ready to start processing.\n", "step - \t2 - \tloading new processing text - 1 new entries\n", "step - \t3 - \tloading tool - ner\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "/usr/local/lib/python3.10/dist-packages/huggingface_hub/utils/_token.py:89: UserWarning: \n", "The secret `HF_TOKEN` does not exist in your Colab secrets.\n", "To authenticate with the Hugging Face Hub, create a token in your settings tab (https://huggingface.co/settings/tokens), set it as secret in your Google Colab and restart your session.\n", "You will be able to reuse this secret in all of your notebooks.\n", "Please note that authentication is recommended but still optional to access public models or datasets.\n", " warnings.warn(\n", "/usr/local/lib/python3.10/dist-packages/huggingface_hub/file_download.py:1194: UserWarning: `local_dir_use_symlinks` parameter is deprecated and will be ignored. The process to download files to a local folder has been updated and do not rely on symlinks anymore. You only need to pass a destination folder as`local_dir`.\n", "For more details, check out https://huggingface.co/docs/huggingface_hub/main/en/guides/download#download-files-to-local-folder.\n", " warnings.warn(\n" ] }, { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "b5ba93edf3694b91b6c022357bc63c5f", "version_major": 2, "version_minor": 0 }, "text/plain": [ "Fetching 4 files: 0%| | 0/4 [00:00