lbakar/health-log-extraction-dataset
Viewer • Updated • 126k • 33
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.
{
"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"]
}
}
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"
)
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()
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()