{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "colab": { "base_uri": "https://localhost:8080/" }, "id": "Ayft6ZiJaoHw", "outputId": "6b336e7f-75df-47eb-d97c-1e6903ea73a9" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Requirement already satisfied: httpx in /usr/local/lib/python3.11/dist-packages (0.28.1)\n", "Requirement already satisfied: anyio in /usr/local/lib/python3.11/dist-packages (from httpx) (4.9.0)\n", "Requirement already satisfied: certifi in /usr/local/lib/python3.11/dist-packages (from httpx) (2025.6.15)\n", "Requirement already satisfied: httpcore==1.* in /usr/local/lib/python3.11/dist-packages (from httpx) (1.0.9)\n", "Requirement already satisfied: idna in /usr/local/lib/python3.11/dist-packages (from httpx) (3.10)\n", "Requirement already satisfied: h11>=0.16 in /usr/local/lib/python3.11/dist-packages (from httpcore==1.*->httpx) (0.16.0)\n", "Requirement already satisfied: sniffio>=1.1 in /usr/local/lib/python3.11/dist-packages (from anyio->httpx) (1.3.1)\n", "Requirement already satisfied: typing_extensions>=4.5 in /usr/local/lib/python3.11/dist-packages (from anyio->httpx) (4.14.0)\n", "Collecting groq\n", " Downloading groq-0.28.0-py3-none-any.whl.metadata (15 kB)\n", "Requirement already satisfied: anyio<5,>=3.5.0 in /usr/local/lib/python3.11/dist-packages (from groq) (4.9.0)\n", "Requirement already satisfied: distro<2,>=1.7.0 in /usr/local/lib/python3.11/dist-packages (from groq) (1.9.0)\n", "Requirement already satisfied: httpx<1,>=0.23.0 in /usr/local/lib/python3.11/dist-packages (from groq) (0.28.1)\n", "Requirement already satisfied: pydantic<3,>=1.9.0 in /usr/local/lib/python3.11/dist-packages (from groq) (2.11.7)\n", "Requirement already satisfied: sniffio in /usr/local/lib/python3.11/dist-packages (from groq) (1.3.1)\n", "Requirement already satisfied: typing-extensions<5,>=4.10 in /usr/local/lib/python3.11/dist-packages (from groq) (4.14.0)\n", "Requirement already satisfied: idna>=2.8 in /usr/local/lib/python3.11/dist-packages (from anyio<5,>=3.5.0->groq) (3.10)\n", "Requirement already satisfied: certifi in /usr/local/lib/python3.11/dist-packages (from httpx<1,>=0.23.0->groq) (2025.6.15)\n", "Requirement already satisfied: httpcore==1.* in /usr/local/lib/python3.11/dist-packages (from httpx<1,>=0.23.0->groq) (1.0.9)\n", "Requirement already satisfied: h11>=0.16 in /usr/local/lib/python3.11/dist-packages (from httpcore==1.*->httpx<1,>=0.23.0->groq) (0.16.0)\n", "Requirement already satisfied: annotated-types>=0.6.0 in /usr/local/lib/python3.11/dist-packages (from pydantic<3,>=1.9.0->groq) (0.7.0)\n", "Requirement already satisfied: pydantic-core==2.33.2 in /usr/local/lib/python3.11/dist-packages (from pydantic<3,>=1.9.0->groq) (2.33.2)\n", "Requirement already satisfied: typing-inspection>=0.4.0 in /usr/local/lib/python3.11/dist-packages (from pydantic<3,>=1.9.0->groq) (0.4.1)\n", "Downloading groq-0.28.0-py3-none-any.whl (130 kB)\n", "\u001b[2K \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m130.2/130.2 kB\u001b[0m \u001b[31m8.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n", "\u001b[?25hInstalling collected packages: groq\n", "Successfully installed groq-0.28.0\n" ] } ], "source": [ "# 🔧 Install required packages\n", "!pip install -q sentence-transformers faiss-cpu\n", "!pip install httpx\n", "!pip install groq" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "zNdBhhWOa7z2" }, "outputs": [], "source": [ "\n", "passages = [\n", " \"Neural networks are computing systems inspired by the human brain. They consist of layers of nodes, or neurons, which can learn complex patterns.\",\n", " \"Transfer learning is a technique where a model trained on one task is reused on a second related task.\",\n", " \"Attention mechanisms allow models to focus on different parts of input data when making decisions, which improves performance in tasks like translation and summarization.\",\n", " \"Retrieval-augmented generation combines vector search with language models to answer questions from external documents.\",\n", " \"Convolutional Neural Networks are especially effective for image classification and computer vision tasks.\"\n", "]" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "omy6zkSfa_q7" }, "outputs": [], "source": [ "from sentence_transformers import SentenceTransformer\n", "import faiss\n", "import numpy as np\n", "import json" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 369, "referenced_widgets": [ "2182adeab9264cd7b80ec145dba995b1", "531493967b424fa58310490d063098d1", "7295650bcc3a4558a1ccde2fa3e44785", "1d0758f1ff9f45bdb049d4a5f58ad1e8", "f758c8b091574eafabcd3b983c645330", "1dc3908dd5bc4248b4538e293992f807", "d8751fb5d32f4b0a84e034a0e3c55276", "79303302ccd5469a90ce61a04d13e78f", "1b496950ee3e4429b20e091d7458849c", "557b0ba0a21949fc8594fa7b2543e9a5", "716a5859e9df4bc58d7567c83702da18", "b05ff9b0cc6d427ea44100f791c4f3a7", "890eea8fcaba403891777be2ac3b576c", "520d31e91fea4097a1a9aef7f214663a", "366acbe88af84ccf88fc89c8b02db624", "a1ef6a23a80f46ca952591bc825c3024", "eb135727a05a4fddb6fbf2b1d020f3ce", "9bf862aa934f445d812f6762a1119761", "4d2976a8db544957837b4a87d471bfd7", "114a35d794c34561b043f850178c7af3", "e8ae4b0568684b62ad47b8d0636c3297", "120fc24643294119a9252188f9b84b44", "1be2cbc6cbd24f4b9a29a413c5a6c642", "79dfe5a251bc40a8bd333aed4a3a1667", "654b1eb6e0314b5cbe63f21309d737a1", "1c215ed709074e219d33cda9892e3534", "6aeb792180cf4a01abb82b1bbc10590a", "d82ab1d90d4c4a5bac3654b9c26047a5", "7a9750aee76b417f9cdf5464ce9b0b0d", "7dbb34b1c22f4731bbf8e841f7d38a2d", "e5f5347ef4ae4fbabe7f619ab4fb82bc", "0a33735b854544ea9f6414da6bf64828", "7ee42750330247a8beca2c838904e32d", "eb18b6f2be5c4e6ab6c5a64ceb1d081e", "bdfab95e858e49f1baa30cb90583eecb", "823adf1f318641f9aa32ce53349fd18a", "13745bcae3474ae69d4b8623596ddf99", "fc141025568342dc9c74b04908b87f22", "1506b35c29ec4acd809849efe91c2f77", "12a5289c43194352b84e7e9728f52b8a", "55e4fe8ec8114c00b2358b7b4136c4fd", "8fd088e2fc794138b63bb3f7549b8ba5", "6c74ab29ad7246068b1724ed5f25a78e", "687bcb112b3c44269f5e6a8550764a06", "ac49d6e6fa1b4cd1ac9f7ec57385d315", "e4ae232f2244479f91777a7a5ad7a7d5", "a6e7264cb0994b239dac885667e0b3b5", "cd8e75dc25c94c3eabc8f1248e5999ee", "44d9c692399649c981e43c211386981c", "eb2bbf0bbf6c4fcabcfb84cafecf7be4", "e2f70edbfe524660ad25783a877a4c71", "fa7a7b62406f4c27868d9b6557d3bfe7", "fb1fd5e84b7c46a78f0026b85c1c5e96", "dcf6e109ea2c4d6998d4c9d9b867b243", "9f6cbe603ae54673a007d9f5ee6514a4", "f0f6aeb2aa05413da304f09abe635f51", "4bd599ff801340a88434f75ab4a189f0", "9fc4ef060e2c43a3ba3332dacde74c76", "d2731968c98b4d4d82feafa6a50ac205", "d0044f0efdb743509f335c9bbc94ce3d", "2b1feb41171a4b1db3b42fd79c55cb90", "794eeea9dab448258441591c6e7a9092", "d280602eabf04259a3cb77f747a58c34", "4e1e8babba6e467aabb53a8b773a839b", "c94b6042412145368b923332d6e577a5", "7527df336547433b8517c5c91b1a55dd", "cfc5fee1f1c0409c89c41d0b6e093cda", "c529e213782b401ba6b6e771bf3cb8be", "59a2a3c8a32742e99581908c09acb654", "67b4d3341ef749e29274f7298fc72baa", "3e36f024eaa54e1ea41f91beb1212961", "5c26d6ff686a4307b7d4a0dca7e05170", "8bd750a8a8014c0ab0518abecc4a5780", "e9a5cabf1eae4578b293054a2789bf0d", "00fd89d9df864186b72575dc006dde41", "960d9c5757c94d71bceeae4b45656cf9", "cd17ec06afa148fe93df74c1db045ce6", "b2b268ad7a0e4bd98ae6fffe01c4b344", "093cacaa145b40f09e5928962015d4e5", "951810679bb54b159b11ec2222a58691", "16951e4b9e014e768e7a2da7b387738d", "b4063db0ca3d4137b36de5bae82baa4b", "fd137693d1494e2e944425299b8d4ec9", "395e2743eb8d4600a6d6673dba695849", "ff43c3dc56ae40adb530843a1cab0259", "b5e6bd77532e488984a1f98530f92e5b", "cfc2c1d02490408ca9164b356225ac92", "0777bb953779406e95bbca0be08b8870", "0359956d7a3e48cd9c12c30f0c93b6c7", "375fbc05be7e44baa4b2566e159edc3d", "0cfe9fbbc55e4700a9ada861eacda8fd", "d0bec5f559444dabb612dc465e6e93c0", "135b63408eb04bbb96695a8242061fbe", "6d002b59afa143c491aa9417f144c5ee", "3b026e1c0eae467382a1297c98c3005a", "1016352e716044be86cb05e453093b00", "5831454c0d9b421e8af51f117a2e9fc8", "795902eb76394d2dbf80c4a77c8a67a4", "7bc3e8f7f990420b97dd842a6a47faf8", "3cbeffc6437c4c36896e7ac82ec46779", "da5cd07cd3e54b439d778b8ba355acc2", "3e0c41cce5dc4a018ff4d6731e6611a4", "8cdc9ab97fea4c6392f9980481ee6099", "84901213e3c645d9879acb3cc4b9f1cc", "13f7466d41df4452be51bfd3c59c2ed0", "c17bb4cdc63042d896d3f64d49b19f06", "a454573a90bc4de4a6cdc5f58b23dc51", "a849bfc39d7942c9aad5eccca4e4a377", "fe566f15539f4466977593295603e7fb", "f90d8bc0068d428d94c13ff03d05930b", "b24d9b0e4f8346aeadfbee5124555a0d", "1a806c4297a34066bed194e01fcc5455", "134351c63c204165a321f4acd4200c4d", "c5b40d20489a4080836b8c21461d9f82", "ba70ce56d1a540efad6a0ed249932726", "83dd647f2cbc4f2b8df567562255e714", "b67c9f69dcea4c7987dd5d7c736ba881", "62deadbc0eb94673ab833fc8f2ccca53", "36a23f38994d4afda8fcf1d98ec4efda", "967a495fc1af4c69a2379794a7677bcf", "49785c3d88074db4821c4196abf635bb" ] }, "id": "qDLXClvSjH4v", "outputId": "5c1623ab-d767-42e3-c6f7-1e81dec6f423" }, "outputs": [ { "data": { "application/vnd.jupyter.widget-view+json": { "model_id": "2182adeab9264cd7b80ec145dba995b1", "version_major": 2, "version_minor": 0 }, "text/plain": [ "modules.json: 0%| | 0.00/349 [00:00