Health Log Extraction

Usage

This is an information extraction model built from a fine-tuned instance of Qwen3.0-0.6b for just one extraction template using lbakar/health-log-extraction-dataset. The goal is to be able to extract important health information from diary-like user entries.

Extraction Template:

{
    "activity": {
        "type": ["physical", "social", "intellectual", "productive"],
        "keywords": ["string"],
        "duration": "duration",
        "location": "string",
        "date": "date-time"
    },
    "food": {
        "consumed_items": ["string"],
        "missing_items": ["string"],
        "amount": ["string"]
    },
    "mood": {
        "description": "string",
        "classification": ["positive", "neutral", "negative"]
    },
    "symptom": {
        "keywords": ["string"],
        "description": "string"
    },
    "treatment": {
        "name": "string",
        "dosage": "string",
        "status": ["taken", "recommended", "postponed", "missed"]
    }
}

How to use:

Setup

template = {
    "activity": {
        "type": ["physical", "social", "intellectual", "productive"],
        "keywords": ["string"],
        "duration": "duration",
        "location": "string",
        "date": "date-time"
    },
    "food": {
        "consumed_items": ["string"],
        "missing_items": ["string"],
        "amount": ["string"]
    },
    "mood": {
        "description": "string",
        "classification": ["positive", "neutral", "negative"]
    },
    "symptom": {
        "keywords": ["string"],
        "description": "string"
    },
    "treatment": {
        "name": "string",
        "dosage": "string",
        "status": ["taken", "recommended", "postponed", "missed"]
    }
}

def build_prompt(utterance: str, template: Mapping[str, Any]) -> str:
    return (
        "<|im_start|>template\n"
        f"{format_json(template)}\n"
        "<|im_end|>\n"
        "<|im_start|>user\n"
        f"{utterance}\n"
        "<|im_end|>\n"
        "<|im_start|>assistant\n"
    )

Load Model

tokenizer = AutoTokenizer.from_pretrained('lbakar/health-log-extraction')
model = AutoModelForCausalLM.from_pretrained(
    'lbakar/health-log-extraction',
    low_cpu_mem_usage=True,
    use_safetensors=True,
)
model.eval()

Inference

utterance = 'I went for a jog today. Since my legs are pretty sore, i think i will drink some gatorade for the electrolytes'

prompt = build_prompt(utterance, template)

inputs = tokenizer(
    prompt,
    return_tensors="pt",
    add_special_tokens=False,
).to(device)

output_ids = self.model.generate(
    **inputs,
    max_new_tokens=2048,
    pad_token_id=self.tokenizer.pad_token_id,
)

prompt_length = inputs["input_ids"].shape[1]
generated_ids = output_ids[0, prompt_length:]
generated_text = self.tokenizer.decode(
    generated_ids,
    skip_special_tokens=True,
).strip()
Downloads last month
21
Safetensors
Model size
0.6B params
Tensor type
BF16
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for lbakar/health-log-extraction

Finetuned
Qwen/Qwen3-0.6B
Finetuned
(1190)
this model

Dataset used to train lbakar/health-log-extraction