kargaranamir commited on
Commit
ed38a69
1 Parent(s): 743820b

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +28 -28
README.md CHANGED
@@ -8,6 +8,7 @@ tags:
8
  - ner
9
  - named-entity-recognition
10
  pipeline_tag: token-classification
 
11
  language:
12
  - fa
13
  ---
@@ -15,40 +16,39 @@ language:
15
 
16
  # Hengam: An Adversarially Trained Transformer for Persian Temporal Tagging
17
 
18
- ## HuggingFace
19
- - [HengamTrans Space](https://huggingface.co/spaces/kargaranamir/Hengam)
20
- - [HengamTagger (Parstdex) Space](https://huggingface.co/spaces/kargaranamir/parstdex)
21
- - [HengamTrans Models (ModelCard)](https://huggingface.co/kargaranamir/Hengam)
22
- - [HengamCorpus (Dataset)](https://huggingface.co/datasets/kargaranamir/HengamCorpus)
23
 
 
24
 
25
- ## Code (Software)
26
-
27
- ### HengamTagger
28
- The HengamTagger is distributed as [Parstdex](https://github.com/kargaranamir/parstdex) package (will be continuously updated) and is available via [pip](https://pypi.org/project/parstdex).
29
-
30
- ### HengamTransformer
31
- In this directory 4 different notebooks are provided. Click on the hyperlinks to open each in Google Colab.
32
 
33
- - Inference and Test
34
- - [Inference_HengamTransW.ipynb](https://colab.research.google.com/github/kargaranamir/hengam/blob/main/code/Inference_HengamTransW.ipynb): In this notebook, [HengamTransW.pth](https://huggingface.co/kargaranamir/Hengam/resolve/main/HengamTransW.pth) is downloaded from [Hengam HuggingFace model card](https://huggingface.co/kargaranamir/Hengam), and an inference is provided in the last cells.
35
- - [Inference_HengamTransA.ipynb](https://colab.research.google.com/github/kargaranamir/hengam/blob/main/code/Inference_HengamTransA.ipynb): In this notebook, [HengamTransA.pth](https://huggingface.co/kargaranamir/Hengam/resolve/main/HengamTransA.pth) is downloaded from [Hengam HuggingFace model card](https://huggingface.co/kargaranamir/Hengam), and an inference is provided in the last cells.
36
- - Train
37
- - [Train_HengamTransW.ipynb](https://colab.research.google.com/github/kargaranamir/hengam/blob/main/code/Train_HengamTransW.ipynb): This notebook uses the [HengamCorpus](https://huggingface.co/datasets/kargaranamir/HengamCorpus) dataset uploaded on HuggingFace. Afterwards, the HengamTransW will be trained.
38
- - [Train_HengamTransA.ipynb](https://colab.research.google.com/github/kargaranamir/hengam/blob/main/code/Train_HengamTransA.ipynb): This notebook uses the trained [HengamTransW.pth](https://huggingface.co/kargaranamir/Hengam/resolve/main/HengamTransW.pth) downloaded from HuggingFace and then trains it on [strong labeled data](https://huggingface.co/datasets/kargaranamir/HengamCorpus/raw/main/strong.txt) in an adverserial manner to produce [HengamTransA](https://huggingface.co/kargaranamir/Hengam/resolve/main/HengamTransA.pth).
39
 
40
- ## Data
 
 
 
41
 
42
- ### Train Data
43
- HengamCorpus data along with strong labeled data is uploaded in [HuggingFace](https://huggingface.co/datasets/kargaranamir/HengamCorpus). Click on hyperlinks to download.
44
- - HengamCorpus
45
- - [HengamCorpus train data](https://huggingface.co/datasets/kargaranamir/HengamCorpus/resolve/main/train.txt)
46
- - [HengamCorpus test data](https://huggingface.co/datasets/kargaranamir/HengamCorpus/resolve/main/test.txt)
47
- - [HengamCorpus validation data](https://huggingface.co/datasets/kargaranamir/HengamCorpus/resolve/main/val.txt)
48
- - [Strong labeled data](https://huggingface.co/datasets/kargaranamir/HengamCorpus/raw/main/strong.txt)
49
 
50
- ### Evaluation Data
51
- HengamGold, challenge set and prediction result of different models on HengamGold is available in [evaluation](./data/evaluation) folder.
 
 
 
 
 
 
 
 
 
 
52
 
53
 
54
  ## Citation
 
8
  - ner
9
  - named-entity-recognition
10
  pipeline_tag: token-classification
11
+ inference: false
12
  language:
13
  - fa
14
  ---
 
16
 
17
  # Hengam: An Adversarially Trained Transformer for Persian Temporal Tagging
18
 
19
+ # Usage
 
 
 
 
20
 
21
+ You can use this model directly downloading the utils and requirements files and installing requirements:
22
 
23
+ ```python
24
+ ! wget https://huggingface.co/spaces/kargaranamir/Hengam/raw/main/utils.py
25
+ ! wget https://huggingface.co/spaces/kargaranamir/Hengam/raw/main/requirements.txt
26
+ ! pip install -r requirements.txt
27
+ ```
 
 
28
 
29
+ and downloading the models HengamTransA.pth or HengamTransW.pth and building ner pipline:
 
 
 
 
 
30
 
31
+ ```python
32
+ import torch
33
+ from huggingface_hub import hf_hub_download
34
+ from utils import *
35
 
36
+ # HengamTransW = hf_hub_download(repo_id="kargaranamir/Hengam", filename="HengamTransW.pth")
37
+ HengamTransA = hf_hub_download(repo_id="kargaranamir/Hengam", filename="HengamTransA.pth")
38
+ ```
 
 
 
 
39
 
40
+ ```python
41
+ # ner = NER(model_path=HengamTransW, tags=['B-TIM', 'I-TIM', 'B-DAT', 'I-DAT', 'O'])
42
+ ner = NER(model_path=HengamTransA, tags=['B-TIM', 'I-TIM', 'B-DAT', 'I-DAT', 'O'])
43
+ ner('.سلام من و دوستم ساعت ۸ صبح روز سه شنبه رفتیم دوشنبه بازار ')
44
+ >>
45
+ [{'Text': 'ساعت', 'Tag': 'B-TIM', 'Start': 17, 'End': 21},
46
+ {'Text': '۸', 'Tag': 'I-TIM', 'Start': 22, 'End': 23},
47
+ {'Text': 'صبح', 'Tag': 'I-TIM', 'Start': 24, 'End': 27},
48
+ {'Text': 'روز', 'Tag': 'I-TIM', 'Start': 28, 'End': 31},
49
+ {'Text': 'سه', 'Tag': 'B-DAT', 'Start': 32, 'End': 34},
50
+ {'Text': 'شنبه', 'Tag': 'I-DAT', 'Start': 35, 'End': 39}]
51
+ ```
52
 
53
 
54
  ## Citation