ประสิทธิภาพ
ตัวเลข throughput และความแม่นยำของ kham v0.5.0 วัดบน Apple M-series (arm64)
benchmark ทั้งหมดรันด้วย --release และ LTO เปิดใช้งาน
สภาพแวดล้อม
| CPU | Apple M-series (arm64) |
| OS | macOS |
| Rust | 1.85+ stable, LTO เปิดใช้งาน |
| Profile | release |
| dictionary ในตัว | 62,102 คำ · 669,387 DARTS states · 5.1 MiB |
| ตาราง TNC frequency | 106,125 รายการ |
รันเองได้: cargo bench -p kham-core
— รายงาน HTML ที่ target/criterion/report/index.html
ความแม่นยำ
Precision / Recall / F1 ระดับขอบเขตคำเทียบกับ gold corpus แบบ CC0 (kham-core/testdata/)
และเปรียบเทียบกับ PyThaiNLP word_tokenize(engine='newmm') บน 39 ประโยค
cargo run -p kham-bench-accuracy cargo run -p kham-bench-accuracy -- --threshold 0.95 # CI gate cargo run -p kham-bench-accuracy -- --verbose # แสดงกรณีที่ผิดพลาด
Throughput การตัดคำ
ข้อความภาษาไทยล้วน, dictionary ในตัว, benchmark segment/by_length
| ขนาด input | Bytes | เวลา (median) | Throughput |
|---|---|---|---|
| สั้น (short) | 37 B | 879 ns | 42.3 MiB/s |
| กลาง (medium) | 182 B | 3.80 µs | 45.1 MiB/s |
| ยาว (long) | 546 B | 10.9 µs | 47.1 MiB/s |
หลายภาษาผสมกัน (Mixed-script)
ภาษาไทย + ภาษาอังกฤษ + ตัวเลขในข้อความเดียวกัน — segment/mixed
| Input | Bytes | เวลา (median) | Throughput |
|---|---|---|---|
| sparse (ธนาคาร100แห่ง) | 26 B | 744 ns | 42.3 MiB/s |
| medium (หลาย boundary) | 74 B | 1.73 µs | 43.5 MiB/s |
| dense (สลับภาษา) | 29 B | 535 ns | 55.3 MiB/s |
Normalization
Unicode normalization (จัดเรียงสระลอย, ลบวรรณยุกต์ซ้ำ, NFC) — normalize/thai
| ขนาด input | Bytes | เวลา (median) | Throughput |
|---|---|---|---|
| สั้น | 37 B | 79.9 ns | 465 MiB/s |
| กลาง | 182 B | 199 ns | 864 MiB/s |
| ยาว | 546 B | 507 ns | 1.0 GiB/s |
SQLite FTS5 Extension
Criterion benchmarks ผ่าน rusqlite, in-memory database, FTS5 เปิดใช้งาน
pipeline ต่อการเรียก xTokenize: normalize → NE → stopword → POS → synonym → RTGS
Throughput การ index (INSERT)
| Benchmark | Input | ขนาด | เวลา (median) | Throughput |
|---|---|---|---|---|
| index/single/short | กินข้าวกับปลา | 21 B | 15.5 µs | 2.47 MiB/s |
| index/single/medium | ข้อความภาษาไทย ~63 B | 63 B | 41.8 µs | 4.14 MiB/s |
| index/single/long | 3× medium | 189 B | 94.3 µs | 5.46 MiB/s |
| index/batch_100/short | 100 × short | 2.1 KB | 640 µs (6.4 µs/doc) | 6.0 MiB/s |
| index/batch_100/medium | 100 × medium | 6.3 KB | 2.54 ms (25.4 µs/doc) | 7.1 MiB/s |
| index/batch_100/long | 100 × long | 18.9 KB | 6.75 ms (67.5 µs/doc) | 7.6 MiB/s |
Latency การค้นหา
ตาราง 1,000 แถว ข้อความขนาดกลาง
| Benchmark | Query | แถวผลลัพธ์ | เวลา (median) |
|---|---|---|---|
| query/single_word/thai_common | ข้าว | 1,000 | 88.3 µs |
| query/single_word/thai_rare | ปลา | 1,000 | 88.9 µs |
| query/single_word/number | 100 | 0 | 1.4 µs |
| query/single_word/latin | hello | 0 | 1.5 µs |
| query/snippet | ข้าว (top 10) | 10 | 417 µs |