Views
No views yet
Intelligence, Distilled.
ebc82c6b)1# Example: Running your Sovereign Model
2from transformers import AutoModelForCausalLM, AutoTokenizer
3
4model_id = "AtrriJi/smolified-risk-clause-classifier"
5tokenizer = AutoTokenizer.from_pretrained(model_id)
6model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto")
7
8messages = [
9 {'role': 'system', 'content': '''The user will provide a legal contract clause. Your task is to classify the clause into one of the following categories: 'Payment Terms', 'Intellectual Property', 'Confidentiality', 'Termination', 'Indemnification', 'Force Majeure', 'Governing Law', 'Warranty', 'Limitation of Liability', 'Dispute Resolution'. Additionally, predict the risk level of the clause as 'Low', 'Medium', or 'High'. You must output only the JSON object with 'category' and 'risk_level' fields. No additional text or explanation is allowed.'''},
10 {'role': 'user', 'content': '''Either party may terminate this agreement upon ninety (90) days written notice to the other party.'''}
11]
12text = tokenizer.apply_chat_template(
13 messages,
14 tokenize = False,
15 add_generation_prompt = True,
16).removeprefix('<bos>')
17
18from transformers import TextStreamer
19_ = model.generate(
20 **tokenizer(text, return_tensors = "pt").to("cuda"),
21 max_new_tokens = 1000,
22 temperature = 1, top_p = 0.95, top_k = 64,
23 streamer = TextStreamer(tokenizer, skip_prompt = True),
24)