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.2 kB

12345678910111213141516171819202122232425262728293031323334353637
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using LLama.OldVersion;
  7. namespace LLama.Examples.Old
  8. {
  9. [Obsolete("The entire LLama.OldVersion namespace will be removed")]
  10. public class InstructMode
  11. {
  12. LLama.OldVersion.LLamaModel _model;
  13. public InstructMode(string modelPath, string promptFile)
  14. {
  15. _model = new LLama.OldVersion.LLamaModel(new LLamaParams(model: modelPath, n_ctx: 2048, n_predict: -1, top_k: 10000, instruct: true,
  16. repeat_penalty: 1.1f, n_batch: 256, temp: 0.2f)).WithPromptFile(promptFile);
  17. }
  18. public void Run()
  19. {
  20. Console.WriteLine("\n### Instruction:\n >");
  21. while (true)
  22. {
  23. Console.ForegroundColor = ConsoleColor.Green;
  24. var question = Console.ReadLine();
  25. question += "\n";
  26. Console.ForegroundColor = ConsoleColor.White;
  27. var outputs = _model.Call(question);
  28. foreach (var output in outputs)
  29. {
  30. Console.Write(output);
  31. }
  32. }
  33. }
  34. }
  35. }