Views
No views yet
1from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
2from peft import PeftModel
3import torch
4
5# Load base model with 4-bit quantization
6bnb_config = BitsAndBytesConfig(
7 load_in_4bit=True,
8 bnb_4bit_quant_type="nf4",
9 bnb_4bit_compute_dtype=torch.bfloat16,
10)
11
12base_model = AutoModelForCausalLM.from_pretrained(
13 "mistralai/Mistral-7B-Instruct-v0.3",
14 quantization_config=bnb_config,
15 device_map="auto",
16)
17
18# Load LoRA adapters
19model = PeftModel.from_pretrained(
20 base_model,
21 "TesterColab/Mistral-BP-LLMV5",
22)
23
24tokenizer = AutoTokenizer.from_pretrained("mistralai/Mistral-7B-Instruct-v0.3")1from bp_assistant import BPAssistant
2
3# Initialize (will download adapters automatically)
4assistant = BPAssistant(
5 model_path="TesterColab/Mistral-BP-LLMV5",
6 base_model="mistralai/Mistral-7B-Instruct-v0.3",
7)
8
9# Parse voice input
10result = assistant.parse_voice_input("My BP is 135 over 88")
11print(result)
12# {'systolic': 135, 'diastolic': 88, 'extracted': True}
13
14# Quick check
15check = assistant.quick_check(135, 88)
16print(check['spoken_message'])
17# "Your blood pressure is 135 over 88, which is elevated..."
18
19# Get medical advice
20advice = assistant.get_medical_advice(
21 "What should I do about my high blood pressure?",
22 context="Current BP: 145/92"
23)
24print(advice)adapter_config.json: LoRA configurationadapter_model.safetensors: LoRA weights (small file, ~100MB)README.md: This file1@misc{bp_monitoring_lora,
2 title={BP Monitoring LLM - LoRA Adapters},
3 author={Your Name},
4 year={2024},
5 publisher={Hugging Face},
6 url={https://huggingface.co/TesterColab/Mistral-BP-LLMV5}
7}