Skip to content

Pivot to natural-language vs LLM-prompt detection (warp style) - #9

Closed
ealmloff wants to merge 1 commit into
mainfrom
devin/1785184624-prompt-detection
Closed

Pivot to natural-language vs LLM-prompt detection (warp style)#9
ealmloff wants to merge 1 commit into
mainfrom
devin/1785184624-prompt-detection

Conversation

@ealmloff

@ealmloff ealmloff commented Jul 27, 2026

Copy link
Copy Markdown
Member

Summary

Complete pivot of betlang's classes and data: the 48-class source-language student is replaced by a 2-class detector that decides whether text is ordinary prose or a prompt for a language model (the Warp-style "should this input go to the AI?" routing decision).

Model / data (new training pipeline, no Magika teacher):

  • scripts/build_prompt_corpus.py builds a ~105k-sample corpus from public HF datasets — prompts from Alpaca, Dolly, awesome-chatgpt-prompts; prose from WikiText-103, AG News, IMDB, Yelp. Long prose samples also emit a random 1–2 sentence slice so length can't become a proxy for the label (this fixed a strong short-text→prompt bias in the first training run).
  • scripts/train_prompt_student.py trains the same wordseq-b1024-k3-m2048-tiny-3conv-hidden architecture from scratch with hard labels + label smoothing, QAT for the second half of the schedule, and exports through the existing MSQ1 serializer (head now 96 -> 2).
  • New embedded artifact (45,448 bytes): test_accuracy=0.983, recall natural_language=0.976 / prompt=0.995. MODEL_CARD/TRAINING docs rewritten.

Rust API (LanguageKind):

pub enum Kind { NaturalLanguage = 0, Prompt = 1 }   // slugs: natural_language, prompt

let detection = betlang::detect("Write a short poem about the ocean.");
assert_eq!(detection.kind(), Some(betlang::Kind::Prompt));
detection.top_kinds() // ranked (probability, Kind) pairs
  • src/language.rssrc/kind.rs; Detection::language()/top_languages()kind()/top_kinds(); CLASSES: 48 → 2. Runtime/tokenizer/quantized layers unchanged.
  • 48 language fixtures/tests replaced with prompt & natural-language fixtures under tests/fixtures/{prompt,natural_language}/; example CLI tree mode now reports a prompt-vs-prose breakdown; bench uses a prompt snippet.

cargo fmt --check, cargo test (all pass incl. doctests), cargo clippy --all-targets --all-features -- -D warnings, and RUSTDOCFLAGS="-D warnings" cargo doc are green locally.

Link to Devin session: https://dioxus.staging.devinenterprise.com/sessions/2d01d14ba6444015ae43aac7fc183d60
Requested by: @ealmloff


Devin Review

Status Commit
⚪ Not started

Run Devin Review

Open in Devin Review (Staging)

Replace the 48-class source-language head with a 2-class head
(natural_language, prompt), retrain the tiny MSQ1 student from scratch on a
public prompt/prose corpus, and pivot the Rust API from Language to Kind.

Co-Authored-By: Staging-Devin AI <166158716+staging-devin-ai-integration[bot]@users.noreply.github.com>
@ealmloff ealmloff self-assigned this Jul 27, 2026
@staging-devin-ai-integration

Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant