Automatic prompt quality scoring for IBM Bob, IBM's AI coding assistant.
Scores user prompts on a 1–10 scale and explains what's missing.
Issue #444: This work supersedes the original TinyLlama fine-tuning approach
with faster, more accurate, and more interpretable alternatives.
What changed
The original TinyLlama model (v1) scored prompts using 8 criteria but had weak
alignment with human judgment (Spearman r=0.304) and was slow (1,680ms/prompt).
This release (v2) introduces two new scoring approaches validated on 510 manually
annotated IBM Bob prompts and confirmed on 191 additional unseen prompts:
Approach
Spearman r
ms/prompt
vs TinyLlama
TinyLlama v1 (original)
0.304–0.346
1,680ms
baseline
Regex-only (new)
0.649
0.264ms
2× accuracy, 6,363× faster
agentlans+regex (new)
0.753
~12.8ms
2.4× accuracy, 131× faster
Both new approaches are free, run locally with no API calls, and require no GPU.
agentlans-only vs agentlans+regex: p=0.003 ✅ significant
Regex-only vs Regex+SetFit: p=0.407 — not significant at this dataset size
agentlans vs gpt-oss: p=0.185 — not significant (statistically equivalent)
Production scale estimates (1M prompts, single CPU core):
Model
Time
Regex-only
0.8 minutes
agentlans+regex
22.5 hours
TinyLlama v1
467 hours
gpt-oss API
833 hours
Training
SetFit models (for Hybrid scorer and for the 3 weaker regex criteria) need to be
trained before use. This requires access to IBM OSS (gpt-oss-120b) for auto-labeling.
bash
1# 1. Split annotated data into train/val/test2# (requires annotated_prompts.csv — see Evaluation section)3jupyter nbconvert --to notebook --execute notebooks/nb1_data_split.ipynb
45# 2. Auto-label training data and train SetFit models6# (requires RITS_API_KEY and IBM_OSS_BASE_URL environment variables)7jupyter nbconvert --to notebook --execute notebooks/nb2_training.ipynb
Pre-trained SetFit models are available on HuggingFace:
center-of-excellence/extract-prompt-quality-criteria under setfit_models/.
Evaluation
To reproduce the evaluation results on your own annotated data:
python
1import numpy as np
2from src.regex_detector import score as regex_score
3from src.evaluate import print_summary, compare_models, permutation_test
45# Load your annotated prompts6# Format: CSV with columns: text, quality_score, category_label7import pandas as pd
8df = pd.read_csv("your_annotated_prompts.csv").dropna(subset=["quality_score"])910y_true = df["quality_score"].values
11regex_preds = np.array([regex_score(t)["score"]for t in df["text"]])1213# Single model metrics14from src.evaluate import evaluate
15print(evaluate(y_true, regex_preds, label="Regex-only"))1617# Compare two models18r_a, r_b, delta, p = permutation_test(y_true, regex_preds, other_preds)19print(f"p={p:.4f}")2021# Full pairwise comparison with Bonferroni correction22df_results = compare_models(y_true,{23"Regex-only": regex_preds,24"agentlans": agentlans_preds,25})26print(df_results.to_string(index=False))
Note on ground truth data: The prompts annotated used in our
evaluation is not included in this repository due to IBM data privacy policy.
The evaluation code works with any CSV following the format above.
The agentlans/bge-small-en-v1.5-prompt-quality model used in agentlans_scorer.py
is a fine-tune of BAAI/bge-small-en-v1.5 (MIT license, commercial use permitted).
The fine-tuned model does not explicitly state a license on HuggingFace.
Therefore, a licensing confirmation request has been submitted. agentlans_scorer.py will be
pushed once approval is received.
Alternative: fine-tune BAAI/bge-small-en-v1.5 directly on IBM-annotated data
for a fully IBM-owned model with no third-party IP risk.