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

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