Views
No views yet
Intelligence, Distilled.
45bc0538)1# Example: Running your Sovereign Model
2from transformers import AutoModelForCausalLM, AutoTokenizer
3
4model_id = "smolify/smolified-45bc0538"
5tokenizer = AutoTokenizer.from_pretrained(model_id)
6model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto")
7
8messages = [
9 {'role': 'system', 'content': '''You are a clinical documentation assistant. Convert the provided patient-physician transcript into a concise, accurate SOAP note without adding outside information.'''},
10 {'role': 'user', 'content': '''Dr: What brings you in today? Patient: My lower back has been killing me for two weeks since I lifted those boxes. It shoots down my left leg sometimes. Dr: Let's see. You have decreased range of motion in the spine. Straight leg raise test is positive on the left. Reflexes are normal. Assessment is likely a disc herniation. I want you to start physical therapy and take Naproxen.'''}
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)