[C#]基于C# winform结合llamasharp部署llama3中文的gguf模子

打印 上一主题 下一主题

主题 1895|帖子 1895|积分 5685

【llmasharp源码】
https://github.com/SciSharp/LLamaSharp
【测试模子】
https://www.modelscope.cn/pooka74/LLaMA3-8B-Chat-Chinese-GGUF.git
【测试通过情况】
vs2019
netframework4.7.2
llamasharp==0.15.0
cuda11.7.1+cudnn8.8.0
注意测试发现使用cpu推理非常卡,因此建议配置有个nvidia显卡电脑举行测试,要求显存>=6GB,我电脑是RTX2070 8GB显存
【界面演示】


【部分实现源码】
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using FIRC;
  11. namespace WindowsFormsApp1
  12. {
  13.     public partial class Form1 : Form
  14.     {
  15.         LLamaInfer infer = null;
  16.         public Form1()
  17.         {
  18.             InitializeComponent();
  19.         }
  20.         
  21.         private void Form1_Load(object sender, EventArgs e)
  22.         {
  23.           //模型在https://www.modelscope.cn/pooka74/LLaMA3-8B-Chat-Chinese-GGUF.git下载
  24.            infer= new LLamaInfer(@"H:\llama3-8b-chat-chinese-gguf\LLaMA3-8B-Chat-Chinese-Q4_K_M.gguf");
  25.             infer.CallBack += Infer_CallBack;
  26.         }
  27.         private void Infer_CallBack(string msg)
  28.         {
  29.             tb_output.AppendText(msg);
  30.         }
  31.         private void btn_input_Click(object sender, EventArgs e)
  32.         {
  33.             if(string.IsNullOrEmpty(tb_input.Text))
  34.             {
  35.                 return;
  36.             }
  37.             infer.GetResult(tb_input.Text);
  38.         }
  39.         private void button1_Click(object sender, EventArgs e)
  40.         {
  41.             tb_output.Clear();
  42.         }
  43.     }
  44. }
复制代码
【源码下载所在】
https://download.csdn.net/download/FL1623863129/89628543

免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
回复

举报

0 个回复

倒序浏览

快速回复

您需要登录后才可以回帖 登录 or 立即注册

本版积分规则

宝塔山

论坛元老
这个人很懒什么都没写!
快速回复 返回顶部 返回列表