Skip to main content

llm_kernel

张量计算、机器学习、深度学习与模型训练推理的函数与最佳实践,边学边写、持续补充。

Reusable functions and best practices for tensor math, machine learning, deep learning and model training / inference. Small, dependency-light and grown as the notes accumulate.

安装 / Installation

pip install llm_kernel
# 绘图模块需要 matplotlib / the plot module needs matplotlib
pip install "llm_kernel[plot]"

模块 / Modules

模块 Module 内容 Contents
llm_kernel.math 张量/数学计算,如正态分布 normal
llm_kernel.performance 性能测试,如计时器 Timer
llm_kernel.plot 二维可视化 vector(需要 matplotlib)

用法 / Usage

正态分布 / Normal distribution

import numpy as np
from llm_kernel.math import normal

normal(0.0, 0, 1)                       # 单点 0.3989422804014327
normal(np.array([-1.0, 0.0, 1.0]), 0, 1)  # 逐元素计算

mu 为均值,sigma 为标准差,必须为正实数。

计时 / Timing

from llm_kernel.performance import Timer

t = Timer()
t.start()
# ... 需要测量的代码 ...
t.stop()

t.sum()      # 累计耗时
t.avg()      # 平均耗时
t.cumsum()   # 累计耗时序列

二维绘图 / 2D plotting

from llm_kernel.plot import vector

vector([1, 2, 3], [1, 4, 9])  # x、y 长度必须相同

开发 / Development

git clone https://github.com/lmliheng/llm_kernel.git
cd llm_kernel
pip install -e ".[plot]"

发布 / Release

发布走 GitHub Actions 的 PyPI 可信发布(Trusted Publishing),无需在仓库里存 token: 在 GitHub 上创建 Release(例如标签 v0.1.0)即触发 .github/workflows/publish.yml, 构建 sdist/wheel 并上传到 PyPI。

Publishing uses PyPI Trusted Publishing through GitHub Actions, so no API token is stored in the repository: creating a GitHub Release (e.g. tag v0.1.0) triggers .github/workflows/publish.yml, which builds the sdist/wheel and uploads it to PyPI.

Metadata

Release files for llm-kernel 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for llm-kernel 0.1.0
File Size Uploaded
llm_kernel-0.1.0.tar.gz 3.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for llm-kernel 0.1.0
File Interpreter ABI Platform
llm_kernel-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 8.2 kB

Release files / llm_kernel-0.1.0.tar.gz

Download URL llm_kernel-0.1.0.tar.gz
Size 3.6 kB
Tags Source
SHA-256 checksum
How to use checksums
47e5ab8f8f8e1cb40f367f8b654a69d5acae73f6fd887c4327f2fe890360ba79
BLAKE2b-256 checksum
How to use checksums
480ac43c6013dabd1bcfb626235c8f42914a17c69b10d3eeb6270229e41ac504
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / llm_kernel-0.1.0-py3-none-any.whl

Download URL llm_kernel-0.1.0-py3-none-any.whl
Size 4.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a488f6ec6fbd49b85441c4e2d123016a3cd1aed97211e0956de922efcda2e3ed
BLAKE2b-256 checksum
How to use checksums
c6677ebb597e793de68b90b5253a6736ac12cafa7789fbf3d31ee0af6c17b970
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page