Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
nlp
ahisto-modules
Named Entity Recognition Experiments
Commits
7263450d
Commit
7263450d
authored
Sep 11, 2022
by
Vít Novotný
Browse files
Make `NerModel.__init__()` lazy and add `str()` and `repr()`
parent
b78567bb
Changes
1
Hide whitespace changes
Inline
Side-by-side
ahisto_named_entity_search/recognition/model.py
View file @
7263450d
...
...
@@ -36,8 +36,18 @@ class NerModel:
NUM_VALIDATION_SAMPLES
=
CONFIG
.
getint
(
'number_of_validation_samples'
)
STOPPING_PATIENCE
=
CONFIG
.
getint
(
'stopping_patience'
)
def
__init__
(
self
,
model
:
AutoModelForTokenClassification
):
self
.
model
=
model
def
__init__
(
self
,
model_name_or_basename
:
str
):
self
.
model_name_or_basename
=
model_name_or_basename
@
property
def
model
(
self
)
->
AutoModelForTokenClassification
:
model
=
AutoModelForTokenClassification
.
from_pretrained
(
self
.
model_name_or_basename
)
def
__str__
(
self
)
->
str
:
return
self
.
model_name_or_basename
def
__repr__
(
self
)
->
str
:
return
'{}: {}'
.
format
(
self
.
__class__
.
__name__
,
self
)
@
classmethod
def
train_and_save
(
cls
,
model_checkpoint_basename
:
str
,
model_basename
:
str
,
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment