Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
language:
|
| 3 |
+
- en
|
| 4 |
+
metrics:
|
| 5 |
+
- f1
|
| 6 |
+
base_model:
|
| 7 |
+
- FacebookAI/roberta-base
|
| 8 |
+
tags:
|
| 9 |
+
- parsing
|
| 10 |
+
- hashing
|
| 11 |
+
- unsupervised
|
| 12 |
+
---
|
| 13 |
+
|
| 14 |
+
## On Eliciting Syntax from Language Models via Hashing
|
| 15 |
+
|
| 16 |
+
## Model Details
|
| 17 |
+
|
| 18 |
+
This repository contains the implementation of [**Parserker v2**](https://aclanthology.org/2024.emnlp-main.479/), a
|
| 19 |
+
hashing-based unsupervised parser trained on the Penn Treebank dataset using only the raw text (no syntactic annotations
|
| 20 |
+
or tree labels).
|
| 21 |
+
|
| 22 |
+
## Usage
|
| 23 |
+
|
| 24 |
+
### Requirements
|
| 25 |
+
|
| 26 |
+
`pip install transformers torch nltk torchrua`
|
| 27 |
+
|
| 28 |
+
### Demo
|
| 29 |
+
|
| 30 |
+
```python
|
| 31 |
+
from nltk import TreePrettyPrinter
|
| 32 |
+
from transformers import AutoModel, AutoTokenizer
|
| 33 |
+
|
| 34 |
+
model = AutoModel.from_pretrained("yehzw/parserker", trust_remote_code=True)
|
| 35 |
+
tokenizer = AutoTokenizer.from_pretrained("yehzw/parserker", trust_remote_code=True)
|
| 36 |
+
|
| 37 |
+
model.eval()
|
| 38 |
+
|
| 39 |
+
words, input_ids, duration = tokenizer([
|
| 40 |
+
"The quick brown fox jumps over the lazy dog",
|
| 41 |
+
"Have a nice day",
|
| 42 |
+
])
|
| 43 |
+
|
| 44 |
+
for w, s in zip(words, model.parse(input_ids, duration).tolist()):
|
| 45 |
+
t = model.to_tree(w, s)
|
| 46 |
+
t = TreePrettyPrinter(t).text()
|
| 47 |
+
print(t)
|
| 48 |
+
```
|
| 49 |
+
|
| 50 |
+
### Ouput Examples
|
| 51 |
+
|
| 52 |
+
The quick brown fox jumps over the lazy dog
|
| 53 |
+
|
| 54 |
+
```
|
| 55 |
+
854D
|
| 56 |
+
_____________________|_________
|
| 57 |
+
| DF41
|
| 58 |
+
| _________|____
|
| 59 |
+
955F | DD59
|
| 60 |
+
__________|_____ | _________|____
|
| 61 |
+
| DC45 | | D457
|
| 62 |
+
| __________|____ | | _________|____
|
| 63 |
+
| | DE45 | | | DECD
|
| 64 |
+
| | ____|____ | | | ____|____
|
| 65 |
+
103B C404 DC05 D60D 9300 C995 D0B7 DC8D DE8D
|
| 66 |
+
| | | | | | | | |
|
| 67 |
+
The quick brown fox jumps over the lazy dog
|
| 68 |
+
```
|
| 69 |
+
|
| 70 |
+
Have a nice day
|
| 71 |
+
|
| 72 |
+
```
|
| 73 |
+
955B
|
| 74 |
+
_________|____
|
| 75 |
+
| 8C57
|
| 76 |
+
| _________|____
|
| 77 |
+
| | CEE5
|
| 78 |
+
| | ____|____
|
| 79 |
+
151B 3817 8C04 8E2D
|
| 80 |
+
| | | |
|
| 81 |
+
Have a nice day
|
| 82 |
+
```
|
| 83 |
+
|
| 84 |
+
## Citation
|
| 85 |
+
|
| 86 |
+
```bib
|
| 87 |
+
@inproceedings{wang-utiyama-2024-eliciting,
|
| 88 |
+
title = "On Eliciting Syntax from Language Models via Hashing",
|
| 89 |
+
author = "Wang, Yiran and
|
| 90 |
+
Utiyama, Masao",
|
| 91 |
+
editor = "Al-Onaizan, Yaser and
|
| 92 |
+
Bansal, Mohit and
|
| 93 |
+
Chen, Yun-Nung",
|
| 94 |
+
booktitle = "Proceedings of the 2024 Conference on Empirical Methods in Natural Language Processing",
|
| 95 |
+
month = nov,
|
| 96 |
+
year = "2024",
|
| 97 |
+
address = "Miami, Florida, USA",
|
| 98 |
+
publisher = "Association for Computational Linguistics",
|
| 99 |
+
url = "https://aclanthology.org/2024.emnlp-main.479/",
|
| 100 |
+
doi = "10.18653/v1/2024.emnlp-main.479",
|
| 101 |
+
pages = "8412--8427"
|
| 102 |
+
}
|
| 103 |
+
```
|