Instructions to use samwell/ncd-gemma4-e4b-lora with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use samwell/ncd-gemma4-e4b-lora with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="samwell/ncd-gemma4-e4b-lora") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] pipe(text=messages)# Load model directly from transformers import AutoProcessor, AutoModelForImageTextToText processor = AutoProcessor.from_pretrained("samwell/ncd-gemma4-e4b-lora") model = AutoModelForImageTextToText.from_pretrained("samwell/ncd-gemma4-e4b-lora") messages = [ { "role": "user", "content": [ {"type": "image", "url": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/p-blog/candy.JPG"}, {"type": "text", "text": "What animal is on the candy?"} ] }, ] inputs = processor.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(processor.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - llama-cpp-python
How to use samwell/ncd-gemma4-e4b-lora with llama-cpp-python:
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="samwell/ncd-gemma4-e4b-lora", filename="ncd-gemma4-q4_k_m.gguf", )
llm.create_chat_completion( messages = [ { "role": "user", "content": "What is the capital of France?" } ] ) - Notebooks
- Google Colab
- Kaggle
- Local Apps
- llama.cpp
How to use samwell/ncd-gemma4-e4b-lora with llama.cpp:
Install from brew
brew install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf samwell/ncd-gemma4-e4b-lora:Q4_K_M # Run inference directly in the terminal: llama-cli -hf samwell/ncd-gemma4-e4b-lora:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama-server -hf samwell/ncd-gemma4-e4b-lora:Q4_K_M # Run inference directly in the terminal: llama-cli -hf samwell/ncd-gemma4-e4b-lora:Q4_K_M
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf samwell/ncd-gemma4-e4b-lora:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf samwell/ncd-gemma4-e4b-lora:Q4_K_M
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf samwell/ncd-gemma4-e4b-lora:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf samwell/ncd-gemma4-e4b-lora:Q4_K_M
Use Docker
docker model run hf.co/samwell/ncd-gemma4-e4b-lora:Q4_K_M
- LM Studio
- Jan
- vLLM
How to use samwell/ncd-gemma4-e4b-lora with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "samwell/ncd-gemma4-e4b-lora" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "samwell/ncd-gemma4-e4b-lora", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/samwell/ncd-gemma4-e4b-lora:Q4_K_M
- SGLang
How to use samwell/ncd-gemma4-e4b-lora with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "samwell/ncd-gemma4-e4b-lora" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "samwell/ncd-gemma4-e4b-lora", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "samwell/ncd-gemma4-e4b-lora" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "samwell/ncd-gemma4-e4b-lora", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Ollama
How to use samwell/ncd-gemma4-e4b-lora with Ollama:
ollama run hf.co/samwell/ncd-gemma4-e4b-lora:Q4_K_M
- Unsloth Studio new
How to use samwell/ncd-gemma4-e4b-lora with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for samwell/ncd-gemma4-e4b-lora to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for samwell/ncd-gemma4-e4b-lora to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for samwell/ncd-gemma4-e4b-lora to start chatting
- Pi new
How to use samwell/ncd-gemma4-e4b-lora with Pi:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama-server -hf samwell/ncd-gemma4-e4b-lora:Q4_K_M
Configure the model in Pi
# Install Pi: npm install -g @mariozechner/pi-coding-agent # Add to ~/.pi/agent/models.json: { "providers": { "llama-cpp": { "baseUrl": "http://localhost:8080/v1", "api": "openai-completions", "apiKey": "none", "models": [ { "id": "samwell/ncd-gemma4-e4b-lora:Q4_K_M" } ] } } }Run Pi
# Start Pi in your project directory: pi
- Hermes Agent new
How to use samwell/ncd-gemma4-e4b-lora with Hermes Agent:
Start the llama.cpp server
# Install llama.cpp: brew install llama.cpp # Start a local OpenAI-compatible server: llama-server -hf samwell/ncd-gemma4-e4b-lora:Q4_K_M
Configure Hermes
# Install Hermes: curl -fsSL https://hermes-agent.nousresearch.com/install.sh | bash hermes setup # Point Hermes at the local server: hermes config set model.provider custom hermes config set model.base_url http://127.0.0.1:8080/v1 hermes config set model.default samwell/ncd-gemma4-e4b-lora:Q4_K_M
Run Hermes
hermes
- Docker Model Runner
How to use samwell/ncd-gemma4-e4b-lora with Docker Model Runner:
docker model run hf.co/samwell/ncd-gemma4-e4b-lora:Q4_K_M
- Lemonade
How to use samwell/ncd-gemma4-e4b-lora with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull samwell/ncd-gemma4-e4b-lora:Q4_K_M
Run and chat with the model
lemonade run user.ncd-gemma4-e4b-lora-Q4_K_M
List all available models
lemonade list
llm.create_chat_completion(
messages = [
{
"role": "user",
"content": "What is the capital of France?"
}
]
)NCD Risk Assessment Model (Gemma 4 E4B Fine-tuned)
A fine-tuned Gemma 4 E4B model for predicting Non-Communicable Disease (NCD) risk - specifically Type 2 Diabetes and Hypertension - from patient clinical data.
Model Description
This model was fine-tuned on 49,214 synthetic patient records to provide clinical decision support for NCD screening in resource-limited settings, particularly designed for deployment in Ghana and similar healthcare contexts.
| Attribute | Value |
|---|---|
| Base Model | google/gemma-4-E4B-it |
| Fine-tuning Method | QLoRA (4-bit) with Unsloth |
| LoRA Rank | 32 |
| Training Data | 39,371 examples |
| Final Loss | 0.1842 |
| Training Time | 100 minutes (H200 GPU) |
Intended Use
Primary Use Case: Clinical Decision Support (CDS) for NCD risk screening
Target Users:
- Healthcare workers in primary care settings
- Community health workers conducting NCD screenings
- EHR systems (e.g., OpenMRS/HopeOS) for automated risk assessment
Input: Patient demographics, vitals, and lab values Output: Structured risk assessment with clinical reasoning
Model Files
| File | Format | Size | Use Case |
|---|---|---|---|
adapter_model.safetensors |
LoRA | ~340MB | Fine-tuning, merging |
ncd-gemma4-q4_k_m.gguf |
GGUF | ~2.5GB | Local inference (llama.cpp, Ollama) |
How to Use
With Transformers + PEFT (LoRA)
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
# Load base model
base_model = AutoModelForCausalLM.from_pretrained("google/gemma-4-E4B-it")
tokenizer = AutoTokenizer.from_pretrained("google/gemma-4-E4B-it")
# Load LoRA adapter
model = PeftModel.from_pretrained(base_model, "samwell/ncd-gemma4-e4b-lora")
# Inference
prompt = """Based on the following patient record, assess the risk of Type 2 diabetes and hypertension.
Patient: 55yo Male
Vitals: BP 152/94 mmHg, BMI 31.2
Labs: Glucose 126 mg/dL, HbA1c 6.4%
Active conditions: Prediabetes"""
inputs = tokenizer(prompt, return_tensors="pt")
outputs = model.generate(**inputs, max_new_tokens=512)
print(tokenizer.decode(outputs[0]))
With llama.cpp (GGUF)
# Download GGUF
huggingface-cli download samwell/ncd-gemma4-e4b-lora ncd-gemma4-q4_k_m.gguf
# Run inference
./llama-cli -m ncd-gemma4-q4_k_m.gguf -p "Patient: 45yo Female, BP 140/90..."
With Ollama
# Create model
echo 'FROM ./ncd-gemma4-q4_k_m.gguf' > Modelfile
ollama create ncd-cds -f Modelfile
# Run
ollama run ncd-cds "Patient: 45yo Female, BP 140/90..."
Example Output
Input:
Patient: 55yo Male
Vitals: BP 152/94 mmHg, BMI 31.2
Labs: Glucose 126 mg/dL, HbA1c 6.4%
Active conditions: Prediabetes
Output:
## Risk Assessment
**Type 2 Diabetes: MODERATE**
- HbA1c 6.4% (prediabetes range 5.7-6.4%)
- BMI 31.2 (obese)
- Age 55 years (≥45 increases risk)
**Hypertension: HIGH**
- BP 152/94 mmHg (Stage 2 Hypertension)
- Systolic ≥140 or Diastolic ≥90 confirms diagnosis
## Recommendations
1. **Lifestyle modifications**: Weight loss, DASH diet, sodium reduction
2. **Blood pressure monitoring**: Home BP monitoring recommended
3. **Lab follow-up**: Repeat HbA1c in 3 months
4. **Consider referral**: If BP remains elevated, initiate antihypertensive therapy
Training Details
Dataset
- Source: Synthea synthetic patient generator
- Size: 49,214 examples (39,371 train / 4,921 val / 4,922 test)
- Format: Instruction-tuning (instruction/input/output)
- Dataset:
samwell/synthea-ncd-instructions
Training Configuration
# Model
MODEL_NAME = "google/gemma-4-E4B-it"
MAX_SEQ_LENGTH = 2048
LOAD_IN_4BIT = True # QLoRA
# LoRA
LORA_R = 32
LORA_ALPHA = 32
TARGET_MODULES = ["q_proj", "k_proj", "v_proj", "o_proj",
"gate_proj", "up_proj", "down_proj"]
# Training
BATCH_SIZE = 8
GRADIENT_ACCUMULATION = 2 # Effective batch = 16
LEARNING_RATE = 2e-4
NUM_EPOCHS = 3
Training Curve
- Initial loss: 1.71
- Final loss: 0.1842
- Training time: 100 minutes on NVIDIA H200 (80GB)
Limitations
- Synthetic data only: Trained on Synthea-generated data, not real patient records
- Limited NCDs: Currently only assesses diabetes and hypertension
- Not a diagnostic tool: Intended for screening support, not clinical diagnosis
- Requires clinical validation: Must be validated by healthcare professionals before clinical use
Ethical Considerations
- Not FDA/CE approved for clinical diagnosis
- Should be used as decision support, not replacement for clinical judgment
- Predictions should be reviewed by qualified healthcare providers
- Model may reflect biases in training data
Citation
@misc{ncd-gemma4-2026,
author = {HopeOS Team},
title = {NCD Risk Assessment Model: Fine-tuned Gemma 4 for Diabetes and Hypertension Prediction},
year = {2026},
publisher = {HuggingFace},
url = {https://huggingface.co/samwell/ncd-gemma4-e4b-lora}
}
Related Resources
- Dataset: samwell/synthea-ncd-instructions
- Base Model: google/gemma-4-E4B-it
- Training Library: Unsloth
License
This model is released under the Gemma license.
- Downloads last month
- 103
4-bit
# !pip install llama-cpp-python from llama_cpp import Llama llm = Llama.from_pretrained( repo_id="samwell/ncd-gemma4-e4b-lora", filename="ncd-gemma4-q4_k_m.gguf", )