Nursing Citizen Development commited on
Commit
6131c9a
·
1 Parent(s): 6075804

Feat: Use merged MedGemma model (person-centred fine-tuned)

Browse files
Files changed (3) hide show
  1. README.md +2 -2
  2. merge_lora_adapter.ipynb +120 -0
  3. pna_client.py +2 -3
README.md CHANGED
@@ -17,9 +17,9 @@ An AI-powered tutor designed to guide nursing professionals through the **A-EQUI
17
  Automatically synced from GitHub via GitHub Actions.
18
 
19
  ## 🧠 Model Strategy
20
- - **Base Model**: `google/gemma-2-2b-it` (fast, ZeroGPU optimized, 2.5B params)
21
  - **Knowledge Base**: RAG implementation using the official PNA A-EQUIP guide.
22
- - **Persona**: Strong PNA Tutor system prompting for person-centred, restorative voice.
23
 
24
  ## ⚖️ Disclaimer
25
  This tool is for educational and supportive purposes for Professional Nurse Advocates and nursing staff. It does not provide direct clinical advice.
 
17
  Automatically synced from GitHub via GitHub Actions.
18
 
19
  ## 🧠 Model Strategy
20
+ - **Base Model**: `NurseCitizenDeveloper/relational-intelligence-medgemma-merged` (person-centred, fine-tuned on FONS principles)
21
  - **Knowledge Base**: RAG implementation using the official PNA A-EQUIP guide.
22
+ - **Persona**: Strong PNA Tutor system prompting for restorative supervision focus.
23
 
24
  ## ⚖️ Disclaimer
25
  This tool is for educational and supportive purposes for Professional Nurse Advocates and nursing staff. It does not provide direct clinical advice.
merge_lora_adapter.ipynb ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "nbformat": 4,
3
+ "nbformat_minor": 0,
4
+ "metadata": {
5
+ "colab": {
6
+ "provenance": [],
7
+ "gpuType": "T4"
8
+ },
9
+ "kernelspec": {
10
+ "name": "python3",
11
+ "display_name": "Python 3"
12
+ },
13
+ "accelerator": "GPU"
14
+ },
15
+ "cells": [
16
+ {
17
+ "cell_type": "markdown",
18
+ "source": [
19
+ "# 🔧 Merge LoRA Adapter to Full Model\n",
20
+ "\n",
21
+ "This notebook merges your Unsloth LoRA adapter with its base model and uploads the result to Hugging Face.\n",
22
+ "\n",
23
+ "**Before running:**\n",
24
+ "1. Go to Runtime > Change runtime type > Select **T4 GPU**\n",
25
+ "2. Have your Hugging Face **Write Token** ready"
26
+ ],
27
+ "metadata": {}
28
+ },
29
+ {
30
+ "cell_type": "code",
31
+ "source": [
32
+ "# Step 1: Install dependencies\n",
33
+ "!pip install unsloth transformers accelerate bitsandbytes -q"
34
+ ],
35
+ "metadata": {},
36
+ "execution_count": null,
37
+ "outputs": []
38
+ },
39
+ {
40
+ "cell_type": "code",
41
+ "source": [
42
+ "# Step 2: Login to Hugging Face\n",
43
+ "from huggingface_hub import login\n",
44
+ "\n",
45
+ "# Paste your HF token when prompted\n",
46
+ "login()"
47
+ ],
48
+ "metadata": {},
49
+ "execution_count": null,
50
+ "outputs": []
51
+ },
52
+ {
53
+ "cell_type": "code",
54
+ "source": [
55
+ "# Step 3: Configuration\n",
56
+ "# =====================\n",
57
+ "# Change these values to match your model\n",
58
+ "\n",
59
+ "ADAPTER_MODEL = \"NurseCitizenDeveloper/relational-intelligence-unsloth-medgemma\" # Your LoRA adapter\n",
60
+ "OUTPUT_NAME = \"NurseCitizenDeveloper/relational-intelligence-medgemma-merged\" # Where to save merged model\n",
61
+ "MAX_SEQ_LENGTH = 2048"
62
+ ],
63
+ "metadata": {},
64
+ "execution_count": null,
65
+ "outputs": []
66
+ },
67
+ {
68
+ "cell_type": "code",
69
+ "source": [
70
+ "# Step 4: Load the adapter model\n",
71
+ "from unsloth import FastLanguageModel\n",
72
+ "\n",
73
+ "print(f\"Loading adapter: {ADAPTER_MODEL}\")\n",
74
+ "\n",
75
+ "model, tokenizer = FastLanguageModel.from_pretrained(\n",
76
+ " model_name=ADAPTER_MODEL,\n",
77
+ " max_seq_length=MAX_SEQ_LENGTH,\n",
78
+ " dtype=None, # Auto-detect\n",
79
+ " load_in_4bit=True,\n",
80
+ ")\n",
81
+ "\n",
82
+ "print(\"✅ Model loaded successfully!\")"
83
+ ],
84
+ "metadata": {},
85
+ "execution_count": null,
86
+ "outputs": []
87
+ },
88
+ {
89
+ "cell_type": "code",
90
+ "source": [
91
+ "# Step 5: Merge and push to Hugging Face\n",
92
+ "print(f\"Merging adapter and pushing to: {OUTPUT_NAME}\")\n",
93
+ "\n",
94
+ "model.push_to_hub_merged(\n",
95
+ " OUTPUT_NAME,\n",
96
+ " tokenizer,\n",
97
+ " save_method=\"merged_16bit\", # Full precision merged model\n",
98
+ ")\n",
99
+ "\n",
100
+ "print(\"🎉 Done! Your merged model is now available at:\")\n",
101
+ "print(f\"https://huggingface.co/{OUTPUT_NAME}\")"
102
+ ],
103
+ "metadata": {},
104
+ "execution_count": null,
105
+ "outputs": []
106
+ },
107
+ {
108
+ "cell_type": "markdown",
109
+ "source": [
110
+ "## ✅ Next Steps\n",
111
+ "\n",
112
+ "Once the upload completes:\n",
113
+ "1. Go to your new model page on Hugging Face\n",
114
+ "2. Verify it has a `model.safetensors` file\n",
115
+ "3. Update your PNA Assistant to use the new merged model ID"
116
+ ],
117
+ "metadata": {}
118
+ }
119
+ ]
120
+ }
pna_client.py CHANGED
@@ -4,9 +4,8 @@ from transformers import AutoModelForCausalLM, AutoTokenizer
4
  import spaces
5
 
6
  class PNAAssistantClient:
7
- # Using google/gemma-2-2b-it - a fast, reliable model that works on ZeroGPU
8
- # Person-centred voice is achieved through strong PNA system prompting
9
- def __init__(self, model_id="google/gemma-2-2b-it"):
10
  self.model_id = model_id
11
  self.device = "cuda" if torch.cuda.is_available() else "cpu"
12
  self.tokenizer = None
 
4
  import spaces
5
 
6
  class PNAAssistantClient:
7
+ # Using user's merged MedGemma model - trained on person-centred language
8
+ def __init__(self, model_id="NurseCitizenDeveloper/relational-intelligence-medgemma-merged"):
 
9
  self.model_id = model_id
10
  self.device = "cuda" if torch.cuda.is_available() else "cpu"
11
  self.tokenizer = None