Skip to main content

ประสิทธิภาพ

ตัวเลข 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 ประโยค

0.975
Micro F1
เทียบกับ CC0 gold corpus
94.9%
ประโยคที่ตรงกัน
37/39 เทียบกับ PyThaiNLP newmm
0
ความต่างที่แท้จริง
2 รายการที่เหลือเป็นข้อผิดพลาดของ PyThaiNLP
วิธีรันเอง:
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

ขนาด inputBytesเวลา (median)Throughput
สั้น (short)37 B879 ns42.3 MiB/s
กลาง (medium)182 B3.80 µs45.1 MiB/s
ยาว (long)546 B10.9 µs47.1 MiB/s

หลายภาษาผสมกัน (Mixed-script)

ภาษาไทย + ภาษาอังกฤษ + ตัวเลขในข้อความเดียวกัน — segment/mixed

InputBytesเวลา (median)Throughput
sparse (ธนาคาร100แห่ง)26 B744 ns42.3 MiB/s
medium (หลาย boundary)74 B1.73 µs43.5 MiB/s
dense (สลับภาษา)29 B535 ns55.3 MiB/s

Normalization

Unicode normalization (จัดเรียงสระลอย, ลบวรรณยุกต์ซ้ำ, NFC) — normalize/thai

ขนาด inputBytesเวลา (median)Throughput
สั้น37 B79.9 ns465 MiB/s
กลาง182 B199 ns864 MiB/s
ยาว546 B507 ns1.0 GiB/s

SQLite FTS5 Extension

Criterion benchmarks ผ่าน rusqlite, in-memory database, FTS5 เปิดใช้งาน pipeline ต่อการเรียก xTokenize: normalize → NE → stopword → POS → synonym → RTGS

Throughput การ index (INSERT)

BenchmarkInputขนาดเวลา (median)Throughput
index/single/shortกินข้าวกับปลา21 B15.5 µs2.47 MiB/s
index/single/mediumข้อความภาษาไทย ~63 B63 B41.8 µs4.14 MiB/s
index/single/long3× medium189 B94.3 µs5.46 MiB/s
index/batch_100/short100 × short2.1 KB640 µs (6.4 µs/doc)6.0 MiB/s
index/batch_100/medium100 × medium6.3 KB2.54 ms (25.4 µs/doc)7.1 MiB/s
index/batch_100/long100 × long18.9 KB6.75 ms (67.5 µs/doc)7.6 MiB/s

Latency การค้นหา

ตาราง 1,000 แถว ข้อความขนาดกลาง

BenchmarkQueryแถวผลลัพธ์เวลา (median)
query/single_word/thai_commonข้าว1,00088.3 µs
query/single_word/thai_rareปลา1,00088.9 µs
query/single_word/number10001.4 µs
query/single_word/latinhello01.5 µs
query/snippetข้าว (top 10)10417 µs