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.

ChatWithLLamaModel.cs 1.1 kB

123456789101112131415161718192021222324252627282930313233343536
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using LLama.Old;
  7. namespace LLama.Examples.Old
  8. {
  9. public class ChatWithLLamaModel
  10. {
  11. LLama.Old.LLamaModel _model;
  12. public ChatWithLLamaModel(string modelPath, string promptFilePath, string[] antiprompt)
  13. {
  14. _model = new LLama.Old.LLamaModel(new LLamaParams(model: modelPath, n_ctx: 512, interactive: true, antiprompt: antiprompt.ToList(),
  15. repeat_penalty: 1.0f)).WithPromptFile(promptFilePath);
  16. }
  17. public void Run()
  18. {
  19. Console.Write("\nUser:");
  20. while (true)
  21. {
  22. Console.ForegroundColor = ConsoleColor.Green;
  23. var question = Console.ReadLine();
  24. question += "\n";
  25. Console.ForegroundColor = ConsoleColor.White;
  26. var outputs = _model.Call(question);
  27. foreach (var output in outputs)
  28. {
  29. Console.Write(output);
  30. }
  31. }
  32. }
  33. }
  34. }

C#/.NET上易用的LLM高性能推理框架,支持LLaMA和LLaVA系列模型。