Classify every message and show its bot-probability#3
Open
mkhlndrv wants to merge 3 commits into
Open
Conversation
Replace the English-only typeform/distilbert-base-uncased-mnli baseline with MoritzLaurer/mDeBERTa-v3-base-mnli-xnli so RU+EN chats are both handled. - Compare two explicit hypotheses (single-label softmax): "written by a real person" vs "written by an AI chatbot"; is_bot_probability = bot score. - Wording chosen by a local sweep on the Kaggle train set (best ROC-AUC 0.60 / log-loss 0.72 of the variants tested). - Load once at startup, log per-call latency, empty text -> 0.5, cap at 1500 chars. /predict and /get_message request/response contracts are unchanged.
mkhlndrv
force-pushed
the
feature/classify-messages
branch
from
June 22, 2026 11:26
5c17786 to
4acb48d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Upgrades the echo-chat so every message gets a bot-probability instead of the placeholder random number.
Server (FastAPI):
app/core/classifier.pyloads a zero-shot text-classification model (same setup as the baseline youarebot-classifier: candidate labels bot/human, take the bot score). Model name comes fromMODEL_NAME, defaulttypeform/distilbert-base-uncased-mnli./predictnow returns a realis_bot_probabilityfor the message text.Client (Streamlit):
/predictand the probability is shown under the bubble.st.session_statekeeps the chat history and running metrics (count, average bot-probability, and accuracy@0.5 using the known roles — user = human, echo = bot), shown in the sidebar.Also fixed
IncomingMessageto extendCustomBaseModelso itsmodel_dump()stringifies the UUID fields — otherwise the client'srequestscall to/predictfails to serialize. Addedtransformers,torchandrequeststo the deps and re-locked.Ran it locally (FastAPI on 6872, Streamlit on 8502): each message shows its probability and the metrics update live. With the default model the scores sit around 0.2–0.4 and accuracy hovers at 50%, which makes sense — the user message and its echo have identical text, so the model gives them the same score and can't separate the human/bot pair.