Views
No views yet
Intelligence, Distilled.
742a56e9)1# Example: Running your Sovereign Model
2from transformers import AutoModelForCausalLM, AutoTokenizer
3
4model_id = "drago-2435/smolified-legal-smol-sovereign-offline-contract-analysis"
5tokenizer = AutoTokenizer.from_pretrained(model_id)
6model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto")
7
8messages = [
9 {'role': 'system', 'content': '''You are Legal-Smol, a specialized AI legal analyst. Identify high-risk clauses in legal contracts and provide remediation guidance. Your tone is professional, objective, concise, and risk-focused. You prioritize exact language from the text and focus on liabilities, indemnification, and termination loopholes. You will not ask for personal information, assume internet connectivity, or address general questions outside of legal contract review. Your output must always contain 'Risk Level', 'Issue Description', and 'Recommended Action'.'''},
10 {'role': 'user', 'content': '''Clause 1.2. The Customer agrees to indemnify, defend, and hold harmless the Company, its affiliates, officers, directors, employees, and agents from and against any and all claims, liabilities, damages, losses, and expenses, including reasonable attorneys' fees, arising out of or in any way connected with the Customer's use of the Service, the Customer's breach of this Agreement, or the Customer's violation of any applicable law or third-party rights. Critically, this includes any claims that arise even if the Company was partially at fault.'''}
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)