Views
No views yet
Qwen/Qwen3.5-4B, trained with GRPO to classify trademarks on the Abercrombie distinctiveness spectrum (Generic / Descriptive / Suggestive / Arbitrary / Fanciful).Important: this adapter only works with the specific system prompt below and withenable_thinking=False. The model was trained to emit a strict 6-line format; without the system prompt or with thinking mode on, output will be unreliable.
| Category | Base Qwen3.5-4B | + Abercrombie-GRPO LoRA | Delta |
|---|---|---|---|
| Generic | 89% | 100% | +11 |
| Descriptive | 100% | 74% | -26 |
| Suggestive | 5% | 26% | +21 |
| Arbitrary | 0% | 47% | +47 |
| Fanciful | 5% | 95% | +90 |
| Overall | 40.0% | 68.4% | +28.4 |
Q1: [Yes/No]
Q2: [Yes/No]
Q3: [Yes/No]
Q4: [Yes/No]
Q5: [Yes/No]
FINAL_CLASSIFICATION: [Generic/Descriptive/Suggestive/Arbitrary/Fanciful]pip install transformers accelerate peft torch1SYSTEM_PROMPT = """You are a trademark distinctiveness classifier. Given a mark and the goods or services it identifies, classify the mark on the Abercrombie spectrum: Generic, Descriptive, Suggestive, Arbitrary, or Fanciful.
2
3Answer five questions about the mark, then provide a final classification. Evaluate each question in relation to the specific goods or services and the relevant purchasing public. Treat the mark as a whole; do not decompose compound marks into separate components.
4
5Q1 - Coined Term Test. Is the mark an invented term created solely for trademark use, with no prior independent meaning?
6
7Q2 - Semantic Relationship Test. Does the mark's ordinary dictionary meaning have any plausible semantic relationship to the goods or services?
8
9Q3 - Imagination Test. Must the consumer use imagination, thought, or a multi-step mental process to connect the mark to the nature of the goods or services?
10
11Q4 - Immediate Conveyance Test. Does the mark immediately convey an idea of a feature, quality, function, ingredient, or characteristic of the goods or services to the relevant purchasing public?
12
13Q5 - Genus Test. Does the relevant purchasing public understand the mark primarily as the name of the general category of goods or services, rather than as an indicator of source?
14
15When Q2=Yes and Q5=No, exactly one of Q3 or Q4 must be Yes: a semantically-related, non-generic mark is either descriptively immediate or suggestively imaginative, never neither.
16
17Apply this routing rule to determine the final classification:
18- If Q1 = Yes, classify as Fanciful
19- Else if Q2 = No, classify as Arbitrary
20- Else if Q5 = Yes, classify as Generic
21- Else if Q4 = Yes, classify as Descriptive
22- Else if Q3 = Yes, classify as Suggestive
23
24Respond in exactly this format with no other text:
25Q1: [Yes/No]
26Q2: [Yes/No]
27Q3: [Yes/No]
28Q4: [Yes/No]
29Q5: [Yes/No]
30FINAL_CLASSIFICATION: [Generic/Descriptive/Suggestive/Arbitrary/Fanciful]"""1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer
3from peft import PeftModel
4
5BASE = "Qwen/Qwen3.5-4B"
6LORA = "DoodDood/abercrombie-grpo"
7dtype = torch.bfloat16
8
9tok = AutoTokenizer.from_pretrained(BASE)
10model = AutoModelForCausalLM.from_pretrained(BASE, torch_dtype=dtype, device_map="auto")
11model = PeftModel.from_pretrained(model, LORA)
12model.eval()
13
14def classify(mark_and_goods: str) -> str:
15 msgs = [
16 {"role": "system", "content": SYSTEM_PROMPT},
17 {"role": "user", "content": mark_and_goods},
18 ]
19 prompt = tok.apply_chat_template(
20 msgs, tokenize=False, add_generation_prompt=True,
21 enable_thinking=False,
22 )
23 inputs = tok(prompt, return_tensors="pt").to(model.device)
24 with torch.no_grad():
25 out = model.generate(
26 **inputs, max_new_tokens=128, do_sample=False,
27 pad_token_id=tok.eos_token_id,
28 )
29 return tok.decode(out[0][inputs.input_ids.shape[1]:], skip_special_tokens=True)
30
31# Input format: `The mark "X" for Y.` (matches LegalBench phrasing)
32print(classify('The mark "Kodak" for cameras.'))
33# Expected: Q1: Yes, Q2-Q5: No, FINAL_CLASSIFICATION: Fanciful
34
35print(classify('The mark "Apple" for personal computers.'))
36# Expected: Q1: No, Q2: No, ..., FINAL_CLASSIFICATION: Arbitrary
37
38print(classify('The mark "Salt" for packages of sodium chloride.'))
39# Expected: Q1-Q4: No, Q5: Yes, FINAL_CLASSIFICATION: Genericenable_thinking=False. The adapter was shaped on non-thinking forward passes; thinking-mode inference produces unreliable outputs.do_sample=False.The mark "X" for Y. This matches the LegalBench surface form the model was trained on. Other phrasings may work but are not guaranteed.