OpenParable
Skip to content
← Back to skills

Most Relevant Entities Aggregator

Documents
most_relevant_entities_aggregator

Most Relevant Entities Aggregator is an Agent Skill for documents published in the cas-bigdatalab/piflow repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.

最相关实体聚合工具。从文档中提取与给定实体最相关的指定类型实体,并按重要性排序。 当用户提到提取相关人物、查找相关实体、排序实体、分析实体关系、提取主要角色等需求时使用此skill。 即使用户没有明确说出"最相关实体",只要任务涉及从文档中分析并提取与目标相关的实体, 就应该使用此skill。

View on GitHub ↗
QUICK START

How to use this skill

Bring this guide into your coding agent with a prompt tailored to the tool you use.

  1. Open your project in Codex.
  2. Copy and paste the prompt below.
  3. Review files and risks before approving any action.
Prompt to paste
Inspect the Agent Skill at https://github.com/cas-bigdatalab/piflow/blob/HEAD/workspace/skills/most_relevant_entities_aggregator/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/most-relevant-entities-aggregator, but wait for my approval before writing files or running scripts.

Copying this prompt does not install or run the skill. Review third-party files before use.

Most Relevant Entities Aggregator 最相关实体聚合 Skill

功能概述

本skill通过调用大语言模型(LLM)API,从多个相关文档中智能识别并提取与指定实体最相关的特定类型实体。 例如:从多篇武侠小说片段中提取与"李莲花"最相关的"人物",并按重要性排序。

触发条件

当用户请求以下任务时,应使用此skill:

  • 提取相关实体
  • 查找相关人物
  • 分析实体关系
  • 提取主要角色
  • 实体排序分析
  • 关联实体提取

核心参数说明

必需参数

参数说明
--input输入JSON文件路径
--output输出JSON文件路径
--api_modelAPI模型名称
--entity要查询的实体名称
--query_entity_type要查询的相关实体类型 (如 人物、地点、组织)

可选参数

参数说明默认值
--input_key输入文档的键名event_description
--output_key输出结果的键名most_relevant_entities
--max_token_num输入文档的最大token数None
--api_endpointAPI端点URLNone

输入文件格式

{
  "meta": [
    {"event_description": "文档内容1"},
    {"event_description": "文档内容2"},
    {"event_description": "文档内容3"}
  ]
}

或自定义键名:

{
  "meta": [
    {"events": "文档内容1"},
    {"events": "文档内容2"}
  ]
}

使用方法

# 基本用法
python scripts/run_most_relevant_entities_aggregator.py \
  --input ./input.json \
  --output ./output.json \
  --api_model qwen2.5-72b-instruct \
  --entity 李莲花 \
  --query_entity_type 人物

# 自定义输入输出键名
python scripts/run_most_relevant_entities_aggregator.py \
  --input ./input.json \
  --output ./output.json \
  --api_model qwen2.5-72b-instruct \
  --entity 李莲花 \
  --query_entity_type 人物 \
  --input_key events \
  --output_key relevant_roles

# 限制token数量
python scripts/run_most_relevant_entities_aggregator.py \
  --input ./input.json \
  --output ./output.json \
  --api_model qwen2.5-72b-instruct \
  --entity 李莲花 \
  --query_entity_type 人物 \
  --max_token_num 100

输出示例

命令行输出:

[OK] Most relevant entities aggregation completed!
   Entity: 李莲花
   Query entity type: 人物
   Input file: ./input.json
   Output file: ./output.json

输出JSON格式:

[
  {
    "most_relevant_entities": ["李相夷", "笛飞声", "单孤刀", "方多病"]
  }
]

环境要求

安装依赖: 本SKILL使用依赖 data_juicer,请在调用前安装好python环境并安装data_juicer,可用以下指令进行安装:

pip install py-data-juicer

API配置:

export OPENAI_BASE_URL=https://dashscope.aliyuncs.com/compatible-mode/v1/
export OPENAI_API_KEY=your_api_key

注意事项

  1. 必需参数:需要指定 --api_model、--entity 和 --query_entity_type
  2. 输入格式:输入JSON必须包含 meta 字段
  3. 输出排序:结果按重要性从高到低排序
  4. 实体类型:可指定任意实体类型,如"人物"、"地点"、"组织"、"事件"等