Downloads · 30 days
0
wcosmas/sbcc-qwen
sbcc-qwen is a machine learning model from wcosmas. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as apache-2.0.
Fine-tuned Qwen2.5-7B model for generating Social and Behavior Change Communication (SBCC) messages for rural health and agriculture practices.
Downloads · 30 days
0
Access
Public
Updated Nov 26, 2025
Repo size
657 MB
Likes
0
Public
Click a slice to open those files.
.safetensors646 MB · 98%
From the Hugging Face model README
Fine-tuned Qwen2.5-7B model for generating Social and Behavior Change Communication (SBCC) messages for rural health and agriculture practices.
This model generates contextually appropriate, culturally sensitive health and agriculture messages that:
Base Model: unsloth/Qwen2.5-7B-Instruct-bnb-4bit Fine-tuning Method: QLoRA with 4-bit quantization Training Framework: Unsloth + TRL
pip install transformers torch unsloth
import json
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
# Load model and tokenizer
model_name = "wcosmas/sbcc-qwen"
model = AutoModelForCausalLM.from_pretrained(
model_name,
torch_dtype=torch.float16,
device_map="auto"
)
tokenizer = AutoTokenizer.from_pretrained(model_name)
# System prompt (critical for quality output)
SYSTEM_PROMPT = '''You write natural, helpful SBCC messages for rural households.
CRITICAL RULES:
1. NEVER use formulaic openings like "It's easy to forget..." or "It's normal to feel..."
2. Each opening must be UNIQUE and match the specific barrier emotion
3. Vary your language - don't repeat phrases across messages
4. Natural conversational tone (like talking to a neighbor, not a script)
5. Address the ACTUAL barrier constraint with alternatives that work WITHIN limitations
SBCC MESSAGE QUALITY METRICS:
- ACCURATE: Information is factually correct, evidence-based
- CLEAR: Simple language, specific implementable steps
- RESPECTFUL: Maintains dignity, respects local practices
- ENCOURAGING: Motivates positive behavior change
CRITICAL REQUIREMENTS:
1. DIRECTLY address barrier with alternatives that work WITHIN limitations
2. NATURAL MESSAGE STRUCTURE (4 parts, 260-343 chars):
- Acknowledge SPECIFIC barrier naturally
- Practical solution WITHIN the limitation
- Concrete details (measurements, materials, steps)
- Tangible benefit
3. LENGTH: 260-343 characters (STRICT)
4. FORMAT: Plain text, NO markdown, NO greetings
Return valid JSON: {"practice": "...", "barrier": "...", "message_type": "...", "sbcc_message": "...", "additional_instructions": "...", "deficiencies": [...]}'''
def generate_sbcc_message(practice, message_type="adoption", barrier=None, deficiencies=None):
# Prepare input
input_data = {"practice": practice, "message_type": message_type}
if barrier:
input_data["barrier_text"] = barrier
if deficiencies:
input_data["deficiencies"] = deficiencies
# Build prompt
user_msg = f"Generate an SBCC message for: {json.dumps(input_data, ensure_ascii=False)}"
prompt = f"<|im_start|>system\n{SYSTEM_PROMPT}<|im_end|>\n<|im_start|>user\n{user_msg}<|im_end|>\n<|im_start|>assistant\n"
# Tokenize
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
# Generate
with torch.no_grad():
outputs = model.generate(
**inputs,
max_new_tokens=300,
temperature=0.3,
do_sample=True,
pad_token_id=tokenizer.eos_token_id
)
# Decode
response = tokenizer.decode(
outputs[0][len(inputs["input_ids"][0]):],
skip_special_tokens=True
).strip()
# Parse JSON
try:
return json.loads(response)
except json.JSONDecodeError:
return {
"practice": practice,
"barrier": barrier,
"message_type": message_type,
"sbcc_message": response,
"deficiencies": deficiencies or []
}
# Example usage
result = generate_sbcc_message(
practice="Handwashing",
message_type="adoption",
barrier="Soap is too expensive for daily use"
)
print(f"Message: {result['sbcc_message']}")
print(f"Length: {len(result['sbcc_message'])} characters")
Input:
{
"practice": "Handwashing",
"message_type": "adoption",
"barrier_text": "Soap is too expensive for daily use"
}
Output:
"I understand soap can be costly. You can make simple handwashing solution with ash and water—mix 1 cup wood ash with 2 cups water, strain it. Use this solution to wash hands after toilet and before cooking. This costs nothing and still removes germs effectively to protect your family's health."
Input:
{
"practice": "Pit Composting",
"message_type": "adoption",
"barrier_text": "Land size is too small for proper composting"
}
Output:
"I hear your land is small. You can still compost in a small space—build a simple heap 3 ft × 3 ft × 3 ft against your fence or house wall. Layer kitchen scraps, dry leaves, and a bit of soil. Turn it every week and keep moist. In 6-8 weeks you'll have rich compost to improve your vegetables."
A quantized GGUF version (Q4_K_M) is available for local deployment:
# Download GGUF file from the repo
# Use with Ollama or LM Studio
If you use this model, please cite:
@misc{sbcc-qwen-2025,
author = {Wamozo Cosmas},
title = {SBCC Message Generator - Qwen2.5-7B},
year = {2025},
publisher = {HuggingFace},
url = {https://huggingface.co/wcosmas/sbcc-qwen}
}
Apache 2.0 (inherited from base model)