Personal Jurisdiction GRPO
Qwen3.5-4B fine-tuned via GRPO to classify whether a US state court has personal jurisdiction over a defendant. The model decomposes the question into three doctrinal yes/no sub-questions (domicile, sufficient contacts, nexus), applies a deterministic routing rule, and outputs a Yes/No final classification.
This repository contains the merged LoRA adapter (r=16, alpha=16) trained on a 2,000-example synthetic corpus and evaluated against the LegalBench personal_jurisdiction test set.
Important: this model only works with the specific system prompt below and with
enable_thinking=False. The model was trained to emit a strict 4-line format; without the system prompt or with thinking mode on, output will be unreliable.
Links
- Base model: Qwen/Qwen3.5-4B
- Training environment: smolclaims/pj on Prime Intellect
- Benchmark: LegalBench personal_jurisdiction
- Training data: DoodDood/personal-jurisdiction-grpo — the 2,000-row synthetic corpus this adapter was GRPO-trained on.
Results
On the 50-row LegalBench personal_jurisdiction test set (non-thinking inference, greedy decoding):
| Slice | Base Qwen3.5-4B | This model | Δ |
|---|---|---|---|
| Domicile | 30.0% | 40.0% | +10.0 |
| No contacts, no nexus | 100.0% | 100.0% | 0.0 |
| Yes contacts, no nexus | 87.5% | 100.0% | +12.5 |
| Yes contacts, yes nexus | 25.0% | 41.7% | +16.7 |
| Overall | 66.0% | 74.0% | +8.0 |
The base model exhibited a complete Q1 collapse — it never said "Q1 = Yes" on any row of the eval set, even on textbook domicile cases. This checkpoint catches Q1 firing correctly on actual domicile cases without leaking into the no-contacts class. Zero slice regressions.
Output format
The model emits exactly four lines and nothing else:
Q1: [Yes/No]
Q2: [Yes/No]
Q3: [Yes/No]
FINAL_CLASSIFICATION: [Yes/No]
- Q1 — Domicile: is the defendant domiciled in the forum state (general jurisdiction)
- Q2 — Sufficient Contacts: purposeful availment in the forum
- Q3 — Nexus: claim arises out of or relates to those forum contacts
Routing rule (deterministic, applied to the model own Q-answers):
- If Q1 = Yes -> Yes (general jurisdiction)
- Else if Q2 = Yes AND Q3 = Yes -> Yes (specific jurisdiction)
- Else -> No
Usage
1. Install
pip install transformers accelerate torch
2. System prompt (required — do not modify)
SYSTEM_PROMPT = """You are a personal jurisdiction classifier. Given a fact pattern about a lawsuit, decide whether the court in the forum state where the suit was filed has personal jurisdiction over the defendant.
There is personal jurisdiction over a defendant in the forum state when EITHER:
(a) the defendant is domiciled in the forum state (general jurisdiction), OR
(b) (i) the defendant has sufficient contacts with the forum state such that they have purposefully availed themselves of the privileges of the state, AND (ii) the plaintiff's claim arises out of or relates to those contacts (nexus).
Answer three questions about the fact pattern, then provide a final classification. The forum state is the state in which the lawsuit is filed.
Q1 — Domicile. Is the defendant domiciled in the forum state at the time the lawsuit is filed? A plan or intent to move to the forum state does not establish domicile; the defendant must actually be present in the state with intent to remain.
Q2 — Sufficient Contacts. Has the defendant purposefully availed themselves of the privileges of conducting activities in the forum state? Brief, isolated, or unrelated visits — such as vacationing, passing through, or being injured in the state without more — generally do not count. Conducting regular business, residing, or actively soliciting in the state does.
Q3 — Nexus. Does the plaintiff's claim arise out of or relate to the defendant's contacts with the forum state? The claim must connect to the activities the defendant carried out in the forum state, not merely be coincident with the defendant's presence there.
Apply this routing rule to determine the final classification:
- If Q1 = Yes, classify as Yes (general jurisdiction)
- Else if Q2 = Yes AND Q3 = Yes, classify as Yes (specific jurisdiction)
- Else, classify as No
Respond in exactly this format with no other text:
Q1: [Yes/No]
Q2: [Yes/No]
Q3: [Yes/No]
FINAL_CLASSIFICATION: [Yes/No]"""
3. Load and run
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
MODEL = "DoodDood/Personal-Jurisdiction-GRPO"
dtype = torch.bfloat16
tok = AutoTokenizer.from_pretrained(MODEL)
model = AutoModelForCausalLM.from_pretrained(MODEL, torch_dtype=dtype, device_map="auto")
model.eval()
def classify(fact_pattern: str) -> str:
msgs = [
{"role": "system", "content": SYSTEM_PROMPT},
{"role": "user", "content": fact_pattern},
]
prompt = tok.apply_chat_template(
msgs, tokenize=False, add_generation_prompt=True,
enable_thinking=False,
)
inputs = tok(prompt, return_tensors="pt").to(model.device)
with torch.no_grad():
out = model.generate(
**inputs, max_new_tokens=96, do_sample=False,
pad_token_id=tok.eos_token_id,
)
return tok.decode(out[0][inputs.input_ids.shape[1]:], skip_special_tokens=True)
# Example: defendant domiciled in the forum (general jurisdiction)
print(classify(
"Maria is a doctor who has lived in Ohio for the past twelve years. "
"While driving home from work in Ohio, she rear-ends Pedro, a citizen of "
"Indiana visiting Ohio for a concert. Pedro sues Maria in Ohio."
))
# Expected: Q1: Yes, then Q2-Q3 either, then FINAL_CLASSIFICATION: Yes
Important caveats
- Do not modify the system prompt. The model was trained against this exact prompt, including the Q numbering and routing rule. Changes will degrade output.
- Always use
enable_thinking=False. The model was trained on non-thinking forward passes; thinking-mode inference produces unreliable outputs. - Greedy decoding only. Sampling adds noise to a strict-format task. Use
do_sample=False. - Match the LegalBench surface form. Fact patterns phrased as 3-5 sentence brief paragraphs naming the defendant, their connection to states, the cause of action, and the forum where suit is filed work best. Anything substantially longer or more discursive drifts from the training distribution.
Training
Trained via GRPO on the smolclaims/pj verifiers environment hosted on Prime Intellect, using a 2,000-example synthetic corpus built by parallel orchestrated agents across 100 batches. A cross-family blind audit pass (Claude relabeling Gemini-generated rows on a 130-row stratified sample) found 99.2% slice agreement; 4 doctrinally clear errors were corrected by hand.
Corpus composition weighted to attack the base model's Q1-collapse failure mode:
| Slice | Count |
|---|---|
| Domicile / Yes | 500 |
| Domicile / No (plan-to-move traps) | 100 |
| Yes contacts, yes nexus / Yes | 500 |
| Yes contacts, no nexus / No | 396 |
| No contacts, no nexus / No | 504 |
| Total | 2,000 |
Reward stack (5 functions, default weights (1.0, 0.3, 0.2, 0.15, 0.3)):
final_accuracy_reward— +1/-1 on the final Yes/No. Dominant signal.decisive_q_reward— +1/-1 on the dispositive sub-element for the true label. Designed specifically to push Q1=Yes for Domicile cases.consistency_bonus— +1 only when final correct AND decisive Q correct. Gated to block format-carries-wrong-answer hacks.routing_consistency_reward— +1 when stated FINAL matches the routing of the model's own Q-answers.routed_truth_reward— +1 when the Q-chain routes to the true label.
300 GRPO steps, batch 128, 16 rollouts/example, LR 1e-4, LoRA r=16 alpha=16 on Qwen3.5-4B. Checkpoint step 150 was selected after sweeping multiple candidates against the LegalBench eval — step 150 caught the Q1 lift on Domicile cases (+10 pts) without yet over-firing on no-contacts cases (NCNN stayed at 100%).
Method context
This is the third project in a series applying the same GRPO reward shape (final-accuracy dominant + decisive-element gated bonus + routing-coherence signals) to different doctrinal decomposition shapes:
- TOMAGPT — hearsay 3-element conjunction (binary).
- Abercrombie-GRPO — trademark distinctiveness ordinal 5-class.
- Personal-Jurisdiction-GRPO (this) — binary jurisdiction with a general/specific routing switch over conjunction.
Each project targeted a different doctrinal shape; the same reward stack landed all three.
License
Apache 2.0, matching the base model.