You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

GetEmbeddings.md 847 B

1234567891011121314151617181920212223242526272829303132
  1. # Get embeddings
  2. ```cs
  3. using LLama.Common;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. public class GetEmbeddings
  10. {
  11. public static void Run()
  12. {
  13. Console.Write("Please input your model path: ");
  14. string modelPath = Console.ReadLine();
  15. var modelParams = new ModelParams(modelPath) { EmbeddingMode = true };
  16. var embedder = new LLamaEmbedder(modelParams);
  17. while (true)
  18. {
  19. Console.Write("Please input your text: ");
  20. Console.ForegroundColor = ConsoleColor.Green;
  21. var text = Console.ReadLine();
  22. Console.ForegroundColor = ConsoleColor.White;
  23. Console.WriteLine(string.Join(", ", embedder.GetEmbeddings(text)));
  24. Console.WriteLine();
  25. }
  26. }
  27. }
  28. ```