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.

InstructMode.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 InstructMode
  10. {
  11. LLama.Old.LLamaModel _model;
  12. public InstructMode(string modelPath, string promptFile)
  13. {
  14. _model = new LLama.Old.LLamaModel(new LLamaParams(model: modelPath, n_ctx: 2048, n_predict: -1, top_k: 10000, instruct: true,
  15. repeat_penalty: 1.1f, n_batch: 256, temp: 0.2f)).WithPromptFile(promptFile);
  16. }
  17. public void Run()
  18. {
  19. Console.WriteLine("\n### Instruction:\n >");
  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系列模型。