|
17 | 17 | }, |
18 | 18 | { |
19 | 19 | "cell_type": "code", |
20 | | - "execution_count": null, |
| 20 | + "execution_count": 17, |
21 | 21 | "metadata": { |
22 | 22 | "dotnet_interactive": { |
23 | 23 | "language": "csharp" |
|
29 | 29 | "languageId": "polyglot-notebook" |
30 | 30 | } |
31 | 31 | }, |
32 | | - "outputs": [], |
| 32 | + "outputs": [ |
| 33 | + { |
| 34 | + "data": { |
| 35 | + "text/html": [ |
| 36 | + "<div><div></div><div></div><div><strong>Installed Packages</strong><ul><li><span>Azure.AI.OpenAI, 1.0.0-beta.14</span></li><li><span>Microsoft.DotNet.Interactive.AIUtilities, 1.0.0-beta.24129.1</span></li></ul></div></div>" |
| 37 | + ] |
| 38 | + }, |
| 39 | + "metadata": {}, |
| 40 | + "output_type": "display_data" |
| 41 | + } |
| 42 | + ], |
33 | 43 | "source": [ |
34 | 44 | "#r \"nuget: Azure.AI.OpenAI, 1.0.0-beta.14\"\n", |
35 | 45 | "#r \"nuget:Microsoft.DotNet.Interactive.AIUtilities, 1.0.0-beta.24129.1\"" |
36 | 46 | ] |
37 | 47 | }, |
38 | 48 | { |
39 | 49 | "cell_type": "code", |
40 | | - "execution_count": 4, |
| 50 | + "execution_count": 18, |
41 | 51 | "metadata": { |
42 | 52 | "dotnet_interactive": { |
43 | 53 | "language": "csharp" |
|
63 | 73 | }, |
64 | 74 | { |
65 | 75 | "cell_type": "code", |
66 | | - "execution_count": 8, |
| 76 | + "execution_count": null, |
67 | 77 | "metadata": { |
68 | 78 | "dotnet_interactive": { |
69 | 79 | "language": "csharp" |
|
95 | 105 | }, |
96 | 106 | { |
97 | 107 | "cell_type": "code", |
98 | | - "execution_count": 7, |
| 108 | + "execution_count": 19, |
99 | 109 | "metadata": { |
100 | 110 | "dotnet_interactive": { |
101 | 111 | "language": "csharp" |
|
115 | 125 | }, |
116 | 126 | { |
117 | 127 | "cell_type": "code", |
118 | | - "execution_count": 10, |
| 128 | + "execution_count": 20, |
119 | 129 | "metadata": { |
120 | 130 | "dotnet_interactive": { |
121 | 131 | "language": "csharp" |
|
141 | 151 | }, |
142 | 152 | { |
143 | 153 | "cell_type": "code", |
144 | | - "execution_count": 11, |
| 154 | + "execution_count": 33, |
145 | 155 | "metadata": { |
146 | 156 | "dotnet_interactive": { |
147 | 157 | "language": "csharp" |
|
156 | 166 | "outputs": [], |
157 | 167 | "source": [ |
158 | 168 | "var firstSentence = \"The quick brown fox jumps over the lazy dog\";\n", |
159 | | - "var secondSentence = \"The quick fox jumps over the black dog\";" |
| 169 | + "var secondSentence = \"The quick fox jumps over the lazy dog\";" |
160 | 170 | ] |
161 | 171 | }, |
162 | 172 | { |
|
168 | 178 | }, |
169 | 179 | { |
170 | 180 | "cell_type": "code", |
171 | | - "execution_count": 14, |
| 181 | + "execution_count": 34, |
172 | 182 | "metadata": { |
173 | 183 | "dotnet_interactive": { |
174 | 184 | "language": "csharp" |
|
186 | 196 | "var secondEmbeddings = (await client.GetEmbeddingsAsync(new EmbeddingsOptions(deployment, new []{ secondSentence }))).Value.Data[0].Embedding.ToArray();" |
187 | 197 | ] |
188 | 198 | }, |
| 199 | + { |
| 200 | + "cell_type": "code", |
| 201 | + "execution_count": 35, |
| 202 | + "metadata": { |
| 203 | + "dotnet_interactive": { |
| 204 | + "language": "csharp" |
| 205 | + }, |
| 206 | + "polyglot_notebook": { |
| 207 | + "kernelName": "csharp" |
| 208 | + }, |
| 209 | + "vscode": { |
| 210 | + "languageId": "polyglot-notebook" |
| 211 | + } |
| 212 | + }, |
| 213 | + "outputs": [ |
| 214 | + { |
| 215 | + "data": { |
| 216 | + "text/html": [ |
| 217 | + "<div class=\"dni-plaintext\"><pre>[ -0.0035237537, 0.008311155, -0.014132736, -0.0045390725, -0.015415244, 0.018583793, -0.02041954 ]</pre></div><style>\r\n", |
| 218 | + ".dni-code-hint {\r\n", |
| 219 | + " font-style: italic;\r\n", |
| 220 | + " overflow: hidden;\r\n", |
| 221 | + " white-space: nowrap;\r\n", |
| 222 | + "}\r\n", |
| 223 | + ".dni-treeview {\r\n", |
| 224 | + " white-space: nowrap;\r\n", |
| 225 | + "}\r\n", |
| 226 | + ".dni-treeview td {\r\n", |
| 227 | + " vertical-align: top;\r\n", |
| 228 | + " text-align: start;\r\n", |
| 229 | + "}\r\n", |
| 230 | + "details.dni-treeview {\r\n", |
| 231 | + " padding-left: 1em;\r\n", |
| 232 | + "}\r\n", |
| 233 | + "table td {\r\n", |
| 234 | + " text-align: start;\r\n", |
| 235 | + "}\r\n", |
| 236 | + "table tr { \r\n", |
| 237 | + " vertical-align: top; \r\n", |
| 238 | + " margin: 0em 0px;\r\n", |
| 239 | + "}\r\n", |
| 240 | + "table tr td pre \r\n", |
| 241 | + "{ \r\n", |
| 242 | + " vertical-align: top !important; \r\n", |
| 243 | + " margin: 0em 0px !important;\r\n", |
| 244 | + "} \r\n", |
| 245 | + "table th {\r\n", |
| 246 | + " text-align: start;\r\n", |
| 247 | + "}\r\n", |
| 248 | + "</style>" |
| 249 | + ] |
| 250 | + }, |
| 251 | + "metadata": {}, |
| 252 | + "output_type": "display_data" |
| 253 | + }, |
| 254 | + { |
| 255 | + "data": { |
| 256 | + "text/html": [ |
| 257 | + "<div class=\"dni-plaintext\"><pre>[ -0.003907447, 0.008527633, -0.013624029, -0.006285345, -0.0026570011, 0.016840814, -0.019313322 ]</pre></div><style>\r\n", |
| 258 | + ".dni-code-hint {\r\n", |
| 259 | + " font-style: italic;\r\n", |
| 260 | + " overflow: hidden;\r\n", |
| 261 | + " white-space: nowrap;\r\n", |
| 262 | + "}\r\n", |
| 263 | + ".dni-treeview {\r\n", |
| 264 | + " white-space: nowrap;\r\n", |
| 265 | + "}\r\n", |
| 266 | + ".dni-treeview td {\r\n", |
| 267 | + " vertical-align: top;\r\n", |
| 268 | + " text-align: start;\r\n", |
| 269 | + "}\r\n", |
| 270 | + "details.dni-treeview {\r\n", |
| 271 | + " padding-left: 1em;\r\n", |
| 272 | + "}\r\n", |
| 273 | + "table td {\r\n", |
| 274 | + " text-align: start;\r\n", |
| 275 | + "}\r\n", |
| 276 | + "table tr { \r\n", |
| 277 | + " vertical-align: top; \r\n", |
| 278 | + " margin: 0em 0px;\r\n", |
| 279 | + "}\r\n", |
| 280 | + "table tr td pre \r\n", |
| 281 | + "{ \r\n", |
| 282 | + " vertical-align: top !important; \r\n", |
| 283 | + " margin: 0em 0px !important;\r\n", |
| 284 | + "} \r\n", |
| 285 | + "table th {\r\n", |
| 286 | + " text-align: start;\r\n", |
| 287 | + "}\r\n", |
| 288 | + "</style>" |
| 289 | + ] |
| 290 | + }, |
| 291 | + "metadata": {}, |
| 292 | + "output_type": "display_data" |
| 293 | + } |
| 294 | + ], |
| 295 | + "source": [ |
| 296 | + "firstEmbeddings.Take(7).Display();\n", |
| 297 | + "secondEmbeddings.Take(7).Display();" |
| 298 | + ] |
| 299 | + }, |
189 | 300 | { |
190 | 301 | "cell_type": "markdown", |
191 | 302 | "metadata": {}, |
192 | 303 | "source": [ |
193 | | - "# calculate Cosine Similarity" |
| 304 | + "### calculate Cosine Similarity" |
194 | 305 | ] |
195 | 306 | }, |
196 | 307 | { |
197 | 308 | "cell_type": "code", |
198 | | - "execution_count": 16, |
| 309 | + "execution_count": 36, |
199 | 310 | "metadata": { |
200 | 311 | "dotnet_interactive": { |
201 | 312 | "language": "csharp" |
|
211 | 322 | { |
212 | 323 | "data": { |
213 | 324 | "text/html": [ |
214 | | - "<div class=\"dni-plaintext\"><pre>0.948887</pre></div><style>\r\n", |
| 325 | + "<div class=\"dni-plaintext\"><pre>0.9821579</pre></div><style>\r\n", |
215 | 326 | ".dni-code-hint {\r\n", |
216 | 327 | " font-style: italic;\r\n", |
217 | 328 | " overflow: hidden;\r\n", |
|
0 commit comments