更新时间:2024-08-29 GMT+08:00
分享

长文本摘要

场景介绍

切割长文本,利用大模型逐步总结。 如对会议/报告/文章等较长内容总结概述。

工程实现

  1. 获取并安装SDK包。
  2. 在配置文件(llm.properties)中配置模型信息。
    # IAM 认证信息,根据实际填写
    sdk.llm.pangu.iam.url=
    sdk.llm.pangu.iam.domail=
    sdk.llm.pangu.iam.user=
    sdk.llm.pangu.iam.password=
    sdk.llm.pangu.iam.project=
    
    ## 盘古模型信息,根据实际情况填写
    sdk.llm.pangu.url=
  3. 工程实现。
    import docx
    from pangukitsappdev.api.llms.factory import LLMs
    from pangukitsappdev.skill.doc.summary import DocSummaryMapReduceSkill
    # 加载原始内容, 需根据文件源自行实现读取步骤
    # 以word文件为例,需安装docx库
    doc = docx.Document(r'报告.docx')
    documents = [d.text for d in doc.paragraphs]
    
    # 对文档进行摘要
    skill = DocSummaryMapReduceSkill(LLMs.of("pangu"))
    summarize = skill.execute_with_texts(documents)

相关文档