File size: 12,576 Bytes
b7731cd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
da7c7ce
 
 
 
 
 
 
 
 
 
b7731cd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "# PINECONE_API_KEY = 7b886e48-e3d3-4644-bf8d-74b94d49c18c\n",
    "# PINECONE_ENV = gcp-starter"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/Users/aakashbhatnagar/Documents/masters/LLM/myenv/lib/python3.10/site-packages/pinecone/index.py:4: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
      "  from tqdm.autonotebook import tqdm\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Downloading model\n",
      "\n",
      "\n",
      "Models downloaded\n"
     ]
    }
   ],
   "source": [
    "from rag import fetch_top_k"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Pseudophakia is the loss of:\n",
    "A. Accommodation\n",
    "B. Conversion\n",
    "C. Saccadic eye movements\n",
    "D. Contrast sensitivity"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Running on local URL:  http://127.0.0.1:7861\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "huggingface/tokenizers: The current process just got forked, after parallelism has already been used. Disabling parallelism to avoid deadlocks...\n",
      "To disable this warning, you can either:\n",
      "\t- Avoid using `tokenizers` before the fork if possible\n",
      "\t- Explicitly set the environment variable TOKENIZERS_PARALLELISM=(true | false)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Running on public URL: https://49a86c835b55baa011.gradio.live\n",
      "\n",
      "This share link expires in 72 hours. For free permanent hosting and GPU upgrades, run `gradio deploy` from Terminal to deploy to Spaces (https://huggingface.co/spaces)\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div><iframe src=\"https://49a86c835b55baa011.gradio.live\" width=\"100%\" height=\"500\" allow=\"autoplay; camera; microphone; clipboard-read; clipboard-write;\" frameborder=\"0\" allowfullscreen></iframe></div>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/plain": []
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import gradio as gr\n",
    "\n",
    "gr.ChatInterface(fetch_top_k).launch(share=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "huggingface/tokenizers: The current process just got forked, after parallelism has already been used. Disabling parallelism to avoid deadlocks...\n",
      "To disable this warning, you can either:\n",
      "\t- Avoid using `tokenizers` before the fork if possible\n",
      "\t- Explicitly set the environment variable TOKENIZERS_PARALLELISM=(true | false)\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Need \u001b[32m'write'\u001b[0m access token to create a Spaces repo.\n",
      "\n",
      "    _|    _|  _|    _|    _|_|_|    _|_|_|  _|_|_|  _|      _|    _|_|_|      _|_|_|_|    _|_|      _|_|_|  _|_|_|_|\n",
      "    _|    _|  _|    _|  _|        _|          _|    _|_|    _|  _|            _|        _|    _|  _|        _|\n",
      "    _|_|_|_|  _|    _|  _|  _|_|  _|  _|_|    _|    _|  _|  _|  _|  _|_|      _|_|_|    _|_|_|_|  _|        _|_|_|\n",
      "    _|    _|  _|    _|  _|    _|  _|    _|    _|    _|    _|_|  _|    _|      _|        _|    _|  _|        _|\n",
      "    _|    _|    _|_|      _|_|_|    _|_|_|  _|_|_|  _|      _|    _|_|_|      _|        _|    _|    _|_|_|  _|_|_|_|\n",
      "    \n",
      "    To login, `huggingface_hub` requires a token generated from https://huggingface.co/settings/tokens .\n",
      "Token: \n",
      "\u001b[31mAborted.\u001b[0m\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['side of scotoma, the seotoma\\n‘moves in opposite direction (ce.\\n‘towards the fixation point). The\\nobjects tend to appear and,\\ndisappear in the most discon-\\ncerting way, hence called |\\n“Jack-in-box phenomenon”.\\n\\n5. Pin-cushion effect due to |\\napherical aberrations. In this\\ncondition the straight lines\\nhecome curves and linear becomes «', \"2. Inflteating tumors !\\n2. Burns '\\n4. Radiotherapy or Cryotherapy of lid *\\n‘umors ,\\n», Skin\\n=\\n1, Peoria !\\n2 Generalized alopecia, :\\n©. Systemie:\\n1. Myxoedema, P\\n2. Leprosy. ;\\n3. Syphilis :\\n4. SLE. ;\\n4. Following Removal :\\n1 Iatrogenie trichiasis. !\\n2 Trichotillomania, :\\nPotiosis\\nWhitening of eye lashes is known as polioss.\\nCauses: ‘\\na. Local :\", 'ab Dacryocystorhinostomy ia a\\nprocedure in which we make a\\nfistula between the lacrimal sae and\\nthe middle mestus of nose.\\nCrocodile tears are a complication\\nof VII nerve palay. It occurs due to\\nfaulty regeneration of parasym-\\npathetic fibres which now supply\\nthe lacrimal glands instead of\\nsalivary glands\\n|. b Tear formation occurs at six weeks']\n",
      "['componed predominantly of eos\\nmon\\ni. Mle form: Both inbal nd pal\\nbea conunetes sree\\n+ Comal Changes in VEC!\\nb. Macrocroion ;\\n© Plague ie he desiccated mucus\\nvette epihlal macrelne\\nd. Subepithelial scarring: Wt is\\nsenate tag\\n. Preudogerantomn: Ie renemblea\\necw seni hihi sled\\n‘oar hone the sae Tet\\nStd Cupiarbow\\n{ Kerstocmus may be abated. &', 'A Laminar dot ign\\nB, Nasal abifting of vessla\\nC. Bayonettingsign\\nD, Allofthe above\\n‘\\n\\nzz PI\\nA. ants B. Adak\\nC. Cornealopacties D. Allofthe above\\n\\x0c\\neviwofOpiaiigy\\nA. Autorfractonute\\n3. Automated porinet\\n€. Goldana perimeter\\nD. Kinetiperinetry\\n| The following investigation i\\n@ fi\\n= ff\\\\n[ 7_ /\\n\\\\ |\\nA. Listes perimetry\\n1. Goldmann perimete', 'D. Selermalacnperirans\\n¥ )\\n| a\\nue I\\n\\x0c\\neins of Otte\\nB. Groce dosoy\\n©. Kenzer\\nD Keronlada\\nith ey hich rnin woken\\not the eyeball The presence\\ntneeeaed TOP contin\\nfart apy\\nA Normal Bosan\\n Powaie ari\\nRanda\\nD. Poe\\n4. Thediagnossi\\n\"i in\\ni ee a\\nA sus haenoras\\n1 Poseraesaptnoma\\n© Bruna aapyione\\nD Pater']\n",
      "['componed predominantly of eos\\nmon\\ni. Mle form: Both inbal nd pal\\nbea conunetes sree\\n+ Comal Changes in VEC!\\nb. Macrocroion ;\\n© Plague ie he desiccated mucus\\nvette epihlal macrelne\\nd. Subepithelial scarring: Wt is\\nsenate tag\\n. Preudogerantomn: Ie renemblea\\necw seni hihi sled\\n‘oar hone the sae Tet\\nStd Cupiarbow\\n{ Kerstocmus may be abated. &', 'A Laminar dot ign\\nB, Nasal abifting of vessla\\nC. Bayonettingsign\\nD, Allofthe above\\n‘\\n\\nzz PI\\nA. ants B. Adak\\nC. Cornealopacties D. Allofthe above\\n\\x0c\\neviwofOpiaiigy\\nA. Autorfractonute\\n3. Automated porinet\\n€. Goldana perimeter\\nD. Kinetiperinetry\\n| The following investigation i\\n@ fi\\n= ff\\\\n[ 7_ /\\n\\\\ |\\nA. Listes perimetry\\n1. Goldmann perimete', 'D. Selermalacnperirans\\n¥ )\\n| a\\nue I\\n\\x0c\\neins of Otte\\nB. Groce dosoy\\n©. Kenzer\\nD Keronlada\\nith ey hich rnin woken\\not the eyeball The presence\\ntneeeaed TOP contin\\nfart apy\\nA Normal Bosan\\n Powaie ari\\nRanda\\nD. Poe\\n4. Thediagnossi\\n\"i in\\ni ee a\\nA sus haenoras\\n1 Poseraesaptnoma\\n© Bruna aapyione\\nD Pater']\n",
      "['. Preuopyoeyanca\\nD. Propionabacterium\\n57. All are risk factors for catarac\\nexcept\\n‘A. Dishetes mellitus\\nB. Hypertension\\n. Sioking\\nD, Recurrent diarehoea', 'catarat is retinal pathologies. Retinal\\ndegenerations and other fundal\\nchanges is a feature of pathological\\n‘myopia but not of hypermetropia,\\n\\nfd Refractive index is maximum atthe\\ncontre ofthe lens where the nucles\\nis hard compared tothe cortex\\n\\n5. a Endophytic retinoblastoma (which\\n‘rows towards the vitreous) may lead\\nto dislocation of the lens.', 'te i meno\\ntw Tn cs ales\\nPour avin ener ose Ti\\nBaran Cone dna, eons Ie\\nSheil melanme,retblawa |\\nfd eur hypuony at h\\nIroc pean or psrtion ef\\nee\\n\\n:\\n\\nClinical Features:\\n\\n4. Pontos: Opacin in the vious i\\nIon ns fotera, fe meus ie to\\nAiprios of pigs a a\\nPion piel celle Ti rot in\\n‘Repmatopenan Rand inv ane\\nSteutatne RD (ve to proce af']\n"
     ]
    }
   ],
   "source": [
    "!gradio deploy"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "['side of scotoma, the seotoma\\n‘moves in opposite direction (ce.\\n‘towards the fixation point). The\\nobjects tend to appear and,\\ndisappear in the most discon-\\ncerting way, hence called |\\n“Jack-in-box phenomenon”.\\n\\n5. Pin-cushion effect due to |\\napherical aberrations. In this\\ncondition the straight lines\\nhecome curves and linear becomes «', 'D. Selermalacnperirans\\n¥ )\\n| a\\nue I\\n\\x0c\\neins of Otte\\nB. Groce dosoy\\n©. Kenzer\\nD Keronlada\\nith ey hich rnin woken\\not the eyeball The presence\\ntneeeaed TOP contin\\nfart apy\\nA Normal Bosan\\n Powaie ari\\nRanda\\nD. Poe\\n4. Thediagnossi\\n\"i in\\ni ee a\\nA sus haenoras\\n1 Poseraesaptnoma\\n© Bruna aapyione\\nD Pater', \"2. Soro-nogative arthropathies :\\n\\x0c\\nog\\n\\n+ Reiter's syndrome.\\n+ Ankylosing spondylitis\\n+ Poriti arthritis\\n+ aka,\\n\\n| Taftanamatory bowel disease.\\n\\n| Puch’ hetroehromi cyl\\n\\n. Viral (HSV, HZ0) keratouveits\\n\\nPosner Schloeeman syndrome\\n\\n‘auses of Panuveitis\\nSympathetic ophehalmiti\\n\\n- Saroidot\\n\\n- Syphilis\\n\\n. Vogt Koyanagi Harada syndrome\\n\\n Tuberculoi\"]\n"
     ]
    }
   ],
   "source": [
    "a = fetch_top_k(\"What is the meaning of life?\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "str"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "type(a)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'side of scotoma, the seotoma\\n‘moves in opposite direction (ce.\\n‘towards the fixation point). The\\nobjects tend to appear and,\\ndisappear in the most discon-\\ncerting way, hence called |\\n“Jack-in-box phenomenon”.\\n\\n5. Pin-cushion effect due to |\\napherical aberrations. In this\\ncondition the straight lines\\nhecome curves and linear becomes «\\nD. Selermalacnperirans\\n¥ )\\n| a\\nue I\\n\\x0c\\neins of Otte\\nB. Groce dosoy\\n©. Kenzer\\nD Keronlada\\nith ey hich rnin woken\\not the eyeball The presence\\ntneeeaed TOP contin\\nfart apy\\nA Normal Bosan\\n Powaie ari\\nRanda\\nD. Poe\\n4. Thediagnossi\\n\"i in\\ni ee a\\nA sus haenoras\\n1 Poseraesaptnoma\\n© Bruna aapyione\\nD Pater\\n2. Soro-nogative arthropathies :\\n\\x0c\\nog\\n\\n+ Reiter\\'s syndrome.\\n+ Ankylosing spondylitis\\n+ Poriti arthritis\\n+ aka,\\n\\n| Taftanamatory bowel disease.\\n\\n| Puch’ hetroehromi cyl\\n\\n. Viral (HSV, HZ0) keratouveits\\n\\nPosner Schloeeman syndrome\\n\\n‘auses of Panuveitis\\nSympathetic ophehalmiti\\n\\n- Saroidot\\n\\n- Syphilis\\n\\n. Vogt Koyanagi Harada syndrome\\n\\n Tuberculoi'"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "a"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "myenv",
   "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.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}