Skip to main content

thai filler word prediction for voice bots - picks the right acknowledgment phrase while llm thinks

Project description

filler-prediction

thai filler word prediction for voice bots. classifies customer input into categories and returns the appropriate filler phrase to play instantly while the llm generates a full response.

built for ingfah.ai voice bot but easily adaptable to any thai voice ai system.

why

voice bots have a latency problem: the user speaks, asr transcribes, then the llm takes 1-3 seconds to respond. dead silence feels broken. the solution is to play a short filler phrase ("สักครู่นะคะ", "ขออภัยด้วยน่ะคะ") immediately while the llm thinks.

but you can't play the same filler for everything. if someone is angry, "ได้เลยค่ะ" sounds dismissive. if someone asks a question, "ขออภัยด้วยน่ะคะ" makes no sense.

this classifier picks the right filler by category.

categories

category when example fillers
complaint angry, frustrated, profanity, threats ขออภัยด้วยน่ะคะ
question asking for info, pricing, how-to สักครู่นะคะ, ตรวจสอบให้นะคะ
default greetings, agreements, requests, everything else รับทราบค่ะ, ได้เลยค่ะ

default filler phrases

category fillers
complaint ขออภัยด้วยน่ะคะ
question สักครู่นะคะ, สักครู่ค่ะ, ตรวจสอบให้นะคะ
default รับทราบค่ะ, ค่ะ ได้ค่ะ, ได้เลยค่ะ, ดีเลยค่ะ, ยินดีค่ะ

a random filler is picked from the matching category each time. these are designed to be short (~0.3-0.5s when synthesized) for minimal latency.

how it works

uses intfloat/multilingual-e5-small embeddings with centroid-based cosine similarity:

  1. each category has ~30-60 anchor phrases (real thai customer service examples)
  2. on init, all anchors are embedded and averaged into category centroids
  3. at inference, the input is embedded and compared to centroids via cosine similarity
  4. the closest category wins, and a random filler from that category is returned

performance

  • accuracy: 89.6% on 1,000 thai customer service sentences
  • inference: <10ms per classification (after model load)
  • init: ~200ms for centroid computation
  • model size: ~118mb (multilingual-e5-small)

installation

pip install filler-prediction

usage

from filler_prediction import FillerClassifier

# loads model automatically on first init
clf = FillerClassifier()

# classify and get category + confidence + filler
category, confidence, filler = clf.classify("อยากถามเรื่องบิลครับ")
# ("question", 0.872, "สักครู่นะคะ")

category, confidence, filler = clf.classify("ใช้งานไม่ได้เลย")
# ("complaint", 0.891, "ขออภัยด้วยน่ะคะ")

category, confidence, filler = clf.classify("ได้ครับ ตกลง")
# ("default", 0.845, "ได้เลยค่ะ")

# or just get the filler phrase directly
filler = clf.get_filler("มีโปรอะไรบ้างครับ")
# "ตรวจสอบให้นะคะ"

sharing the model

if you alr have a SentenceTransformer instance loaded (e.g., for other tasks), pass it in to avoid loading twice:

from sentence_transformers import SentenceTransformer
from filler_prediction import FillerClassifier

model = SentenceTransformer("intfloat/multilingual-e5-small")
clf = FillerClassifier(model=model)

customizing fillers

override CATEGORY_FILLERS to use your own phrases:

import filler_prediction

filler_prediction.CATEGORY_FILLERS["complaint"] = ["ขออภัยค่ะ", "เข้าใจค่ะ"]
filler_prediction.CATEGORY_FILLERS["question"] = ["รอสักครู่นะคะ"]

license

mit

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

filler_prediction-0.4.3.tar.gz (13.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

filler_prediction-0.4.3-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file filler_prediction-0.4.3.tar.gz.

File metadata

  • Download URL: filler_prediction-0.4.3.tar.gz
  • Upload date:
  • Size: 13.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for filler_prediction-0.4.3.tar.gz
Algorithm Hash digest
SHA256 f14763aa692042c3fb0c146a18d2797de29e971d63ecaaffc4a2cb46e3bfcbec
MD5 8d92a5360ca014705d163594121acf2d
BLAKE2b-256 9d8e7fb4f18faaf420a87dc28d5b9995fc9ccf112edd4ac8d0572a4df2b73529

See more details on using hashes here.

File details

Details for the file filler_prediction-0.4.3-py3-none-any.whl.

File metadata

File hashes

Hashes for filler_prediction-0.4.3-py3-none-any.whl
Algorithm Hash digest
SHA256 8b8b9b5d31bcfa3ffc8f0096dfc1bec55e1e769b24ea7b77d24e993788e31e8b
MD5 263b548de598bf546941b0bf65776958
BLAKE2b-256 c84e4b0dce2cb0c90cd1e6522e4e4ac40688fa584ce677493e5097c80879f419

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page