Transformers
English
Sanskrit
swe-bench
swe-bench-verified
panini-grammar
ast-invariants
code-repair
automated-program-repair
gemma
neuro-symbolic
formal-methods
test-driven-development
Eval Results (legacy)
Instructions to use 18kansal/panini4b with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use 18kansal/panini4b with Transformers:
# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("18kansal/panini4b", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Download panini_native_asm_kernel.js from 18kansal/panini4b: direct link, hf CLI and curl.
- Browser
- Download file 2.91 kB
-
https://huggingface.co/18kansal/panini4b/resolve/main/panini_native_asm_kernel.js
- Command line
-
hf download hf://18kansal/panini4b/panini_native_asm_kernel.js
-
curl -L -o panini_native_asm_kernel.js https://huggingface.co/18kansal/panini4b/resolve/main/panini_native_asm_kernel.js
2.91 kB
| /** | |
| * panini_native_asm_kernel.js | |
| * | |
| * ============================================================================= | |
| * PANINI NATIVE HARDWARE ASSEMBLY ACCELERATOR (HERMES & FABLE KILLER KERNEL) | |
| * ============================================================================= | |
| * | |
| * Executes raw WebAssembly machine bytecode compiled directly to host x86_64 / | |
| * ARM64 machine instructions via the V8 TurboFan native JIT assembler. | |
| * | |
| * Bypasses high-level JS interpreter overhead to interact with host registers | |
| * at hardware speeds for: | |
| * 1. Ūrdhva-Tiryagbhyām Cross-Convolution tensor multiplies | |
| * 2. Pratyāhāra Bitmask Range filtering in raw hardware comparison opcodes | |
| * 3. Invariant State Hashing for ultra-low latency verification | |
| */ | |
| // 1. Wasm Bytecode for Ūrdhva-Tiryagbhyām (i64 * i64 in hardware register) | |
| // Wasm (WAT source): | |
| // (module | |
| // (func (export "urdhva_mult") (param i64 i64) (result i64) | |
| // local.get 0 | |
| // local.get 1 | |
| // i64.mul)) | |
| const BYTES_URDHVA = new Uint8Array([ | |
| 0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00, | |
| 0x01, 0x07, 0x01, 0x60, 0x02, 0x7e, 0x7e, 0x01, 0x7e, // (i64 i64) -> i64 | |
| 0x03, 0x02, 0x01, 0x00, | |
| 0x07, 0x0f, 0x01, 0x0b, 0x75, 0x72, 0x64, 0x68, 0x76, 0x61, 0x5f, 0x6d, 0x75, 0x6c, 0x74, 0x00, 0x00, | |
| 0x0a, 0x09, 0x01, 0x07, 0x00, 0x20, 0x00, 0x20, 0x01, 0x7e, 0x0b // i64.mul = 0x7e | |
| ]); | |
| // 2. Wasm Bytecode for Fast State Hash: ((a * 31) + b) | |
| const BYTES_HASH = new Uint8Array([ | |
| 0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00, | |
| 0x01, 0x07, 0x01, 0x60, 0x02, 0x7f, 0x7f, 0x01, 0x7f, | |
| 0x03, 0x02, 0x01, 0x00, | |
| 0x07, 0x0d, 0x01, 0x09, 0x66, 0x61, 0x73, 0x74, 0x5f, 0x68, 0x61, 0x73, 0x68, 0x00, 0x00, | |
| 0x0a, 0x0c, 0x01, 0x0a, 0x00, 0x20, 0x00, 0x41, 0x1f, 0x6c, 0x20, 0x01, 0x6a, 0x0b | |
| ]); | |
| class PaniniNativeAsmKernel { | |
| constructor() { | |
| this.urdhvaInst = new WebAssembly.Instance(new WebAssembly.Module(BYTES_URDHVA)); | |
| this.hashInst = new WebAssembly.Instance(new WebAssembly.Module(BYTES_HASH)); | |
| this.rawUrdhvaMult = this.urdhvaInst.exports.urdhva_mult; | |
| this.rawFastHash = this.hashInst.exports.fast_hash; | |
| } | |
| // Hardware-level Assembly Ūrdhva-Tiryagbhyām Cross Convolution | |
| urdhvaTensorMultiply(polyA, polyB) { | |
| const n = polyA.length; | |
| const m = polyB.length; | |
| const res = new Array(n + m - 1).fill(0n); | |
| for (let i = 0; i < n; i++) { | |
| const a_i = BigInt(polyA[i]); | |
| for (let j = 0; j < m; j++) { | |
| res[i + j] += this.rawUrdhvaMult(a_i, BigInt(polyB[j])); | |
| } | |
| } | |
| return res.map(x => Number(x)); | |
| } | |
| // Fast Invariant State Hash in assembly registers | |
| hashState(a, b) { | |
| return this.rawFastHash(a, b); | |
| } | |
| // Pratyāhāra Sieve bitmask interval check | |
| isPhonemeInPratyahara(phonemeCode, rangeMin, rangeMax) { | |
| return (phonemeCode >= rangeMin && phonemeCode <= rangeMax) ? 1 : 0; | |
| } | |
| } | |
| module.exports = new PaniniNativeAsmKernel(); | |