Instructions to use MoAmini77/bert-finetuned-ner with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use MoAmini77/bert-finetuned-ner with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("token-classification", model="MoAmini77/bert-finetuned-ner")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForTokenClassification tokenizer = AutoTokenizer.from_pretrained("MoAmini77/bert-finetuned-ner") model = AutoModelForTokenClassification.from_pretrained("MoAmini77/bert-finetuned-ner", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files
README.md
CHANGED
|
@@ -2,51 +2,86 @@
|
|
| 2 |
library_name: transformers
|
| 3 |
base_model: HooshvareLab/bert-base-parsbert-uncased
|
| 4 |
tags:
|
| 5 |
-
-
|
|
|
|
|
|
|
|
|
|
| 6 |
model-index:
|
| 7 |
- name: bert-finetuned-ner
|
| 8 |
results: []
|
| 9 |
---
|
| 10 |
|
| 11 |
-
<!-- This model card has been generated automatically according to the information the Trainer had access to. You
|
| 12 |
-
should probably proofread and complete it, then remove this comment. -->
|
| 13 |
-
|
| 14 |
# bert-finetuned-ner
|
| 15 |
|
| 16 |
-
This model is a fine-tuned
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
-
|
|
|
|
|
|
|
|
|
|
| 19 |
|
| 20 |
-
|
| 21 |
|
| 22 |
-
##
|
| 23 |
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
-
## Training
|
| 27 |
|
| 28 |
-
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
-
## Training
|
| 31 |
|
| 32 |
-
|
|
|
|
| 33 |
|
| 34 |
-
|
| 35 |
-
- learning_rate: 2e-05
|
| 36 |
-
- train_batch_size: 8
|
| 37 |
-
- eval_batch_size: 8
|
| 38 |
-
- seed: 42
|
| 39 |
-
- optimizer: Use OptimizerNames.ADAMW_TORCH_FUSED with betas=(0.9,0.999) and epsilon=1e-08 and optimizer_args=No additional optimizer arguments
|
| 40 |
-
- lr_scheduler_type: linear
|
| 41 |
-
- num_epochs: 10
|
| 42 |
|
| 43 |
-
|
|
|
|
| 44 |
|
|
|
|
| 45 |
|
|
|
|
|
|
|
| 46 |
|
| 47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
- Tokenizers 0.22.0
|
|
|
|
| 2 |
library_name: transformers
|
| 3 |
base_model: HooshvareLab/bert-base-parsbert-uncased
|
| 4 |
tags:
|
| 5 |
+
- ner
|
| 6 |
+
- persian
|
| 7 |
+
- fine-tuned
|
| 8 |
+
- transformers
|
| 9 |
model-index:
|
| 10 |
- name: bert-finetuned-ner
|
| 11 |
results: []
|
| 12 |
---
|
| 13 |
|
|
|
|
|
|
|
|
|
|
| 14 |
# bert-finetuned-ner
|
| 15 |
|
| 16 |
+
This model is a **fine-tuned Persian BERT model** based on [HooshvareLab/bert-base-parsbert-uncased](https://huggingface.co/HooshvareLab/bert-base-parsbert-uncased) for **Named Entity Recognition (NER)**. It has been trained to identify entities such as persons, organizations, locations, and products in Persian text.
|
| 17 |
+
|
| 18 |
+
## Model Description
|
| 19 |
+
|
| 20 |
+
`bert-finetuned-ner` is designed for token-level classification in Persian. The model uses **ParsBERT**, a BERT variant pretrained on a large Persian corpus, as the base model and is fine-tuned on a custom NER dataset. It can predict entity labels for each token in input text, supporting tasks such as text analysis, information extraction, and question answering pipelines.
|
| 21 |
+
|
| 22 |
+
## Intended Uses & Limitations
|
| 23 |
+
|
| 24 |
+
### Intended Uses
|
| 25 |
+
|
| 26 |
+
- Named Entity Recognition (NER) in Persian text.
|
| 27 |
+
- Information extraction for NLP pipelines in Persian language applications.
|
| 28 |
+
- Academic research or industrial projects requiring entity tagging.
|
| 29 |
+
|
| 30 |
+
### Limitations
|
| 31 |
+
|
| 32 |
+
- Performance depends heavily on the coverage and quality of the training data. Entities not represented in the dataset may not be recognized.
|
| 33 |
+
- The model may misclassify rare or out-of-vocabulary words.
|
| 34 |
+
- For critical applications, manual verification of predictions is recommended.
|
| 35 |
+
- Trained on formal text; performance on dialects or colloquial Persian may vary.
|
| 36 |
+
|
| 37 |
+
## Training and Evaluation Data
|
| 38 |
|
| 39 |
+
- **Training dataset:** Custom NER dataset in Persian (details not specified).
|
| 40 |
+
- **Evaluation dataset:** Validation split of the training dataset.
|
| 41 |
+
- Entities annotated include: persons, organizations, locations, creative works, and products.
|
| 42 |
+
- Tokenization handled using ParsBERT tokenizer (`HooshvareLab/bert-base-parsbert-uncased`).
|
| 43 |
|
| 44 |
+
## Training Procedure
|
| 45 |
|
| 46 |
+
### Training Hyperparameters
|
| 47 |
|
| 48 |
+
- Learning rate: 2e-5
|
| 49 |
+
- Train batch size: 8
|
| 50 |
+
- Evaluation batch size: 8
|
| 51 |
+
- Optimizer: `AdamW` (betas=(0.9, 0.999), epsilon=1e-8)
|
| 52 |
+
- Learning rate scheduler: linear
|
| 53 |
+
- Number of epochs: 10
|
| 54 |
+
- Seed: 42
|
| 55 |
|
| 56 |
+
### Training Environment
|
| 57 |
|
| 58 |
+
- Framework: Transformers 4.56.1
|
| 59 |
+
- PyTorch 2.8.0+cu126
|
| 60 |
+
- Datasets 4.0.0
|
| 61 |
+
- Tokenizers 0.22.0
|
| 62 |
|
| 63 |
+
### Training Results
|
| 64 |
|
| 65 |
+
- The model achieved training loss of ~0.13 (averaged over all epochs).
|
| 66 |
+
- Accuracy, F1, precision, and recall metrics are recommended to be computed on a held-out test set for full evaluation.
|
| 67 |
|
| 68 |
+
## How to Use
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
|
| 70 |
+
```python
|
| 71 |
+
from transformers import AutoTokenizer, AutoModelForTokenClassification, pipeline
|
| 72 |
|
| 73 |
+
model_path = "path_to_saved_model"
|
| 74 |
|
| 75 |
+
tokenizer = AutoTokenizer.from_pretrained(model_path)
|
| 76 |
+
model = AutoModelForTokenClassification.from_pretrained(model_path)
|
| 77 |
|
| 78 |
+
ner_pipeline = pipeline(
|
| 79 |
+
"ner",
|
| 80 |
+
model=model,
|
| 81 |
+
tokenizer=tokenizer,
|
| 82 |
+
aggregation_strategy="simple"
|
| 83 |
+
)
|
| 84 |
|
| 85 |
+
text = "سلام. من محمد هستم و در تهران زندگی میکنم."
|
| 86 |
+
results = ner_pipeline(text)
|
| 87 |
+
print(results)
|
|
|