@@ -32,7 +32,7 @@ PaddleNLP提供**开箱即用**的产业级NLP预置任务能力,无需训练
32
32
| [ 词性标注] ( #词性标注 ) | ` Taskflow("pos_tagging") ` | ✅ | ✅ | ✅ | ✅ | ✅ | 基于百度前沿词法分析工具LAC |
33
33
| [ 命名实体识别] ( #命名实体识别 ) | ` Taskflow("ner") ` | ✅ | ✅ | ✅ | ✅ | ✅ | 覆盖最全中文实体标签 |
34
34
| [ 依存句法分析] ( #依存句法分析 ) | ` Taskflow("dependency_parsing") ` | ✅ | ✅ | ✅ | | ✅ | 基于最大规模中文依存句法树库研发的DDParser |
35
- | [ 信息抽取] ( #信息抽取 ) | ` Taskflow("information_extraction") ` | ✅ | ✅ | ✅ | ✅ | ✅ | 适配多场景的开放域通用信息抽取工具 |
35
+ | [ 信息抽取] ( #信息抽取 ) | ` Taskflow("information_extraction") ` | ✅ | ✅ | ✅ | ✅ | ✅ | 适配多场景的开放域通用信息抽取工具 |
36
36
| [ 『解语』-知识标注] ( #解语知识标注 ) | ` Taskflow("knowledge_mining") ` | ✅ | ✅ | ✅ | ✅ | ✅ | 覆盖所有中文词汇的知识标注工具 |
37
37
| [ 文本纠错] ( #文本纠错 ) | ` Taskflow("text_correction") ` | ✅ | ✅ | ✅ | ✅ | ✅ | 融合拼音特征的端到端文本纠错模型ERNIE-CSC |
38
38
| [ 文本相似度] ( #文本相似度 ) | ` Taskflow("text_similarity") ` | ✅ | ✅ | ✅ | | | 基于百度知道2200万对相似句组训练 |
@@ -422,15 +422,15 @@ from paddlenlp import Taskflow
422
422
>> > ie = Taskflow(' information_extraction' , schema = schema)
423
423
>> > pprint(ie(" 2月8日上午北京冬奥会自由式滑雪女子大跳台决赛中中国选手谷爱凌以188.25分获得金牌!" )) # Better print results using pprint
424
424
[{' 时间' : [{' end' : 6 ,
425
- ' probability' : 0.9907337794563702 ,
425
+ ' probability' : 0.9857378532924486 ,
426
426
' start' : 0 ,
427
427
' text' : ' 2月8日上午' }],
428
428
' 赛事名称' : [{' end' : 23 ,
429
- ' probability' : 0.8944205558197353 ,
429
+ ' probability' : 0.8503089953268272 ,
430
430
' start' : 6 ,
431
431
' text' : ' 北京冬奥会自由式滑雪女子大跳台决赛' }],
432
432
' 选手' : [{' end' : 31 ,
433
- ' probability' : 0.8914297225026147 ,
433
+ ' probability' : 0.8981548639781138 ,
434
434
' start' : 28 ,
435
435
' text' : ' 谷爱凌' }]}]
436
436
```
@@ -481,21 +481,48 @@ from paddlenlp import Taskflow
481
481
482
482
评论观点抽取,是指抽取文本中包含的评价维度、观点词。
483
483
484
- 例如抽取的目标是文本中包含的评价维度以及对应的观点词 ,schema构造如下:
484
+ 例如抽取的目标是文本中包含的评价维度及其对应的观点词和情感倾向 ,schema构造如下:
485
485
486
486
``` text
487
- {'评价维度': '观点词'}
487
+ {'评价维度': [ '观点词', '情感倾向[正向,负向]'] }
488
488
```
489
489
490
- 评论观点抽取默认统一使用` 评价维度 ` 和` 观点词 ` 作为schema。
491
-
492
490
预测:
493
491
494
492
``` python
495
- >> > schema = {' 评价维度' : ' 观点词' } # Define the schema for opinion extraction
493
+ >> > schema = {' 评价维度' : [ ' 观点词' , ' 情感倾向[正向,负向] ' ] } # Define the schema for opinion extraction
496
494
>> > ie.set_schema(schema) # Reset schema
497
- >> > ie(' 个人觉得管理太混乱了,票价太高了' )
498
- [{' 评价维度' : [{' text' : ' 管理' , ' start' : 4 , ' end' : 6 , ' probability' : 0.8902373594544031 , ' relations' : {' 观点词' : [{' text' : ' 混乱' , ' start' : 7 , ' end' : 9 , ' probability' : 0.9993566520321409 }]}}, {' text' : ' 票价' , ' start' : 11 , ' end' : 13 , ' probability' : 0.9856116411308662 , ' relations' : {' 观点词' : [{' text' : ' 高' , ' start' : 14 , ' end' : 15 , ' probability' : 0.995628420935013 }]}}]}]
495
+ >> > pprint(ie(" 地址不错,服务一般,设施陈旧" )) # Better print results using pprint
496
+ [{' 评价维度' : [{' end' : 2 ,
497
+ ' probability' : 0.9888139270606509 ,
498
+ ' relations' : {' 情感倾向[正向,负向]' : [{' probability' : 0.998228967796706 ,
499
+ ' text' : ' 正向' }],
500
+ ' 观点词' : [{' end' : 4 ,
501
+ ' probability' : 0.9927847072459528 ,
502
+ ' start' : 2 ,
503
+ ' text' : ' 不错' }]},
504
+ ' start' : 0 ,
505
+ ' text' : ' 地址' },
506
+ {' end' : 12 ,
507
+ ' probability' : 0.9588297379365116 ,
508
+ ' relations' : {' 情感倾向[正向,负向]' : [{' probability' : 0.9949389795770394 ,
509
+ ' text' : ' 负向' }],
510
+ ' 观点词' : [{' end' : 14 ,
511
+ ' probability' : 0.9286753967902683 ,
512
+ ' start' : 12 ,
513
+ ' text' : ' 陈旧' }]},
514
+ ' start' : 10 ,
515
+ ' text' : ' 设施' },
516
+ {' end' : 7 ,
517
+ ' probability' : 0.9592857070501211 ,
518
+ ' relations' : {' 情感倾向[正向,负向]' : [{' probability' : 0.9952498258302498 ,
519
+ ' text' : ' 负向' }],
520
+ ' 观点词' : [{' end' : 9 ,
521
+ ' probability' : 0.9949359182521675 ,
522
+ ' start' : 7 ,
523
+ ' text' : ' 一般' }]},
524
+ ' start' : 5 ,
525
+ ' text' : ' 服务' }]}]
499
526
```
500
527
501
528
@@ -531,15 +558,15 @@ from paddlenlp import Taskflow
531
558
>> > ie.set_schema(schema)
532
559
>> > pprint(ie(' 李治即位后,让身在感业寺的武则天续起头发,重新纳入后宫。' )) # Better print results using pprint
533
560
[{' 丈夫' : [{' end' : 2 ,
534
- ' probability' : 0.993496447299993 ,
561
+ ' probability' : 0.989690572797457 ,
535
562
' relations' : {' 妻子' : [{' end' : 16 ,
536
- ' probability' : 0.9994008822614759 ,
563
+ ' probability' : 0.9987625986790256 ,
537
564
' start' : 13 ,
538
565
' text' : ' 武则天' }]},
539
566
' start' : 0 ,
540
567
' text' : ' 李治' }],
541
568
' 寺庙' : [{' end' : 12 ,
542
- ' probability' : 0.998334669586864 ,
569
+ ' probability' : 0.9888581774497425 ,
543
570
' start' : 9 ,
544
571
' text' : ' 感业寺' }]}]
545
572
```
@@ -563,20 +590,20 @@ from paddlenlp import Taskflow
563
590
>> > schema = [' 时间' , ' 选手' , ' 赛事名称' ]
564
591
>> > ie = Taskflow(' information_extraction' , schema = schema, model = " uie-tiny" )
565
592
>> > ie(" 2月8日上午北京冬奥会自由式滑雪女子大跳台决赛中中国选手谷爱凌以188.25分获得金牌!" )
566
- [{' 时间' : [{' text' : ' 2月8日上午' , ' start' : 0 , ' end' : 6 , ' probability' : 0.9939956659967066 }], ' 选手' : [{' text' : ' 谷爱凌' , ' start' : 28 , ' end' : 31 , ' probability' : 0.8323544377549155 }], ' 赛事名称' : [{' text' : ' 北京冬奥会自由式滑雪女子大跳台决赛' , ' start' : 6 , ' end' : 23 , ' probability' : 0.624098394612048 }]}]
593
+ [{' 时间' : [{' text' : ' 2月8日上午' , ' start' : 0 , ' end' : 6 , ' probability' : 0.9492842181233527 }], ' 选手' : [{' text' : ' 谷爱凌' , ' start' : 28 , ' end' : 31 , ' probability' : 0.7277186614493836 }], ' 赛事名称' : [{' text' : ' 北京冬奥会自由式滑雪女子大跳台决赛' , ' start' : 6 , ' end' : 23 , ' probability' : 0.8751028059367947 }]}]
567
594
```
568
595
569
596
#### 定制训练
570
597
571
- 对于简单的抽取目标可以直接使用``` paddlenlp.Taskflow ``` 实现零样本(zero-shot)抽取,对于细分场景我们推荐使用[ 定制训练] ( https://github.com/PaddlePaddle/PaddleNLP/tree/develop/examples/information_extraction /uie ) (标注少量数据进行模型微调)以进一步提升效果。
598
+ 对于简单的抽取目标可以直接使用``` paddlenlp.Taskflow ``` 实现零样本(zero-shot)抽取,对于细分场景我们推荐使用[ 定制训练] ( https://github.com/PaddlePaddle/PaddleNLP/tree/develop/model_zoo /uie ) (标注少量数据进行模型微调)以进一步提升效果。
572
599
573
600
我们在互联网、医疗、金融三大垂类自建测试集上进行了实验:
574
601
575
602
<table >
576
- <tr ><th row_span =' 2 ' ><th colspan =' 2 ' >互联网 <th colspan =' 2 ' >医疗<th colspan =' 2 ' >金融
603
+ <tr ><th row_span =' 2 ' ><th colspan =' 2 ' >金融 <th colspan =' 2 ' >医疗<th colspan =' 2 ' >互联网
577
604
<tr ><td ><th >0-shot<th >5-shot<th >0-shot<th >5-shot<th >0-shot<th >5-shot
578
- <tr ><td >uie-tiny<td >75.92 <td >78.45 <td >63.34 <td >74.65 <td >42.03 <td >65.78
579
- <tr ><td >uie-base<td >80.13 <td >81.53 <td >66.71 <td >79.94 <td >41.29 <td >70.91
605
+ <tr ><td >uie-tiny<td >41.11 <td >64.53 <td >65.40 <td >75.72 <td >78.32 <td >79.68
606
+ <tr ><td >uie-base<td >46.43 <td >70.92 <td >71.83 <td >85.72 <td >78.33 <td >81.86
580
607
</table >
581
608
582
609
0-shot表示无训练数据直接通过``` paddlenlp.Taskflow ``` 进行预测,5-shot表示基于5条标注数据进行模型微调。
@@ -826,8 +853,8 @@ from paddlenlp import Taskflow
826
853
| ` Taskflow("pos_tagging") ` | ` $HOME/.paddlenlp/taskflow/lac ` | [ 示例] ( https://github.com/PaddlePaddle/PaddleNLP/tree/develop/examples/lexical_analysis ) |
827
854
| ` Taskflow("ner", mode="fast") ` | ` $HOME/.paddlenlp/taskflow/lac ` | [ 示例] ( https://github.com/PaddlePaddle/PaddleNLP/tree/develop/examples/lexical_analysis ) |
828
855
| ` Taskflow("ner", mode="accurate") ` | ` $HOME/.paddlenlp/taskflow/wordtag ` | [ 示例] ( https://github.com/PaddlePaddle/PaddleNLP/tree/develop/examples/text_to_knowledge/ernie-ctm ) |
829
- | ` Taskflow("information_extraction", model="uie-base") ` | ` $HOME/.paddlenlp/taskflow/information_extraction/uie-base ` | [ 示例] ( https://github.com/PaddlePaddle/PaddleNLP/tree/develop/examples/information_extraction /uie ) |
830
- | ` Taskflow("information_extraction", model="uie-tiny") ` | ` $HOME/.paddlenlp/taskflow/information_extraction/uie-tiny ` | [ 示例] ( https://github.com/PaddlePaddle/PaddleNLP/tree/develop/examples/information_extraction /uie ) |
856
+ | ` Taskflow("information_extraction", model="uie-base") ` | ` $HOME/.paddlenlp/taskflow/information_extraction/uie-base ` | [ 示例] ( https://github.com/PaddlePaddle/PaddleNLP/tree/develop/model_zoo /uie ) |
857
+ | ` Taskflow("information_extraction", model="uie-tiny") ` | ` $HOME/.paddlenlp/taskflow/information_extraction/uie-tiny ` | [ 示例] ( https://github.com/PaddlePaddle/PaddleNLP/tree/develop/model_zoo /uie ) |
831
858
| ` Taskflow("text_correction", model="ernie-csc") ` | ` $HOME/.paddlenlp/taskflow/text_correction/ernie-csc ` | [ 示例] ( https://github.com/PaddlePaddle/PaddleNLP/tree/develop/examples/text_correction/ernie-csc ) |
832
859
| ` Taskflow("dependency_parsing", model="ddparser") ` | ` $HOME/.paddlenlp/taskflow/dependency_parsing/ddparser ` | [ 示例] ( https://github.com/PaddlePaddle/PaddleNLP/tree/develop/examples/dependency_parsing/ddparser ) |
833
860
| ` Taskflow("dependency_parsing", model="ddparser-ernie-1.0") ` | ` $HOME/.paddlenlp/taskflow/dependency_parsing/ddparser-ernie-1.0 ` | [ 示例] ( https://github.com/PaddlePaddle/PaddleNLP/tree/develop/examples/dependency_parsing/ddparser ) |
0 commit comments