Files
magpie/go.mod
T
yetone 6e9820a3a4 pii/guard: run AstrLink Guard's int8 model in Go (#3578)
AstrLink Guard (QuantumNous/astrlink-guard, Apache-2.0, on Microsoft's
MIT Multilingual-MiniLM-L12-H384) is a 36.9M-parameter BERT token
classifier for Chinese and English: 21 BIO labels (email, phone,
account, payment_card, ip_address, url, common_secret, private_address,
private_date, private_person), 512-token windows overlapping by 128,
a 0.8 score floor. Its int8 ONNX is 37 MB.

This package runs it with no new dependency and nothing native: an ONNX
protobuf reader for the graph and its external data (onnx.go), the
XLM-R Unigram tokenizer from tokenizer.json (tokenizer.go), and the
encoder with int8 x int8 matmuls (bert.go) on NEON/SDOT kernels on
arm64, SSE2 on amd64 and Go elsewhere (kernel*). Word embeddings stay
quantized (15 MB in memory, not 61 MB). uax29 moves from an indirect to
a direct requirement for the tokenizer's pre-split.

Checked against onnxruntime on the publisher's files: the same spans
on 69 of 71 eval texts, 232 of 234 real code segments and 24 of 25
positive samples; the rest differ by a span edge at the score floor.
One 512-token window takes ~0.5s CPU on arm64 and ~1.2s under Rosetta
on amd64, on a box at load ~100.

Run: go test ./internal/pii/guard (kernels against the Go reference,
tokenizer against the publisher's tokenizer on testdata/tokens.json),
gofmt -l, go vet, GOOS=linux go vet -tags nogui and GOOS=windows go
vet on amd64 and arm64, at the pushed head.
2026-10-27 02:01:16 +08:00

62 lines
2.4 KiB
AMPL

module github.com/yetone/magpie
go 1.26.8
require (
github.com/Calcium-Ion/moejs v0.1.0-alpha.4
github.com/charmbracelet/bubbles v0.21.1
github.com/charmbracelet/bubbletea v1.3.10
github.com/charmbracelet/lipgloss v1.1.1-0.20250404203927-76690c660834
github.com/clipperhouse/uax29/v2 v2.5.0
github.com/coder/websocket v1.8.14
github.com/fsnotify/fsnotify v1.9.0
github.com/go-ole/go-ole v1.3.0
github.com/godbus/dbus/v5 v5.2.2
github.com/google/uuid v1.6.0
github.com/klauspost/compress v1.18.3
github.com/pelletier/go-toml/v2 v2.2.4
github.com/tidwall/gjson v1.19.0
github.com/tidwall/jsonc v0.3.3
github.com/wailsapp/wails/v3 v3.0.0-beta.24
golang.org/x/image v0.43.0
golang.org/x/net v0.56.0
golang.org/x/sys v0.46.0
golang.org/x/term v0.44.0
golang.org/x/text v0.39.0
gopkg.in/yaml.v3 v3.0.1
modernc.org/libc v1.67.6
modernc.org/sqlite v1.44.3
)
require (
git.sr.ht/~jackmordaunt/go-toast/v2 v2.0.3 // indirect
github.com/adrg/xdg v0.5.3 // indirect
github.com/atotto/clipboard v0.1.4 // indirect
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
github.com/charmbracelet/colorprofile v0.4.1 // indirect
github.com/charmbracelet/x/ansi v0.11.5 // indirect
github.com/charmbracelet/x/cellbuf v0.0.15 // indirect
github.com/charmbracelet/x/term v0.2.2 // indirect
github.com/clipperhouse/displaywidth v0.9.0 // indirect
github.com/clipperhouse/stringish v0.1.1 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
github.com/lucasb-eyer/go-colorful v1.3.0 // indirect
github.com/mattn/go-colorable v0.1.14 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mattn/go-localereader v0.0.1 // indirect
github.com/mattn/go-runewidth v0.0.19 // indirect
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
github.com/muesli/cancelreader v0.2.2 // indirect
github.com/muesli/termenv v0.16.0 // indirect
github.com/ncruces/go-strftime v1.0.0 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.0 // indirect
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
golang.org/x/exp v0.0.0-20260410095643-746e56fc9e2f // indirect
modernc.org/mathutil v1.7.1 // indirect
modernc.org/memory v1.11.0 // indirect
)