Skip to content

Commit 328056c

Browse files
committed
change code
1 parent 5e19ec7 commit 328056c

File tree

1 file changed

+123
-12
lines changed

1 file changed

+123
-12
lines changed

Basic_Samples/Embeddings/dotnet/csharp/Comparing_embeddings.ipynb

Lines changed: 123 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
},
1818
{
1919
"cell_type": "code",
20-
"execution_count": null,
20+
"execution_count": 17,
2121
"metadata": {
2222
"dotnet_interactive": {
2323
"language": "csharp"
@@ -29,15 +29,25 @@
2929
"languageId": "polyglot-notebook"
3030
}
3131
},
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+
],
3343
"source": [
3444
"#r \"nuget: Azure.AI.OpenAI, 1.0.0-beta.14\"\n",
3545
"#r \"nuget:Microsoft.DotNet.Interactive.AIUtilities, 1.0.0-beta.24129.1\""
3646
]
3747
},
3848
{
3949
"cell_type": "code",
40-
"execution_count": 4,
50+
"execution_count": 18,
4151
"metadata": {
4252
"dotnet_interactive": {
4353
"language": "csharp"
@@ -63,7 +73,7 @@
6373
},
6474
{
6575
"cell_type": "code",
66-
"execution_count": 8,
76+
"execution_count": null,
6777
"metadata": {
6878
"dotnet_interactive": {
6979
"language": "csharp"
@@ -95,7 +105,7 @@
95105
},
96106
{
97107
"cell_type": "code",
98-
"execution_count": 7,
108+
"execution_count": 19,
99109
"metadata": {
100110
"dotnet_interactive": {
101111
"language": "csharp"
@@ -115,7 +125,7 @@
115125
},
116126
{
117127
"cell_type": "code",
118-
"execution_count": 10,
128+
"execution_count": 20,
119129
"metadata": {
120130
"dotnet_interactive": {
121131
"language": "csharp"
@@ -141,7 +151,7 @@
141151
},
142152
{
143153
"cell_type": "code",
144-
"execution_count": 11,
154+
"execution_count": 33,
145155
"metadata": {
146156
"dotnet_interactive": {
147157
"language": "csharp"
@@ -156,7 +166,7 @@
156166
"outputs": [],
157167
"source": [
158168
"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\";"
160170
]
161171
},
162172
{
@@ -168,7 +178,7 @@
168178
},
169179
{
170180
"cell_type": "code",
171-
"execution_count": 14,
181+
"execution_count": 34,
172182
"metadata": {
173183
"dotnet_interactive": {
174184
"language": "csharp"
@@ -186,16 +196,117 @@
186196
"var secondEmbeddings = (await client.GetEmbeddingsAsync(new EmbeddingsOptions(deployment, new []{ secondSentence }))).Value.Data[0].Embedding.ToArray();"
187197
]
188198
},
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+
},
189300
{
190301
"cell_type": "markdown",
191302
"metadata": {},
192303
"source": [
193-
"# calculate Cosine Similarity"
304+
"### calculate Cosine Similarity"
194305
]
195306
},
196307
{
197308
"cell_type": "code",
198-
"execution_count": 16,
309+
"execution_count": 36,
199310
"metadata": {
200311
"dotnet_interactive": {
201312
"language": "csharp"
@@ -211,7 +322,7 @@
211322
{
212323
"data": {
213324
"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",
215326
".dni-code-hint {\r\n",
216327
" font-style: italic;\r\n",
217328
" overflow: hidden;\r\n",

0 commit comments

Comments
 (0)