Spaces:
Sleeping
Sleeping
| import gradio as gr | |
| from transformers import AutoModelForCausalLM, AutoTokenizer | |
| import torch | |
| MODEL_ID = "thaddickson/Delphi-7B-v2" | |
| SYSTEM = "You are Delphi, a 7B reasoning model built by Thaddeus Dickson at Xpio Health. You think through problems step by step. You don't hedge. You say what you mean. You trace root causes. You name specific standards, tools, and codes." | |
| tokenizer = AutoTokenizer.from_pretrained(MODEL_ID) | |
| model = AutoModelForCausalLM.from_pretrained(MODEL_ID, torch_dtype=torch.bfloat16, device_map="auto") | |
| def respond(message, history): | |
| messages = [{"role": "system", "content": SYSTEM}] | |
| for h in history: | |
| messages.append({"role": "user", "content": h[0]}) | |
| if h[1]: | |
| messages.append({"role": "assistant", "content": h[1]}) | |
| messages.append({"role": "user", "content": message}) | |
| text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True) | |
| inputs = tokenizer(text, return_tensors="pt").to(model.device) | |
| with torch.no_grad(): | |
| out = model.generate(**inputs, max_new_tokens=512, temperature=0.3, do_sample=True, repetition_penalty=1.3, pad_token_id=tokenizer.pad_token_id) | |
| return tokenizer.decode(out[0][inputs["input_ids"].shape[1]:], skip_special_tokens=True) | |
| demo = gr.ChatInterface( | |
| respond, | |
| title="Delphi-7B | Healthcare Cybersecurity AI", | |
| description="Built by Thaddeus Dickson at Xpio Health. Ask about HIPAA, breach response, HL7 troubleshooting, security architecture, or clinical operations.", | |
| examples=[ | |
| "A hospital just failed their first HIPAA risk assessment. What do you tell the CEO?", | |
| "Our HL7 ADT feed is creating duplicate patients in the MPI. Walk me through the diagnosis.", | |
| "What makes you different from ChatGPT?", | |
| "A vendor says they are HIPAA compliant. Should I trust that?", | |
| ], | |
| ) | |
| demo.launch() | |