@@ -48,22 +48,22 @@ dotnet add package Microsoft.ML
48
48
In a new C# file, import the required classes. Note that the ` #pragma `
49
49
directive suppresses warnings about the experimental status of the vector set API:
50
50
51
- {{< clients-example set="home_vecsets" step="import" lang_filter="C#" >}}
51
+ {{< clients-example set="home_vecsets" step="import" lang_filter="C#-Sync " >}}
52
52
{{< /clients-example >}}
53
53
54
54
## Access the model
55
55
56
56
Use the ` GetPredictionEngine() ` helper function declared in the example below to load the model that creates the embeddings:
57
57
58
- {{< clients-example set="home_vecsets" step="model" lang_filter="C#" >}}
58
+ {{< clients-example set="home_vecsets" step="model" lang_filter="C#-Sync " >}}
59
59
{{< /clients-example >}}
60
60
61
61
The ` GetPredictionEngine() ` function uses two classes, ` TextData ` and ` TransformedTextData ` ,
62
62
to specify the ` PredictionEngine ` model. These have a very simple definition
63
63
and are required because the model expects the input and output to be
64
64
passed in named object fields:
65
65
66
- {{< clients-example set="home_vecsets" step="data_classes" lang_filter="C#" >}}
66
+ {{< clients-example set="home_vecsets" step="data_classes" lang_filter="C#-Sync " >}}
67
67
{{< /clients-example >}}
68
68
69
69
Note that you must declare these classes at the end of the source file
@@ -73,15 +73,15 @@ The `GetEmbedding()` function declared below can then use this model to
73
73
generate an embedding from a section of text and return it as a ` float[] ` array,
74
74
which is the format required by the vector set API:
75
75
76
- {{< clients-example set="home_vecsets" step="get_embedding" lang_filter="C#" >}}
76
+ {{< clients-example set="home_vecsets" step="get_embedding" lang_filter="C#-Sync " >}}
77
77
{{< /clients-example >}}
78
78
79
79
## Create the data
80
80
81
81
The example data is contained a ` Dictionary ` object with some brief
82
82
descriptions of famous people:
83
83
84
- {{< clients-example set="home_vecsets" step="data" lang_filter="C#" >}}
84
+ {{< clients-example set="home_vecsets" step="data" lang_filter="C#-Sync " >}}
85
85
{{< /clients-example >}}
86
86
87
87
## Add the data to a vector set
@@ -99,7 +99,7 @@ The call to `VectorSetAdd()` also adds the `born` and `died` values from the
99
99
original dictionary as attribute data. You can access this during a query
100
100
or by using the [ ` VectorSetGetAttributesJson() ` ] ({{< relref "/commands/vgetattr" >}}) method.
101
101
102
- {{< clients-example set="home_vecsets" step="add_data" lang_filter="C#" >}}
102
+ {{< clients-example set="home_vecsets" step="add_data" lang_filter="C#-Sync " >}}
103
103
{{< /clients-example >}}
104
104
105
105
## Query the vector set
@@ -112,7 +112,7 @@ return elements of the set, ranked in order of similarity to the query.
112
112
113
113
Start with a simple query for "actors":
114
114
115
- {{< clients-example set="home_vecsets" step="basic_query" lang_filter="C#" >}}
115
+ {{< clients-example set="home_vecsets" step="basic_query" lang_filter="C#-Sync " >}}
116
116
{{< /clients-example >}}
117
117
118
118
This returns the following list of elements (formatted slightly for clarity):
@@ -131,7 +131,7 @@ on the information contained in the embedding model.
131
131
You can use the ` Count ` property of ` VectorSetSimilaritySearchRequest ` to limit the
132
132
list of elements to just the most relevant few items:
133
133
134
- {{< clients-example set="home_vecsets" step="limited_query" lang_filter="C#" >}}
134
+ {{< clients-example set="home_vecsets" step="limited_query" lang_filter="C#-Sync " >}}
135
135
{{< /clients-example >}}
136
136
137
137
The reason for using text embeddings rather than simple text search
@@ -141,7 +141,7 @@ different. For example, the word "entertainer" doesn't appear in any of the
141
141
descriptions but if you use it as a query, the actors and musicians are ranked
142
142
highest in the results list:
143
143
144
- {{< clients-example set="home_vecsets" step="entertainer_query" lang_filter="C#" >}}
144
+ {{< clients-example set="home_vecsets" step="entertainer_query" lang_filter="C#-Sync " >}}
145
145
{{< /clients-example >}}
146
146
147
147
Similarly, if you use "science" as a query, you get the following results:
@@ -162,7 +162,7 @@ with `VectorSetSimilaritySearch()` to restrict the search further. For example,
162
162
repeat the "science" query, but this time limit the results to people
163
163
who died before the year 2000:
164
164
165
- {{< clients-example set="home_vecsets" step="filtered_query" lang_filter="C#" >}}
165
+ {{< clients-example set="home_vecsets" step="filtered_query" lang_filter="C#-Sync " >}}
166
166
{{< /clients-example >}}
167
167
168
168
Note that the boolean filter expression is applied to items in the list
0 commit comments