Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleHub
提交
f914eff5
P
PaddleHub
项目概览
PaddlePaddle
/
PaddleHub
大约 1 年 前同步成功
通知
282
Star
12117
Fork
2091
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
200
列表
看板
标记
里程碑
合并请求
4
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleHub
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
200
Issue
200
列表
看板
标记
里程碑
合并请求
4
合并请求
4
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
f914eff5
编写于
8月 06, 2021
作者:
K
KP
提交者:
GitHub
8月 06, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1560 from linjieccc/bug_fix
add suffix for ChunkEvaluator
上级
3f83a8b3
01c032d5
变更
44
隐藏空白更改
内联
并排
Showing
44 changed file
with
98 addition
and
22 deletion
+98
-22
modules/text/language_model/bert-base-cased/README.md
modules/text/language_model/bert-base-cased/README.md
+2
-0
modules/text/language_model/bert-base-cased/module.py
modules/text/language_model/bert-base-cased/module.py
+2
-1
modules/text/language_model/bert-base-chinese/README.md
modules/text/language_model/bert-base-chinese/README.md
+2
-0
modules/text/language_model/bert-base-chinese/module.py
modules/text/language_model/bert-base-chinese/module.py
+2
-1
modules/text/language_model/bert-base-multilingual-cased/README.md
...ext/language_model/bert-base-multilingual-cased/README.md
+2
-0
modules/text/language_model/bert-base-multilingual-cased/module.py
...ext/language_model/bert-base-multilingual-cased/module.py
+2
-1
modules/text/language_model/bert-base-multilingual-uncased/README.md
...t/language_model/bert-base-multilingual-uncased/README.md
+2
-0
modules/text/language_model/bert-base-multilingual-uncased/module.py
...t/language_model/bert-base-multilingual-uncased/module.py
+2
-1
modules/text/language_model/bert-base-uncased/README.md
modules/text/language_model/bert-base-uncased/README.md
+3
-0
modules/text/language_model/bert-base-uncased/module.py
modules/text/language_model/bert-base-uncased/module.py
+2
-1
modules/text/language_model/bert-large-cased/README.md
modules/text/language_model/bert-large-cased/README.md
+3
-0
modules/text/language_model/bert-large-cased/module.py
modules/text/language_model/bert-large-cased/module.py
+2
-1
modules/text/language_model/bert-large-uncased/README.md
modules/text/language_model/bert-large-uncased/README.md
+3
-0
modules/text/language_model/bert-large-uncased/module.py
modules/text/language_model/bert-large-uncased/module.py
+2
-1
modules/text/language_model/chinese_bert_wwm/README.md
modules/text/language_model/chinese_bert_wwm/README.md
+3
-0
modules/text/language_model/chinese_bert_wwm/module.py
modules/text/language_model/chinese_bert_wwm/module.py
+2
-1
modules/text/language_model/chinese_bert_wwm_ext/README.md
modules/text/language_model/chinese_bert_wwm_ext/README.md
+3
-0
modules/text/language_model/chinese_bert_wwm_ext/module.py
modules/text/language_model/chinese_bert_wwm_ext/module.py
+2
-1
modules/text/language_model/chinese_electra_base/README.md
modules/text/language_model/chinese_electra_base/README.md
+2
-0
modules/text/language_model/chinese_electra_base/module.py
modules/text/language_model/chinese_electra_base/module.py
+2
-1
modules/text/language_model/chinese_electra_small/README.md
modules/text/language_model/chinese_electra_small/README.md
+2
-0
modules/text/language_model/chinese_electra_small/module.py
modules/text/language_model/chinese_electra_small/module.py
+2
-1
modules/text/language_model/electra_base/README.md
modules/text/language_model/electra_base/README.md
+2
-0
modules/text/language_model/electra_base/module.py
modules/text/language_model/electra_base/module.py
+2
-1
modules/text/language_model/electra_large/README.md
modules/text/language_model/electra_large/README.md
+2
-0
modules/text/language_model/electra_large/module.py
modules/text/language_model/electra_large/module.py
+2
-1
modules/text/language_model/electra_small/README.md
modules/text/language_model/electra_small/README.md
+2
-0
modules/text/language_model/electra_small/module.py
modules/text/language_model/electra_small/module.py
+2
-1
modules/text/language_model/ernie/README.md
modules/text/language_model/ernie/README.md
+2
-0
modules/text/language_model/ernie/module.py
modules/text/language_model/ernie/module.py
+2
-1
modules/text/language_model/ernie_tiny/README.md
modules/text/language_model/ernie_tiny/README.md
+2
-0
modules/text/language_model/ernie_tiny/module.py
modules/text/language_model/ernie_tiny/module.py
+2
-1
modules/text/language_model/ernie_v2_eng_base/README.md
modules/text/language_model/ernie_v2_eng_base/README.md
+2
-0
modules/text/language_model/ernie_v2_eng_base/module.py
modules/text/language_model/ernie_v2_eng_base/module.py
+2
-1
modules/text/language_model/ernie_v2_eng_large/README.md
modules/text/language_model/ernie_v2_eng_large/README.md
+3
-0
modules/text/language_model/ernie_v2_eng_large/module.py
modules/text/language_model/ernie_v2_eng_large/module.py
+2
-1
modules/text/language_model/rbt3/README.md
modules/text/language_model/rbt3/README.md
+3
-0
modules/text/language_model/rbt3/module.py
modules/text/language_model/rbt3/module.py
+2
-1
modules/text/language_model/rbtl3/README.md
modules/text/language_model/rbtl3/README.md
+3
-0
modules/text/language_model/rbtl3/module.py
modules/text/language_model/rbtl3/module.py
+2
-1
modules/text/language_model/roberta-wwm-ext-large/README.md
modules/text/language_model/roberta-wwm-ext-large/README.md
+3
-0
modules/text/language_model/roberta-wwm-ext-large/module.py
modules/text/language_model/roberta-wwm-ext-large/module.py
+2
-1
modules/text/language_model/roberta-wwm-ext/README.md
modules/text/language_model/roberta-wwm-ext/README.md
+3
-0
modules/text/language_model/roberta-wwm-ext/module.py
modules/text/language_model/roberta-wwm-ext/module.py
+2
-1
未找到文件。
modules/text/language_model/bert-base-cased/README.md
浏览文件 @
f914eff5
...
...
@@ -16,6 +16,7 @@ def __init__(
load_checkpoint
=
None
,
label_map
=
None
,
num_classes
=
2
,
suffix
=
False
,
**
kwargs
,
)
```
...
...
@@ -28,6 +29,7 @@ def __init__(
*
`load_checkpoint`
:使用PaddleHub Fine-tune api训练保存的模型参数文件路径。
*
`label_map`
:预测时的类别映射表。
*
`num_classes`
:分类任务的类别数,如果指定了
`label_map`
,此参数可不传,默认2分类。
*
`suffix`
: 序列标注任务的标签格式,如果设定为
`True`
,标签以'-B', '-I', '-E' 或者 '-S'为结尾,此参数默认为
`False`
。
*
`**kwargs`
:用户额外指定的关键字字典类型的参数。
```
python
...
...
modules/text/language_model/bert-base-cased/module.py
浏览文件 @
f914eff5
...
...
@@ -47,6 +47,7 @@ class Bert(nn.Layer):
load_checkpoint
:
str
=
None
,
label_map
:
Dict
=
None
,
num_classes
:
int
=
2
,
suffix
:
bool
=
False
,
**
kwargs
,
):
super
(
Bert
,
self
).
__init__
()
...
...
@@ -70,7 +71,7 @@ class Bert(nn.Layer):
self
.
model
=
BertForTokenClassification
.
from_pretrained
(
pretrained_model_name_or_path
=
'bert-base-cased'
,
num_classes
=
self
.
num_classes
,
**
kwargs
)
self
.
criterion
=
paddle
.
nn
.
loss
.
CrossEntropyLoss
()
self
.
metric
=
ChunkEvaluator
(
label_list
=
[
self
.
label_map
[
i
]
for
i
in
sorted
(
self
.
label_map
.
keys
())])
self
.
metric
=
ChunkEvaluator
(
label_list
=
[
self
.
label_map
[
i
]
for
i
in
sorted
(
self
.
label_map
.
keys
())]
,
suffix
=
suffix
)
elif
task
==
'text-matching'
:
self
.
model
=
BertModel
.
from_pretrained
(
pretrained_model_name_or_path
=
'bert-base-cased'
,
**
kwargs
)
self
.
dropout
=
paddle
.
nn
.
Dropout
(
0.1
)
...
...
modules/text/language_model/bert-base-chinese/README.md
浏览文件 @
f914eff5
...
...
@@ -16,6 +16,7 @@ def __init__(
load_checkpoint
=
None
,
label_map
=
None
,
num_classes
=
2
,
suffix
=
False
,
**
kwargs
,
)
```
...
...
@@ -28,6 +29,7 @@ def __init__(
*
`load_checkpoint`
:使用PaddleHub Fine-tune api训练保存的模型参数文件路径。
*
`label_map`
:预测时的类别映射表。
*
`num_classes`
:分类任务的类别数,如果指定了
`label_map`
,此参数可不传,默认2分类。
*
`suffix`
: 序列标注任务的标签格式,如果设定为
`True`
,标签以'-B', '-I', '-E' 或者 '-S'为结尾,此参数默认为
`False`
。
*
`**kwargs`
:用户额外指定的关键字字典类型的参数。
```
python
def
predict
(
...
...
modules/text/language_model/bert-base-chinese/module.py
浏览文件 @
f914eff5
...
...
@@ -47,6 +47,7 @@ class Bert(nn.Layer):
load_checkpoint
:
str
=
None
,
label_map
:
Dict
=
None
,
num_classes
:
int
=
2
,
suffix
:
bool
=
False
,
**
kwargs
,
):
super
(
Bert
,
self
).
__init__
()
...
...
@@ -70,7 +71,7 @@ class Bert(nn.Layer):
self
.
model
=
BertForTokenClassification
.
from_pretrained
(
pretrained_model_name_or_path
=
'bert-base-chinese'
,
num_classes
=
self
.
num_classes
,
**
kwargs
)
self
.
criterion
=
paddle
.
nn
.
loss
.
CrossEntropyLoss
()
self
.
metric
=
ChunkEvaluator
(
label_list
=
[
self
.
label_map
[
i
]
for
i
in
sorted
(
self
.
label_map
.
keys
())])
self
.
metric
=
ChunkEvaluator
(
label_list
=
[
self
.
label_map
[
i
]
for
i
in
sorted
(
self
.
label_map
.
keys
())]
,
suffix
=
suffix
)
elif
task
==
'text-matching'
:
self
.
model
=
BertModel
.
from_pretrained
(
pretrained_model_name_or_path
=
'bert-base-chinese'
,
**
kwargs
)
self
.
dropout
=
paddle
.
nn
.
Dropout
(
0.1
)
...
...
modules/text/language_model/bert-base-multilingual-cased/README.md
浏览文件 @
f914eff5
...
...
@@ -16,6 +16,7 @@ def __init__(
load_checkpoint
=
None
,
label_map
=
None
,
num_classes
=
2
,
suffix
=
False
,
**
kwargs
,
)
```
...
...
@@ -28,6 +29,7 @@ def __init__(
*
`load_checkpoint`
:使用PaddleHub Fine-tune api训练保存的模型参数文件路径。
*
`label_map`
:预测时的类别映射表。
*
`num_classes`
:分类任务的类别数,如果指定了
`label_map`
,此参数可不传,默认2分类。
*
`suffix`
: 序列标注任务的标签格式,如果设定为
`True`
,标签以'-B', '-I', '-E' 或者 '-S'为结尾,此参数默认为
`False`
。
*
`**kwargs`
:用户额外指定的关键字字典类型的参数。
```
python
def
predict
(
...
...
modules/text/language_model/bert-base-multilingual-cased/module.py
浏览文件 @
f914eff5
...
...
@@ -47,6 +47,7 @@ class Bert(nn.Layer):
load_checkpoint
:
str
=
None
,
label_map
:
Dict
=
None
,
num_classes
:
int
=
2
,
suffix
:
bool
=
False
,
**
kwargs
,
):
super
(
Bert
,
self
).
__init__
()
...
...
@@ -70,7 +71,7 @@ class Bert(nn.Layer):
self
.
model
=
BertForTokenClassification
.
from_pretrained
(
pretrained_model_name_or_path
=
'bert-base-multilingual-cased'
,
num_classes
=
self
.
num_classes
,
**
kwargs
)
self
.
criterion
=
paddle
.
nn
.
loss
.
CrossEntropyLoss
()
self
.
metric
=
ChunkEvaluator
(
label_list
=
[
self
.
label_map
[
i
]
for
i
in
sorted
(
self
.
label_map
.
keys
())])
self
.
metric
=
ChunkEvaluator
(
label_list
=
[
self
.
label_map
[
i
]
for
i
in
sorted
(
self
.
label_map
.
keys
())]
,
suffix
=
suffix
)
elif
task
==
'text-matching'
:
self
.
model
=
BertModel
.
from_pretrained
(
pretrained_model_name_or_path
=
'bert-base-multilingual-cased'
,
**
kwargs
)
...
...
modules/text/language_model/bert-base-multilingual-uncased/README.md
浏览文件 @
f914eff5
...
...
@@ -16,6 +16,7 @@ def __init__(
load_checkpoint
=
None
,
label_map
=
None
,
num_classes
=
2
,
suffix
=
False
,
**
kwargs
,
)
```
...
...
@@ -28,6 +29,7 @@ def __init__(
*
`load_checkpoint`
:使用PaddleHub Fine-tune api训练保存的模型参数文件路径。
*
`label_map`
:预测时的类别映射表。
*
`num_classes`
:分类任务的类别数,如果指定了
`label_map`
,此参数可不传,默认2分类。
*
`suffix`
: 序列标注任务的标签格式,如果设定为
`True`
,标签以'-B', '-I', '-E' 或者 '-S'为结尾,此参数默认为
`False`
。
*
`**kwargs`
:用户额外指定的关键字字典类型的参数。
```
python
def
predict
(
...
...
modules/text/language_model/bert-base-multilingual-uncased/module.py
浏览文件 @
f914eff5
...
...
@@ -47,6 +47,7 @@ class Bert(nn.Layer):
load_checkpoint
:
str
=
None
,
label_map
:
Dict
=
None
,
num_classes
:
int
=
2
,
suffix
:
bool
=
False
,
**
kwargs
,
):
super
(
Bert
,
self
).
__init__
()
...
...
@@ -70,7 +71,7 @@ class Bert(nn.Layer):
self
.
model
=
BertForTokenClassification
.
from_pretrained
(
pretrained_model_name_or_path
=
'bert-base-multilingual-uncased'
,
num_classes
=
self
.
num_classes
,
**
kwargs
)
self
.
criterion
=
paddle
.
nn
.
loss
.
CrossEntropyLoss
()
self
.
metric
=
ChunkEvaluator
(
label_list
=
[
self
.
label_map
[
i
]
for
i
in
sorted
(
self
.
label_map
.
keys
())])
self
.
metric
=
ChunkEvaluator
(
label_list
=
[
self
.
label_map
[
i
]
for
i
in
sorted
(
self
.
label_map
.
keys
())]
,
suffix
=
suffix
)
elif
task
==
'text-matching'
:
self
.
model
=
BertModel
.
from_pretrained
(
pretrained_model_name_or_path
=
'bert-base-multilingual-uncased'
,
**
kwargs
)
...
...
modules/text/language_model/bert-base-uncased/README.md
浏览文件 @
f914eff5
...
...
@@ -16,6 +16,7 @@ def __init__(
load_checkpoint
=
None
,
label_map
=
None
,
num_classes
=
2
,
suffix
=
False
,
**
kwargs
,
)
```
...
...
@@ -28,7 +29,9 @@ def __init__(
*
`load_checkpoint`
:使用PaddleHub Fine-tune api训练保存的模型参数文件路径。
*
`label_map`
:预测时的类别映射表。
*
`num_classes`
:分类任务的类别数,如果指定了
`label_map`
,此参数可不传,默认2分类。
*
`suffix`
: 序列标注任务的标签格式,如果设定为
`True`
,标签以'-B', '-I', '-E' 或者 '-S'为结尾,此参数默认为
`False`
。
*
`**kwargs`
:用户额外指定的关键字字典类型的参数。
```
python
def
predict
(
data
,
...
...
modules/text/language_model/bert-base-uncased/module.py
浏览文件 @
f914eff5
...
...
@@ -47,6 +47,7 @@ class Bert(nn.Layer):
load_checkpoint
:
str
=
None
,
label_map
:
Dict
=
None
,
num_classes
:
int
=
2
,
suffix
:
bool
=
False
,
**
kwargs
,
):
super
(
Bert
,
self
).
__init__
()
...
...
@@ -70,7 +71,7 @@ class Bert(nn.Layer):
self
.
model
=
BertForTokenClassification
.
from_pretrained
(
pretrained_model_name_or_path
=
'bert-base-uncased'
,
num_classes
=
self
.
num_classes
,
**
kwargs
)
self
.
criterion
=
paddle
.
nn
.
loss
.
CrossEntropyLoss
()
self
.
metric
=
ChunkEvaluator
(
label_list
=
[
self
.
label_map
[
i
]
for
i
in
sorted
(
self
.
label_map
.
keys
())])
self
.
metric
=
ChunkEvaluator
(
label_list
=
[
self
.
label_map
[
i
]
for
i
in
sorted
(
self
.
label_map
.
keys
())]
,
suffix
=
suffix
)
elif
task
==
'text-matching'
:
self
.
model
=
BertModel
.
from_pretrained
(
pretrained_model_name_or_path
=
'bert-base-uncased'
,
**
kwargs
)
self
.
dropout
=
paddle
.
nn
.
Dropout
(
0.1
)
...
...
modules/text/language_model/bert-large-cased/README.md
浏览文件 @
f914eff5
...
...
@@ -16,6 +16,7 @@ def __init__(
load_checkpoint
=
None
,
label_map
=
None
,
num_classes
=
2
,
suffix
=
False
,
**
kwargs
,
)
```
...
...
@@ -28,7 +29,9 @@ def __init__(
*
`load_checkpoint`
:使用PaddleHub Fine-tune api训练保存的模型参数文件路径。
*
`label_map`
:预测时的类别映射表。
*
`num_classes`
:分类任务的类别数,如果指定了
`label_map`
,此参数可不传,默认2分类。
*
`suffix`
: 序列标注任务的标签格式,如果设定为
`True`
,标签以'-B', '-I', '-E' 或者 '-S'为结尾,此参数默认为
`False`
。
*
`**kwargs`
:用户额外指定的关键字字典类型的参数。
```
python
def
predict
(
data
,
...
...
modules/text/language_model/bert-large-cased/module.py
浏览文件 @
f914eff5
...
...
@@ -47,6 +47,7 @@ class Bert(nn.Layer):
load_checkpoint
:
str
=
None
,
label_map
:
Dict
=
None
,
num_classes
:
int
=
2
,
suffix
:
bool
=
False
,
**
kwargs
,
):
super
(
Bert
,
self
).
__init__
()
...
...
@@ -70,7 +71,7 @@ class Bert(nn.Layer):
self
.
model
=
BertForTokenClassification
.
from_pretrained
(
pretrained_model_name_or_path
=
'bert-large-cased'
,
num_classes
=
self
.
num_classes
,
**
kwargs
)
self
.
criterion
=
paddle
.
nn
.
loss
.
CrossEntropyLoss
()
self
.
metric
=
ChunkEvaluator
(
label_list
=
[
self
.
label_map
[
i
]
for
i
in
sorted
(
self
.
label_map
.
keys
())])
self
.
metric
=
ChunkEvaluator
(
label_list
=
[
self
.
label_map
[
i
]
for
i
in
sorted
(
self
.
label_map
.
keys
())]
,
suffix
=
suffix
)
elif
task
==
'text-matching'
:
self
.
model
=
BertModel
.
from_pretrained
(
pretrained_model_name_or_path
=
'bert-large-cased'
,
**
kwargs
)
self
.
dropout
=
paddle
.
nn
.
Dropout
(
0.1
)
...
...
modules/text/language_model/bert-large-uncased/README.md
浏览文件 @
f914eff5
...
...
@@ -16,6 +16,7 @@ def __init__(
load_checkpoint
=
None
,
label_map
=
None
,
num_classes
=
2
,
suffix
=
False
,
**
kwargs
,
)
```
...
...
@@ -28,7 +29,9 @@ def __init__(
*
`load_checkpoint`
:使用PaddleHub Fine-tune api训练保存的模型参数文件路径。
*
`label_map`
:预测时的类别映射表。
*
`num_classes`
:分类任务的类别数,如果指定了
`label_map`
,此参数可不传,默认2分类。
*
`suffix`
: 序列标注任务的标签格式,如果设定为
`True`
,标签以'-B', '-I', '-E' 或者 '-S'为结尾,此参数默认为
`False`
。
*
`**kwargs`
:用户额外指定的关键字字典类型的参数。
```
python
def
predict
(
data
,
...
...
modules/text/language_model/bert-large-uncased/module.py
浏览文件 @
f914eff5
...
...
@@ -47,6 +47,7 @@ class Bert(nn.Layer):
load_checkpoint
:
str
=
None
,
label_map
:
Dict
=
None
,
num_classes
:
int
=
2
,
suffix
:
bool
=
False
,
**
kwargs
,
):
super
(
Bert
,
self
).
__init__
()
...
...
@@ -70,7 +71,7 @@ class Bert(nn.Layer):
self
.
model
=
BertForTokenClassification
.
from_pretrained
(
pretrained_model_name_or_path
=
'bert-large-uncased'
,
num_classes
=
self
.
num_classes
,
**
kwargs
)
self
.
criterion
=
paddle
.
nn
.
loss
.
CrossEntropyLoss
()
self
.
metric
=
ChunkEvaluator
(
label_list
=
[
self
.
label_map
[
i
]
for
i
in
sorted
(
self
.
label_map
.
keys
())])
self
.
metric
=
ChunkEvaluator
(
label_list
=
[
self
.
label_map
[
i
]
for
i
in
sorted
(
self
.
label_map
.
keys
())]
,
suffix
=
suffix
)
elif
task
==
'text-matching'
:
self
.
model
=
BertModel
.
from_pretrained
(
pretrained_model_name_or_path
=
'bert-large-uncased'
,
**
kwargs
)
self
.
dropout
=
paddle
.
nn
.
Dropout
(
0.1
)
...
...
modules/text/language_model/chinese_bert_wwm/README.md
浏览文件 @
f914eff5
...
...
@@ -14,6 +14,7 @@ def __init__(
load_checkpoint
=
None
,
label_map
=
None
,
num_classes
=
2
,
suffix
=
False
,
**
kwargs
,
)
```
...
...
@@ -26,7 +27,9 @@ def __init__(
*
`load_checkpoint`
:使用PaddleHub Fine-tune api训练保存的模型参数文件路径。
*
`label_map`
:预测时的类别映射表。
*
`num_classes`
:分类任务的类别数,如果指定了
`label_map`
,此参数可不传,默认2分类。
*
`suffix`
: 序列标注任务的标签格式,如果设定为
`True`
,标签以'-B', '-I', '-E' 或者 '-S'为结尾,此参数默认为
`False`
。
*
`**kwargs`
:用户额外指定的关键字字典类型的参数。
```
python
def
predict
(
data
,
...
...
modules/text/language_model/chinese_bert_wwm/module.py
浏览文件 @
f914eff5
...
...
@@ -47,6 +47,7 @@ class BertWwm(nn.Layer):
load_checkpoint
:
str
=
None
,
label_map
:
Dict
=
None
,
num_classes
:
int
=
2
,
suffix
:
bool
=
False
,
**
kwargs
,
):
super
(
BertWwm
,
self
).
__init__
()
...
...
@@ -70,7 +71,7 @@ class BertWwm(nn.Layer):
self
.
model
=
BertForTokenClassification
.
from_pretrained
(
pretrained_model_name_or_path
=
'bert-wwm-chinese'
,
num_classes
=
self
.
num_classes
,
**
kwargs
)
self
.
criterion
=
paddle
.
nn
.
loss
.
CrossEntropyLoss
()
self
.
metric
=
ChunkEvaluator
(
label_list
=
[
self
.
label_map
[
i
]
for
i
in
sorted
(
self
.
label_map
.
keys
())])
self
.
metric
=
ChunkEvaluator
(
label_list
=
[
self
.
label_map
[
i
]
for
i
in
sorted
(
self
.
label_map
.
keys
())]
,
suffix
=
suffix
)
elif
task
==
'text-matching'
:
self
.
model
=
BertModel
.
from_pretrained
(
pretrained_model_name_or_path
=
'bert-wwm-chinese'
,
**
kwargs
)
self
.
dropout
=
paddle
.
nn
.
Dropout
(
0.1
)
...
...
modules/text/language_model/chinese_bert_wwm_ext/README.md
浏览文件 @
f914eff5
...
...
@@ -14,6 +14,7 @@ def __init__(
load_checkpoint
=
None
,
label_map
=
None
,
num_classes
=
2
,
suffix
=
False
,
**
kwargs
,
)
```
...
...
@@ -26,7 +27,9 @@ def __init__(
*
`load_checkpoint`
:使用PaddleHub Fine-tune api训练保存的模型参数文件路径。
*
`label_map`
:预测时的类别映射表。
*
`num_classes`
:分类任务的类别数,如果指定了
`label_map`
,此参数可不传,默认2分类。
*
`suffix`
: 序列标注任务的标签格式,如果设定为
`True`
,标签以'-B', '-I', '-E' 或者 '-S'为结尾,此参数默认为
`False`
。
*
`**kwargs`
:用户额外指定的关键字字典类型的参数。
```
python
def
predict
(
data
,
...
...
modules/text/language_model/chinese_bert_wwm_ext/module.py
浏览文件 @
f914eff5
...
...
@@ -47,6 +47,7 @@ class BertWwm(nn.Layer):
load_checkpoint
:
str
=
None
,
label_map
:
Dict
=
None
,
num_classes
:
int
=
2
,
suffix
:
bool
=
False
,
**
kwargs
,
):
super
(
BertWwm
,
self
).
__init__
()
...
...
@@ -70,7 +71,7 @@ class BertWwm(nn.Layer):
self
.
model
=
BertForTokenClassification
.
from_pretrained
(
pretrained_model_name_or_path
=
'bert-wwm-ext-chinese'
,
num_classes
=
self
.
num_classes
,
**
kwargs
)
self
.
criterion
=
paddle
.
nn
.
loss
.
CrossEntropyLoss
()
self
.
metric
=
ChunkEvaluator
(
label_list
=
[
self
.
label_map
[
i
]
for
i
in
sorted
(
self
.
label_map
.
keys
())])
self
.
metric
=
ChunkEvaluator
(
label_list
=
[
self
.
label_map
[
i
]
for
i
in
sorted
(
self
.
label_map
.
keys
())]
,
suffix
=
suffix
)
elif
task
==
'text-matching'
:
self
.
model
=
BertModel
.
from_pretrained
(
pretrained_model_name_or_path
=
'bert-wwm-ext-chinese'
,
**
kwargs
)
self
.
dropout
=
paddle
.
nn
.
Dropout
(
0.1
)
...
...
modules/text/language_model/chinese_electra_base/README.md
浏览文件 @
f914eff5
...
...
@@ -15,6 +15,7 @@ def __init__(
load_checkpoint
=
None
,
label_map
=
None
,
num_classes
=
2
,
suffix
=
False
,
**
kwargs
,
)
```
...
...
@@ -27,6 +28,7 @@ def __init__(
*
`load_checkpoint`
:使用PaddleHub Fine-tune api训练保存的模型参数文件路径。
*
`label_map`
:预测时的类别映射表。
*
`num_classes`
:分类任务的类别数,如果指定了
`label_map`
,此参数可不传,默认2分类。
*
`suffix`
: 序列标注任务的标签格式,如果设定为
`True`
,标签以'-B', '-I', '-E' 或者 '-S'为结尾,此参数默认为
`False`
。
*
`**kwargs`
:用户额外指定的关键字字典类型的参数。
```
python
...
...
modules/text/language_model/chinese_electra_base/module.py
浏览文件 @
f914eff5
...
...
@@ -47,6 +47,7 @@ class Electra(nn.Layer):
load_checkpoint
:
str
=
None
,
label_map
:
Dict
=
None
,
num_classes
:
int
=
2
,
suffix
:
bool
=
False
,
**
kwargs
,
):
super
(
Electra
,
self
).
__init__
()
...
...
@@ -70,7 +71,7 @@ class Electra(nn.Layer):
self
.
model
=
ElectraForTokenClassification
.
from_pretrained
(
pretrained_model_name_or_path
=
'chinese-electra-base'
,
num_classes
=
self
.
num_classes
,
**
kwargs
)
self
.
criterion
=
paddle
.
nn
.
loss
.
CrossEntropyLoss
()
self
.
metric
=
ChunkEvaluator
(
label_list
=
[
self
.
label_map
[
i
]
for
i
in
sorted
(
self
.
label_map
.
keys
())])
self
.
metric
=
ChunkEvaluator
(
label_list
=
[
self
.
label_map
[
i
]
for
i
in
sorted
(
self
.
label_map
.
keys
())]
,
suffix
=
suffix
)
elif
task
==
'text-matching'
:
self
.
model
=
ElectraModel
.
from_pretrained
(
pretrained_model_name_or_path
=
'chinese-electra-base'
,
**
kwargs
)
self
.
dropout
=
paddle
.
nn
.
Dropout
(
0.1
)
...
...
modules/text/language_model/chinese_electra_small/README.md
浏览文件 @
f914eff5
...
...
@@ -15,6 +15,7 @@ def __init__(
load_checkpoint
=
None
,
label_map
=
None
,
num_classes
=
2
,
suffix
=
False
,
**
kwargs
,
)
```
...
...
@@ -27,6 +28,7 @@ def __init__(
*
`load_checkpoint`
:使用PaddleHub Fine-tune api训练保存的模型参数文件路径。
*
`label_map`
:预测时的类别映射表。
*
`num_classes`
:分类任务的类别数,如果指定了
`label_map`
,此参数可不传,默认2分类。
*
`suffix`
: 序列标注任务的标签格式,如果设定为
`True`
,标签以'-B', '-I', '-E' 或者 '-S'为结尾,此参数默认为
`False`
。
*
`**kwargs`
:用户额外指定的关键字字典类型的参数。
```
python
...
...
modules/text/language_model/chinese_electra_small/module.py
浏览文件 @
f914eff5
...
...
@@ -47,6 +47,7 @@ class Electra(nn.Layer):
load_checkpoint
:
str
=
None
,
label_map
:
Dict
=
None
,
num_classes
:
int
=
2
,
suffix
:
bool
=
False
,
**
kwargs
,
):
super
(
Electra
,
self
).
__init__
()
...
...
@@ -70,7 +71,7 @@ class Electra(nn.Layer):
self
.
model
=
ElectraForTokenClassification
.
from_pretrained
(
pretrained_model_name_or_path
=
'chinese-electra-small'
,
num_classes
=
self
.
num_classes
,
**
kwargs
)
self
.
criterion
=
paddle
.
nn
.
loss
.
CrossEntropyLoss
()
self
.
metric
=
ChunkEvaluator
(
label_list
=
[
self
.
label_map
[
i
]
for
i
in
sorted
(
self
.
label_map
.
keys
())])
self
.
metric
=
ChunkEvaluator
(
label_list
=
[
self
.
label_map
[
i
]
for
i
in
sorted
(
self
.
label_map
.
keys
())]
,
suffix
=
suffix
)
elif
task
==
'text-matching'
:
self
.
model
=
ElectraModel
.
from_pretrained
(
pretrained_model_name_or_path
=
'chinese-electra-small'
,
**
kwargs
)
self
.
dropout
=
paddle
.
nn
.
Dropout
(
0.1
)
...
...
modules/text/language_model/electra_base/README.md
浏览文件 @
f914eff5
...
...
@@ -15,6 +15,7 @@ def __init__(
load_checkpoint
=
None
,
label_map
=
None
,
num_classes
=
2
,
suffix
=
False
,
**
kwargs
,
)
```
...
...
@@ -27,6 +28,7 @@ def __init__(
*
`load_checkpoint`
:使用PaddleHub Fine-tune api训练保存的模型参数文件路径。
*
`label_map`
:预测时的类别映射表。
*
`num_classes`
:分类任务的类别数,如果指定了
`label_map`
,此参数可不传,默认2分类。
*
`suffix`
: 序列标注任务的标签格式,如果设定为
`True`
,标签以'-B', '-I', '-E' 或者 '-S'为结尾,此参数默认为
`False`
。
*
`**kwargs`
:用户额外指定的关键字字典类型的参数。
```
python
...
...
modules/text/language_model/electra_base/module.py
浏览文件 @
f914eff5
...
...
@@ -46,6 +46,7 @@ class Electra(nn.Layer):
load_checkpoint
:
str
=
None
,
label_map
:
Dict
=
None
,
num_classes
:
int
=
2
,
suffix
:
bool
=
False
,
**
kwargs
,
):
super
(
Electra
,
self
).
__init__
()
...
...
@@ -69,7 +70,7 @@ class Electra(nn.Layer):
self
.
model
=
ElectraForTokenClassification
.
from_pretrained
(
pretrained_model_name_or_path
=
'electra-base'
,
num_classes
=
self
.
num_classes
,
**
kwargs
)
self
.
criterion
=
paddle
.
nn
.
loss
.
CrossEntropyLoss
()
self
.
metric
=
ChunkEvaluator
(
label_list
=
[
self
.
label_map
[
i
]
for
i
in
sorted
(
self
.
label_map
.
keys
())])
self
.
metric
=
ChunkEvaluator
(
label_list
=
[
self
.
label_map
[
i
]
for
i
in
sorted
(
self
.
label_map
.
keys
())]
,
suffix
=
suffix
)
elif
task
==
'text-matching'
:
self
.
model
=
ElectraModel
.
from_pretrained
(
pretrained_model_name_or_path
=
'electra-base'
,
**
kwargs
)
self
.
dropout
=
paddle
.
nn
.
Dropout
(
0.1
)
...
...
modules/text/language_model/electra_large/README.md
浏览文件 @
f914eff5
...
...
@@ -15,6 +15,7 @@ def __init__(
load_checkpoint
=
None
,
label_map
=
None
,
num_classes
=
2
,
suffix
=
False
,
**
kwargs
,
)
```
...
...
@@ -27,6 +28,7 @@ def __init__(
*
`load_checkpoint`
:使用PaddleHub Fine-tune api训练保存的模型参数文件路径。
*
`label_map`
:预测时的类别映射表。
*
`num_classes`
:分类任务的类别数,如果指定了
`label_map`
,此参数可不传,默认2分类。
*
`suffix`
: 序列标注任务的标签格式,如果设定为
`True`
,标签以'-B', '-I', '-E' 或者 '-S'为结尾,此参数默认为
`False`
。
*
`**kwargs`
:用户额外指定的关键字字典类型的参数。
```
python
...
...
modules/text/language_model/electra_large/module.py
浏览文件 @
f914eff5
...
...
@@ -46,6 +46,7 @@ class Electra(nn.Layer):
load_checkpoint
:
str
=
None
,
label_map
:
Dict
=
None
,
num_classes
:
int
=
2
,
suffix
:
bool
=
False
,
**
kwargs
,
):
super
(
Electra
,
self
).
__init__
()
...
...
@@ -69,7 +70,7 @@ class Electra(nn.Layer):
self
.
model
=
ElectraForTokenClassification
.
from_pretrained
(
pretrained_model_name_or_path
=
'electra-large'
,
num_classes
=
self
.
num_classes
,
**
kwargs
)
self
.
criterion
=
paddle
.
nn
.
loss
.
CrossEntropyLoss
()
self
.
metric
=
ChunkEvaluator
(
label_list
=
[
self
.
label_map
[
i
]
for
i
in
sorted
(
self
.
label_map
.
keys
())])
self
.
metric
=
ChunkEvaluator
(
label_list
=
[
self
.
label_map
[
i
]
for
i
in
sorted
(
self
.
label_map
.
keys
())]
,
suffix
=
suffix
)
elif
task
==
'text-matching'
:
self
.
model
=
ElectraModel
.
from_pretrained
(
pretrained_model_name_or_path
=
'electra-large'
,
**
kwargs
)
self
.
dropout
=
paddle
.
nn
.
Dropout
(
0.1
)
...
...
modules/text/language_model/electra_small/README.md
浏览文件 @
f914eff5
...
...
@@ -15,6 +15,7 @@ def __init__(
load_checkpoint
=
None
,
label_map
=
None
,
num_classes
=
2
,
suffix
=
False
,
**
kwargs
,
)
```
...
...
@@ -27,6 +28,7 @@ def __init__(
*
`load_checkpoint`
:使用PaddleHub Fine-tune api训练保存的模型参数文件路径。
*
`label_map`
:预测时的类别映射表。
*
`num_classes`
:分类任务的类别数,如果指定了
`label_map`
,此参数可不传,默认2分类。
*
`suffix`
: 序列标注任务的标签格式,如果设定为
`True`
,标签以'-B', '-I', '-E' 或者 '-S'为结尾,此参数默认为
`False`
。
*
`**kwargs`
:用户额外指定的关键字字典类型的参数。
```
python
...
...
modules/text/language_model/electra_small/module.py
浏览文件 @
f914eff5
...
...
@@ -46,6 +46,7 @@ class Electra(nn.Layer):
load_checkpoint
:
str
=
None
,
label_map
:
Dict
=
None
,
num_classes
:
int
=
2
,
suffix
:
bool
=
False
,
**
kwargs
,
):
super
(
Electra
,
self
).
__init__
()
...
...
@@ -69,7 +70,7 @@ class Electra(nn.Layer):
self
.
model
=
ElectraForTokenClassification
.
from_pretrained
(
pretrained_model_name_or_path
=
'electra-small'
,
num_classes
=
self
.
num_classes
,
**
kwargs
)
self
.
criterion
=
paddle
.
nn
.
loss
.
CrossEntropyLoss
()
self
.
metric
=
ChunkEvaluator
(
label_list
=
[
self
.
label_map
[
i
]
for
i
in
sorted
(
self
.
label_map
.
keys
())])
self
.
metric
=
ChunkEvaluator
(
label_list
=
[
self
.
label_map
[
i
]
for
i
in
sorted
(
self
.
label_map
.
keys
())]
,
suffix
=
suffix
)
elif
task
==
'text-matching'
:
self
.
model
=
ElectraModel
.
from_pretrained
(
pretrained_model_name_or_path
=
'electra-small'
,
**
kwargs
)
self
.
dropout
=
paddle
.
nn
.
Dropout
(
0.1
)
...
...
modules/text/language_model/ernie/README.md
浏览文件 @
f914eff5
...
...
@@ -25,6 +25,7 @@ def __init__(
load_checkpoint
=
None
,
label_map
=
None
,
num_classes
=
2
,
suffix
=
False
,
**
kwargs
,
)
```
...
...
@@ -37,6 +38,7 @@ def __init__(
*
`load_checkpoint`
:使用PaddleHub Fine-tune api训练保存的模型参数文件路径。
*
`label_map`
:预测时的类别映射表。
*
`num_classes`
:分类任务的类别数,如果指定了
`label_map`
,此参数可不传,默认2分类。
*
`suffix`
: 序列标注任务的标签格式,如果设定为
`True`
,标签以'-B', '-I', '-E' 或者 '-S'为结尾,此参数默认为
`False`
。
*
`**kwargs`
:用户额外指定的关键字字典类型的参数。
```
python
...
...
modules/text/language_model/ernie/module.py
浏览文件 @
f914eff5
...
...
@@ -47,6 +47,7 @@ class Ernie(nn.Layer):
load_checkpoint
:
str
=
None
,
label_map
:
Dict
=
None
,
num_classes
:
int
=
2
,
suffix
:
bool
=
False
,
**
kwargs
,
):
super
(
Ernie
,
self
).
__init__
()
...
...
@@ -70,7 +71,7 @@ class Ernie(nn.Layer):
self
.
model
=
ErnieForTokenClassification
.
from_pretrained
(
pretrained_model_name_or_path
=
'ernie-1.0'
,
num_classes
=
self
.
num_classes
,
**
kwargs
)
self
.
criterion
=
paddle
.
nn
.
loss
.
CrossEntropyLoss
()
self
.
metric
=
ChunkEvaluator
(
label_list
=
[
self
.
label_map
[
i
]
for
i
in
sorted
(
self
.
label_map
.
keys
())])
self
.
metric
=
ChunkEvaluator
(
label_list
=
[
self
.
label_map
[
i
]
for
i
in
sorted
(
self
.
label_map
.
keys
())]
,
suffix
=
suffix
)
elif
task
==
'text-matching'
:
self
.
model
=
ErnieModel
.
from_pretrained
(
pretrained_model_name_or_path
=
'ernie-1.0'
,
**
kwargs
)
self
.
dropout
=
paddle
.
nn
.
Dropout
(
0.1
)
...
...
modules/text/language_model/ernie_tiny/README.md
浏览文件 @
f914eff5
...
...
@@ -25,6 +25,7 @@ def __init__(
load_checkpoint
=
None
,
label_map
=
None
,
num_classes
=
2
,
suffix
=
False
,
**
kwargs
,
)
```
...
...
@@ -37,6 +38,7 @@ def __init__(
*
`load_checkpoint`
:使用PaddleHub Fine-tune api训练保存的模型参数文件路径。
*
`label_map`
:预测时的类别映射表。
*
`num_classes`
:分类任务的类别数,如果指定了
`label_map`
,此参数可不传,默认2分类。
*
`suffix`
: 序列标注任务的标签格式,如果设定为
`True`
,标签以'-B', '-I', '-E' 或者 '-S'为结尾,此参数默认为
`False`
。
*
`**kwargs`
:用户额外指定的关键字字典类型的参数。
```
python
...
...
modules/text/language_model/ernie_tiny/module.py
浏览文件 @
f914eff5
...
...
@@ -46,6 +46,7 @@ class ErnieTiny(nn.Layer):
load_checkpoint
:
str
=
None
,
label_map
:
Dict
=
None
,
num_classes
:
int
=
2
,
suffix
:
bool
=
False
,
**
kwargs
,
):
super
(
ErnieTiny
,
self
).
__init__
()
...
...
@@ -69,7 +70,7 @@ class ErnieTiny(nn.Layer):
self
.
model
=
ErnieForTokenClassification
.
from_pretrained
(
pretrained_model_name_or_path
=
'ernie-tiny'
,
num_classes
=
self
.
num_classes
,
**
kwargs
)
self
.
criterion
=
paddle
.
nn
.
loss
.
CrossEntropyLoss
()
self
.
metric
=
ChunkEvaluator
(
label_list
=
[
self
.
label_map
[
i
]
for
i
in
sorted
(
self
.
label_map
.
keys
())])
self
.
metric
=
ChunkEvaluator
(
label_list
=
[
self
.
label_map
[
i
]
for
i
in
sorted
(
self
.
label_map
.
keys
())]
,
suffix
=
suffix
)
elif
task
==
'text-matching'
:
self
.
model
=
ErnieModel
.
from_pretrained
(
pretrained_model_name_or_path
=
'ernie-tiny'
,
**
kwargs
)
self
.
dropout
=
paddle
.
nn
.
Dropout
(
0.1
)
...
...
modules/text/language_model/ernie_v2_eng_base/README.md
浏览文件 @
f914eff5
...
...
@@ -21,6 +21,7 @@ def __init__(
load_checkpoint
=
None
,
label_map
=
None
,
num_classes
=
2
,
suffix
=
False
,
**
kwargs
,
)
```
...
...
@@ -33,6 +34,7 @@ def __init__(
*
`load_checkpoint`
:使用PaddleHub Fine-tune api训练保存的模型参数文件路径。
*
`label_map`
:预测时的类别映射表。
*
`num_classes`
:分类任务的类别数,如果指定了
`label_map`
,此参数可不传,默认2分类。
*
`suffix`
: 序列标注任务的标签格式,如果设定为
`True`
,标签以'-B', '-I', '-E' 或者 '-S'为结尾,此参数默认为
`False`
。
*
`**kwargs`
:用户额外指定的关键字字典类型的参数。
```
python
...
...
modules/text/language_model/ernie_v2_eng_base/module.py
浏览文件 @
f914eff5
...
...
@@ -47,6 +47,7 @@ class ErnieV2(nn.Layer):
load_checkpoint
:
str
=
None
,
label_map
:
Dict
=
None
,
num_classes
:
int
=
2
,
suffix
:
bool
=
False
,
**
kwargs
,
):
super
(
ErnieV2
,
self
).
__init__
()
...
...
@@ -70,7 +71,7 @@ class ErnieV2(nn.Layer):
self
.
model
=
ErnieForTokenClassification
.
from_pretrained
(
pretrained_model_name_or_path
=
'ernie-2.0-en'
,
num_classes
=
self
.
num_classes
,
**
kwargs
)
self
.
criterion
=
paddle
.
nn
.
loss
.
CrossEntropyLoss
()
self
.
metric
=
ChunkEvaluator
(
label_list
=
[
self
.
label_map
[
i
]
for
i
in
sorted
(
self
.
label_map
.
keys
())])
self
.
metric
=
ChunkEvaluator
(
label_list
=
[
self
.
label_map
[
i
]
for
i
in
sorted
(
self
.
label_map
.
keys
())]
,
suffix
=
suffix
)
elif
task
==
'text-matching'
:
self
.
model
=
ErnieModel
.
from_pretrained
(
pretrained_model_name_or_path
=
'ernie-2.0-en'
,
**
kwargs
)
self
.
dropout
=
paddle
.
nn
.
Dropout
(
0.1
)
...
...
modules/text/language_model/ernie_v2_eng_large/README.md
浏览文件 @
f914eff5
...
...
@@ -21,6 +21,7 @@ def __init__(
load_checkpoint
=
None
,
label_map
=
None
,
num_classes
=
2
,
suffix
=
False
,
**
kwargs
,
)
```
...
...
@@ -33,7 +34,9 @@ def __init__(
*
`load_checkpoint`
:使用PaddleHub Fine-tune api训练保存的模型参数文件路径。
*
`label_map`
:预测时的类别映射表。
*
`num_classes`
:分类任务的类别数,如果指定了
`label_map`
,此参数可不传,默认2分类。
*
`suffix`
: 序列标注任务的标签格式,如果设定为
`True`
,标签以'-B', '-I', '-E' 或者 '-S'为结尾,此参数默认为
`False`
。
*
`**kwargs`
:用户额外指定的关键字字典类型的参数。
```
python
def
predict
(
data
,
...
...
modules/text/language_model/ernie_v2_eng_large/module.py
浏览文件 @
f914eff5
...
...
@@ -47,6 +47,7 @@ class ErnieV2(nn.Layer):
load_checkpoint
:
str
=
None
,
label_map
:
Dict
=
None
,
num_classes
:
int
=
2
,
suffix
:
bool
=
False
,
**
kwargs
,
):
super
(
ErnieV2
,
self
).
__init__
()
...
...
@@ -70,7 +71,7 @@ class ErnieV2(nn.Layer):
self
.
model
=
ErnieForTokenClassification
.
from_pretrained
(
pretrained_model_name_or_path
=
'ernie-2.0-large-en'
,
num_classes
=
self
.
num_classes
,
**
kwargs
)
self
.
criterion
=
paddle
.
nn
.
loss
.
CrossEntropyLoss
()
self
.
metric
=
ChunkEvaluator
(
label_list
=
[
self
.
label_map
[
i
]
for
i
in
sorted
(
self
.
label_map
.
keys
())])
self
.
metric
=
ChunkEvaluator
(
label_list
=
[
self
.
label_map
[
i
]
for
i
in
sorted
(
self
.
label_map
.
keys
())]
,
suffix
=
suffix
)
elif
task
==
'text-matching'
:
self
.
model
=
ErnieModel
.
from_pretrained
(
pretrained_model_name_or_path
=
'ernie-2.0-large-en'
,
**
kwargs
)
self
.
dropout
=
paddle
.
nn
.
Dropout
(
0.1
)
...
...
modules/text/language_model/rbt3/README.md
浏览文件 @
f914eff5
...
...
@@ -14,6 +14,7 @@ def __init__(
load_checkpoint
=
None
,
label_map
=
None
,
num_classes
=
2
,
suffix
=
False
,
**
kwargs
,
)
```
...
...
@@ -26,7 +27,9 @@ def __init__(
*
`load_checkpoint`
:使用PaddleHub Fine-tune api训练保存的模型参数文件路径。
*
`label_map`
:预测时的类别映射表。
*
`num_classes`
:分类任务的类别数,如果指定了
`label_map`
,此参数可不传,默认2分类。
*
`suffix`
: 序列标注任务的标签格式,如果设定为
`True`
,标签以'-B', '-I', '-E' 或者 '-S'为结尾,此参数默认为
`False`
。
*
`**kwargs`
:用户额外指定的关键字字典类型的参数。
```
python
def
predict
(
data
,
...
...
modules/text/language_model/rbt3/module.py
浏览文件 @
f914eff5
...
...
@@ -47,6 +47,7 @@ class Roberta(nn.Layer):
load_checkpoint
:
str
=
None
,
label_map
:
Dict
=
None
,
num_classes
:
int
=
2
,
suffix
:
bool
=
False
,
**
kwargs
,
):
super
(
Roberta
,
self
).
__init__
()
...
...
@@ -70,7 +71,7 @@ class Roberta(nn.Layer):
self
.
model
=
RobertaForTokenClassification
.
from_pretrained
(
pretrained_model_name_or_path
=
'rbt3'
,
num_classes
=
self
.
num_classes
,
**
kwargs
)
self
.
criterion
=
paddle
.
nn
.
loss
.
CrossEntropyLoss
()
self
.
metric
=
ChunkEvaluator
(
label_list
=
[
self
.
label_map
[
i
]
for
i
in
sorted
(
self
.
label_map
.
keys
())])
self
.
metric
=
ChunkEvaluator
(
label_list
=
[
self
.
label_map
[
i
]
for
i
in
sorted
(
self
.
label_map
.
keys
())]
,
suffix
=
suffix
)
elif
task
==
'text-matching'
:
self
.
model
=
RobertaModel
.
from_pretrained
(
pretrained_model_name_or_path
=
'rbt3'
,
**
kwargs
)
self
.
dropout
=
paddle
.
nn
.
Dropout
(
0.1
)
...
...
modules/text/language_model/rbtl3/README.md
浏览文件 @
f914eff5
...
...
@@ -14,6 +14,7 @@ def __init__(
load_checkpoint
=
None
,
label_map
=
None
,
num_classes
=
2
,
suffix
=
False
,
**
kwargs
,
)
```
...
...
@@ -26,7 +27,9 @@ def __init__(
*
`load_checkpoint`
:使用PaddleHub Fine-tune api训练保存的模型参数文件路径。
*
`label_map`
:预测时的类别映射表。
*
`num_classes`
:分类任务的类别数,如果指定了
`label_map`
,此参数可不传,默认2分类。
*
`suffix`
: 序列标注任务的标签格式,如果设定为
`True`
,标签以'-B', '-I', '-E' 或者 '-S'为结尾,此参数默认为
`False`
。
*
`**kwargs`
:用户额外指定的关键字字典类型的参数。
```
python
def
predict
(
data
,
...
...
modules/text/language_model/rbtl3/module.py
浏览文件 @
f914eff5
...
...
@@ -47,6 +47,7 @@ class Roberta(nn.Layer):
load_checkpoint
:
str
=
None
,
label_map
:
Dict
=
None
,
num_classes
:
int
=
2
,
suffix
:
bool
=
False
,
**
kwargs
,
):
super
(
Roberta
,
self
).
__init__
()
...
...
@@ -70,7 +71,7 @@ class Roberta(nn.Layer):
self
.
model
=
RobertaForTokenClassification
.
from_pretrained
(
pretrained_model_name_or_path
=
'rbtl3'
,
num_classes
=
self
.
num_classes
,
**
kwargs
)
self
.
criterion
=
paddle
.
nn
.
loss
.
CrossEntropyLoss
()
self
.
metric
=
ChunkEvaluator
(
label_list
=
[
self
.
label_map
[
i
]
for
i
in
sorted
(
self
.
label_map
.
keys
())])
self
.
metric
=
ChunkEvaluator
(
label_list
=
[
self
.
label_map
[
i
]
for
i
in
sorted
(
self
.
label_map
.
keys
())]
,
suffix
=
suffix
)
elif
task
==
'text-matching'
:
self
.
model
=
RobertaModel
.
from_pretrained
(
pretrained_model_name_or_path
=
'rbtl3'
,
**
kwargs
)
self
.
dropout
=
paddle
.
nn
.
Dropout
(
0.1
)
...
...
modules/text/language_model/roberta-wwm-ext-large/README.md
浏览文件 @
f914eff5
...
...
@@ -15,6 +15,7 @@ def __init__(
load_checkpoint
=
None
,
label_map
=
None
,
num_classes
=
2
,
suffix
=
False
,
**
kwargs
,
)
```
...
...
@@ -27,7 +28,9 @@ def __init__(
*
`load_checkpoint`
:使用PaddleHub Fine-tune api训练保存的模型参数文件路径。
*
`label_map`
:预测时的类别映射表。
*
`num_classes`
:分类任务的类别数,如果指定了
`label_map`
,此参数可不传,默认2分类。
*
`suffix`
: 序列标注任务的标签格式,如果设定为
`True`
,标签以'-B', '-I', '-E' 或者 '-S'为结尾,此参数默认为
`False`
。
*
`**kwargs`
:用户额外指定的关键字字典类型的参数。
```
python
def
predict
(
data
,
...
...
modules/text/language_model/roberta-wwm-ext-large/module.py
浏览文件 @
f914eff5
...
...
@@ -48,6 +48,7 @@ class Roberta(nn.Layer):
load_checkpoint
:
str
=
None
,
label_map
:
Dict
=
None
,
num_classes
:
int
=
2
,
suffix
:
bool
=
False
,
**
kwargs
,
):
super
(
Roberta
,
self
).
__init__
()
...
...
@@ -71,7 +72,7 @@ class Roberta(nn.Layer):
self
.
model
=
RobertaForTokenClassification
.
from_pretrained
(
pretrained_model_name_or_path
=
'roberta-wwm-ext-large'
,
num_classes
=
self
.
num_classes
,
**
kwargs
)
self
.
criterion
=
paddle
.
nn
.
loss
.
CrossEntropyLoss
()
self
.
metric
=
ChunkEvaluator
(
label_list
=
[
self
.
label_map
[
i
]
for
i
in
sorted
(
self
.
label_map
.
keys
())])
self
.
metric
=
ChunkEvaluator
(
label_list
=
[
self
.
label_map
[
i
]
for
i
in
sorted
(
self
.
label_map
.
keys
())]
,
suffix
=
suffix
)
elif
task
==
'text-matching'
:
self
.
model
=
RobertaModel
.
from_pretrained
(
pretrained_model_name_or_path
=
'roberta-wwm-ext-large'
,
**
kwargs
)
self
.
dropout
=
paddle
.
nn
.
Dropout
(
0.1
)
...
...
modules/text/language_model/roberta-wwm-ext/README.md
浏览文件 @
f914eff5
...
...
@@ -15,6 +15,7 @@ def __init__(
load_checkpoint
=
None
,
label_map
=
None
,
num_classes
=
2
,
suffix
=
False
,
**
kwargs
,
)
```
...
...
@@ -27,7 +28,9 @@ def __init__(
*
`load_checkpoint`
:使用PaddleHub Fine-tune api训练保存的模型参数文件路径。
*
`label_map`
:预测时的类别映射表。
*
`num_classes`
:分类任务的类别数,如果指定了
`label_map`
,此参数可不传,默认2分类。
*
`suffix`
: 序列标注任务的标签格式,如果设定为
`True`
,标签以'-B', '-I', '-E' 或者 '-S'为结尾,此参数默认为
`False`
。
*
`**kwargs`
:用户额外指定的关键字字典类型的参数。
```
python
def
predict
(
data
,
...
...
modules/text/language_model/roberta-wwm-ext/module.py
浏览文件 @
f914eff5
...
...
@@ -48,6 +48,7 @@ class Roberta(nn.Layer):
load_checkpoint
:
str
=
None
,
label_map
:
Dict
=
None
,
num_classes
:
int
=
2
,
suffix
:
bool
=
False
,
**
kwargs
,
):
super
(
Roberta
,
self
).
__init__
()
...
...
@@ -71,7 +72,7 @@ class Roberta(nn.Layer):
self
.
model
=
RobertaForTokenClassification
.
from_pretrained
(
pretrained_model_name_or_path
=
'roberta-wwm-ext'
,
num_classes
=
self
.
num_classes
,
**
kwargs
)
self
.
criterion
=
paddle
.
nn
.
loss
.
CrossEntropyLoss
()
self
.
metric
=
ChunkEvaluator
(
label_list
=
[
self
.
label_map
[
i
]
for
i
in
sorted
(
self
.
label_map
.
keys
())])
self
.
metric
=
ChunkEvaluator
(
label_list
=
[
self
.
label_map
[
i
]
for
i
in
sorted
(
self
.
label_map
.
keys
())]
,
suffix
=
suffix
)
elif
task
==
'text-matching'
:
self
.
model
=
RobertaModel
.
from_pretrained
(
pretrained_model_name_or_path
=
'roberta-wwm-ext'
,
**
kwargs
)
self
.
dropout
=
paddle
.
nn
.
Dropout
(
0.1
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录