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.cs 862 B

12345678910111213141516171819202122232425262728
  1. using LLama.Common;
  2. namespace LLama.Examples.NewVersion
  3. {
  4. public class GetEmbeddings
  5. {
  6. public static void Run()
  7. {
  8. Console.Write("Please input your model path: ");
  9. var modelPath = Console.ReadLine();
  10. var @params = new ModelParams(modelPath);
  11. using var weights = LLamaWeights.LoadFromFile(@params);
  12. var embedder = new LLamaEmbedder(weights, @params);
  13. while (true)
  14. {
  15. Console.Write("Please input your text: ");
  16. Console.ForegroundColor = ConsoleColor.Green;
  17. var text = Console.ReadLine();
  18. Console.ForegroundColor = ConsoleColor.White;
  19. Console.WriteLine(string.Join(", ", embedder.GetEmbeddings(text)));
  20. Console.WriteLine();
  21. }
  22. }
  23. }
  24. }