Views
No views yet
1from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
2
3tokenizer = AutoTokenizer.from_pretrained("guilopgar/flan-t5-xl-medication-ner")
4model = AutoModelForSeq2SeqLM.from_pretrained("guilopgar/flan-t5-xl-medication-ner")
5
6input_text = ("You are given a tweet followed by a specific question asking about the content of the tweet. "
7 "Your objective is to identify and list any drug names, medications, or dietary supplements mentioned "
8 "in the tweet. If one or more are mentioned, list each distinctly, separated by a comma. "
9 "If none are mentioned, return an empty list [].\n\n"
10 "Input: Tweet: Benadryl, bedtime snack, and New Girl. The party is getting real.\n"
11 "Question: What are the drugs, medications or dietary supplements mentioned in the tweet?\n"
12 "Output:")
13
14inputs = tokenizer(input_text, return_tensors="pt")
15outputs = model.generate(**inputs)
16print(tokenizer.decode(outputs[0], skip_special_tokens=True))1@article{Lopez-Garcia2025.05.16.25327791,
2 author = {Lopez-Garcia, Guillermo and Xu, Dongfang and Gonzalez-Hernandez, Graciela},
3 title = {Detecting Medication Mentions in Social Media Data Using Large Language Models},
4 year = {2025},
5 doi = {10.1101/2025.05.16.25327791},
6 publisher = {Cold Spring Harbor Laboratory Press},
7 URL = {https://www.medrxiv.org/content/early/2025/05/18/2025.05.16.25327791},
8 journal = {medRxiv}
9}