readme: add initial version
Browse files
README.md
CHANGED
@@ -1,3 +1,44 @@
|
|
1 |
---
|
2 |
license: mit
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
license: mit
|
3 |
---
|
4 |
+
|
5 |
+
# SpanMarker Base Model Detection
|
6 |
+
|
7 |
+
It is relative simply to determine base model of a fine-tuned SpanMarker model:
|
8 |
+
|
9 |
+
```python
|
10 |
+
import os
|
11 |
+
|
12 |
+
from huggingface_hub import login, HfApi
|
13 |
+
|
14 |
+
hf_token = os.environ.get("HF_TOKEN")
|
15 |
+
login(token=hf_token, add_to_git_credential=True)
|
16 |
+
api = HfApi()
|
17 |
+
```
|
18 |
+
|
19 |
+
Please make sure that `HF_TOKEN` is set as environment variable.
|
20 |
+
|
21 |
+
After that, list of all SpanMarker models can be retrieved and configuration file is parsed.
|
22 |
+
Please make sure that `span-marker` library is installed:
|
23 |
+
|
24 |
+
```python
|
25 |
+
from span_marker import SpanMarkerConfig
|
26 |
+
|
27 |
+
f_out = open("span_marker_base_model_detection.csv", "wt")
|
28 |
+
|
29 |
+
f_out.write("Nr,Model ID,Base Model ID\n")
|
30 |
+
|
31 |
+
counter = 1
|
32 |
+
for span_marker_model in api.list_models(filter="span-marker"):
|
33 |
+
try:
|
34 |
+
config = SpanMarkerConfig.from_pretrained(span_marker_model.modelId)
|
35 |
+
|
36 |
+
base_model = config.encoder["_name_or_path"]
|
37 |
+
|
38 |
+
f_out.write(f"{counter},{span_marker_model.modelId},{base_model}\n")
|
39 |
+
|
40 |
+
counter +=1
|
41 |
+
except Exception as e:
|
42 |
+
print(e)
|
43 |
+
f_out.close()
|
44 |
+
```
|