webassembly010 ggml的其他封装:Python,Rust ,javascript

news/2024/10/21 10:01:30/
其他封装
Tensor library for machine learning, inspired by ggmlhttps://github.com/candrewlee14/zgml
Bleeding edge low level Rust binding for GGMLhttps://github.com/KerfuffleV2/ggml-sys-bleedingedge
Your customized AI characters - personal assistants on any hardware! With llama.cpp, whisper.cpp, ggml, LLaMA-v2.https://github.com/nrl-ai/CustomChar
cpu inference example for mpt-7b with ggml+rusthttps://github.com/apage43/mptgen
Python bindings for the GGML GPT-J Laguage modelhttps://github.com/abdeladim-s/pygptj
Run any ggml ported ML models directly on your web browser with ggml.jshttps://github.com/rahuldshetty/ggml.js
Python bindings for the Transformer models implemented in C/C++ using GGML library.https://github.com/marella/ctransformers

ggml-python

  • 在github上有一个使用python对ggml进行封装的项目ggml-python,通过下面的例子可以看出使用ggml进行推理主要包括以下几个步骤:
  • 上下文环境创建=>
  • tensors数据初始化=>
  • 构建计算图=>
  • 设置tensor值=>
  • 前向推理=>
  • 输出值,释放上下文<=>
#  https://github.com/abetlen/ggml-python
import ggml
import ctypes# Allocate a new context with 16 MB of memory
params = ggml.ggml_init_params(mem_size=16 * 1024 * 1024, mem_buffer=None)
ctx = ggml.ggml_init(params=params)# Instantiate tensors
x = ggml.ggml_new_tensor_1d(ctx, ggml.GGML_TYPE_F32, 1)
a = ggml.ggml_new_tensor_1d(ctx, ggml.GGML_TYPE_F32, 1)
b = ggml.ggml_new_tensor_1d(ctx, ggml.GGML_TYPE_F32, 1)# Use ggml operations to build a computational graph
x2 = ggml.ggml_mul(ctx, x, x)
f = ggml.ggml_add(ctx, ggml.ggml_mul(ctx, a, x2), b)gf = ggml.ggml_build_forward(f)# Set the input values
ggml.ggml_set_f32(x, 2.0)
ggml.ggml_set_f32(a, 3.0)
ggml.ggml_set_f32(b, 4.0)# Compute the graph
ggml.ggml_graph_compute_with_ctx(ctx, ctypes.pointer(gf), 1)# Get the output value
output = ggml.ggml_get_f32_1d(f, 0)
assert output == 16.0# Free the context
ggml.ggml_free(ctx)

CG

  • https://ggml-python.readthedocs.io/en/latest/
  • https://github.com/ggerganov/ggml/tree/master/examples/python
  • https://github.com/ggerganov/whisper.cpp/issues/9
  • https://github.com/go-skynet/LocalAI

http://www.ppmy.cn/news/1069257.html

相关文章

Elasticsearch中倒排索引、分词器、DSL语法使用介绍

&#x1f353; 简介&#xff1a;java系列技术分享(&#x1f449;持续更新中…&#x1f525;) &#x1f353; 初衷:一起学习、一起进步、坚持不懈 &#x1f353; 如果文章内容有误与您的想法不一致,欢迎大家在评论区指正&#x1f64f; &#x1f353; 希望这篇文章对你有所帮助,欢…

机器学习-神经网络(西瓜书)

神经网络 5.1 神经元模型 在生物神经网络中&#xff0c;神经元之间相互连接&#xff0c;当一个神经元受到的外界刺激足够大时&#xff0c;就会产生兴奋&#xff08;称为"激活"&#xff09;&#xff0c;并将剩余的"刺激"向相邻的神经元传导。 神经元模型…

服务网格实施周期缩短 50%,丽迅物流基于阿里云 ACK 和 ASM 的云原生应用管理实践

作者&#xff1a;王夕宁、 刘强、 华相 公司介绍 丽迅物流是百丽旗下专注于时尚产业、为企业提供专业物流及供应链解决方案的服务商。其产品服务主要包括城市落地配、仓配一体、干线运输及定制化解决方案。通过自研智能化物流管理平台&#xff0c;全面助力企业合作集约化发展…

防御网络攻击风险的4个步骤

如今&#xff0c;人们正在做大量工作来保护 IT 系统免受网络犯罪的侵害。令人担忧的是&#xff0c;对于运营技术系统来说&#xff0c;情况却并非如此&#xff0c;运营技术系统用于运行从工厂到石油管道再到发电厂的所有业务。 组织应该强化其网络安全策略&#xff0c;因为针对…

Html 补充

accesskey 设置快捷键 Alt设定的键 <a href"https://blog.csdn.net/lcatake/article/details/131716967?spm1001.2014.3001.5501" target"_blank" accesskey"i">我的博客</a> contenteditable 使文本可编译 默认为false 对输入框无…

【C语言每日一题】05. 输出保留12位小数的浮点数

题目来源&#xff1a;http://noi.openjudge.cn/ch0101/05/ 05 输出保留12位小数的浮点数 总时间限制: 1000ms 内存限制: 65536kB 问题描述 读入一个双精度浮点数&#xff0c;保留12位小数&#xff0c;输出这个浮点数。 输入 只有一行&#xff0c;一个双精度浮点数。 输出 …

掌握SEO优化:让您的网站在搜索引擎中脱颖而出

导言&#xff1a; 在当今数字化的时代&#xff0c;搜索引擎成为了人们获取信息的主要途径。作为网站拥有者&#xff0c;如何让您的网站在搜索引擎结果中排名靠前&#xff0c;成为用户首选&#xff0c;就显得尤为重要。这就需要掌握搜索引擎优化&#xff08;SEO&#xff09;的技…

centos环境下idea开发问题集锦

1、端口不能访问&#xff0c;可能是访问的协议问题或者防火墙拦截为问题导致。 1.1 centos环境下idea直接拉起部署&#xff0c;查看端口信息如下&#xff0c;命令为 [rootlocalhost ~]# lsof -i:8088 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME java …