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.

Program.cs 2.2 kB

1234567891011121314151617181920212223242526272829
  1. using LLama;
  2. using LLama.Types;
  3. //string modelPath = @"D:\development\llama\weights\LLaMA\7B\ggml-model-q4_0.bin";
  4. //LLamaModel model = new(modelPath, logits_all: false, verbose: false, n_ctx: 2048);
  5. //List<ChatCompletionMessage> chats = new List<ChatCompletionMessage>();
  6. //chats.Add(new ChatCompletionMessage("user", "Hi, Alice, I'm Rinne.", null));
  7. //chats.Add(new ChatCompletionMessage("assistant", "Hi, Rinne, I'm Alice. What can I do for you?", null));
  8. //Console.Write("You: ");
  9. //var question = "This is a text classification task, below are the category list:\r\n1. Air Handler\r\n2. Tub/Shower\r\n3. Fireplace\r\n4. Bathroom\r\n5. Kitchen\r\n6. Powerwash roof eves and soffits\r\n\r\nFor example:\r\n1. \"Clear drain clog at kitchen sink\": Kitchen\r\n2. \"Change blower motor speed\": Air Handler\r\n3. \"Clear drain clog at tub/shower\": Bathroom\r\n4. \"Clear drain clog at toilet\": Bathroom\r\n\r\nPlease classify this text \"toilet clogged\" in provided list. output in json format: {\"category\": \"\", \"confidence\":0.0}";
  10. //chats.Add(new ChatCompletionMessage("user", question, null));
  11. //var output = model.CreateChatCompletion(chats, max_tokens: 1024);
  12. //Console.WriteLine($"LLama AI: {output.Choices[0].Message.Content}");
  13. string modelPath = @"D:\development\llama\weights\LLaMA\7B\ggml-model-q4_0.bin";
  14. GptModel model = new(new GptParams(model: modelPath, n_ctx: 512, interactive: true, antiprompt: new List<string>(){"User:"},
  15. repeat_penalty: 1.0f));
  16. model = model.WithPrompt("Transcript of a dialog, where the User interacts with an Assistant named Bob. Bob is helpful, kind, honest, good at writing, and never fails to answer the User's requests immediately and with precision.\r\n\r\nUser: Hello, Bob.\r\nBob: Hello. How may I help you today?\r\nUser: Please tell me the largest city in Europe.\r\nBob: Sure. The largest city in Europe is Moscow, the capital of Russia.\r\nUser:");
  17. while (true)
  18. {
  19. Console.ForegroundColor = ConsoleColor.Green;
  20. var question = Console.ReadLine();
  21. Console.ForegroundColor = ConsoleColor.White;
  22. var outputs = model.Call(question);
  23. foreach (var output in outputs)
  24. {
  25. Console.Write(output);
  26. }
  27. }

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

Contributors (1)