Health Log Extraction

Usage

This is an information extraction model built from a fine-tuned instance of Qwen3.0-0.6b for just any of the sub-templates of the main extraction template found in lbakar/health-log-extraction-dataset. The goal is to be able to extract important health information from diary-like user entries. Note that the model is less effective than the full model template due to a lack of detail in the extraction templates, but this model is proof of concept.

How to use:

Setup

template = {
    "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-partial-template')
model = AutoModelForCausalLM.from_pretrained(
    'lbakar/health-log-extraction-partial-template',
    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()

Available Extraction Templates:

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"]
}

Symptoms

{
    "keywords": ["string"],
    "description": "string"
}

Treatment

{
    "name": "string",
    "dosage": "string",
    "status": ["taken", "recommended", "postponed", "missed"]
}
Downloads last month
22
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-partial-template

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

Dataset used to train lbakar/health-log-extraction-partial-template