Edit model card

Hengam: An Adversarially Trained Transformer for Persian Temporal Tagging

Usage

You can use this model directly downloading the utils and requirements files and installing requirements:

>>> ! wget https://huggingface.co/kargaranamir/Hengam/raw/main/utils.py
>>> ! wget https://huggingface.co/kargaranamir/Hengam/raw/main/requirements.txt
>>> ! pip install -r requirements.txt

and downloading the models HengamTransA.pth or HengamTransW.pth and building ner pipline:

>>> import torch
>>> from huggingface_hub import hf_hub_download
>>> from utils import *

>>> # HengamTransW = hf_hub_download(repo_id="kargaranamir/Hengam", filename="HengamTransW.pth")
>>> HengamTransA = hf_hub_download(repo_id="kargaranamir/Hengam", filename="HengamTransA.pth")
>>> # ner = NER(model_path=HengamTransW, tags=['B-TIM', 'I-TIM', 'B-DAT', 'I-DAT', 'O'])
>>> ner = NER(model_path=HengamTransA, tags=['B-TIM', 'I-TIM', 'B-DAT', 'I-DAT', 'O'])
>>> ner('.سلام من و دوستم ساعت ۸ صبح روز سه شنبه رفتیم دوشنبه بازار ')

[{'Text': 'ساعت', 'Tag': 'B-TIM', 'Start': 17, 'End': 21},
 {'Text': '۸', 'Tag': 'I-TIM', 'Start': 22, 'End': 23},
 {'Text': 'صبح', 'Tag': 'I-TIM', 'Start': 24, 'End': 27},
 {'Text': 'روز', 'Tag': 'I-TIM', 'Start': 28, 'End': 31},
 {'Text': 'سه', 'Tag': 'B-DAT', 'Start': 32, 'End': 34},
 {'Text': 'شنبه', 'Tag': 'I-DAT', 'Start': 35, 'End': 39}]

Citation

If you use any part of this repository in your research, please cite it using the following BibTex entry.

@inproceedings{mirzababaei-etal-2022-hengam,
    title        = {Hengam: An Adversarially Trained Transformer for {P}ersian Temporal Tagging},
    author       = {Mirzababaei, Sajad  and Kargaran, Amir Hossein  and Sch{\"u}tze, Hinrich  and Asgari, Ehsaneddin},
    year         = 2022,
    booktitle    = {Proceedings of the 2nd Conference of the Asia-Pacific Chapter of the Association for Computational Linguistics and the 12th International Joint Conference on Natural Language Processing},
    publisher    = {Association for Computational Linguistics},
    address      = {Online only},
    pages        = {1013--1024},
    url          = {https://aclanthology.org/2022.aacl-main.74}
}
Downloads last month
19
Inference Examples
Inference API (serverless) has been turned off for this model.

Dataset used to train kargaranamir/Hengam

Space using kargaranamir/Hengam 1