Views
No views yet
Intelligence, Distilled.
70830d12)1from transformers import AutoModelForCausalLM, AutoTokenizer
2
3model_id = "Sayan25/smolified-file-context-extractor"
4tokenizer = AutoTokenizer.from_pretrained(model_id)
5model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto")
6
7messages = [
8 {"role": "system", "content": '''You are an legal analyst.'''},
9 {"role": "user", "content": '''Review this standard Service Level Agreement (SLA). The vendor guarantees 99.9% uptime. Failure to meet this results in 10% credit to the client account. Liability is capped at the total amount paid in the previous 12 months. Confidentiality clause remains valid for three years post-termination.'''}
10]
11text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True).removeprefix('<bos>')
12
13from transformers import TextStreamer
14_ = model.generate(**tokenizer(text, return_tensors="pt").to("cuda"), max_new_tokens=1000, streamer=TextStreamer(tokenizer, skip_prompt=True))