Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
NER-project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
fsem25-project-nerds
NER-project
Commits
f1db10fc
Commit
f1db10fc
authored
1 month ago
by
kupper
Browse files
Options
Downloads
Patches
Plain Diff
Context importance analysis
parent
b4f3637e
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
scripts/NEC_context_cl.sh
+16
-0
16 additions, 0 deletions
scripts/NEC_context_cl.sh
src/experiments/NEC_evaluation/context_sensitivity.py
+33
-0
33 additions, 0 deletions
src/experiments/NEC_evaluation/context_sensitivity.py
with
49 additions
and
0 deletions
scripts/NEC_context_cl.sh
0 → 100644
+
16
−
0
View file @
f1db10fc
#!/bin/bash
#SBATCH --job-name=NEC_context_sensitivity
#SBATCH --output=logs/NEC_context_sensitivity_%j.txt
#SBATCH --ntasks=1
#SBATCH --time=24:00:00
#SBATCH --mem=8000
#SBATCH --mail-type=ALL
#SBATCH --mail-user=kupper@cl.uni-heidelberg.de
#SBATCH --partition=students
#SBATCH --cpus-per-task=4
#SBATCH --qos=batch
#SBATCH --gres=gpu
export
PYTHONUNBUFFERED
=
1
srun python3
-m
src.experiments.NEC_evaluation.context_sensitivity
This diff is collapsed.
Click to expand it.
src/experiments/NEC_evaluation/context_sensitivity.py
0 → 100644
+
33
−
0
View file @
f1db10fc
import
data.data_manager
as
data_manager
from
src.common_interface
import
classify_entity
def
run_context_analysis
(
model_name
,
dataset
,
num_sentences
):
labels
=
data_manager
.
get_labels
(
dataset
)
data
=
data_manager
.
get_annotated_sentences
(
dataset
,
num_sentences
)
for
i
in
range
(
min
(
len
(
data
),
num_sentences
)):
annotated_sentence
=
data
[
i
]
sentence
=
annotated_sentence
[
0
]
entity
=
annotated_sentence
[
1
][
0
]
words
=
sentence
.
split
()
print
(
f
"
Original sentence:
{
sentence
}
"
)
print
(
f
"
Entity:
{
entity
[
0
]
}
"
)
for
word_index
in
range
(
len
(
words
)):
modified_words
=
words
.
copy
()
modified_words
[
word_index
]
=
"
[blank]
"
modified_sentence
=
'
'
.
join
(
modified_words
)
predicted
=
classify_entity
(
model_name
,
modified_sentence
,
entity
[
0
],
labels
)
print
(
f
"
Modified sentence:
{
modified_sentence
}
"
)
if
predicted
!=
entity
[
1
]:
print
(
"
!!MISPREDICTION!!
"
)
print
(
f
"
Predicted:
{
predicted
}
, True:
{
entity
[
1
]
}
"
)
run_context_analysis
(
"
T5-NLI
"
,
"
FIGER-coarse
"
,
50
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment