Text Generation
PEFT
Safetensors
Transformers
medical
healthcare
africa
community-health
chw
lora
sft
trl
medgemma
conversational
Instructions to use electricsheepafrica/chewie-1.2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use electricsheepafrica/chewie-1.2 with PEFT:
from peft import PeftModel from transformers import AutoModelForCausalLM base_model = AutoModelForCausalLM.from_pretrained("google/medgemma-4b-it") model = PeftModel.from_pretrained(base_model, "electricsheepafrica/chewie-1.2") - Transformers
How to use electricsheepafrica/chewie-1.2 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="electricsheepafrica/chewie-1.2") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("electricsheepafrica/chewie-1.2", device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use electricsheepafrica/chewie-1.2 with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "electricsheepafrica/chewie-1.2" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "electricsheepafrica/chewie-1.2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/electricsheepafrica/chewie-1.2
- SGLang
How to use electricsheepafrica/chewie-1.2 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 "electricsheepafrica/chewie-1.2" \ --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": "electricsheepafrica/chewie-1.2", "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 "electricsheepafrica/chewie-1.2" \ --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": "electricsheepafrica/chewie-1.2", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use electricsheepafrica/chewie-1.2 with Docker Model Runner:
docker model run hf.co/electricsheepafrica/chewie-1.2
File size: 6,936 Bytes
caee9d6 c4c2795 caee9d6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 | ---
base_model: google/medgemma-4b-it
library_name: peft
pipeline_tag: text-generation
license: apache-2.0
language:
- en
- sw
- ha
- yo
- am
- zu
- fr
tags:
- medical
- healthcare
- africa
- community-health
- chw
- lora
- sft
- transformers
- trl
- medgemma
---
# Chewie 1.2: African Community Health Worker AI Assistant
<img src="https://huggingface.co/electricsheepafrica/chewie-1.2/resolve/main/chewie-banner.png" alt="Chewie Banner" width="100%"/>
**Chewie 1.2** is a medical AI assistant fine-tuned specifically for **Community Health Workers (CHWs)** in Africa. Built on Google's MedGemma-4B, it provides structured clinical guidance following a consistent **Assessment → Action → Advice** format.
## Model Details
### Model Description
Chewie 1.2 is a LoRA adapter fine-tuned on top of [google/medgemma-4b-it](https://huggingface.co/google/medgemma-4b-it) using a curated dataset of 11,880 multilingual medical conversations designed for community health settings in Africa.
- **Developed by:** [Electric Sheep Africa](https://huggingface.co/electricsheepafrica)
- **Model type:** Causal Language Model (LoRA Adapter)
- **Language(s):** English, Swahili, Hausa, Yoruba, Amharic, Zulu, French
- **License:** Apache 2.0
- **Finetuned from:** [google/medgemma-4b-it](https://huggingface.co/google/medgemma-4b-it)
### Model Sources
- **Repository:** [electricsheepafrica/chewie-1.2](https://huggingface.co/electricsheepafrica/chewie-1.2)
- **Previous Version:** [electricsheepafrica/chewie-llama-3b](https://huggingface.co/electricsheepafrica/chewie-llama-3b)
## Intended Use
### Primary Use Cases
- **Clinical Decision Support:** Helping CHWs assess symptoms and determine appropriate actions
- **Triage Assistance:** Identifying danger signs that require immediate referral
- **Health Education:** Providing patient-friendly explanations and preventive advice
- **Multilingual Support:** Serving diverse African language communities
### Target Users
- Community Health Workers (CHWs)
- Primary healthcare providers in resource-limited settings
- Health education programs
- Mobile health (mHealth) applications
### Out-of-Scope Use
- **NOT for direct patient diagnosis** - Always requires human clinical oversight
- **NOT a replacement for professional medical care**
- **NOT validated for emergency/critical care decisions**
- Should not be used without proper clinical supervision
## How to Get Started
### Installation
```bash
pip install transformers peft bitsandbytes accelerate
```
### Inference Code
```python
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer, BitsAndBytesConfig
from peft import PeftModel
# Load base model with 4-bit quantization
base_model_id = "google/medgemma-4b-it"
adapter_id = "electricsheepafrica/chewie-1.2"
bnb_config = BitsAndBytesConfig(
load_in_4bit=True,
bnb_4bit_use_double_quant=True,
bnb_4bit_quant_type="nf4",
bnb_4bit_compute_dtype=torch.float16,
)
# Load base model
base_model = AutoModelForCausalLM.from_pretrained(
base_model_id,
quantization_config=bnb_config,
attn_implementation="eager",
device_map="auto",
)
# Load adapter
model = PeftModel.from_pretrained(base_model, adapter_id)
tokenizer = AutoTokenizer.from_pretrained(adapter_id)
# Generate response
def chat(prompt):
messages = [{"role": "user", "content": prompt}]
inputs = tokenizer.apply_chat_template(
messages,
add_generation_prompt=True,
return_tensors="pt"
).to(model.device)
with torch.no_grad():
outputs = model.generate(
inputs,
max_new_tokens=512,
do_sample=True,
temperature=0.7,
top_p=0.9,
)
return tokenizer.decode(outputs[0][inputs.shape[1]:], skip_special_tokens=True)
# Example usage
response = chat("What are the danger signs in a child with diarrhea?")
print(response)
```
## Training Details
### Training Data
- **Dataset Size:** 11,880 examples
- **Languages:** English, Swahili, Hausa, Yoruba, Amharic, Zulu, French
- **Domain:** Community health, primary care, maternal/child health, infectious diseases
- **Format:** Structured Assessment → Action → Advice responses
### Training Procedure
- **Base Model:** google/medgemma-4b-it
- **Method:** LoRA (Low-Rank Adaptation)
- **Framework:** Hugging Face TRL (SFTTrainer)
#### Training Hyperparameters
| Parameter | Value |
|-----------|-------|
| LoRA Rank (r) | 16 |
| LoRA Alpha | 16 |
| LoRA Dropout | 0.05 |
| Target Modules | all-linear |
| Learning Rate | 2e-4 |
| Batch Size | 1-2 |
| Gradient Accumulation | 8-16 |
| Epochs | 1 |
| Precision | bf16/fp16 |
| Optimizer | AdamW (fused) |
#### Training Results
| Metric | Value |
|--------|-------|
| Final Training Loss | 1.08 |
| Final Validation Loss | 1.13 |
| Mean Token Accuracy | 72.5% |
| Training Time | ~1 hour |
### Compute Infrastructure
- **Hardware:** NVIDIA A100 40GB / T4 16GB (compatible with both)
- **Cloud Provider:** Google Colab
- **Training Framework:** Transformers, PEFT, TRL, BitsAndBytes
## Evaluation
### Sample Outputs
**Input:** "What are the symptoms of malaria?"
**Output:**
```
**Assessment:** Malaria can cause various symptoms, including fever, chills,
sweating, headache, muscle aches, nausea, vomiting, and fatigue. In severe
cases, it may lead to anemia, kidney failure, or brain damage.
**Action:** If you or someone you know has a high fever (above 102°F or 39°C),
persistent headaches, or unusual weakness, seek medical help immediately at
a clinic. These could be danger signs for severe malaria.
**Advice:** To prevent malaria, use insect repellent when outdoors, sleep
under mosquito nets, and take preventative medications if recommended by
your healthcare provider.
```
## Limitations and Risks
### Known Limitations
- Model outputs should always be verified by qualified healthcare professionals
- May not reflect the most current medical guidelines
- Performance may vary across different African languages
- Not trained on region-specific drug formularies or protocols
### Ethical Considerations
- This model is intended as a decision-support tool, not a replacement for clinical judgment
- Healthcare providers should use their professional expertise alongside model outputs
- Patient safety must always take precedence over model recommendations
## Citation
```bibtex
@misc{chewie-1.2,
author = {Electric Sheep Africa},
title = {Chewie 1.2: African Community Health Worker AI Assistant},
year = {2026},
publisher = {Hugging Face},
url = {https://huggingface.co/electricsheepafrica/chewie-1.2}
}
```
## Model Card Contact
- **Organization:** [Electric Sheep Africa](https://huggingface.co/electricsheepafrica)
- **Issues:** Please open an issue on the model repository
---
### Framework Versions
- PEFT: 0.18.0
- Transformers: 4.x
- TRL: 0.x
- BitsAndBytes: 0.x
- PyTorch: 2.x |