Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BERT Gloss Methods #115

Open
wants to merge 10 commits into
base: 88-time-bert
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
446 changes: 446 additions & 0 deletions 114.1 - review notebook - glossbert.ipynb

Large diffs are not rendered by default.

111 changes: 111 additions & 0 deletions 114.2 - review notebook - multidataset.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
{
"metadata": {
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.5-final"
},
"orig_nbformat": 2,
"kernelspec": {
"name": "python3",
"display_name": "Python 3",
"language": "python"
}
},
"nbformat": 4,
"nbformat_minor": 2,
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"%load_ext autoreload\n",
"%autoreload 2"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"from tasks.wsd_gloss import create_md_training_data, train_gloss_and_context"
]
},
{
"cell_type": "code",
"execution_count": 27,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"lemma, pos = 'machine','NN'\n",
"senses = {'machine_nn01-38474140'} # machine_nn01-38475772 machine_nn01-38475923 machine_nn01-38475835 machine_nn01-38474140\n",
"relations = ['seed','synonym'] # ,'descendant','sibling'\n",
"eval_mode = \"lemma_etal\" # lemma or lemma_etal\n",
"experiment_id = 0"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"# senses before filtering by date = 517\n",
"# senses after filtering by date = 433\n",
"\n",
"\n",
"# of seed senses 26 \n",
"# of synonyms 383 \n",
"# of branch senses 0\n",
"\n",
"\n",
"# of seeds selected 1 \n",
"# of synonyms selected 44 \n",
"# of branches selected 0\n",
"[LOG] #rows before removing None vector (1947, 21)\n",
"[LOG] #rows after removing None vector (1911, 21)\n"
]
}
],
"source": [
"create_md_training_data(lemma,pos,senses,relations,experiment_id=experiment_id)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"train_gloss_and_context(lemma,pos,experiment_id=experiment_id)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
]
}
Empty file modified data/grouped_senses.md
100644 → 100755
Empty file.
Empty file modified data/words_for_evaluation_selection_criteria.md
100644 → 100755
Empty file.
10 changes: 10 additions & 0 deletions run_glossbert.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from tasks.wsd_gloss import create_glossbert_data, train_glossbert
import sys

def run(lemma,pos):
data_path = create_glossbert_data(lemma,pos)
train_glossbert(data_path,downsample=True)

if __name__=="__main__":
lemma,pos = sys.argv[1],sys.argv[2]
run(lemma,pos)
2 changes: 1 addition & 1 deletion tasks/wsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def svm_wemb_baseline(df_train,df_test,wemb_model):
return y_pred

### ---------------------------------------------------
# BERT CENTROID METHODS
BERT CENTROID METHODS

### ---------------------------------------------------
# binary centroid vectors
Expand Down
Loading