Skip to content

Commit b8d0f6a

Browse files
committed
2 parents 38bafd7 + b3bc054 commit b8d0f6a

File tree

8 files changed

+46
-50
lines changed

8 files changed

+46
-50
lines changed

03-CoreGenerativeAITechniques/02-retrieval-augmented-generation.md

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,11 @@ You may have heard of vector databases. These are databases that store data in a
3636
We'll use the Microsoft.Extension.AI along with the [Microsoft.Extensions.VectorData](https://www.nuget.org/packages/Microsoft.Extensions.VectorData.Abstractions/) and [Microsoft.SemanticKernel.Connectors.InMemory](https://www.nuget.org/packages/Microsoft.SemanticKernel.Connectors.InMemory) libraries to implement RAG below.
3737

3838
> 🧑‍💻**Sample code:** You can follow along with the [sample code here](./src/RAGSimple-02MEAIVectorsMemory/).
39-
>
39+
>
4040
> You can also see how to implement a RAG app [using Semantic Kernel by itself in our sample source code here](./src/RAGSimple-01SK/).
4141
>
4242
> We have additional RAG examples for different vector stores and models:
43+
>
4344
> - [RAGSimple-03MEAIVectorsAISearch](./src/RAGSimple-03MEAIVectorsAISearch/) - Using Azure AI Search as a vector store
4445
> - [RAGSimple-04MEAIVectorsQdrant](./src/RAGSimple-04MEAIVectorsQdrant/) - Using Qdrant as a vector store
4546
> - [RAGSimple-10SKOllama](./src/RAGSimple-10SKOllama/) - Using Semantic Kernel with Ollama
@@ -52,21 +53,21 @@ We'll use the Microsoft.Extension.AI along with the [Microsoft.Extensions.Vector
5253
```csharp
5354
public class Movie
5455
{
55-
[VectorStoreRecordKey]
56+
[VectorStoreKey]
5657
public int Key { get; set; }
5758

58-
[VectorStoreRecordData]
59+
[VectorStoreData]
5960
public string Title { get; set; }
6061

61-
[VectorStoreRecordData]
62+
[VectorStoreData]
6263
public string Description { get; set; }
6364

64-
[VectorStoreRecordVector(384, DistanceFunction.CosineSimilarity)]
65+
[VectorStoreVector(384, DistanceFunction.CosineSimilarity)]
6566
public ReadOnlyMemory<float> Vector { get; set; }
6667
}
6768
```
6869

69-
Using the attributes like `[VectorStoreRecordKey]` makes it easier for the vector store implementations to map POCO objects to their underlying data models.
70+
Using the attributes like `[VectorStoreKey]` makes it easier for the vector store implementations to map POCO objects to their underlying data models.
7071

7172
2. Of course we're going to need that knowledge data populated. Create a list of `Movie` objects, and create an `InMemoryVectorStore` that will have a collection of movies.
7273

@@ -75,7 +76,7 @@ We'll use the Microsoft.Extension.AI along with the [Microsoft.Extensions.Vector
7576

7677
// get movie list
7778
var movies = vectorStore.GetCollection<int, MovieVector<int>>("movies");
78-
await movies.CreateCollectionIfNotExistsAsync();
79+
await movies.EnsureCollectionExistsAsync();
7980
var movieData = MovieFactory<int>.GetMovieVectorList();
8081

8182
```
@@ -107,14 +108,9 @@ We'll use the Microsoft.Extension.AI along with the [Microsoft.Extensions.Vector
107108
// generate the embedding vector for the user's prompt
108109
var query = "A family friendly movie that includes ogres and dragons";
109110
var queryEmbedding = await generator.GenerateVectorAsync(query);
110-
var searchOptions = new VectorSearchOptions()
111-
{
112-
Top = 2,
113-
VectorPropertyName = "Vector"
114-
};
115111

116112
// search the knowledge store based on the user's prompt
117-
var results = await movies.VectorizedSearchAsync(queryEmbedding, searchOptions);
113+
var results = movies.SearchAsync(queryEmbedding, 2, new VectorSearchOptions<MovieVector<int>>());
118114

119115
// let's see the results just so we know what they look like
120116
await foreach (var result in results.Results)
@@ -136,7 +132,7 @@ So we could do something like the following while looping through the results of
136132

137133
```csharp
138134

139-
// assuming chatClient is instatiated as before to a language model
135+
// assuming chatClient is instantiated as before to a language model
140136
// assuming the vector search is done as above
141137
// assuming List<ChatMessage> conversation object is already instantiated and has a system prompt
142138
@@ -157,7 +153,7 @@ var response = await chatClient.GetResponseAsync(conversation);
157153
conversation.Add(new ChatMessage(ChatRole.Assistant, response.Message));
158154

159155
//display the conversation
160-
Console.WriteLine($"Bot:> {response.Message.Text});
156+
Console.WriteLine($"Bot:> {response.Message.Text}");
161157
```
162158

163159
> 🙋 **Need help?**: If you encounter any issues, [open an issue in the repository](https://github.com/microsoft/Generative-AI-for-beginners-dotnet/issues/new).

translations/de/03-CoreGenerativeAITechniques/02-retrieval-augmented-generation.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,21 @@ Wir verwenden Microsoft.Extension.AI zusammen mit den Bibliotheken [Microsoft.Ex
4646
```csharp
4747
public class Movie
4848
{
49-
[VectorStoreRecordKey]
49+
[VectorStoreKey]
5050
public int Key { get; set; }
5151

52-
[VectorStoreRecordData]
52+
[VectorStoreData]
5353
public string Title { get; set; }
5454

55-
[VectorStoreRecordData]
55+
[VectorStoreData]
5656
public string Description { get; set; }
5757

58-
[VectorStoreRecordVector(384, DistanceFunction.CosineSimilarity)]
58+
[VectorStoreVector(384, DistanceFunction.CosineSimilarity)]
5959
public ReadOnlyMemory<float> Vector { get; set; }
6060
}
6161
```
6262

63-
Mit Attributen wie `[VectorStoreRecordKey]` makes it easier for the vector store implementations to map POCO objects to their underlying data models.
63+
Mit Attributen wie `[VectorStoreKey]` makes it easier for the vector store implementations to map POCO objects to their underlying data models.
6464

6565
2. Of course we're going to need that knowledge data populated. Create a list of `Movie` objects, and create an `InMemoryVectorStore`, die eine Sammlung von Filmen enthalten wird.
6666

translations/fr/03-CoreGenerativeAITechniques/02-retrieval-augmented-generation.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,21 @@ Nous utiliserons la bibliothèque Microsoft.Extension.AI ainsi que [Microsoft.Ex
4646
```csharp
4747
public class Movie
4848
{
49-
[VectorStoreRecordKey]
49+
[VectorStoreKey]
5050
public int Key { get; set; }
5151

52-
[VectorStoreRecordData]
52+
[VectorStoreData]
5353
public string Title { get; set; }
5454

55-
[VectorStoreRecordData]
55+
[VectorStoreData]
5656
public string Description { get; set; }
5757

58-
[VectorStoreRecordVector(384, DistanceFunction.CosineSimilarity)]
58+
[VectorStoreVector(384, DistanceFunction.CosineSimilarity)]
5959
public ReadOnlyMemory<float> Vector { get; set; }
6060
}
6161
```
6262

63-
En utilisant des attributs comme `[VectorStoreRecordKey]` makes it easier for the vector store implementations to map POCO objects to their underlying data models.
63+
En utilisant des attributs comme `[VectorStoreKey]` makes it easier for the vector store implementations to map POCO objects to their underlying data models.
6464

6565
2. Of course we're going to need that knowledge data populated. Create a list of `Movie` objects, and create an `InMemoryVectorStore`, nous aurons une collection de films.
6666

translations/ja/03-CoreGenerativeAITechniques/02-retrieval-augmented-generation.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,21 @@ RAG アーキテクチャには主に2つのフェーズがあります: **検
4646
```csharp
4747
public class Movie
4848
{
49-
[VectorStoreRecordKey]
49+
[VectorStoreKey]
5050
public int Key { get; set; }
5151

52-
[VectorStoreRecordData]
52+
[VectorStoreData]
5353
public string Title { get; set; }
5454

55-
[VectorStoreRecordData]
55+
[VectorStoreData]
5656
public string Description { get; set; }
5757

58-
[VectorStoreRecordVector(384, DistanceFunction.CosineSimilarity)]
58+
[VectorStoreVector(384, DistanceFunction.CosineSimilarity)]
5959
public ReadOnlyMemory<float> Vector { get; set; }
6060
}
6161
```
6262

63-
`[VectorStoreRecordKey]` makes it easier for the vector store implementations to map POCO objects to their underlying data models.
63+
`[VectorStoreKey]` makes it easier for the vector store implementations to map POCO objects to their underlying data models.
6464

6565
2. Of course we're going to need that knowledge data populated. Create a list of `Movie` objects, and create an `InMemoryVectorStore` のような属性を使用して、映画のコレクションを持つことができます。
6666

translations/ko/03-CoreGenerativeAITechniques/02-retrieval-augmented-generation.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,21 @@ RAG 아키텍처에는 두 가지 주요 단계가 있습니다: **검색(Retrie
4646
```csharp
4747
public class Movie
4848
{
49-
[VectorStoreRecordKey]
49+
[VectorStoreKey]
5050
public int Key { get; set; }
5151

52-
[VectorStoreRecordData]
52+
[VectorStoreData]
5353
public string Title { get; set; }
5454

55-
[VectorStoreRecordData]
55+
[VectorStoreData]
5656
public string Description { get; set; }
5757

58-
[VectorStoreRecordVector(384, DistanceFunction.CosineSimilarity)]
58+
[VectorStoreVector(384, DistanceFunction.CosineSimilarity)]
5959
public ReadOnlyMemory<float> Vector { get; set; }
6060
}
6161
```
6262

63-
`[VectorStoreRecordKey]` makes it easier for the vector store implementations to map POCO objects to their underlying data models.
63+
`[VectorStoreKey]` makes it easier for the vector store implementations to map POCO objects to their underlying data models.
6464

6565
2. Of course we're going to need that knowledge data populated. Create a list of `Movie` objects, and create an `InMemoryVectorStore`와 같은 속성을 사용하여 영화 컬렉션을 포함한 인메모리 벡터 저장소를 구성합니다.
6666

translations/pt/03-CoreGenerativeAITechniques/02-retrieval-augmented-generation.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,21 @@ Usaremos o Microsoft.Extension.AI junto com as bibliotecas [Microsoft.Extensions
4646
```csharp
4747
public class Movie
4848
{
49-
[VectorStoreRecordKey]
49+
[VectorStoreKey]
5050
public int Key { get; set; }
5151

52-
[VectorStoreRecordData]
52+
[VectorStoreData]
5353
public string Title { get; set; }
5454

55-
[VectorStoreRecordData]
55+
[VectorStoreData]
5656
public string Description { get; set; }
5757

58-
[VectorStoreRecordVector(384, DistanceFunction.CosineSimilarity)]
58+
[VectorStoreVector(384, DistanceFunction.CosineSimilarity)]
5959
public ReadOnlyMemory<float> Vector { get; set; }
6060
}
6161
```
6262

63-
Usando os atributos como `[VectorStoreRecordKey]` makes it easier for the vector store implementations to map POCO objects to their underlying data models.
63+
Usando os atributos como `[VectorStoreKey]` makes it easier for the vector store implementations to map POCO objects to their underlying data models.
6464

6565
2. Of course we're going to need that knowledge data populated. Create a list of `Movie` objects, and create an `InMemoryVectorStore`, que terá uma coleção de filmes.
6666

translations/tw/03-CoreGenerativeAITechniques/02-retrieval-augmented-generation.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,21 @@ RAG 架構主要包含兩個階段:**檢索** 和 **生成**。
4646
```csharp
4747
public class Movie
4848
{
49-
[VectorStoreRecordKey]
49+
[VectorStoreKey]
5050
public int Key { get; set; }
5151

52-
[VectorStoreRecordData]
52+
[VectorStoreData]
5353
public string Title { get; set; }
5454

55-
[VectorStoreRecordData]
55+
[VectorStoreData]
5656
public string Description { get; set; }
5757

58-
[VectorStoreRecordVector(384, DistanceFunction.CosineSimilarity)]
58+
[VectorStoreVector(384, DistanceFunction.CosineSimilarity)]
5959
public ReadOnlyMemory<float> Vector { get; set; }
6060
}
6161
```
6262

63-
使用類似 `[VectorStoreRecordKey]` makes it easier for the vector store implementations to map POCO objects to their underlying data models.
63+
使用類似 `[VectorStoreKey]` makes it easier for the vector store implementations to map POCO objects to their underlying data models.
6464

6565
2. Of course we're going to need that knowledge data populated. Create a list of `Movie` objects, and create an `InMemoryVectorStore` 的屬性,這將包含一系列的電影。
6666

translations/zh/03-CoreGenerativeAITechniques/02-retrieval-augmented-generation.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,21 @@ RAG 架构主要分为两个阶段:**检索** 和 **生成**。
4646
```csharp
4747
public class Movie
4848
{
49-
[VectorStoreRecordKey]
49+
[VectorStoreKey]
5050
public int Key { get; set; }
5151

52-
[VectorStoreRecordData]
52+
[VectorStoreData]
5353
public string Title { get; set; }
5454

55-
[VectorStoreRecordData]
55+
[VectorStoreData]
5656
public string Description { get; set; }
5757

58-
[VectorStoreRecordVector(384, DistanceFunction.CosineSimilarity)]
58+
[VectorStoreVector(384, DistanceFunction.CosineSimilarity)]
5959
public ReadOnlyMemory<float> Vector { get; set; }
6060
}
6161
```
6262

63-
使用类似 `[VectorStoreRecordKey]` makes it easier for the vector store implementations to map POCO objects to their underlying data models.
63+
使用类似 `[VectorStoreKey]` makes it easier for the vector store implementations to map POCO objects to their underlying data models.
6464

6565
2. Of course we're going to need that knowledge data populated. Create a list of `Movie` objects, and create an `InMemoryVectorStore` 的属性,这将包含一组电影数据。
6666

0 commit comments

Comments
 (0)