You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用LlamaSharp调用本地LLM时程序无报错终止的问题求助

LlamaSharp调用本地LLM时程序无报错终止的问题求助

各位好,我最近在尝试用C#搭配LlamaSharp库运行本地大语言模型,结果遇到了一个棘手的问题:程序运行到await foreach (var text1 in executor.InferAsync(input))这一行就直接终止了,既没有抛出任何异常,也没有错误提示,退出码是0x0,完全找不到原因。不过这个模型在LM Studio里是能正常运行的,说明模型本身没问题。

以下是我的代码:

var @params = new ModelParams(ModelPath);
var model = LLamaWeights.LoadFromFile(@params);
var context = model.CreateContext(@params);
var executor = new InteractiveExecutor(context);

Console.WriteLine("Model loaded! Write exit to stop the program");

while (true)
{
    Console.ForegroundColor = ConsoleColor.Green;
    Console.Write("\nYou: ");
    Console.ResetColor();
    
    var input = Console.ReadLine();
    if (input == "exit") break;
    
    Console.ForegroundColor = ConsoleColor.Blue;
    Console.Write("Model: ");
    Console.ResetColor();
    
    await foreach (var text1 in executor.InferAsync(input))
    {
        Console.Write(text1);
    }
}

有没有大佬能帮我分析下问题出在哪?或者给些排查的方向也行,谢谢了!


内容来源于stack exchange

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.08 07:39:31