Search a Blazor DataGrid by meaning instead of exact words. "Something to drink" finds the beverages and "Italian cheese" finds Gorgonzola and Mozzarella, even though none of the rows contain those words.
Product | Category | Package | Price |
|---|---|---|---|
| Alice Mutton | Meat/Poultry | 20 - 1 kg tins | ¤39.00 |
| Aniseed Syrup | Condiments | 12 - 550 ml bottles | ¤10.00 |
| Boston Crab Meat | Seafood | 24 - 4 oz tins | ¤18.40 |
| Camembert Pierrot | Dairy Products | 15 - 300 g rounds | ¤34.00 |
| Carnarvon Tigers | Seafood | 16 kg pkg. | ¤62.50 |
| Chai | Beverages | 10 boxes x 20 bags | ¤18.00 |
| Chang | Beverages | 24 - 12 oz bottles | ¤19.00 |
| Chartreuse verte | Beverages | 750 cc per bottle | ¤18.00 |
Every row is turned into a short description and embedded once with the IEmbeddingGenerator from IAIChatService.GetEmbeddingGenerator() - the one registered in the
service collection or the built-in OpenAICompatibleEmbeddingGenerator configured by AIChatServiceOptions.EmbeddingsModel and EmbeddingsEndpoint.
The query is embedded the same way and the rows are ranked by cosine similarity with TensorPrimitives.CosineSimilarity; the top matches are shown with their score.
For large data sets store the vectors next to the rows, or in a vector database, instead of computing them on the page.
Each row is turned into a short text and embedded once with IAIChatService.GetEmbeddingGenerator(). A query is embedded the same way and the rows are ranked by cosine similarity, so 'something to drink' finds beverages.
Radzen Blazor Components, © 2018-2026 Radzen.
Source Code licensed under
MIT