Update README.md
Browse files
README.md
CHANGED
|
@@ -32,6 +32,47 @@ model-index:
|
|
| 32 |
This model was finetuned using the [GLiNER v2.5 suite](https://github.com/urchade/GLiNER) of models.
|
| 33 |
You can find and replicate the training pipeline on [Github](https://github.com/ljvmiranda921/calamanCy/tree/master/models/v0.1.0-gliner).
|
| 34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
## Citation
|
| 36 |
|
| 37 |
Please cite the following papers when using these models:
|
|
|
|
| 32 |
This model was finetuned using the [GLiNER v2.5 suite](https://github.com/urchade/GLiNER) of models.
|
| 33 |
You can find and replicate the training pipeline on [Github](https://github.com/ljvmiranda921/calamanCy/tree/master/models/v0.1.0-gliner).
|
| 34 |
|
| 35 |
+
## Usage
|
| 36 |
+
|
| 37 |
+
```python
|
| 38 |
+
from gliner import GLiNER
|
| 39 |
+
|
| 40 |
+
# Initialize GLiNER with the base model
|
| 41 |
+
model = GLiNER.from_pretrained("ljvmiranda921/tl_gliner_small")
|
| 42 |
+
|
| 43 |
+
# Sample text for entity prediction
|
| 44 |
+
# Reference: Leni Robredo’s speech at the 2022 UP College of Law recognition rites
|
| 45 |
+
text = """"
|
| 46 |
+
Nagsimula ako sa Public Attorney’s Office, kung saan araw-araw, mula Lunes hanggang Biyernes, nasa loob ako ng iba’t ibang court room at tambak ang kaso.
|
| 47 |
+
Bawat Sabado, nasa BJMP ako para ihanda ang aking mga kliyente. Nahasa ako sa crim law at litigation. Pero kinalaunan, lumipat ako sa isang NGO,
|
| 48 |
+
‘yung Sentro ng Alternatibong Lingap Panligal. Sa SALIGAN talaga ako nahubog bilang abugado: imbes na tinatanggap na lang ang mga batas na kailangang
|
| 49 |
+
sundin, nagtatanong din kung ito ba ay tunay na instrumento para makapagbigay ng katarungan sa ordinaryong Pilipino. Imbes na maghintay ng mga kliyente
|
| 50 |
+
sa de-aircon na opisina, dinadayo namin ang mga malalayong komunidad. Kadalasan, naka-tsinelas, naka-t-shirt at maong, hinahanap namin ang mga komunidad,
|
| 51 |
+
tinatawid ang mga bundok, palayan, at mga ilog para tumungo sa mga lugar kung saan hirap ang mga batayang sektor na makakuha ng access to justice.
|
| 52 |
+
Naaalala ko pa noong naging lead lawyer ako para sa isang proyekto: sa loob ng mahigit dalawang taon, bumibiyahe ako buwan-buwan papunta sa malayong
|
| 53 |
+
isla ng Masbate, nagpa-paralegal training sa mga batayang sektor doon, ipinapaliwanag, itinituturo, at sinasanay sila sa mga batas na nagbibigay-proteksyon
|
| 54 |
+
sa mga karapatan nila.
|
| 55 |
+
"""
|
| 56 |
+
|
| 57 |
+
# Labels for entity prediction
|
| 58 |
+
# Most GLiNER models should work best when entity types are in lower case or title case
|
| 59 |
+
labels = ["person", "organization", "location"]
|
| 60 |
+
|
| 61 |
+
# Perform entity prediction
|
| 62 |
+
entities = model.predict_entities(text, labels, threshold=0.5)
|
| 63 |
+
|
| 64 |
+
# Display predicted entities and their labels
|
| 65 |
+
for entity in entities:
|
| 66 |
+
print(entity["text"], "=>", entity["label"])
|
| 67 |
+
|
| 68 |
+
# Sample output:
|
| 69 |
+
# Public Attorney’s Office => organization
|
| 70 |
+
# BJMP => organization
|
| 71 |
+
# Sentro ng Alternatibong Lingap Panligal => organization
|
| 72 |
+
# Masbate => location
|
| 73 |
+
|
| 74 |
+
```
|
| 75 |
+
|
| 76 |
## Citation
|
| 77 |
|
| 78 |
Please cite the following papers when using these models:
|