node-llama-cpp开源程序使用 llama.cpp 的 node.js 绑定在计算机上本地运行 AI 模型。在生成级别的模型输出上强制实施 JSON 架构

​一、软件介绍

文末提供程序和源码下载

       node-llama-cpp开源程序使用 llama.cpp 的 node.js 绑定在计算机上本地运行 AI 模型。在生成级别的模型输出上强制实施 JSON 架构。

二、Features 特征

三、Try It Without Installing无需安装

文末提供全部版本下载

hat with a model in your terminal using a single command:
使用单个命令与终端中的模型聊天:

npx -y node-llama-cpp chat

四、Installation 安装

npm install node-llama-cpp

This package comes with pre-built binaries for macOS, Linux and Windows.
此软件包附带适用于 macOS、Linux 和 Windows 的预构建二进制文件。

If binaries are not available for your platform, it'll fallback to download a release of llama.cpp and build it from source with cmake. To disable this behavior, set the environment variable NODE_LLAMA_CPP_SKIP_DOWNLOAD to true.
如果二进制文件不适用于您的平台,它将回退以下载 的 llama.cpp 版本并使用 从源代码构建它 cmake 。要禁用此行为,请将环境变量 NODE_LLAMA_CPP_SKIP_DOWNLOAD 设置为 true 。

五、Usage 用法

Usage 用法

import {fileURLToPath} from "url";
import path from "path";
import {getLlama, LlamaChatSession} from "node-llama-cpp";

const __dirname = path.dirname(fileURLToPath(import.meta.url));

const llama = await getLlama();
const model = await llama.loadModel({
    modelPath: path.join(__dirname, "models", "Meta-Llama-3.1-8B-Instruct.Q4_K_M.gguf")
});
const context = await model.createContext();
const session = new LlamaChatSession({
    contextSequence: context.getSequence()
});


const q1 = "Hi there, how are you?";
console.log("User: " + q1);

const a1 = await session.prompt(q1);
console.log("AI: " + a1);


const q2 = "Summarize what you said";
console.log("User: " + q2);

const a2 = await session.prompt(q2);
console.log("AI: " + a2);

六、软件下载

迅雷网盘

本文信息来源于GitHub作者地址:https://github.com/withcatai/node-llama-cpp

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值