Skip to main content
How polite will people find a message? In this cookbook we use 2,000 requests that Wikipedia editors left on each other’s talk pages, each rated for politeness by five people. As a control, we train a CatBoost regressor (gradient-boosted trees) on the raw text, using its default text features, which represent each message by the words it contains. Its error is only 11% lower than always predicting the mean rating, so which words a message contains says little about how polite it reads. In this cookbook an LLM, the proposer, writes questions about the messages. Jev answers every question for every message, and CatBoost trains on the answers. CatBoost then reports which questions it used and which messages it still gets wrong. The proposer reads that report and suggests changes to the questions. A change stays only if it makes CatBoost’s predictions better, and each kept change is one step of the loop. The table scores each approach by RMSE: how far its predictions miss on the rating scale, with big misses counting for more. Lower is better. Every number comes from 800 requests the loop never saw. The proposer’s first call does most of the work. It was told nothing about politeness research, and it wrote questions about thanks and praise, apologies and hedging (softened wording), greetings, asking indirectly (“would you be willing to…”), and framing a request as a shared “we” effort. A 2013 study of this corpus built a feature for each of those by hand. Four more steps lowered the error by another 0.015, about 3%. One of them added a question about “please” and similar courtesy words, another of the study’s features, which the first call had missed. The loop keeps a change only when it lowers the error on rows the proposer never reads, so it turned down most of what the proposer suggested after step 1 and ended with 20 questions. By the end you have a loop you can run on your own labelled text, a curve of held-out error per step, and a table of which questions the final model used most.
To take this notebook further or apply it to another problem, see Next steps.

Setup

Run in Colab

Runs as published without an API key.

Python file

This page as one .py file, to run locally.

Open in playground

Edit one request and run it live. Needs a TypeSafe account.
To run it on your own machine instead:
With uv, uv run autoresearch_feature_discovery.py installs the dependencies for you. The code downloads the published answers into autoresearch_feature_discovery_cache.json, so it runs as published without an API key; to run live, set DOWNLOAD_CACHE = False and delete that file. To change a request, set TYPESAFE_API_KEY and ANTHROPIC_API_KEY; in Colab, add them in the Secrets panel. The propose() function also has a branch for gpt-5.6-luna. It needs OPENAI_API_KEY, and this run did not use it. The numbers below came from jev-1.14.0 and claude-sonnet-5 on 2026-11-05. The first code cell holds the whole implementation: the API calls, the code that turns answers into columns, the metrics and the chart styling. It is there so this file runs on its own, and the docs site shows it folded. Skip it on a first read; the recipe starts in the next cell.

Load the rated requests

Each row is a request from the Wikipedia half of the Stanford Politeness Corpus. Five annotators rated each one, and the label is the average of their normalised ratings: 0 is a typical request, below 0 is blunter, above 0 is more courteous. The two requests printed above are the least and most polite among the dev rows, the rows the loop learns from. The requests are short, from one sentence to a few, and the raters judged each message as a whole. The same word can push either way: “thanks” makes a sincere request read as more polite and a sarcastic one read as less polite. The five raters also disagree with each other, so no model can get the error to zero. The load_slice function takes a random sample of 2,000 of the corpus’s 4,338 distinct requests, with a fixed seed so every run gets the same sample. The code splits them three ways:
  • 800 read rows. The proposer reads its example messages from these, 60 per try.
  • 400 check rows. The proposer never sees these. A change stays only if it lowers the error here. A question written to fix messages the proposer has read would score well on those same messages, so they can’t be the judge.
  • 800 held-out rows. Nothing in the loop touches these. They are scored once, at the end, and every number in the table at the top comes from them.
The read and check rows together are the 1,200 dev rows, and CatBoost trains on all of them.

Turn each answer into columns

Each proposed question is one of two kinds, and the kind decides how its answer becomes columns of numbers for CatBoost.
  • intensity becomes a Score, for anything that comes in degrees. Its five levels are printed below. The first column is the average level, weighted by Jev’s probability for each level, so a message that sits between “moderate” and “strongly” comes out between the two. The second column is how widely that probability is spread around the average.
  • presence becomes a Noul, for a yes/no fact like whether the writer says thanks. Its one column is that probability.
Each request sends the text to Jev as {"message": text}, because the questions refer to it as “the message”.

Run the loop

No proposed question is screened out before Jev answers it. Jev answers all of a try’s new questions about a message in one request, so an extra question costs no extra request. A question that applies to one row in ten can look useless in the 60 messages the proposer reads and still turn out to be the most useful column in the set. The k-fold step splits the dev rows into k parts and predicts each part with a CatBoost model trained on the rest, so every dev row gets a prediction from a model that never saw it. Those predictions do three jobs. Their error on the check rows judges every add, revision and drop. Their misses on the read rows pick the messages the next step reads. And they show the proposer how far its last kept change moved each message. The brief, PROPOSER_TASK, is the instruction text the proposer gets every try. It ends by telling the proposer not to quote any one example message in a question. Without that line the proposer can copy phrases from the rows it was shown into its questions as examples, and a question built around one row’s wording looks tuned to that row. The run_loop call below prints one block per try. Step 1’s questions are the starting set, so each goes straight in unless its column is flat, meaning almost the same value on every dev row. After that, every change is tried first: refit with it, and keep it only if check-row error falls by at least MIN_GAIN. Adds are checked too, because a narrow question can add more noise to the model than it adds signal. A smaller gain is within the noise of a score on 400 rows. A refit makes no API calls, so a rejected change costs nothing extra. In the log, skip is an add that was turned down, reject a revision and keep a drop. A step ends as soon as one try keeps a change. A try that keeps nothing leaves the question set and the predictions as they were, so the next try would see the same prompt and propose much the same changes again. To stop that, every change the check turns down goes into the next prompt with its check-row error before and after, and the proposer is told not to suggest it again. If TRIES tries in a row keep nothing, the loop has run out of ideas that help, and it stops. MAX_STEPS and MAX_PROPOSALS cap the run either way.

Point it at your own data

Inside the loop, the only string that mentions politeness is PROPOSER_TASK, and featurize() takes any list of strings. Rewrite the brief for your own label and text. Cached responses are looked up by prompt, so after an edit the next run calls the API again for every try. The request count grows with rows, not with questions: one request per row per try, so 100,000 rows is 100,000 requests a try, and MAX_PROPOSALS caps the number of tries. A revision is a new question, so its answers are fetched for every row too. The code sends four requests at a time. Eight at a time hit a rate limit on a shared key.

Read what the questions measure

The chart below shows five held-out requests against the questions the final model uses most: the top eight Score questions by importance, plus the three Noul questions the loop kept. The requests are the least polite, the most polite, and three evenly spaced between them. Each row of the chart is a question, and each column is a request, least polite on the left. The questions are sorted by which way their answer moves with the rating. Questions whose answer rises with politeness sit above the divider, and questions whose answer falls with it sit below. So reading left to right, the answers above the divider should climb and the answers below it should fall.
output The two least polite requests score high on the accusation, doubt, sarcasm and insult rows below the divider, and #2 is also the curtest. Request #3 opens with “Hey” and lights up the greeting row, and #4, “Could you please make it a subpage for me?”, is the one with a courtesy word. Request #5, the most polite, is an admin offering to do the job. It scores low on every row above the divider except the one about explaining a request. What makes it polite is the offer itself. The offer-of-help question that step 2 added ranks too low to make this chart, and it gives #5 a 3.9 out of 4.

Score every approach on the held-out rows

The cell below computes the table from the top of the page. All five approaches are scored once on the same 800 held-out rows, and the first three use none of the loop’s questions. The first predicts the mean dev rating for every row and reads nothing from the message. The second is the control: the same CatBoost, reading the raw text with its default text features. The third asks Jev for the rating directly. That third approach is one Score question per row over ten bands, from “insults the reader or is openly hostile” up to “exceptionally gracious and deferential”. Its answer is a level from 0 to 9, and nothing in the question says where those levels fall on this corpus’s rating scale. So the code fits a straight line from level to rating on the dev rows. The line’s two numbers, slope and intercept, are the only thing this approach learns from the ratings. In the printed table, vs mean is each approach’s RMSE divided by the RMSE of predicting the mean. The spearman column is rank correlation: 1.0 would mean the held-out requests come out in exactly the raters’ order. The control is CatBoost’s default text handling, not a tuned text model. All of this is one dataset and one run of the loop.

Check what the later steps add

The chart below plots error for the question set as it stood at the end of each step, starting with the proposer’s first call. The dashed line is the k-fold error on the check rows, the number each change is judged on. The solid line scores the same question set on the held-out rows, which the loop never reads. The interval under the title comes from resampling the held-out rows: drawing 800 rows at random, with repeats allowed, many times over, and scoring both question sets on each draw. It shows whether the change from the first step to the last is bigger than the noise in 800 rows.
output output Both lines stay inside a band 0.05 wide, and the three approaches from the table that use no questions would sit above the top of this chart. Check-row error fell at every step, from 0.450 to 0.423. Held-out error fell from 0.471 to 0.456, with one rise along the way, at step 3. The interval under the title runs from -0.026 to -0.003, which leaves out zero, so the four steps after the first lowered held-out error by more than the noise. Each later step kept one new question, and the log above shows them: offer_of_assistance in step 2, informal_slang_register in step 3, explicit_politeness_marker in step 4 and defensive_self_justification in step 5. Steps 2 and 5 needed more than one try. In step 2, every change from the first try failed the check. The second try saw that list with each change’s error, proposed something else, and its offer-of-help question cut check-row error by 0.009. Step 5 took all three tries. Most of the turned-down questions go after narrower kinds of impoliteness than step 1 asked about: rhetorical challenges, backhanded courtesy, negative labels for the reader, a lecturing tone. Each one raised check-row error or lowered it by less than MIN_GAIN. The proposer also tried rewording six of its step-1 questions and dropping two. Every one of those changes failed the check, so the step-1 wording stayed.
The importance share column is CatBoost’s feature importance, scaled so all the questions in the final set add up to 100%. It is not a share of rows, of questions, or of prediction accuracy. A Score question has two columns, its mean and its spread, so their two importances are added together before the percentage is printed. The top of the list is about hostility: hostile_accusation accounts for 11.8% on its own, and curt_terseness, rudeness_insult and doubt_questioning_competence are close behind. For the 2013 study this corpus comes from, Danescu-Niculescu-Mizil and colleagues built 20 politeness strategies by hand. Their impolite ones are surface forms: negative-sentiment words, direct questions, “in fact”, and a request that opens with “please” or “you”. The loop’s top questions judge the tone instead: whether the writer accuses the reader, is curt, insults them, or doubts their competence. Several of the study’s polite strategies made the set too. Three rank high: explicit_politeness_marker (“please” and similar, second at 9.4%), positive_framing_of_reader (the study’s deference, such as praise for the reader’s work) and gratitude_or_praise. Greetings, hedging, asking with a “we” and asking indirectly are in the set as well, each under 3%.

Next steps

This run keeps the loop small. Ways to extend it:
  • Screen a proposed question before paying to answer it for every row. Send the question itself to Jev as the state and ask Noul questions about it: can it be answered from the source text, does it mean one thing given its criteria, will its answer vary across rows. Answer only the questions that pass all three with a high enough probability.
  • Remove near-duplicate questions. Measure how closely the columns track each other on the dev rows, group the near-duplicates, and keep the clearest or most important question from each group.
  • Add simple baselines. Try TF-IDF (word counts weighted toward rarer words), character counts and other measures of the text’s shape on their own. Then add them to the discovered columns and measure what each one adds.
  • Use proposers from different model makers. Generate batches of questions with Anthropic, OpenAI, Google Gemini and open-source models, then merge them and remove duplicates before any reach Jev. Different model makers should produce a wider range of questions than repeated calls to one proposer.
  • Try other models. Fit linear or elastic-net regression, a support vector regressor, or a random forest on the same columns, and check whether the discovered questions help outside CatBoost. If the value you predict is a probability, also try recalibrating it so predicted probabilities match observed rates.
  • Add an embedding baseline. An embedding turns a message into a few hundred numbers with no question attached: sentence-transformers/all-MiniLM-L6-v2 runs locally, OpenAI’s text-embedding-3-small is a hosted call. Add one to the discovered columns and measure whether it carries anything they do not.
  • Split the data the way the model will be used. If you predict the future, split by date. If related rows must stay together, split by group. Keep a final test set that neither the loop nor your choice of model ever touches.
  • Change the stopping rule. Raise TRIES or MAX_STEPS for a longer search, or stop at a budget of Jev requests instead of a count of proposal calls.
  • Run a longer search in an agent’s Goal mode. Give it a metric, a budget and a rule for when to stop, then let it run more steps of proposing, scoring and revising.
  • Check which questions hold up. Rerun the loop with different seeds or data samples, and keep the questions that stay useful across runs, not the ones that matter on only one split.

Open it in the playground

The link below opens the TypeSafe playground with one request and every question the loop kept.
Open in the TypeSafe playground →