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.

InstructModeExecute.md 1.3 kB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # Use instruct executor
  2. ```cs
  3. using LLama.Common;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. public class InstructModeExecute
  10. {
  11. public static void Run()
  12. {
  13. Console.Write("Please input your model path: ");
  14. string modelPath = Console.ReadLine();
  15. var prompt = File.ReadAllText("Assets/dan.txt").Trim();
  16. InstructExecutor ex = new(new LLamaModel(new ModelParams(modelPath, contextSize: 1024)));
  17. Console.ForegroundColor = ConsoleColor.Yellow;
  18. Console.WriteLine("The executor has been enabled. In this example, the LLM will follow your instructions. For example, you can input \"Write a story about a fox who want to " +
  19. "make friend with human, no less than 200 words.\"");
  20. Console.ForegroundColor = ConsoleColor.White;
  21. var inferenceParams = new InferenceParams() { Temperature = 0.8f, MaxTokens = 300 };
  22. while (true)
  23. {
  24. foreach (var text in ex.Infer(prompt, inferenceParams))
  25. {
  26. Console.Write(text);
  27. }
  28. Console.ForegroundColor = ConsoleColor.Green;
  29. prompt = Console.ReadLine();
  30. Console.ForegroundColor = ConsoleColor.White;
  31. }
  32. }
  33. }
  34. ```