mathguard
Skill này làm gì
Công cụ này giúp chọn các phương pháp toán học nâng cao để giải các bài toán tính toán phức tạp, đặc biệt khi có lượng dữ liệu lớn. Nó gợi ý các lựa chọn hiệu quả hơn các phương pháp truyền thống, ngay cả khi chấp nhận một sai số nhỏ.
Khi nào nên dùng
- ✓Khi bạn có hàng triệu điểm dữ liệu và cần tìm các mục tương tự nhanh chóng.
- ✓Khi bạn xử lý tín hiệu hoặc hình ảnh và cần tính toán nhanh.
- ✓Khi các thuật toán thông thường đã nhanh, nhưng bạn cần giải pháp tốt hơn nữa và chấp nhận được một sai số nhỏ.
Liên kết skill
https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/mathguard/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Tôi cần tìm các bản sao trong tập dữ liệu gồm 10 triệu hình ảnh, nhưng có thể chấp nhận một số kết quả dương tính giả. Tôi có thể dùng kỹ thuật toán học nào?”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Công cụ so sánh bài toán với các kỹ thuật toán học đã biết, hiệu quả hơn với khối lượng dữ liệu lớn. Nó kiểm tra xem bạn có cần lời giải chính xác tuyệt đối hay có thể chấp nhận một phép xấp xỉ với sai số đã biết.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
mathguard — Math-Heavy Optimization for AI Code
lemmaly makes you pick the right classical algorithm. mathguard kicks in when the classical algorithm is already optimal but mathematics gives a better bound — usually by accepting bounded approximation, exploiting structure, or moving to a smarter algebraic space.
The model knows these techniques. It almost never proposes them spontaneously. mathguard fixes that.
Violating the letter of these rules is violating the spirit of the skill. A Bloom filter where the caller assumed exact answers is a production incident, not an optimization.
When to Use This Skill
Use mathguard when:
- Working with large-scale data (
n ≥ 10⁶): similarity search, deduplication, top-K / heavy-hitters, streaming analytics, cardinality estimation, embeddings, recommender systems. - Doing signal/image processing, polynomial or big-integer arithmetic, convolution, graph distance, computational geometry, randomized algorithms.
- The classical O(n log n) is already the floor and you need an asymptotic win (Bloom filter, HyperLogLog, Count-Min Sketch, MinHash/LSH, FFT/NTT, Johnson-Lindenstrauss projection, sweep line, kd-tree/BVH, fast exponentiation, monoid parallel reduction, amortized potential method).
- Loaded after
lemmalyhas confirmed the classical answer is not enough.
Do not use mathguard when:
- The caller needs exact answers (auth, billing, dedup-for-correctness, primary keys).
nis small (n < 10⁴) and the path is not hot.- The bottleneck is I/O, not CPU/memory.
The Iron Law
NO APPROXIMATE STRUCTURE WITHOUT WRITTEN ε/δ AND EXPLICIT CALLER ACCEPTANCE
Probabilistic data structures (Bloom, HyperLogLog, Count-Min, MinHash/LSH, t-digest), randomized projections (JL), and lossy transforms (floating FFT) all change the answer's meaning. Before proposing one:
- Write the error parameter the caller will see (false-positive rate, relative error, distortion bound).
- Identify the caller and state, in one sentence, that they tolerate this kind of wrong answer.
- If you cannot identify the caller, or they need exact (auth checks, billing, dedup keys, deduplication for correctness, anything that flows into a primary key), DO NOT propose the approximate structure. Keep classical, or escalate to a sharded/streaming exact design.
This rule has saved more incidents than any other in this skill. Do not soften it.
Non-negotiable rules
Declare exact vs approximate up front. Before suggesting a math-level technique, state:
mode: exactormode: approximate- If approximate: the error parameter (ε, δ, false-positive rate) and a sentence on whether the caller can tolerate it.
- If the caller needs exact and there is no exact win, say so and stop — do not silently degrade to approximate.
Cite the technique by name. Never describe a probabilistic or numerical trick in vague terms. Name it:
Bloom filter,HyperLogLog,Count-Min Sketch,MinHash + LSH,Johnson–Lindenstrauss projection,FFT,NTT,fast exponentiation,Karatsuba,Strassen,sweep line,kd-tree,BVH,union-find with path compression,Floyd's cycle detection,Boyer-Moore majority,reservoir sampling,Knuth shuffle,Aho-Corasick,suffix automaton,segment tree with lazy propagation,Fenwick tree,monoid scan / parallel prefix. A named technique is auditable; "a smart approximation" is not.State the trade you are making. Every math-level optimization buys something at a cost. In one line:
- Buys:
space,time,wall-clock,parallelism. - Costs:
accuracy ε=?,code complexity,dependency,non-determinism,numerical stability. - If the cost is invisible to the caller, write "callers see no change".
- Buys:
Justify the asymptotic win. Do not propose a math technique without a one-line bound argument:
- "HyperLogLog: count uniques in O(log log n) bits at standard error 1.04/√m."
- "FFT: polynomial multiplication O(n log n) vs schoolbook O(n²)."
- "JL projection: preserves pairwise distances within (1±ε) using O(log n / ε²) dimensions."
- "Sweep line: rectangle overlap from O(n²) pair checks to O(n log n) events." No bound, no proposal.
Forbid math cargo-culting. Do not introduce these techniques when:
- n is small enough that a linear scan finishes in microseconds (n < ~10⁴ unless it is a hot path).
…
Câu hỏi thường gặp
“Xấp xỉ với sai số đã biết” nghĩa là gì?
Nghĩa là kết quả có thể không chính xác 100%, nhưng sai số nhỏ và có thể dự đoán được (ví dụ 1% khả năng sai). Điều này giúp tính toán nhanh hơn nhiều.
Khi nào KHÔNG nên dùng công cụ này?
Đừng dùng khi độ chính xác tuyệt đối là quan trọng (như giao dịch tài chính), hoặc khi dữ liệu ít (dưới 10.000 mục) mà các phương pháp đơn giản đã hoạt động tốt.
Có những kỹ thuật nào mà công cụ có thể gợi ý?
Tùy bài toán, công cụ có thể gợi ý Bloom Filters, HyperLogLog, Count-Min Sketch, MinHash, Fast Fourier Transform (FFT) và các kỹ thuật khác.
Chi tiết
Mô tả gốc của tác giả
Math-heavy escalation for n >= 10^6 — Bloom, HyperLogLog, Count-Min, MinHash/LSH, FFT, JL projection, sweep line. Use when classical O(n log n) is the floor and approximate or math wins.
Độ phổ biến
- Sao GitHub
- 48k
- Vị trí xếp hạng
- #5180
- Giấy phép
- MIT
- Cập nhật
- 15/10/2026
Bình luận
- …
Thêm skill từ kho mã này
00-andruia-consultant
48kGiúp agent của bạn bắt đầu hoặc cải thiện các dự án AI. Phân tích mã, gợi ý công cụ và lập kế hoạch hành động bằng tiếng Tây Ban Nha.
007
48kCho phép agent của bạn thực hiện kiểm toán bảo mật và mô hình hóa mối đe dọa. Hữu ích để bảo vệ dự án khỏi các cuộc tấn công và lỗ hổng.
10-andruia-skill-smith
48kGiúp agent của bạn tạo hoặc cải thiện các công cụ AI. Xác định cách công cụ hoạt động, viết tài liệu và kiểm tra cấu trúc.
20-andruia-niche-intelligence
48kGiúp agent của bạn tạo bản tóm tắt về một ngành cụ thể. Hữu ích để hiểu bối cảnh, quy tắc, cách người dùng tương tác và rủi ro của dự án.
Skill tương tự
pytorch-patterns
280kGiúp agent của bạn dùng PyTorch cho các mô hình học máy. Áp dụng thực hành tốt nhất để huấn luyện mô hình hiệu quả và đảm bảo kết quả có thể lặp lại.
evm-token-decimals
280kGiúp agent tránh lỗi về số thập phân khi làm việc với các mạng blockchain khác nhau. Đảm bảo giá trị token chính xác trong giao dịch và phép tính.
ito-inference
280kGiúp agent kiểm tra xem các mô hình AI đã sẵn sàng để dùng chưa. Kết nối yêu cầu tài nguyên tính toán với dịch vụ mô hình đã sẵn sàng.