LLama for nodejs - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
hlhr202
V2EX    Node.js

LLama for nodejs

  •  
  •   hlhr202 2023-03-23 10:03:46 +08:00 2270 次点击
    这是一个创建于 1005 天前的主题,其中的信息可能已经有所发展或是发生改变。

    AIGC 这么火,小前端来蹭个热度,写了个 llama-node 的库

    https://github.com/hlhr202/llama-node

    起因是为了方便自己调用,又希望降低 llama.cpp 和 llama-rs 的调用门槛,我研究了一下 meta 开源的 llama 社区项目,最终找到了 llama-rs 这个 rust 库。

    https://github.com/setzer22/llama-rs

    对 rust 确实不太熟,还是喜欢留在 typescript 的安全区,所以决定用 llama-rs 写一个 nodejs 的库。

    node addon 方面选择了 @太狼 大佬的 napi-rs 。

    用法展示:

    import path from "path"; import { LLamaClient } from "llama-node"; const model = path.resolve(process.cwd(), "./ggml-alpaca-7b-q4.bin"); const client = new LLamaClient({ path: model, numCtxTokens: 4096 }, true); const prompt = `// Show an example of counter component in react.js. it has increment and decrement buttons where they change the state by 1. export const Counter => {`; client.createTextCompletion( { prompt, numPredict: BigInt(2048), temp: 0.2, topP: 0.8, topK: BigInt(40), repeatPenalty: 1, repeatLastN: BigInt(512), }, (res) => { process.stdout.write(res.token); } ); 

    结论还是:写 ai 程序也是撸 typescript 更快。。。就这样先将就用着吧。rust 写的不好,各位看官轻喷。

    1 条回复    2023-03-23 10:14:01 +08:00
    tool2d
        1
    tool2d  
       2023-03-23 10:14:01 +08:00
    IT 行业有头部通吃原则。

    习惯了 OpenGPT 后,别的 Ai 回答都像刚毕业的小学生,用了几次后,实在没有兴趣继续使用了。
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     1111 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 27ms UTC 18:00 PVG 02:00 LAX 10:00 JFK 13:00
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86