
### Porting [this model](https://huggingface.co/FractalGPT/SbertDistil) for use in C#


* Example of use in C#:

  ```csharp
  using AI.DataPrepaire.DataLoader.NNWBlockLoader;
  using AI.DataStructs.Algebraic;
  using AI.ONNX.NLP.Bert;
  
  
  string path = "SbertDistilAIFr";
  // Загрузка модели Bert
  BertEmbedder embedder = BertEmbedder.FromPretrained(path);
  // Добавление последнего(линейного) слоя
  LinearLayerLoader linearLayer = LinearLayerLoader.LoadFromBinary(@$"{path}\1_Linear\model.aifr");
  embedder.V2VBlocks.Add(linearLayer);
  
  // Векторизация предложений
  Vector vects1 = embedder.ForwardSBert("Kittens love milk");
  Vector vects2 = embedder.ForwardSBert("Visual Studio Code (VS Code) — текстовый редактор, разработанный Microsoft для Windows, Linux и macOS.");
  Vector vects3 = embedder.ForwardSBert("Visual Studio Code, also commonly referred to as VS Code,[12] is a source-code editor developed by Microsoft for Windows, Linux and macOS.");
  Vector vects1_rus = embedder.ForwardSBert("Котята любят молоко");
  
  // Рассчет близости между текстами
  Console.WriteLine(vects1.Cos(vects1_rus));
  Console.WriteLine(vects1.Cos(vects2));
  Console.WriteLine(vects2.Cos(vects3));
  Console.WriteLine(vects1.Cos(vects3));
  Console.ReadKey();
  ```

* Network output

```
0.8312274467817271
0.18402859300814606
0.9556528309990797
0.14738954582438052
```


* [GitHub](https://github.com/AIFramework/AIFrameworkOpen)
{"language": ["ru", "en"], "license": "apache-2.0", "tags": ["AIFramework 2.2 Open", ".net", "sbert", "C#"], "datasets": ["wikimedia/wikipedia", "SiberiaSoft/SiberianPersonaChat-2"], "metrics": ["mse"]}
transformers onnx bert feature-extraction AIFramework 2.2 Open .net sbert C# ru en dataset:wikimedia/wikipedia dataset:SiberiaSoft/SiberianPersonaChat-2 license:apache-2.0 endpoints_compatible region:us