Instructions to use yseop/SMM4H2024_Task2b_ja with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use yseop/SMM4H2024_Task2b_ja with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="yseop/SMM4H2024_Task2b_ja")# Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("yseop/SMM4H2024_Task2b_ja") model = AutoModelForSequenceClassification.from_pretrained("yseop/SMM4H2024_Task2b_ja") - Notebooks
- Google Colab
- Kaggle
| license: afl-3.0 | |
| language: | |
| - ja | |
| library_name: transformers | |
| pipeline_tag: text-classification | |
| # SMM4H-2024 Task 2 Japanese RE | |
| ## Overview | |
| This is a relation extraction model created by fine-tuning [daisaku-s/medtxt_ner_roberta](https://huggingface.co/daisaku-s/medtxt_ner_roberta) on [SMM4H 2024 Task 2b](https://healthlanguageprocessing.org/smm4h-2024/) corpus. | |
| Tag set: | |
| * CAUSED | |
| * TREATMENT_FOR | |
| ## Usage | |
| ```python | |
| from transformers import AutoModelForSequenceClassification, AutoTokenizer | |
| import torch | |
| text = "銈点兂銉椼儷銉嗐偔銈广儓" | |
| model_name = "yseop/SMM4H2024_Task2b_ja" | |
| id2label = ['O', 'CAUSED', 'TREATMENT_FOR'] | |
| with torch.inference_mode(): | |
| model = AutoModelForSequenceClassification.from_pretrained(model_name).eval() | |
| tokenizer = AutoTokenizer.from_pretrained(model_name) | |
| encoded_input = tokenizer(text, return_tensors='pt', max_length=512) | |
| output = re_model(**encoded_input).logits | |
| class_id = output.argmax().item() | |
| print(id2label[class_id]) | |
| ``` | |
| ## Results | |
| |Relation|tp|fp|fn|precision|recall|f1| | |
| |---|---:|---:|---:|---:|---:|---:| | |
| |CAUSED\|DISORDER\|DISORDER|1|163|38|0.0061|0.0256|0.0099| | |
| |CAUSED\|DISORDER\|FUNCTION|0|70|13|0|0|0| | |
| |CAUSED\|DRUG\|DISORDER|9|196|105|0.0439|0.0789|0.0564| | |
| |CAUSED\|DRUG\|FUNCTION|2|59|7|0.0328|0.2222|0.0571| | |
| |TREATMENT_FOR\|DISORDER\|DISORDER|0|12|0|0|0|0| | |
| |TREATMENT_FOR\|DISORDER\|FUNCTION|0|3|0|0|0|0| | |
| |TREATMENT_FOR\|DRUG\|DISORDER|0|15|91|0|0|0| | |
| |TREATMENT_FOR\|DRUG\|FUNCTION|0|0|1|0|0|0| | |
| |all|12|518|255|0.0226|0.0449|0.0301| |