Browse Source

Merge branch 'dev0.5.0' of https://github.com/fastnlp/fastNLP into dev0.5.0

tags/v0.4.10
yh 5 years ago
parent
commit
eca04cd079
6 changed files with 75 additions and 40 deletions
  1. +16
    -0
      .gitignore
  2. +2
    -2
      fastNLP/core/metrics.py
  3. +20
    -35
      reproduction/README.md
  4. +34
    -0
      reproduction/Star_transformer/README.md
  5. +2
    -2
      reproduction/matching/test/test_snlidataloader.py
  6. +1
    -1
      reproduction/seqence_labelling/cws/test/test_CWSDataLoader.py

+ 16
- 0
.gitignore View File

@@ -0,0 +1,16 @@
.gitignore

.DS_Store
.ipynb_checkpoints
*.pyc
__pycache__
*.swp
.vscode/
.idea/**

caches

# fitlog
.fitlog
logs/
.fitconfig

+ 2
- 2
fastNLP/core/metrics.py View File

@@ -476,7 +476,7 @@ class SpanFPreRecMetric(MetricBase):
label的f1, pre, rec
:param str f_type: 'micro'或'macro'. 'micro':通过先计算总体的TP,FN和FP的数量,再计算f, precision, recall; 'macro':
分布计算每个类别的f, precision, recall,然后做平均(各类别f的权重相同)
:param float beta: f_beta分数,:math:`f_beta = \frac{(1 + {beta}^{2})*(pre*rec)}{({beta}^{2}*pre + rec)}`.
:param float beta: f_beta分数, :math:`f_beta = \frac{(1 + {beta}^{2})*(pre*rec)}{({beta}^{2}*pre + rec)}` .
常用为beta=0.5, 1, 2. 若为0.5则精确率的权重高于召回率;若为1,则两者平等;若为2,则召回率权重高于精确率。
"""
@@ -708,7 +708,7 @@ class SQuADMetric(MetricBase):
:param pred2: 参数映射表中`pred2`的映射关系,None表示映射关系为`pred2`->`pred2`
:param target1: 参数映射表中`target1`的映射关系,None表示映射关系为`target1`->`target1`
:param target2: 参数映射表中`target2`的映射关系,None表示映射关系为`target2`->`target2`
:param float beta: f_beta分数,:math:`f_beta = \frac{(1 + {beta}^{2})*(pre*rec)}{({beta}^{2}*pre + rec)}`.
:param float beta: f_beta分数, :math:`f_beta = \frac{(1 + {beta}^{2})*(pre*rec)}{({beta}^{2}*pre + rec)}` .
常用为beta=0.5, 1, 2. 若为0.5则精确率的权重高于召回率;若为1,则两者平等;若为2,则召回率权重高于精确率。
:param bool right_open: right_open为true表示start跟end指针指向一个左闭右开区间,为false表示指向一个左闭右闭区间。
:param bool print_predict_stat: True则输出预测答案是否为空与正确答案是否为空的统计信息, False则不输出


+ 20
- 35
reproduction/README.md View File

@@ -2,43 +2,28 @@
这里复现了在fastNLP中实现的模型,旨在达到与论文中相符的性能。

复现的模型有:
- Star-Transformer
- [Star-Transformer](Star_transformer/)
- ...

# 任务复现
## Text Classification (文本分类)
- still in progress


## Matching (自然语言推理/句子匹配)
- still in progress


## Sequence Labeling (序列标注)
- still in progress


## Coreference resolution (指代消解)
- still in progress


## Summarization (摘要)
- still in progress

## Star-Transformer
[reference](https://arxiv.org/abs/1902.09113)
### Performance (still in progress)
|任务| 数据集 | SOTA | 模型表现 |
|------|------| ------| ------|
|Pos Tagging|CTB 9.0|-|ACC 92.31|
|Pos Tagging|CONLL 2012|-|ACC 96.51|
|Named Entity Recognition|CONLL 2012|-|F1 85.66|
|Text Classification|SST|-|49.18|
|Natural Language Inference|SNLI|-|83.76|

### Usage
``` python
# for sequence labeling(ner, pos tagging, etc)
from fastNLP.models.star_transformer import STSeqLabel
model = STSeqLabel(
vocab_size=10000, num_cls=50,
emb_dim=300)


# for sequence classification
from fastNLP.models.star_transformer import STSeqCls
model = STSeqCls(
vocab_size=10000, num_cls=50,
emb_dim=300)


# for natural language inference
from fastNLP.models.star_transformer import STNLICls
model = STNLICls(
vocab_size=10000, num_cls=50,
emb_dim=300)

```

## ...

+ 34
- 0
reproduction/Star_transformer/README.md View File

@@ -0,0 +1,34 @@
# Star-Transformer
paper: [Star-Transformer](https://arxiv.org/abs/1902.09113)
## Performance (still in progress)
|任务| 数据集 | SOTA | 模型表现 |
|------|------| ------| ------|
|Pos Tagging|CTB 9.0|-|ACC 92.31|
|Pos Tagging|CONLL 2012|-|ACC 96.51|
|Named Entity Recognition|CONLL 2012|-|F1 85.66|
|Text Classification|SST|-|49.18|
|Natural Language Inference|SNLI|-|83.76|

## Usage
``` python
# for sequence labeling(ner, pos tagging, etc)
from fastNLP.models.star_transformer import STSeqLabel
model = STSeqLabel(
vocab_size=10000, num_cls=50,
emb_dim=300)


# for sequence classification
from fastNLP.models.star_transformer import STSeqCls
model = STSeqCls(
vocab_size=10000, num_cls=50,
emb_dim=300)


# for natural language inference
from fastNLP.models.star_transformer import STNLICls
model = STNLICls(
vocab_size=10000, num_cls=50,
emb_dim=300)

```

+ 2
- 2
reproduction/matching/test/test_snlidataloader.py View File

@@ -1,6 +1,6 @@
import unittest
from reproduction.matching.data import SNLIDataLoader
from fastNLP.core.vocabulary import VocabularyOption
from ..data import SNLIDataLoader
from fastNLP.core.vocabulary import Vocabulary


class TestCWSDataLoader(unittest.TestCase):


+ 1
- 1
reproduction/seqence_labelling/cws/test/test_CWSDataLoader.py View File

@@ -1,7 +1,7 @@


import unittest
from reproduction.seqence_labelling.cws.data.CWSDataLoader import SigHanLoader
from ..data.CWSDataLoader import SigHanLoader
from fastNLP.core.vocabulary import VocabularyOption




Loading…
Cancel
Save