from vllm import LLM, SamplingParams
from vllm.sampling_params import GuidedDecodingParams
LABELS = ['Affiliate License-Licensee', 'Affiliate License-Licensor', 'Agreement Date', 'Anti-Assignment', 'Audit Rights', 'Cap On Liability', 'Change Of Control', 'Competitive Restriction Exception', 'Covenant Not To Sue', 'Document Name', 'Effective Date', 'Exclusivity', 'Expiration Date', 'Governing Law', 'Insurance', 'Ip Ownership Assignment', 'Irrevocable Or Perpetual License', 'Joint Ip Ownership', 'License Grant', 'Liquidated Damages', 'Minimum Commitment', 'Most Favored Nation', 'No-Solicit Of Customers', 'No-Solicit Of Employees', 'Non-Compete', 'Non-Disparagement', 'Non-Transferable License', 'None Of The Above', 'Notice Period To Terminate Renewal', 'Parties', 'Post-Termination Services', 'Price Restrictions', 'Renewal Term', 'Revenue/Profit Sharing', 'Rofr/Rofo/Rofn', 'Source Code Escrow', 'Termination For Convenience', 'Third Party Beneficiary', 'Uncapped Liability', 'Unlimited/All-You-Can-Eat-License', 'Volume Restriction', 'Warranty Duration']
SYSTEM = (
"You are a legal contract clause classifier. "
"Classify the given clause into exactly one of these categories:\n"
+ "\n".join(f"- {l}" for l in LABELS)
+ "\n\nRespond with only the category name, nothing else."
)
llm = LLM(model="imvbhuvan/qwen3-4b-cuad-clause-cls", max_model_len=2048)
params = SamplingParams(temperature=0.0, max_tokens=12,
guided_decoding=GuidedDecodingParams(choice=LABELS))
out = llm.chat([[{"role": "system", "content": SYSTEM},
{"role": "user", "content": "<clause text>"}]],
sampling_params=params)
print(out[0].outputs[0].text)