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

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

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