{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "HSTJqVlrqwzs",
"outputId": "7aa0e836-a9fb-41d9-b2a3-4b0e78ec600e"
},
"outputs": [],
"source": [
"# !pip install -q ctransformers langchain"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"id": "5jMCN_Whrp3h"
},
"outputs": [],
"source": [
"from langchain.llms import CTransformers\n",
"from langchain import PromptTemplate, LLMChain\n",
"from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/",
"height": 81,
"referenced_widgets": [
"265f404a350d483faae6ae136f70cc44",
"fc566f0872584383ba16a230b4676194",
"3272131f755d46e58b3592fa716a2ba9",
"3847cfbf259d478ab5e4afca1d53172d",
"f2247320c8074c78ba7c10befce53e85",
"1b936491611446028d8b0a986da90818",
"d0ef1bdb67d94fd1aa97b7071b44c556",
"29b59cd780c74ba2b8cc35495e36e5fd",
"c8830ddc68cf47be9f25acc08c7cacce",
"855c88c8f4e24eaa8485aef05b83ae6c",
"7ee863550d9c40869fefea0b1bd9f283",
"a65a8138762540ebb1584cb6fff58087",
"6c898e4eb5e24b1cbeaeec89f1f1d0a5",
"262bcb2c1d8e4cd9924f3057aea804a0",
"d71387f9f33741eb8c35ef8124d99b12",
"63d131783c8048cfb946ce20fa6ecdf9",
"cd32084e14434381a6b574e877bc19e5",
"e6dc3a391bdf45e1bb5e6baa7ad64c43",
"4ec6267d61e946dba755aaeeae6aa8c6",
"0f4d45c7b8f3415b9ff32011b96a8bbc",
"ac66f4de58b54b4fbdd39ee6c58cc4e4",
"2a9f3c681c524ab5a50d6f93726f0bde"
]
},
"id": "CJnyZAR_q-Mz",
"outputId": "31c3ce3c-f59d-4bc8-e54d-d906822d7afa"
},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "7f14a5d091964e858b431da242728991",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Fetching 1 files: 0%| | 0/1 [00:00, ?it/s]"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "ad115b537efe419693238f78fc3fd9a2",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"Fetching 1 files: 0%| | 0/1 [00:00, ?it/s]"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"llm = CTransformers(model=\"TheBloke/Llama-2-7B-Chat-GGML\", model_file = 'llama-2-7b-chat.ggmlv3.q2_K.bin', callbacks=[StreamingStdOutCallbackHandler()])"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"id": "ixcszGAPrrVN"
},
"outputs": [],
"source": [
"template = \"\"\"\n",
"[INST] <