paddlenlp实现关系抽取

wylc123 5天前 ⋅ 20 阅读
from pprint import pprint
from paddlenlp import Taskflow
# 获取支持的任务列表
schema = ['父子', '夫妻', '母子','姐妹','姐弟','叔侄','祖孙','朋友','兄弟','兄长','妯娌','连襟'] # Define the schema for entity extraction
ie = Taskflow('information_extraction',
              schema= schema,
              schema_lang="zh",
              batch_size=1,
              model='paddlenlp/PP-UIE-0.5B',
              precision='float32')
# 读取整个文件为字符串
# with open('d:\\15681.txt', 'r', encoding='utf-8') as file:
#     content = file.read()
# print(content)
pprint(ie("张伟是李芳的丈夫,他们的儿子张小明和李芳的弟弟李强是叔侄关系。")) # Better print results using pprint

相关文章推荐
  • 该目录下还没有内容!

全部评论: 0

    我有话说: