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 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.
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"
)
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()
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()
{
"type": ["physical", "social", "intellectual", "productive"],
"keywords": ["string"],
"duration": "duration",
"location": "string",
"date": "date-time"
}
{
"consumed_items": ["string"],
"missing_items": ["string"],
"amount": ["string"]
}
{
"description": "string",
"classification": ["positive", "neutral", "negative"]
}
{
"keywords": ["string"],
"description": "string"
}
{
"name": "string",
"dosage": "string",
"status": ["taken", "recommended", "postponed", "missed"]
}