-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2f57f28
commit bc2eb98
Showing
1 changed file
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from datasets import load_dataset | ||
from transformer_ranker import TransformerRanker | ||
|
||
# Load the 'conll2003' dataset | ||
dataset = load_dataset('conll2003') | ||
|
||
# Use smaller models to test on CPU | ||
models = ['prajjwal1/bert-tiny', | ||
'google/electra-small-discriminator', | ||
'microsoft/deberta-v3-small', | ||
'bert-base-uncased', | ||
] | ||
|
||
# Initialize the ranker, set labels to chunk tags | ||
ranker = TransformerRanker(dataset=dataset, | ||
dataset_downsample=0.2, | ||
label_column='chunk_tags') | ||
|
||
# ... and run it | ||
result = ranker.run(models=models, batch_size=64) | ||
|
||
# Print the scores | ||
print(result) | ||
|
||
"""Result | ||
Rank 1. microsoft/deberta-v3-small: 4.398 | ||
Rank 2. bert-base-uncased: 4.149 | ||
Rank 3. google/electra-small-discriminator: 3.7423 | ||
Rank 4. prajjwal1/bert-tiny: 2.9444 | ||
""" |