mirror of
https://github.com/explosion/spaCy.git
synced 2025-07-15 10:42:34 +03:00
set default to 0.0, update quickstart
This commit is contained in:
parent
344e2d6314
commit
7e270de51f
|
@ -69,6 +69,7 @@ grad_factor = 1.0
|
||||||
{% if "tagger" in components %}
|
{% if "tagger" in components %}
|
||||||
[components.tagger]
|
[components.tagger]
|
||||||
factory = "tagger"
|
factory = "tagger"
|
||||||
|
label_smoothing = 0.05
|
||||||
|
|
||||||
[components.tagger.model]
|
[components.tagger.model]
|
||||||
@architectures = "spacy.Tagger.v2"
|
@architectures = "spacy.Tagger.v2"
|
||||||
|
|
|
@ -45,7 +45,7 @@ DEFAULT_TAGGER_MODEL = Config().from_str(default_model_config)["model"]
|
||||||
@Language.factory(
|
@Language.factory(
|
||||||
"tagger",
|
"tagger",
|
||||||
assigns=["token.tag"],
|
assigns=["token.tag"],
|
||||||
default_config={"model": DEFAULT_TAGGER_MODEL, "overwrite": False, "scorer": {"@scorers": "spacy.tagger_scorer.v1"}, "neg_prefix": "!", "label_smoothing": 0.05},
|
default_config={"model": DEFAULT_TAGGER_MODEL, "overwrite": False, "scorer": {"@scorers": "spacy.tagger_scorer.v1"}, "neg_prefix": "!", "label_smoothing": 0.0},
|
||||||
default_score_weights={"tag_acc": 1.0},
|
default_score_weights={"tag_acc": 1.0},
|
||||||
)
|
)
|
||||||
def make_tagger(
|
def make_tagger(
|
||||||
|
|
|
@ -70,10 +70,10 @@ PARTIAL_DATA = [
|
||||||
def test_label_smoothing():
|
def test_label_smoothing():
|
||||||
util.fix_random_seed()
|
util.fix_random_seed()
|
||||||
nlp = Language()
|
nlp = Language()
|
||||||
tagger_no_ls = nlp.add_pipe(
|
tagger_no_ls = nlp.add_pipe("tagger", "no_label_smoothing")
|
||||||
"tagger", "no_label_smoothing", config=dict(label_smoothing=0.0)
|
tagger_ls = nlp.add_pipe(
|
||||||
|
"tagger", "label_smoothing", config=dict(label_smoothing=0.05)
|
||||||
)
|
)
|
||||||
tagger_ls = nlp.add_pipe("tagger", "label_smoothing")
|
|
||||||
train_examples = []
|
train_examples = []
|
||||||
losses = {}
|
losses = {}
|
||||||
for tag in TAGS:
|
for tag in TAGS:
|
||||||
|
@ -160,7 +160,7 @@ def test_no_data():
|
||||||
def test_incomplete_data():
|
def test_incomplete_data():
|
||||||
# Test that the tagger works with incomplete information
|
# Test that the tagger works with incomplete information
|
||||||
nlp = English()
|
nlp = English()
|
||||||
nlp.add_pipe("tagger", config=dict(label_smoothing=0.0))
|
nlp.add_pipe("tagger")
|
||||||
train_examples = []
|
train_examples = []
|
||||||
for t in PARTIAL_DATA:
|
for t in PARTIAL_DATA:
|
||||||
train_examples.append(Example.from_dict(nlp.make_doc(t[0]), t[1]))
|
train_examples.append(Example.from_dict(nlp.make_doc(t[0]), t[1]))
|
||||||
|
@ -180,7 +180,7 @@ def test_incomplete_data():
|
||||||
def test_overfitting_IO():
|
def test_overfitting_IO():
|
||||||
# Simple test to try and quickly overfit the tagger - ensuring the ML models work correctly
|
# Simple test to try and quickly overfit the tagger - ensuring the ML models work correctly
|
||||||
nlp = English()
|
nlp = English()
|
||||||
tagger = nlp.add_pipe("tagger", config=dict(label_smoothing=0.0))
|
tagger = nlp.add_pipe("tagger")
|
||||||
train_examples = []
|
train_examples = []
|
||||||
for t in TRAIN_DATA:
|
for t in TRAIN_DATA:
|
||||||
train_examples.append(Example.from_dict(nlp.make_doc(t[0]), t[1]))
|
train_examples.append(Example.from_dict(nlp.make_doc(t[0]), t[1]))
|
||||||
|
|
|
@ -115,7 +115,6 @@ cfg_string = """
|
||||||
|
|
||||||
[components.tagger]
|
[components.tagger]
|
||||||
factory = "tagger"
|
factory = "tagger"
|
||||||
label_smoothing = 0.0
|
|
||||||
|
|
||||||
[components.tagger.model]
|
[components.tagger.model]
|
||||||
@architectures = "spacy.Tagger.v2"
|
@architectures = "spacy.Tagger.v2"
|
||||||
|
|
|
@ -46,7 +46,7 @@ architectures and their arguments and hyperparameters.
|
||||||
| `overwrite` <Tag variant="new">3.2</Tag> | Whether existing annotation is overwritten. Defaults to `False`. ~~bool~~ |
|
| `overwrite` <Tag variant="new">3.2</Tag> | Whether existing annotation is overwritten. Defaults to `False`. ~~bool~~ |
|
||||||
| `scorer` <Tag variant="new">3.2</Tag> | The scoring method. Defaults to [`Scorer.score_token_attr`](/api/scorer#score_token_attr) for the attribute `"tag"`. ~~Optional[Callable]~~ |
|
| `scorer` <Tag variant="new">3.2</Tag> | The scoring method. Defaults to [`Scorer.score_token_attr`](/api/scorer#score_token_attr) for the attribute `"tag"`. ~~Optional[Callable]~~ |
|
||||||
| `neg_prefix` <Tag variant="new">3.2.1</Tag> | The prefix used to specify incorrect tags while training. The tagger will learn not to predict exactly this tag. Defaults to `!`. ~~str~~ |
|
| `neg_prefix` <Tag variant="new">3.2.1</Tag> | The prefix used to specify incorrect tags while training. The tagger will learn not to predict exactly this tag. Defaults to `!`. ~~str~~ |
|
||||||
| `label_smoothing` <Tag variant="new">3.6</Tag> | Label smoothing factor. Defaults to `0.05`. ~~float~~ |
|
| `label_smoothing` <Tag variant="new">3.6</Tag> | Label smoothing factor. Defaults to `0.0`. ~~float~~ |
|
||||||
|
|
||||||
```python
|
```python
|
||||||
%%GITHUB_SPACY/spacy/pipeline/tagger.pyx
|
%%GITHUB_SPACY/spacy/pipeline/tagger.pyx
|
||||||
|
|
Loading…
Reference in New Issue
Block a user