Home
Softono
z

zjunlp

Professional software vendor delivering innovative solutions on the Softono platform. Specialized in both open-source and proprietary software development.

Total Products
5

Software by zjunlp

DeepKE
Open Source

DeepKE

<p align="center"> <a href="https://github.com/zjunlp/deepke"> <img src="pics/logo.png" width="400"/></a> <p> <p align="center"> <a href="http://deepke.zjukg.cn"> <img alt="Documentation" src="https://img.shields.io/badge/demo-website-blue"> </a> <a href="https://pypi.org/project/deepke/#files"> <img alt="PyPI" src="https://img.shields.io/pypi/v/deepke"> </a> <a href="https://github.com/zjunlp/DeepKE/blob/master/LICENSE"> <img alt="GitHub" src="https://img.shields.io/github/license/zjunlp/deepke"> </a> <a href="http://zjunlp.github.io/DeepKE"> <img alt="Documentation" src="https://img.shields.io/badge/doc-website-red"> </a> <a href="https://colab.research.google.com/drive/1vS8YJhJltzw3hpJczPt24O0Azcs3ZpRi?usp=sharing"> <img alt="Open In Colab" src="https://colab.research.google.com/assets/colab-badge.svg"> </a> </p> <p align="center"> <b> English | <a href="https://github.com/zjunlp/DeepKE/blob/main/README_CN.md">简体中文</a> </b> </p> <h1 align="center"> <p>A Deep Learning Based Knowledge Extraction Toolkit<br>for Knowledge Graph Construction</p> </h1> [DeepKE](https://arxiv.org/pdf/2201.03335.pdf) is a knowledge extraction toolkit for knowledge graph construction supporting **cnSchema**,**low-resource**, **document-level** and **multimodal** scenarios for *entity*, *relation* and *attribute* extraction. We provide [documents](https://zjunlp.github.io/DeepKE/), [online demo](http://deepke.zjukg.cn/), [paper](https://arxiv.org/pdf/2201.03335.pdf), [slides](https://drive.google.com/file/d/1IIeIZAbVduemqXc4zD40FUMoPHCJinLy/view?usp=sharing) and [poster](https://drive.google.com/file/d/1vd7xVHlWzoAxivN4T5qKrcqIGDcSM1_7/view?usp=sharing) for beginners. - ❗Want to use **Large Language Models** with DeepKE? Try [DeepKE-LLM](https://github.com/zjunlp/DeepKE/tree/main/example/llm) and [OneKE](https://github.com/zjunlp/DeepKE/blob/main/example/llm/OneKE.md), have fun! - ❗Want to train supervised models? Try [Quick Start](#quick-start), we provide the NER models (e.g, [LightNER(COLING'22)](https://github.com/zjunlp/DeepKE/tree/main/example/ner/few-shot), [W2NER(AAAI'22)](https://github.com/zjunlp/DeepKE/tree/main/example/ner/standard/w2ner)), relation extraction models (e.g., [KnowPrompt(WWW'22)](https://github.com/zjunlp/DeepKE/tree/main/example/re/few-shot)), relational triple extraction models (e.g., [ASP(EMNLP'22)](https://github.com/zjunlp/DeepKE/tree/main/example/triple/ASP), [PRGC(ACL'21)](https://github.com/zjunlp/DeepKE/tree/main/example/triple/PRGC), [PURE(NAACL'21)](https://github.com/zjunlp/DeepKE/tree/main/example/triple/PURE)), and release off-the-shelf models at [DeepKE-cnSchema](https://github.com/zjunlp/DeepKE/tree/main/example/triple/cnschema), have fun! - We recommend using Linux; if using Windows, please use `\\` in file paths; - If HuggingFace is inaccessible, please consider using `wisemodel` or `modescape`. **If you encounter any issues during the installation of DeepKE and DeepKE-LLM, please check [Tips](https://github.com/zjunlp/DeepKE#tips) or promptly submit an [issue](https://github.com/zjunlp/DeepKE/issues), and we will assist you with resolving the problem!** # Table of Contents - [Table of Contents](#table-of-contents) - [What's New](#whats-new) - [Prediction Demo](#prediction-demo) - [Model Framework](#model-framework) - [Quick Start](#quick-start) - [DeepKE-LLM](#deepke-llm) - [DeepKE-MCP-Tools](#deepke-mcp-tools) - [DeepKE](#deepke) - [🔧Manual Environment Configuration](#manual-environment-configuration) - [🐳Building With Docker Images](#building-with-docker-images) - [Requirements](#requirements) - [DeepKE](#deepke-1) - [Introduction of Three Functions](#introduction-of-three-functions) - [1. Named Entity Recognition](#1-named-entity-recognition) - [2. Relation Extraction](#2-relation-extraction) - [3. Attribute Extraction](#3-attribute-extraction) - [4. Event Extraction](#4-event-extraction) - [Tips](#tips) - [To do](#to-do) - [Reading Materials](#reading-materials) - [Related Toolkit](#related-toolkit) - [Citation](#citation) - [Contributors](#contributors) - [Other Knowledge Extraction Open-Source Projects](#other-knowledge-extraction-open-source-projects) <br> # What's New * `June, 2025` We integrate the [MCP service tools](https://modelscope.cn/mcp/servers/OpenKG/deepke-mcp-tools) into DeepKE, enabling knowledge extraction through large language models (LLMs) as tool callers for lightweight models. * `December, 2024` We open source the [OneKE](https://github.com/zjunlp/OneKE/tree/main) knowledge extraction framework, supporting multi-agent knowledge extraction across various scenarios. * `April, 2024` We release a new bilingual (Chinese and English) schema-based information extraction model called [OneKE](https://huggingface.co/zjunlp/OneKE) based on Chinese-Alpaca-2-13B. * `Feb, 2024` We release a large-scale (0.32B tokens) high-quality bilingual (Chinese and English) Information Extraction (IE) instruction dataset named [IEPile](https://huggingface.co/datasets/zjunlp/iepie), along with two models trained with `IEPile`, [baichuan2-13b-iepile-lora](https://huggingface.co/zjunlp/baichuan2-13b-iepile-lora) and [llama2-13b-iepile-lora](https://huggingface.co/zjunlp/llama2-13b-iepile-lora). * `Sep 2023` a bilingual Chinese English Information Extraction (IE) instruction dataset called `InstructIE` was released for the Instruction based Knowledge Graph Construction Task (Instruction based KGC), as detailed in [here](./example/llm/README.md/#data). * `June, 2023` We update [DeepKE-LLM](https://github.com/zjunlp/DeepKE/tree/main/example/llm) to support **knowledge extraction** with [KnowLM](https://github.com/zjunlp/KnowLM), [ChatGLM](https://github.com/THUDM/ChatGLM-6B), LLaMA-series, GPT-series etc. * `Apr, 2023` We have added new models, including [CP-NER(IJCAI'23)](https://github.com/zjunlp/DeepKE/blob/main/example/ner/cross), [ASP(EMNLP'22)](https://github.com/zjunlp/DeepKE/tree/main/example/triple/ASP), [PRGC(ACL'21)](https://github.com/zjunlp/DeepKE/tree/main/example/triple/PRGC), [PURE(NAACL'21)](https://github.com/zjunlp/DeepKE/tree/main/example/triple/PURE), provided [event extraction](https://github.com/zjunlp/DeepKE/tree/main/example/ee/standard) capabilities (Chinese and English), and offered compatibility with higher versions of Python packages (e.g., Transformers). * `Feb, 2023` We have supported using [LLM](https://github.com/zjunlp/DeepKE/tree/main/example/llm) (GPT-3) with in-context learning (based on [EasyInstruct](https://github.com/zjunlp/EasyInstruct)) & data generation, added a NER model [W2NER(AAAI'22)](https://github.com/zjunlp/DeepKE/tree/main/example/ner/standard/w2ner). <details> <summary><b>Previous News</b></summary> * `Nov, 2022` Add data [annotation instructions](https://github.com/zjunlp/DeepKE/blob/main/README_TAG.md) for entity recognition and relation extraction, automatic labelling of weakly supervised data ([entity extraction](https://github.com/zjunlp/DeepKE/tree/main/example/ner/prepare-data) and [relation extraction](https://github.com/zjunlp/DeepKE/tree/main/example/re/prepare-data)), and optimize [multi-GPU training](https://github.com/zjunlp/DeepKE/tree/main/example/re/standard). * `Sept, 2022` The paper [DeepKE: A Deep Learning Based Knowledge Extraction Toolkit for Knowledge Base Population](https://arxiv.org/abs/2201.03335) has been accepted by the EMNLP 2022 System Demonstration Track. * `Aug, 2022` We have added [data augmentation](https://github.com/zjunlp/DeepKE/tree/main/example/re/few-shot/DA) (Chinese, English) support for [low-resource relation extraction](https://github.com/zjunlp/DeepKE/tree/main/example/re/few-shot). * `June, 2022` We have added multimodal support for [entity](https://github.com/zjunlp/DeepKE/tree/main/example/ner/multimodal) and [relation extraction](https://github.com/zjunlp/DeepKE/tree/main/example/re/multimodal). * `May, 2022` We have released [DeepKE-cnschema](https://github.com/zjunlp/DeepKE/blob/main/README_CNSCHEMA.md) with off-the-shelf knowledge extraction models. * `Jan, 2022` We have released a paper [DeepKE: A Deep Learning Based Knowledge Extraction Toolkit for Knowledge Base Population](https://arxiv.org/abs/2201.03335) * `Dec, 2021` We have added `dockerfile` to create the enviroment automatically. * `Nov, 2021` The demo of DeepKE, supporting real-time extration without deploying and training, has been released. * The documentation of DeepKE, containing the details of DeepKE such as source codes and datasets, has been released. * `Oct, 2021` `pip install deepke` * The codes of deepke-v2.0 have been released. * `Aug, 2019` The codes of deepke-v1.0 have been released. * `Aug, 2018` The project DeepKE startup and codes of deepke-v0.1 have been released. </details> # Prediction Demo There is a demonstration of prediction. The GIF file is created by [Terminalizer](https://github.com/faressoft/terminalizer). Get the [code](https://drive.google.com/file/d/1r4tWfAkpvynH3CBSgd-XG79rf-pB-KR3/view?usp=share_link). <img src="pics/demo.gif" width="636" height="494" align=center> <br> # Model Framework <h3 align="center"> <img src="pics/architectures.png"> </h3> - DeepKE contains a unified framework for **named entity recognition**, **relation extraction** and **attribute extraction**, the three knowledge extraction functions. - Each task can be implemented in different scenarios. For example, we can achieve relation extraction in **standard**, **low-resource (few-shot)**, **document-level** and **multimodal** settings. - Each application scenario comprises of three components: **Data** including Tokenizer, Preprocessor and Loader, **Model** including Module, Encoder and Forwarder, **Core** including Training, Evaluation and Prediction. <br> # Quick Start ## DeepKE-LLM In the era of large models, DeepKE-LLM utilizes a completely new environment dependency. ``` conda create -n deepke-llm python=3.9 conda activate deepke-llm cd example/llm pip install -r requirements.txt ``` Please note that the `requirements.txt` file is located in the `example/llm` folder. ## DeepKE-MCP-Tools We integrate the MCP (Model Calling Protocol) service tools into DeepKE, enabling knowledge extraction through large language models (LLMs) as tool callers for lightweight models. - The MCP service has been deployed and is accessible at [URL](https://modelscope.cn/mcp/servers/OpenKG/deepke-mcp-tools). - For local deployment, refer to the [README](https://github.com/zjunlp/DeepKE/tree/main/mcp-tools/README.md) for detailed operational procedures. ## DeepKE - *DeepKE* supports `pip install deepke`. <br>Take the fully supervised relation extraction for example. - *DeepKE* supports both **manual** and **docker image** environment configuration, you can choose the appropriate way to build. - Highly recommended to install deepke in a Linux environment. #### 🔧Manual Environment Configuration **Step1** Download the basic code ```bash git clone --depth 1 https://github.com/zjunlp/DeepKE.git ``` **Step2** Create a virtual environment using `Anaconda` and enter it.<br> ```bash conda create -n deepke python=3.8 conda activate deepke ``` 1. Install *DeepKE* with source code ```bash pip install -r requirements.txt python setup.py install python setup.py develop ``` 2. Install *DeepKE* with `pip` (**NOT recommended!**) ```bash pip install deepke ``` - Please make sure that pip version <= 24.0 **Step3** Enter the task directory ```bash cd DeepKE/example/re/standard ``` **Step4** Download the dataset, or follow the [annotation instructions](https://github.com/zjunlp/DeepKE/blob/main/README_TAG.md) to obtain data ```bash wget 121.41.117.246:8080/Data/re/standard/data.tar.gz tar -xzvf data.tar.gz ``` Many types of data formats are supported,and details are in each part. **Step5** Training (Parameters for training can be changed in the `conf` folder) We support visual parameter tuning by using *[wandb](https://docs.wandb.ai/quickstart)*. ```bash python run.py ``` **Step6** Prediction (Parameters for prediction can be changed in the `conf` folder) Modify the path of the trained model in `predict.yaml`.The absolute path of the model needs to be used,such as `xxx/checkpoints/2019-12-03_ 17-35-30/cnn_ epoch21.pth`. ```bash python predict.py ``` - **❗NOTE: if you encounter any errors, please refer to the [Tips](#tips) or submit a GitHub issue.** #### 🐳Building With Docker Images **Step1** Install the Docker client Install Docker and start the Docker service. **Step2** Pull the docker image and run the container ```bash docker pull zjunlp/deepke:latest docker run -it zjunlp/deepke:latest /bin/bash ``` The remaining steps are the same as **Step 3 and onwards** in **Manual Environment Configuration**. - **❗NOTE: You can refer to the [Tips](#tips) to speed up installation** ## Requirements ### DeepKE > python == 3.8 - torch>=1.5,<=1.11 - hydra-core==1.0.6 - tensorboard==2.4.1 - matplotlib==3.4.1 - transformers==4.26.0 - jieba==0.42.1 - scikit-learn==0.24.1 - seqeval==1.2.2 - opt-einsum==3.3.0 - wandb==0.12.7 - ujson==5.6.0 - huggingface_hub==0.11.0 - tensorboardX==2.5.1 - nltk==3.8 - protobuf==3.20.1 - numpy==1.21.0 - ipdb==0.13.11 - pytorch-crf==0.7.2 - tqdm==4.66.1 - openai==0.28.0 - Jinja2==3.1.2 - datasets==2.13.2 - pyhocon==0.3.60 <br> ## Introduction of Three Functions ### 1. Named Entity Recognition - Named entity recognition seeks to locate and classify named entities mentioned in unstructured text into pre-defined categories such as person names, organizations, locations, organizations, etc. - The data is stored in `.txt` files. Some instances as following (Users can label data based on the tools [Doccano](https://github.com/doccano/doccano), [MarkTool](https://github.com/FXLP/MarkTool), or they can use the [Weak Supervision](https://github.com/zjunlp/DeepKE/blob/main/example/ner/prepare-data) with DeepKE to obtain data automatically): | Sentence | Person | Location | Organization | | :----------------------------------------------------------: | :------------------------: | :------------: | :----------------------------: | | 本报北京9月4日讯记者杨涌报道:部分省区人民日报宣传发行工作座谈会9月3日在4日在京举行。 | 杨涌 | 北京 | 人民日报 | | 《红楼梦》由王扶林导演,周汝昌、王蒙、周岭等多位专家参与制作。 | 王扶林,周汝昌,王蒙,周岭 | | | | 秦始皇兵马俑位于陕西省西安市,是世界八大奇迹之一。 | 秦始皇 | 陕西省,西安市 | | - Read the detailed process in specific README - **[STANDARD (Fully Supervised)](https://github.com/zjunlp/DeepKE/tree/main/example/ner/standard)** ***We [support LLM](https://github.com/zjunlp/DeepKE/tree/main/example/llm) and provide the off-the-shelf model, [DeepKE-cnSchema-NER](https://github.com/zjunlp/DeepKE/blob/main/README_CNSCHEMA_CN.md), which will extract entities in cnSchema without training.*** **Step1** Enter `DeepKE/example/ner/standard`. Download the dataset. ```bash wget 121.41.117.246:8080/Data/ner/standard/data.tar.gz tar -xzvf data.tar.gz ``` **Step2** Training<br> The dataset and parameters can be customized in the `data` folder and `conf` folder respectively. ```bash python run.py ``` **Step3** Prediction ```bash python predict.py ``` - **[FEW-SHOT](https://github.com/zjunlp/DeepKE/tree/main/example/ner/few-shot)** **Step1** Enter `DeepKE/example/ner/few-shot`. Download the dataset. ```bash wget 121.41.117.246:8080/Data/ner/few_shot/data.tar.gz tar -xzvf data.tar.gz ``` **Step2** Training in the low-resouce setting <br> The directory where the model is loaded and saved and the configuration parameters can be cusomized in the `conf` folder. ```bash python run.py +train=few_shot ``` Users can modify `load_path` in `conf/train/few_shot.yaml` to use existing loaded model.<br> **Step3** Add `- predict` to `conf/config.yaml`, modify `loda_path` as the model path and `write_path` as the path where the predicted results are saved in `conf/predict.yaml`, and then run `python predict.py` ```bash python predict.py ``` - **[MULTIMODAL](https://github.com/zjunlp/DeepKE/tree/main/example/ner/multimodal)** **Step1** Enter `DeepKE/example/ner/multimodal`. Download the dataset. ```bash wget 121.41.117.246:8080/Data/ner/multimodal/data.tar.gz tar -xzvf data.tar.gz ``` We use RCNN detected objects and visual grounding objects from original images as visual local information, where RCNN via [faster_rcnn](https://github.com/pytorch/vision/blob/main/torchvision/models/detection/faster_rcnn.py) and visual grounding via [onestage_grounding](https://github.com/zyang-ur/onestage_grounding). **Step2** Training in the multimodal setting <br> - The dataset and parameters can be customized in the `data` folder and `conf` folder respectively. - Start with the model trained last time: modify `load_path` in `conf/train.yaml`as the path where the model trained last time was saved. And the path saving logs generated in training can be customized by `log_dir`. ```bash python run.py ``` **Step3** Prediction ```bash python predict.py ``` ### 2. Relation Extraction - Relationship extraction is the task of extracting semantic relations between entities from a unstructured text. - The data is stored in `.csv` files. Some instances as following (Users can label data based on the tools [Doccano](https://github.com/doccano/doccano), [MarkTool](https://github.com/FXLP/MarkTool), or they can use the [Weak Supervision](https://github.com/zjunlp/DeepKE/blob/main/example/re/prepare-data) with DeepKE to obtain data automatically): | Sentence | Relation | Head | Head_offset | Tail | Tail_offset | | :----------------------------------------------------: | :------: | :--------: | :---------: | :--------: | :---------: | | 《岳父也是爹》是王军执导的电视剧,由马恩然、范明主演。 | 导演 | 岳父也是爹 | 1 | 王军 | 8 | | 《九玄珠》是在纵横中文网连载的一部小说,作者是龙马。 | 连载网站 | 九玄珠 | 1 | 纵横中文网 | 7 | | 提起杭州的美景,西湖总是第一个映入脑海的词语。 | 所在城市 | 西湖 | 8 | 杭州 | 2 | - **!NOTE: If there are multiple entity types for one relation, entity types can be prefixed with the relation as inputs.** - Read the detailed process in specific README - **[STANDARD (Fully Supervised)](https://github.com/zjunlp/DeepKE/tree/main/example/re/standard)** ***We [support LLM](https://github.com/zjunlp/DeepKE/tree/main/example/llm) and provide the off-the-shelf model, [DeepKE-cnSchema-RE](https://github.com/zjunlp/DeepKE/blob/main/README_CNSCHEMA_CN.md), which will extract relations in cnSchema without training.*** **Step1** Enter the `DeepKE/example/re/standard` folder. Download the dataset. ```bash wget 121.41.117.246:8080/Data/re/standard/data.tar.gz tar -xzvf data.tar.gz ``` **Step2** Training<br> The dataset and parameters can be customized in the `data` folder and `conf` folder respectively. ```bash python run.py ``` **Step3** Prediction ```bash python predict.py ``` - **[FEW-SHOT](https://github.com/zjunlp/DeepKE/tree/main/example/re/few-shot)** **Step1** Enter `DeepKE/example/re/few-shot`. Download the dataset. ```bash wget 121.41.117.246:8080/Data/re/few_shot/data.tar.gz tar -xzvf data.tar.gz ``` **Step 2** Training<br> - The dataset and parameters can be customized in the `data` folder and `conf` folder respectively. - Start with the model trained last time: modify `train_from_saved_model` in `conf/train.yaml`as the path where the model trained last time was saved. And the path saving logs generated in training can be customized by `log_dir`. ```bash python run.py ``` **Step3** Prediction ```bash python predict.py ``` - **[DOCUMENT](https://github.com/zjunlp/DeepKE/tree/main/example/re/document)**<br> **Step1** Enter `DeepKE/example/re/document`. Download the dataset. ```bash wget 121.41.117.246:8080/Data/re/document/data.tar.gz tar -xzvf data.tar.gz ``` **Step2** Training<br> - The dataset and parameters can be customized in the `data` folder and `conf` folder respectively. - Start with the model trained last time: modify `train_from_saved_model` in `conf/train.yaml`as the path where the model trained last time was saved. And the path saving logs generated in training can be customized by `log_dir`. ```bash python run.py ``` **Step3** Prediction ```bash python predict.py ``` - **[MULTIMODAL](https://github.com/zjunlp/DeepKE/tree/main/example/re/multimodal)** **Step1** Enter `DeepKE/example/re/multimodal`. Download the dataset. ```bash wget 121.41.117.246:8080/Data/re/multimodal/data.tar.gz tar -xzvf data.tar.gz ``` We use RCNN detected objects and visual grounding objects from original images as visual local information, where RCNN via [faster_rcnn](https://github.com/pytorch/vision/blob/main/torchvision/models/detection/faster_rcnn.py) and visual grounding via [onestage_grounding](https://github.com/zyang-ur/onestage_grounding). **Step2** Training<br> - The dataset and parameters can be customized in the `data` folder and `conf` folder respectively. - Start with the model trained last time: modify `load_path` in `conf/train.yaml`as the path where the model trained last time was saved. And the path saving logs generated in training can be customized by `log_dir`. ```bash python run.py ``` **Step3** Prediction ```bash python predict.py ``` ### 3. Attribute Extraction - Attribute extraction is to extract attributes for entities in a unstructed text. - The data is stored in `.csv` files. Some instances as following: | Sentence | Att | Ent | Ent_offset | Val | Val_offset | | :----------------------------------------------------------: | :------: | :------: | :--------: | :-----------: | :--------: | | 张冬梅,女,汉族,1968年2月生,河南淇县人 | 民族 | 张冬梅 | 0 | 汉族 | 6 | |诸葛亮,字孔明,三国时期杰出的军事家、文学家、发明家。| 朝代 | 诸葛亮 | 0 | 三国时期 | 8 | | 2014年10月1日许鞍华执导的电影《黄金时代》上映 | 上映时间 | 黄金时代 | 19 | 2014年10月1日 | 0 | - Read the detailed process in specific README - **[STANDARD (Fully Supervised)](https://github.com/zjunlp/DeepKE/tree/main/example/ae/standard)** **Step1** Enter the `DeepKE/example/ae/standard` folder. Download the dataset. ```bash wget 121.41.117.246:8080/Data/ae/standard/data.tar.gz tar -xzvf data.tar.gz ``` **Step2** Training<br> The dataset and parameters can be customized in the `data` folder and `conf` folder respectively. ```bash python run.py ``` **Step3** Prediction ```bash python predict.py ``` <br> ### 4. Event Extraction * Event extraction is the task to extract event type, event trigger words, event arguments from a unstructed text. * The data is stored in `.tsv` files, some instances are as follows: <table h style="text-align:center"> <tr> <th colspan="2"> Sentence </th> <th> Event type </th> <th> Trigger </th> <th> Role </th> <th> Argument </th> </tr> <tr> <td rowspan="3" colspan="2"> 据《欧洲时报》报道,当地时间27日,法国巴黎卢浮宫博物馆员工因不满工作条件恶化而罢工,导致该博物馆也因此闭门谢客一天。 </td> <td rowspan="3"> 组织行为-罢工 </td> <td rowspan="3"> 罢工 </td> <td> 罢工人员 </td> <td> 法国巴黎卢浮宫博物馆员工 </td> </tr> <tr> <td> 时间 </td> <td> 当地时间27日 </td> </tr> <tr> <td> 所属组织 </td> <td> 法国巴黎卢浮宫博物馆 </td> </tr> <tr> <td rowspan="3" colspan="2"> 中国外运2019年上半年归母净利润增长17%:收购了少数股东股权 </td> <td rowspan="3"> 财经/交易-出售/收购 </td> <td rowspan="3"> 收购 </td> <td> 出售方 </td> <td> 少数股东 </td> </tr> <tr> <td> 收购方 </td> <td> 中国外运 </td> </tr> <tr> <td> 交易物 </td> <td> 股权 </td> </tr> <tr> <td rowspan="3" colspan="2"> 美国亚特兰大航展13日发生一起表演机坠机事故,飞行员弹射出舱并安全着陆,事故没有造成人员伤亡。 </td> <td rowspan="3"> 灾害/意外-坠机 </td> <td rowspan="3"> 坠机 </td> <td> 时间 </td> <td> 13日 </td> </tr> <tr> <td> 地点 </td> <td> 美国亚特兰 </td> </tr> </table> * Read the detailed process in specific README * [STANDARD(Fully Supervised)](./example/ee/standard/README.md) **Step1** Enter the `DeepKE/example/ee/standard` folder. Download the dataset. ```bash wget 121.41.117.246:8080/Data/ee/DuEE.zip unzip DuEE.zip ``` **Step 2** Training The dataset and parameters can be customized in the `data` folder and `conf` folder respectively. ```bash python run.py ``` **Step 3** Prediction ```bash python predict.py ``` <br> # Tips 1.```Using nearest mirror```, **[THU](https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/) in China, will speed up the installation of *Anaconda*; [aliyun](http://mirrors.aliyun.com/pypi/simple/) in China, will speed up `pip install XXX`**. 2.When encountering `ModuleNotFoundError: No module named 'past'`,run `pip install future` . 3.It's slow to install the pretrained language models online. Recommend download pretrained models before use and save them in the `pretrained` folder. Read `README.md` in every task directory to check the specific requirement for saving pretrained models. 4.The old version of *DeepKE* is in the [deepke-v1.0](https://github.com/zjunlp/DeepKE/tree/deepke-v1.0) branch. Users can change the branch to use the old version. The old version has been totally transfered to the standard relation extraction ([example/re/standard](https://github.com/zjunlp/DeepKE/blob/main/example/re/standard/README.md)). 5.If you want to modify the source code, it's recommended to install *DeepKE* with source codes. If not, the modification will not work. See [issue](https://github.com/zjunlp/DeepKE/issues/117) 6.More related low-resource knowledge extraction works can be found in [Knowledge Extraction in Low-Resource Scenarios: Survey and Perspective](https://arxiv.org/pdf/2202.08063.pdf). 7.Make sure the exact versions of requirements in `requirements.txt`. # To do In next version, we plan to release a stronger LLM for KE. Meanwhile, we will offer long-term maintenance to **fix bugs**, **solve issues** and meet **new requests**. So if you have any problems, please put issues to us. # Reading Materials Data-Efficient Knowledge Graph Construction, 高效知识图谱构建 ([Tutorial on CCKS 2022](http://sigkg.cn/ccks2022/?page_id=24)) \[[slides](https://drive.google.com/drive/folders/1xqeREw3dSiw-Y1rxLDx77r0hGUvHnuuE)\] Efficient and Robust Knowledge Graph Construction ([Tutorial on AACL-IJCNLP 2022](https://www.aacl2022.org/Program/tutorials)) \[[slides](https://github.com/NLP-Tutorials/AACL-IJCNLP2022-KGC-Tutorial)\] PromptKG Family: a Gallery of Prompt Learning & KG-related Research Works, Toolkits, and Paper-list [[Resources](https://github.com/zjunlp/PromptKG)\] Knowledge Extraction in Low-Resource Scenarios: Survey and Perspective \[[Survey](https://arxiv.org/abs/2202.08063)\]\[[Paper-list](https://github.com/zjunlp/Low-resource-KEPapers)\] # Related Toolkit [Doccano](https://github.com/doccano/doccano)、[MarkTool](https://github.com/FXLP/MarkTool)、[LabelStudio](https://labelstud.io/ ): Data Annotation Toolkits [LambdaKG](https://github.com/zjunlp/PromptKG/tree/main/lambdaKG): A library and benchmark for PLM-based KG embeddings [EasyInstruct](https://github.com/zjunlp/EasyInstruct): An easy-to-use framework to instruct Large Language Models **Reading Materials**: Data-Efficient Knowledge Graph Construction, 高效知识图谱构建 ([Tutorial on CCKS 2022](http://sigkg.cn/ccks2022/?page_id=24)) \[[slides](https://drive.google.com/drive/folders/1xqeREw3dSiw-Y1rxLDx77r0hGUvHnuuE)\] Efficient and Robust Knowledge Graph Construction ([Tutorial on AACL-IJCNLP 2022](https://www.aacl2022.org/Program/tutorials)) \[[slides](https://github.com/NLP-Tutorials/AACL-IJCNLP2022-KGC-Tutorial)\] PromptKG Family: a Gallery of Prompt Learning & KG-related Research Works, Toolkits, and Paper-list [[Resources](https://github.com/zjunlp/PromptKG)\] Knowledge Extraction in Low-Resource Scenarios: Survey and Perspective \[[Survey](https://arxiv.org/abs/2202.08063)\]\[[Paper-list](https://github.com/zjunlp/Low-resource-KEPapers)\] **Related Toolkit**: [Doccano](https://github.com/doccano/doccano)、[MarkTool](https://github.com/FXLP/MarkTool)、[LabelStudio](https://labelstud.io/ ): Data Annotation Toolkits [LambdaKG](https://github.com/zjunlp/PromptKG/tree/main/lambdaKG): A library and benchmark for PLM-based KG embeddings [EasyInstruct](https://github.com/zjunlp/EasyInstruct): An easy-to-use framework to instruct Large Language Models # Citation Please cite our paper if you use DeepKE in your work ```bibtex @inproceedings{EMNLP2022_Demo_DeepKE, author = {Ningyu Zhang and Xin Xu and Liankuan Tao and Haiyang Yu and Hongbin Ye and Shuofei Qiao and Xin Xie and Xiang Chen and Zhoubo Li and Lei Li}, editor = {Wanxiang Che and Ekaterina Shutova}, title = {DeepKE: {A} Deep Learning Based Knowledge Extraction Toolkit for Knowledge Base Population}, booktitle = {{EMNLP} (Demos)}, pages = {98--108}, publisher = {Association for Computational Linguistics}, year = {2022}, url = {https://aclanthology.org/2022.emnlp-demos.10} } ``` <br> # Contributors [Ningyu Zhang](https://person.zju.edu.cn/en/ningyu), [Haofen Wang](https://tjdi.tongji.edu.cn/TeacherDetail.do?id=4991&lang=_en), Fei Huang, Feiyu Xiong, Liankuan Tao, Xin Xu, Honghao Gui, Zhenru Zhang, Chuanqi Tan, Qiang Chen, Xiaohan Wang, Zekun Xi, Xinrong Li, Haiyang Yu, Hongbin Ye, Shuofei Qiao, Peng Wang, Yuqi Zhu, Xin Xie, Xiang Chen, Zhoubo Li, Lei Li, Xiaozhuan Liang, Yunzhi Yao, Jing Chen, Yuqi Zhu, Yujie Luo, Shumin Deng, Wen Zhang, Guozhou Zheng, Huajun Chen Community Contributors: Shuo Shen, Zhoutian Shao, Wei Hu, [thredreams](https://github.com/thredreams), [eltociear](https://github.com/eltociear), Ziwen Xu, Rui Huang, Xiaolong Weng # Other Knowledge Extraction Open-Source Projects - [CogIE](https://github.com/jinzhuoran/CogIE) - [OpenNRE](https://github.com/thunlp/OpenNRE) - [OmniEvent](https://github.com/THU-KEG/OmniEvent) - [OpenUE](https://github.com/zjunlp/OpenUE) - [OpenIE](https://stanfordnlp.github.io/CoreNLP/openie.html) - [RESIN](https://github.com/RESIN-KAIROS/RESIN-pipeline-public) - [ZShot](https://github.com/IBM/zshot) - [ZS4IE](https://github.com/BBN-E/ZS4IE) - [OmniEvent](https://github.com/THU-KEG/OmniEvent)

ML Frameworks
4.4K Github Stars
PromptKG
Open Source

PromptKG

<div align="center"> <img src="https://github.com/zjunlp/PromptKG/blob/main/resources/logo.svg" width="350px"> **PromptKG Family: a Gallery of Prompt Learning & KG-related research works, toolkits, and paper-list.** [![Awesome](https://awesome.re/badge.svg)](https://github.com/zjunlp/Prompt4ReasoningPapers) [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT) ![](https://img.shields.io/github/last-commit/zjunlp/PromptKG?color=green) ![](https://img.shields.io/badge/PRs-Welcome-red) </div> | Directory | Description | |-----------|-------------| | [research](research) | • A collection of prompt learning-related **research model implementations** | | [lambdaKG](lambdaKG) | • A library for **PLM-based KG embeddings and applications** | | [deltaKG](deltaKG) | • A library for **dynamically editing PLM-based KG embeddings** | | [tutorial-notebooks](tutorial-notebooks) | • **Tutorial notebooks** for beginners | # Table of Contents * [Tutorials](#Tutorials) * [Surveys](#Surveys) * [Papers](#Papers) * [Knowledge as Prompt](#Knowledge-as-Prompt) * [1. Language Understanding](#Knowledge-as-Prompt) * [2. Multimodal](#Knowledge-as-Prompt) * [3. Advanced Tasks](#Knowledge-as-Prompt) * [Prompt (PLMs) for Knowledge](#prompt-plms-for-knowledge) * [1. Knowledge Probing](#prompt-plms-for-knowledge) * [2. Knowledge Graph Embedding](#prompt-plms-for-knowledge) * [3. Analysis](#prompt-plms-for-knowledge) * [Contact Information](#Contact-Information) # Tutorials - Zero- and Few-Shot NLP with Pretrained Language Models. AACL 2022 Tutorial \[[ppt](https://github.com/allenai/acl2022-zerofewshot-tutorial)\] - Data-Efficient Knowledge Graph Construction. CCKS2022 Tutorial \[[ppt](https://drive.google.com/drive/folders/1xqeREw3dSiw-Y1rxLDx77r0hGUvHnuuE)\] - Efficient and Robuts Knowledge Graph Construction. AACL-IJCNLP Tutorial \[[ppt](https://github.com/NLP-Tutorials/AACL-IJCNLP2022-KGC-Tutorial)\] - Knowledge Informed Prompt Learning. MLNLP 2022 Tutorial (Chinese) \[[ppt](https://person.zju.edu.cn/person/attachments/2022-11/01-1668830598-859129.pdf)\] # Surveys * Delta Tuning: A Comprehensive Study of Parameter Efficient Methods for Pre-trained Language Models (on arxiv 2021) \[[paper](https://arxiv.org/abs/2203.06904)\] * Pre-train, Prompt, and Predict: A Systematic Survey of Prompting Methods in Natural Language Processing (ACM Computing Surveys 2021) \[[paper](https://arxiv.org/abs/2107.13586)\] * reStructured Pre-training (on arxiv 2022) \[[paper](https://arxiv.org/abs/2206.11147)\] * A Survey of Knowledge-Intensive NLP with Pre-Trained Language Models (on arxiv 2022) \[[paper](https://arxiv.org/abs/2202.08772)\] * A Survey of Knowledge-Enhanced Pre-trained Language Models (on arxiv 2022) \[[paper](https://arxiv.org/abs/2211.05994)\] * A Review on Language Models as Knowledge Bases (on arxiv 2022) \[[paper](https://arxiv.org/abs/2204.06031)\] * Generative Knowledge Graph Construction: A Review (EMNLP, 2022) \[[paper](https://arxiv.org/abs/2210.12714)\] * Reasoning with Language Model Prompting: A Survey (on arxiv 2022) \[[paper](https://arxiv.org/abs/2212.09597)\] * Reasoning over Different Types of Knowledge Graphs: Static, Temporal and Multi-Modal (on arxiv 2022) \[[paper](https://arxiv.org/abs/2212.05767)\] * The Life Cycle of Knowledge in Big Language Models: A Survey (on arxiv 2022) \[[paper](https://arxiv.org/abs/2303.07616)\] * Unifying Large Language Models and Knowledge Graphs: A Roadmap (on arxiv 2023) \[[paper](https://arxiv.org/abs/2306.08302)\] # Papers ## Knowledge as Prompt *Language Understanding* - Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks, in NeurIPS 2020. [\[pdf\]](https://arxiv.org/abs/2005.11401) - REALM: Retrieval-Augmented Language Model Pre-Training, in ICML 2020. [\[pdf\]](https://arxiv.org/abs/2002.08909) - Making Pre-trained Language Models Better Few-shot Learners, in ACL 2022. [\[pdf\]](https://aclanthology.org/2021.acl-long.295/) - PTR: Prompt Tuning with Rules for Text Classification, in OpenAI 2022. [\[pdf\]](https://arxiv.org/pdf/2105.11259.pdf) - Label Verbalization and Entailment for Effective Zero- and Few-Shot Relation Extraction, in EMNLP 2021. [\[pdf\]](https://aclanthology.org/2021.emnlp-main.92.pdf) - RelationPrompt: Leveraging Prompts to Generate Synthetic Data for Zero-Shot Relation Triplet Extraction, in EMNLP 2022 (Findings). [\[pdf\]](https://arxiv.org/abs/2203.09101) - Knowledgeable Prompt-tuning: Incorporating Knowledge into Prompt Verbalizer for Text Classification, in ACL 2022. [\[pdf\]](https://arxiv.org/abs/2108.02035) - PPT: Pre-trained Prompt Tuning for Few-shot Learning, in ACL 2022. [\[pdf\]](https://arxiv.org/abs/2109.04332) - Contrastive Demonstration Tuning for Pre-trained Language Models, in EMNLP 2022 (Findings). [\[pdf\]](https://arxiv.org/abs/2204.04392) - AdaPrompt: Adaptive Model Training for Prompt-based NLP, in arxiv 2022. [\[pdf\]](https://arxiv.org/abs/2202.04824) - KnowPrompt: Knowledge-aware Prompt-tuning with Synergistic Optimization for Relation Extraction, in WWW 2022. [\[pdf\]](https://arxiv.org/abs/2104.07650) - Schema-aware Reference as Prompt Improves Data-Efficient Knowledge Graph Construction, in SIGIR 2023. [\[pdf\]](https://arxiv.org/abs/2210.10709) - Decoupling Knowledge from Memorization: Retrieval-augmented Prompt Learning, in NeurIPS 2022. [\[pdf\]](https://arxiv.org/abs/2205.14704) - Relation Extraction as Open-book Examination: Retrieval-enhanced Prompt Tuning, in SIGIR 2022. [\[pdf\]](https://arxiv.org/abs/2205.02355) - LightNER: A Lightweight Tuning Paradigm for Low-resource NER via Pluggable Prompting, in COLING 2022. [\[pdf\]](https://aclanthology.org/2022.coling-1.209/) - Unified Structure Generation for Universal Information Extraction, in ACL 2022. [\[pdf\]](https://aclanthology.org/2022.acl-long.395/) - LasUIE: Unifying Information Extraction with Latent Adaptive Structure-aware Generative Language Model, in NeurIPS 2022. [\[pdf\]](https://openreview.net/forum?id=a8qX5RG36jd) - Atlas: Few-shot Learning with Retrieval Augmented Language Models, in Arxiv 2022. [\[pdf\]](https://arxiv.org/abs/2208.03299) - Don't Prompt, Search! Mining-based Zero-Shot Learning with Language Models, in ACL 2022. [\[pdf\]](https://arxiv.org/abs/2210.14803) - Knowledge Prompting in Pre-trained Language Model for Natural Language Understanding, in EMNLP 2022. [\[pdf\]](https://arxiv.org/abs/2210.08536) - Unified Knowledge Prompt Pre-training for Customer Service Dialogues, in CIKM 2022. [\[pdf\]](https://arxiv.org/abs/2208.14652) - Knowledge Prompting in Pre-trained Language Model for Natural Language Understanding, in EMNLP 2022. [\[pdf\]](https://arxiv.org/pdf/2210.08536.pdf) - SELF-INSTRUCT: Aligning Language Model with Self Generated Instructions, in arxiv 2022. [\[pdf\]](https://arxiv.org/pdf/2212.10560.pdf) - One Embedder, Any Task: Instruction-Finetuned Text Embeddings, in arxiv 2022. [\[pdf\]](https://arxiv.org/pdf/2212.09741.pdf) - Learning To Retrieve Prompts for In-Context Learning, in NAACL 2022. [\[pdf\]](https://aclanthology.org/2022.naacl-main.191.pdf) - Training Data is More Valuable than You Think: A Simple and Effective Method by Retrieving from Training Data, in ACL 2022. [\[pdf\]](https://aclanthology.org/2022.acl-long.226.pdf) - One Model for All Domains: Collaborative Domain-Prefix Tuning for Cross-Domain NER, in Arxiv 2023. [\[pdf\]](https://arxiv.org/pdf/2301.10410.pdf) - REPLUG: Retrieval-Augmented Black-Box Language Models, in Arxiv 2023. [\[pdf\]](https://arxiv.org/pdf/2301.12652.pdf) - Knowledge-Augmented Language Model Prompting for Zero-Shot Knowledge Graph Question Answering, in Arxiv 2023. [\[pdf\]](https://arxiv.org/pdf/2306.04136.pdf) *Multimodal* - Good Visual Guidance Makes A Better Extractor: Hierarchical Visual Prefix for Multimodal Entity and Relation Extraction, in NAACL 2022 (Findings). [\[pdf\]](https://arxiv.org/pdf/2205.03521.pdf) - Visual Prompt Tuning, in ECCV 2022. [\[pdf\]](https://arxiv.org/abs/2203.12119) - CPT: Colorful Prompt Tuning for Pre-trained Vision-Language Models, in EMNLP 2022. [\[pdf\]](https://arxiv.org/abs/2109.11797) - Learning to Prompt for Vision-Language Models, in IJCV 2022. [\[pdf\]](https://arxiv.org/abs/2109.01134) - Test-Time Prompt Tuning for Zero-Shot Generalization in Vision-Language Models, in NeurIPS 2022. [\[pdf\]](https://arxiv.org/abs/2209.07511) *Advanced Tasks* - Recommendation as Language Processing (RLP): A Unified Pretrain, Personalized Prompt & Predict Paradigm (P5), in ACM RecSys 2022. [\[pdf\]](https://arxiv.org/abs/2203.13366) - Towards Unified Conversational Recommender Systems via Knowledge-Enhanced Prompt Learning, in KDD 2022. [\[pdf\]](https://arxiv.org/abs/2206.09363) - PromptEM: Prompt-tuning for Low-resource Generalized Entity Matching, in VLDB 2023. [\[pdf\]](https://arxiv.org/abs/2207.04802) - VIMA: General Robot Manipulation with Multimodal Prompts, in Arxiv 2022. [\[pdf\]](https://arxiv.org/abs/2210.03094) - Unbiasing Retrosynthesis Language Models with Disconnection Prompts, in Arxiv 2022. [\[pdf\]](https://chemrxiv.org/engage/chemrxiv/article-details/6328d0b8ba8a6d04fc551df7) - ProgPrompt: Generating Situated Robot Task Plans using Large Language Models, in Arxiv 2022. [\[pdf\]](https://arxiv.org/abs/2209.11302) - Collaborating with language models for embodied reasoning, in NeurIPS 2022 Workshop LaReL. [\[pdf\]](https://openreview.net/pdf?id=YoS-abmWjJc) ## Prompt (PLMs) for Knowledge *Knowledge Probing* - How Much Knowledge Can You Pack Into the Parameters of a Language Model? in EMNLP 2020. [\[pdf\]](https://aclanthology.org/2020.emnlp-main.437/) - Language Models as Knowledge Bases? in EMNLP 2019. [\[pdf\]](https://aclanthology.org/D19-1250.pdf) - Materialized Knowledge Bases from Commonsense Transformers, in CSRR 2022. [\[pdf\]](https://aclanthology.org/2022.csrr-1.5/) - Time-Aware Language Models as Temporal Knowledge Bases, in TACL2022. [\[pdf\]](https://aclanthology.org/2022.tacl-1.15/) - Can Generative Pre-trained Language Models Serve as Knowledge Bases for Closed-book QA? in ACL2021. [\[pdf\]](https://aclanthology.org/2021.acl-long.251/) - Language models as knowledge bases: On entity representations, storage capacity, and paraphrased queries, in EACL2021. [\[pdf\]](https://aclanthology.org/2021.eacl-main.153/) - Scientific language models for biomedical knowledge base completion: an empirical study, in AKBC 2021. [\[pdf\]](https://arxiv.org/abs/2106.09700) - Multilingual LAMA: Investigating knowledge in multilingual pretrained language models, in EACL2021. [\[pdf\]](https://aclanthology.org/2021.eacl-main.284/) - How Can We Know What Language Models Know ? in TACL 2020. [\[pdf\]](https://aclanthology.org/2020.tacl-1.28/) - How Context Affects Language Models' Factual Predictions, in AKBC 2020. [\[pdf\]](https://arxiv.org/abs/2005.04611) - COPEN: Probing Conceptual Knowledge in Pre-trained Language Models, in EMNLP 2022. [\[pdf\]](https://arxiv.org/abs/2211.04079) - Probing Simile Knowledge from Pre-trained Language Models, in ACL 2022. [\[pdf\]](https://aclanthology.org/2022.acl-long.404.pdf) *Knowledge Graph Embedding (We provide a library and benchmark [lambdaKG](https://github.com/zjunlp/PromptKG/tree/main/lambdaKG))* - KG-BERT: BERT for knowledge graph completion, in Arxiv 2020. [\[pdf\]](https://arxiv.org/abs/1909.03193) - Multi-Task Learning for Knowledge Graph Completion with Pre-trained Language Models, in Coling 2020. [\[pdf\]](https://aclanthology.org/2020.coling-main.153.pdf) - Structure-Augmented Text Representation Learning for Efficient Knowledge Graph Completion, in WWW 2021. [\[pdf\]](https://arxiv.org/abs/2004.14781) - KEPLER: A Unified Model for Knowledge Embedding and Pre-trained Language Representation, TACL 2021 [\[pdf\]](https://arxiv.org/abs/1911.06136) - StATIK: Structure and Text for Inductive Knowledge Graph, in NAACL 2022. [\[pdf\]](https://aclanthology.org/2022.findings-naacl.46/) - Joint Language Semantic and Structure Embedding for Knowledge Graph Completion, in COLING. [\[pdf\]](https://aclanthology.org/2022.coling-1.171/) - Knowledge Is Flat: A Seq2Seq Generative Framework for Various Knowledge Graph Completion, in COLING. [\[pdf\]](https://aclanthology.org/2022.coling-1.352/) - Do Pre-trained Models Benefit Knowledge Graph Completion? A Reliable Evaluation and a Reasonable Approach, in ACL 2022. [\[pdf\]](https://aclanthology.org/2022.findings-acl.282/) - Language Models as Knowledge Embeddings, in IJCAI 2022. [\[pdf\]](https://arxiv.org/abs/2206.12617) - From Discrimination to Generation: Knowledge Graph Completion with Generative Transformer, in WWW 2022. [\[pdf\]](https://arxiv.org/abs/2202.02113) - Reasoning Through Memorization: Nearest Neighbor Knowledge Graph Embeddings, in Arxiv 2022. [\[pdf\]](https://arxiv.org/abs/2201.05575) - SimKGC: Simple Contrastive Knowledge Graph Completion with Pre-trained Language Models, in ACL 2022. [\[pdf\]](https://arxiv.org/abs/2203.02167) - Sequence to Sequence Knowledge Graph Completion and Question Answering, in ACL 2022. [\[pdf\]](https://arxiv.org/abs/2203.10321) - LP-BERT: Multi-task Pre-training Knowledge Graph BERT for Link Prediction, in Arxiv 2022. [\[pdf\]](https://arxiv.org/pdf/2201.04843.pdf) - Mask and Reason: Pre-Training Knowledge Graph Transformers for Complex Logical Queries, in KDD 2022. [\[pdf\]](https://arxiv.org/pdf/2208.07638.pdf) - Knowledge Is Flat: A Seq2Seq Generative framework For Various Knowledge Graph Completion, in Coling 2022. [\[pdf\]](https://arxiv.org/pdf/2209.07299.pdf) *Analysis* - Knowledgeable or Educated Guess? Revisiting Language Models as Knowledge Bases, in ACL 2021. [\[pdf\]](https://aclanthology.org/2021.acl-long.146/) - Can Prompt Probe Pretrained Language Models? Understanding the Invisible Risks from a Causal View, in ACL 2022. [\[pdf\]](https://arxiv.org/abs/2203.12258) - How Pre-trained Language Models Capture Factual Knowledge? A Causal-Inspired Analysis, in ACl 2022. [\[pdf\]](https://arxiv.org/abs/2203.16747) - Emergent Abilities of Large Language Models, in Arxiv 2022. [\[pdf\]](https://arxiv.org/abs/2206.07682) - Knowledge Neurons in Pretrained Transformers, in ACL 2022. [\[pdf\]](https://arxiv.org/abs/2104.08696) - Finding Skill Neurons in Pre-trained Transformer-based Language Models, in EMNLP 2022. [\[pdf\]](https://arxiv.org/abs/2211.07349) - Do Prompts Solve NLP Tasks Using Natural Languages? in Arxiv 2022. [\[pdf\]](https://arxiv.org/abs/2203.00902) - Rethinking the Role of Demonstrations: What Makes In-Context Learning Work? in EMNLP 2022. [\[pdf\]](https://arxiv.org/abs/2202.12837) - Do Prompt-Based Models Really Understand the Meaning of their Prompts? in NAACL 2022. [\[pdf\]](https://arxiv.org/abs/2109.01247) - When Not to Trust Language Models: Investigating Effectiveness and Limitations of Parametric and Non-Parametric Memories, in arxiv 2022. [\[pdf\]](https://akariasai.github.io/files/llm_memorization.pdf) - Why Can GPT Learn In-Context? Language Models Secretly Perform Gradient Descent as Meta-Optimizers,in arxiv 2022. [\[pdf\]](https://arxiv.org/pdf/2212.10559.pdf) - Fantastically Ordered Prompts and Where to Find Them: Overcoming Few-Shot Prompt Order Sensitivity, in ACL 2022. [\[pdf\]](https://aclanthology.org/2022.acl-long.556.pdf) - Editing Large Language Models: Problems, Methods, and Opportunities, in arxiv 2023. [\[pdf\]](https://arxiv.org/pdf/2305.13172.pdf) ## Contact Information For help or issues using the tookits, please submit a GitHub issue.

ML Frameworks
734 Github Stars
LightMem
Open Source

LightMem

<div align="center"> <picture> <source srcset="./figs/lightmem_logo_dark.png" media="(prefers-color-scheme: dark)"> <img src="./figs/lightmem_logo_light.png" width="60%" height="40%" /> </picture> </div> <h1 align="center"> LightMem: Lightweight and Efficient Memory-Augmented Generation </h1> <p align="center"> <a href="https://arxiv.org/abs/2510.18866"> <img src="https://img.shields.io/badge/arXiv-Paper-red" alt="arXiv"> </a> <a href="https://github.com/zjunlp/LightMem"> <img src="https://img.shields.io/github/stars/zjunlp/LightMem?style=social" alt="GitHub Stars"> </a> <a href="https://github.com/zjunlp/LightMem/blob/main/LICENSE"> <img src="https://img.shields.io/badge/License-MIT-green.svg" alt="License: MIT"> </a> <img src="https://img.shields.io/github/last-commit/zjunlp/LightMem?color=blue" alt="Last Commit"> <img src="https://img.shields.io/badge/PRs-Welcome-red" alt="PRs Welcome"> </p> <h5 align="center"> ⭐ If you like our project, please give us a star on GitHub for the latest updates!</h5> --- **LightMem** is a lightweight and efficient memory management framework designed for Large Language Models and AI Agents. It provides a simple yet powerful memory storage, retrieval, and update mechanism to help you quickly build intelligent applications with long-term memory capabilities. * 🚀 **Lightweight & Efficient** <br> Minimalist design with minimal resource consumption and fast response times * 🎯 **Easy to Use** <br> Simple API design - integrate into your application with just a few lines of code * 🔌 **Flexible & Extensible** <br> Modular architecture supporting custom storage engines and retrieval strategies * 🌐 **Broad Compatibility** <br> Support for cloud APIs (OpenAI, DeepSeek) and local models (Ollama, vLLM, etc.) <div align=center><img src="./figs/Lightmem.png" width="100%" height="60%" /></div> <span id='news'/> ## 📢 News - **[2026-04-24]**: 🚀 LightMem now supports the latest [**DeepSeek**](./src/lightmem/configs/memory_manager/base_config.py) models, including `deepseek-v4-flash` and `deepseek-v4-pro`, with `reasoning_effort` and thinking-mode configuration! - **[2026-04-24]**: 🎉🎉🎉 [**StructMem: Structured Memory for Long-Horizon Behavior in LLMs**](https://arxiv.org/abs/2604.21748) has been accepted by **ACL 2026**! - **[2026-03-21]**: 🚀 We provide a more comprehensive [baseline evaluation framework](https://github.com/zjunlp/MemBase), supporting the benchmarking of memory layers such as Mem0, A-MEM, EverMemOS, LangMem on multiple datasets like LoCoMo and LongMemEval. - **[2026-02-15]**: 🚀 **[StructMem](./StructMem.md)** is released: A hierarchical memory framework that preserves event-level memory bindings and cross-event memory connections. - **[2026-01-26]**: 🎉🎉🎉 [**LightMem: Lightweight and Efficient Memory-Augmented Generation**](https://arxiv.org/abs/2510.18866) has been accepted by **ICLR 2026**! - **[2026-01-17]**: 🚀 We provide a comprehensive [baseline evaluation framework](https://github.com/zjunlp/LightMem/blob/main/src/lightmem/memory_toolkits/readme.md), supporting the benchmarking of memory layers such as Mem0, A-MEM, and LangMem on multiple datasets like LoCoMo and LongMemEval. - **[2025-12-09]**: 🎬 Released a **[Demo Video](#demo)** showcasing long-context handling, along with comprehensive **[Tutorial Notebooks](./tutorial-notebooks/)** for various scenarios! - **[2025-11-30]**: 🚌 LightMem now supports calling multiple tools provided by its [**MCP Server**](https://github.com/zjunlp/LightMem/blob/main/mcp/server.py). - **[2025-11-26]**: 🚀 Added full **LoCoMo** dataset support, delivering strong [results](https://github.com/zjunlp/LightMem?tab=readme-ov-file#locomo) with leading performance and efficiency! Here is the [**reproduction script**](https://github.com/zjunlp/LightMem/blob/main/experiments/locomo/readme.md)! - **[2025-11-09]**: ✨ LightMem now supports local deployment via [**Ollama**](https://github.com/zjunlp/LightMem/blob/main/src/lightmem/factory/memory_manager/ollama.py), [**vLLM**](https://github.com/zjunlp/LightMem/blob/main/src/lightmem/factory/memory_manager/vllm_offline.py), and [**Transformers**](https://github.com/zjunlp/LightMem/blob/main/src/lightmem/factory/memory_manager/transformers.py) auto-loading! - **[2025-10-12]**: 🎉 LightMem project is officially Open-Sourced! <span id='reproduction'/> ## 🧪 Reproduction Scripts for LoCoMo & LongMemEval We provide lightweight, ready-to-run scripts for reproducing results on **LoCoMo**, **LongMemEval**, and their combined baselines. | Dataset | Description | Script | Result | | :----------------------- | :--------------------------------------------------------------------------- | :--------------------------------------------------------------------------------------------------------------| :---------------------------------------------| | **LongMemEval** | Run LightMem on LongMemEval, including evaluation and offline memory update. | [run_lightmem_longmemeval.md](https://github.com/zjunlp/LightMem/blob/main/experiments/longmemeval/readme.md) | [LongMemEval Results](https://github.com/zjunlp/LightMem/blob/main/experiments/longmemeval/readme.md#results) | | **LoCoMo** | Scripts for reproducing LightMem results on LoCoMo. | [run_lightmem_locomo.md](https://github.com/zjunlp/LightMem/blob/main/experiments/locomo/readme.md) | [LoCoMo Results](https://github.com/zjunlp/LightMem/blob/main/experiments/locomo/readme.md#results) | | **LongMemEval & LoCoMo** | Unified baseline scripts for running both datasets. | [run_baselines.md](https://github.com/zjunlp/LightMem/blob/main/src/lightmem/memory_toolkits/readme.md) | [Baseline Results](#experimental-results) | <span id='baseline-evaluation'/> ## 🧪 Baseline Evaluation We provide a comprehensive [baseline evaluation framework](https://github.com/zjunlp/LightMem/blob/main/src/lightmem/memory_toolkits/readme.md), supporting the benchmarking of memory layers such as Mem0, A-MEM, and LangMem on multiple datasets like LoCoMo and LongMemEval. <span id='demo'/> ## 🎥 Demo & Tutorials **Watch Demo:** [YouTube](https://www.youtube.com/watch?v=r7sk_7Yv66I) | [Bilibili](https://www.bilibili.com/video/BV1a7mJBbEVM/) ### 📚 Hands-on Tutorials We provide ready-to-use Jupyter notebooks corresponding to the demo and other use cases. You can find them in the [`tutorial-notebooks`](./tutorial-notebooks/) directory. | Scenario | Description | Notebook Link | | :--- | :--- | :--- | | **Travel Planning** | A complete guide to building a travel agent with memory. | [LightMem_Example_travel.ipynb](./tutorial-notebooks/LightMem_Example_travel.ipynb) | | **Code Assistant** | A complete guide to building a code agent with memory. | [LightMem_Example_code.ipynb](./tutorial-notebooks/LightMem_Example_code.ipynb) | | **LongMemEval** | A tutorial on how to run evaluations on LongMemEval benchmarks using LightMem. | [LightMem_Example_longmemeval.ipynb](./tutorial-notebooks/LightMem_Example_longmemeval.ipynb) | <span id='todo'/> ## ☑️ Todo List LightMem is continuously evolving! Here's what's coming: - Offline Pre-computation of KV Cache for Update (Lossless) - Online Pre-computation of KV Cache Before Q&A (Lossy) - Integration More Models and Feature Enhancement - Coordinated Use of Context and Long-Term Memory Storage - Multi Modal Memory <span id='contents'/> ## 📑 Table of Contents * <a href='#news'>📢 News</a> * <a href='#reproduction'>🧪 Reproduction Scripts</a> * <a href='#baseline-evaluation'>🧪 Baseline Evaluation</a> * <a href='#demo'>🎥 Demo & Tutorials</a> * <a href='#todo'>☑️ Todo List</a> * <a href='#installation'>🔧 Installation</a> * <a href='#quickstart'>⚡ Quick Start</a> * <a href='#architecture'>🏗️ Architecture</a> * <a href='#examples'>💡 Examples</a> * <a href='#experimental-results'>📁 Experimental Results</a> * <a href='#configuration'>⚙️ Configuration</a> * <a href='#contributors'>👥 Contributors</a> * <a href='#related'>🔗 Related Projects</a> <span id='installation'/> ## 🔧 Installation ### Installation Steps #### Option 1: Install from Source ```bash # Clone the repository git clone https://github.com/zjunlp/LightMem.git cd LightMem # Create virtual environment conda create -n lightmem python=3.11 -y conda activate lightmem # Install dependencies unset ALL_PROXY pip install -e . ``` #### Option 2: Install via pip ```bash pip install lightmem # Coming soon ``` ## ⚡ Quick Start 1. Modify the `JUDGE_MODEL`, `LLM_MODEL`, and their respective `API_KEY` and `BASE_URL` in `API Configuration`. 2. Download `LLMLINGUA_MODEL` from [microsoft/llmlingua-2-bert-base-multilingual-cased-meetingbank](https://huggingface.co/microsoft/llmlingua-2-bert-base-multilingual-cased-meetingbank) and `EMBEDDING_MODEL` from [sentence-transformers/all-MiniLM-L6-v2](https://huggingface.co/sentence-transformers/all-MiniLM-L6-v2) and modify their paths in `Model Paths`. 3. Download the dataset from [longmemeval-cleaned](https://huggingface.co/datasets/xiaowu0162/longmemeval-cleaned), and modidy the path in `Data Configuration`. ```python cd experiments python run_lightmem_qwen.py ``` <span id='architecture'/> ## 🏗️ Architecture ### 🗺️ Core Modules Overview LightMem adopts a modular design, breaking down the memory management process into several pluggable components. The core directory structure exposed to users is outlined below, allowing for easy customization and extension: ```python LightMem/ ├── src/lightmem/ # Main package │ ├── __init__.py # Package initialization │ ├── configs/ # Configuration files │ ├── factory/ # Factory methods │ ├── memory/ # Core memory management │ └── memory_toolkits/ # Memory toolkits ├── mcp/ # LightMem MCP server ├── experiments/ # Experiment scripts ├── datasets/ # Datasets files └── examples/ # Examples ``` ### 🧩 Supported Backends per Module The following table lists the backends values currently recognized by each configuration module. Use the `model_name` field (or the corresponding config object) to select one of these backends. | Module (config) | Supported backends | | :--- | :--- | | `PreCompressorConfig` | `llmlingua-2`, `entropy_compress` | | `TopicSegmenterConfig` | `llmlingua-2` | | `MemoryManagerConfig` | `openai`, `deepseek`, `ollama`, `vllm`, etc. | | `TextEmbedderConfig` | `huggingface` | | `MMEmbedderConfig` | `huggingface` | | `RetrieverConfig` | `qdrant`, `FAISS`, `BM25` | <span id='examples'/> ## 💡 Examples ### Initialize LightMem ```python import os from datetime import datetime from lightmem.memory.lightmem import LightMemory LOGS_ROOT = "./logs" RUN_TIMESTAMP = datetime.now().strftime("%Y%m%d_%H%M%S") RUN_LOG_DIR = os.path.join(LOGS_ROOT, RUN_TIMESTAMP) os.makedirs(RUN_LOG_DIR, exist_ok=True) API_KEY='your_api_key' API_BASE_URL='your_api_base_url' LLM_MODEL='your_model_name' # such as 'gpt-4o-mini' (API) or 'gemma3:latest' (Local Ollama) ... EMBEDDING_MODEL_PATH='/your/path/to/models/all-MiniLM-L6-v2' LLMLINGUA_MODEL_PATH='/your/path/to/models/llmlingua-2-bert-base-multilingual-cased-meetingbank' config_dict = { "pre_compress": True, "pre_compressor": { "model_name": "llmlingua-2", "configs": { "llmlingua_config": { "model_name": LLMLINGUA_MODEL_PATH, "device_map": "cuda", "use_llmlingua2": True, }, } }, "topic_segment": True, "precomp_topic_shared": True, "topic_segmenter": { "model_name": "llmlingua-2", }, "messages_use": "user_only", "metadata_generate": True, "text_summary": True, "memory_manager": { "model_name": 'xxx', # such as 'openai' or 'ollama' ... "configs": { "model": LLM_MODEL, "api_key": API_KEY, "max_tokens": 16000, "xxx_base_url": API_BASE_URL # API model specific, such as 'openai_base_url' or 'deepseek_base_url' ... } }, "extract_threshold": 0.1, "index_strategy": "embedding", "text_embedder": { "model_name": "huggingface", "configs": { "model": EMBEDDING_MODEL_PATH, "embedding_dims": 384, "model_kwargs": {"device": "cuda"}, }, }, "retrieve_strategy": "embedding", "embedding_retriever": { "model_name": "qdrant", "configs": { "collection_name": "my_long_term_chat", "embedding_model_dims": 384, "path": "./my_long_term_chat", } }, "summary_retriever": { "model_name": "qdrant", "configs": { "collection_name": "my_chat_summaries", "embedding_model_dims": 384, "path": "./my_chat_summaries", } }, "update": "offline", "logging": { "level": "DEBUG", "file_enabled": True, "log_dir": RUN_LOG_DIR, } } lightmem = LightMemory.from_config(config_dict) ``` ### Add Memory ```python session = { "timestamp": "2025-01-10", "turns": [ [ {"role": "user", "content": "My favorite ice cream flavor is pistachio, and my dog's name is Rex."}, {"role": "assistant", "content": "Got it. Pistachio is a great choice."}], ] } for turn_messages in session["turns"]: timestamp = session["timestamp"] for msg in turn_messages: msg["time_stamp"] = timestamp store_result = lightmem.add_memory( messages=turn_messages, force_segment=True, force_extract=True ) ``` ### Offline Update ```python lightmem.construct_update_queue_all_entries() lightmem.offline_update_all_entries(score_threshold=0.8) ``` ### Generate summaries ```python summary_result = lightmem.summarize() ``` ### Retrieve Memory ```python question = "What is the name of my dog?" related_memories = lightmem.retrieve(question, limit=5) print(related_memories) ``` ### MCP Server LightMem also supports the Model Context Protocol ([MCP](https://modelcontextprotocol.io/docs/getting-started/intro)) server: ```bash # Running at Root Directory cd LightMem # Environment pip install '.[mcp]' # MCP Inspector [Optional] npx @modelcontextprotocol/inspector python mcp/server.py # Start API by HTTP (http://127.0.0.1:8000/mcp) fastmcp run mcp/server.py:mcp --transport http --port 8000 ``` The MCP config `json` file of your local client may looks like: ```json { "yourMcpServers": { "LightMem": { "url": "http://127.0.0.1:8000/mcp", "otherParameters": "..." } } } ``` <span id='experimental-results'/> ## 📁 Experimental Results For transparency and reproducibility, we have shared the results of our experiments on Google Drive. This includes model outputs, evaluation logs, and predictions used in our study. 🔗 Access the data here: [Google Drive - Experimental Results](https://drive.google.com/drive/folders/1n1YCqq0aDeWiPILhkq-uS3sU3FDmslz9?usp=drive_link) Please feel free to download, explore, and use these resources for research or reference purposes. <span id='configuration'/> ### LOCOMO: #### Overview backbone: `gpt-4o-mini`, judge model: `gpt-4o-mini` & `qwen2.5-32b-instruct` | Method | ACC(%) gpt-4o-mini | ACC(%) qwen2.5-32b-instruct | Memory-Con Tokens(k) Total | QA Tokens(k) total | Total(k) | Calls | Runtime(s) total | |-------------------|--------------------|------------------------------|-----------------------------|---------------------|--------------|--------|------------------| | FullText | 73.83 | 73.18 | – | 54,884.479 | 54,884.479 | – | 6,971 | | NaiveRAG | 63.64 | 63.12 | – | 3,870.187 | 3,870.187 | – | 1,884 | | A-MEM | 64.16 | 60.71 | 11,494.344 | 10,170.567 | 21,664.907 | 11,754 | 67,084 | | MemoryOS(eval) | 58.25 | 61.04 | 2,870.036 | 7,649.343 | 10,519.379 | 5,534 | 26,129 | | MemoryOS(pypi) | 54.87 | 55.91 | 5,264.801 | 6,126.111 | 11,390.004 | 10,160 | 37,912 | | Mem0 | 36.49 | 37.01 | 24,304.872 | 1,488.618 | 25,793.490 | 19,070 | 120,175 | | Mem0(api) | 61.69 | 61.69 | 68,347.720 | 4,169.909 | 72,517.629 | 6,022 | 10,445 | | Mem0-g(api) | 60.32 | 59.48 | 69,684.818 | 4,389.147 | 74,073.965 | 6,022 | 10,926 | backbone: `qwen3-30b-a3b-instruct-2507`, judge model: `gpt-4o-mini` & `qwen2.5-32b-instruct` | Method | ACC(%) gpt-4o-mini | ACC(%) qwen2.5-32b-instruct | Memory-Con Tokens(k) Total | QA Tokens(k) total | Total(k) | Calls | Runtime(s) total | |-------------------|--------------------|------------------------------|-----------------------------|---------------------|--------------|--------|------------------| | FullText | 74.87 | 74.35 | – | 60,873.076 | 60,873.076 | – | 10,555 | | NaiveRAG | 66.95 | 64.68 | – | 4,271.052 | 4,271.052 | – | 1,252 | | A-MEM | 56.10 | 54.81 | 16,267.997 | 17,340.881 | 33,608.878 | 11,754 | 69,339 | | MemoryOS(eval) | 61.04 | 59.81 | 3,615.087 | 9,703.169 | 11,946.442 | 4,147 | 13,710 | | MemoryOS(pypi) | 51.30 | 51.95 | 6,663.527 | 7,764.991 | 14,428.518 | 10,046 | 20,830 | | Mem0 | 43.31 | 43.25 | 17,994.035 | 1,765.570 | 19,759.605 | 16,145 | 46,500 | #### Details backbone: `gpt-4o-mini`, judge model: `gpt-4o-mini` & `qwen2.5-32b-instruct` | Method | Summary Tokens(k) In | Summary Tokens(k) Out | Update Tokens(k) In | Update Tokens(k) Out | QA Tokens(k) In | QA Tokens(k) Out | Runtime(s) mem-con | Runtime(s) qa | |-------------------|-----------------------|------------------------|----------------------|-----------------------|------------------|-------------------|----------------------|----------------| | FullText | – | – | – | – | 54,858.770 | 25.709 | – | 6,971 | | NaiveRAG | – | – | – | – | 3,851.029 | 19.158 | – | 1,884 | | A-MEM | 1,827.373 | 492.883 | 7,298.878 | 1,875.210 | 10,113.252 | 57.315 | 60,607 | 6,477 | | MemoryOS(eval) | 1,109.849 | 333.970 | 780.807 | 645.410 | 7,638.539 | 10.804 | 24,220 | 1,909 | | MemoryOS(pypi) | 1,007.729 | 294.601 | 3,037.509 | 924.962 | 6,116.239 | 9.872 | 33,325 | 4,587 | | Mem0 | 8,127.398 | 253.187 | 12,722.011 | 3,202.276 | 1,478.830 | 9.788 | 118,268 | 1,907 | | Mem0(api) | \ | \ | \ | \ | 4,156.850 | 13.059 | 4,328 | 6,117 | | Mem0-g(api) | \ | \ | \ | \ | 4,375.900 | 13.247 | 5,381 | 5,545 | backbone: `qwen3-30b-a3b-instruct-2507`, judge model: `gpt-4o-mini` & `qwen2.5-32b-instruct` | Method | Summary Tokens(k) In | Summary Tokens(k) Out | Update Tokens(k) In | Update Tokens(k) Out | QA Tokens(k) In | QA Tokens(k) Out | Runtime(s) mem-con | Runtime(s) qa | |-------------------|-----------------------|------------------------|----------------------|-----------------------|------------------|-------------------|----------------------|----------------| | FullText | – | – | – | – | 60,838.694 | 34.382 | – | 10,555 | | NaiveRAG | – | – | – | – | 4,239.030 | 32.022 | – | 1,252 | | A-MEM | 1,582.942 | 608.507 | 9,241.928 | 4,835.070 | 17,528.876 | 82.005 | 55,439 | 13,900 | | MemoryOS(eval) | 1,222.139 | 531.157 | 1,044.307 | 817.484 | 9,679.996 | 23.173 | 12,697 | 1,012 | | MemoryOS(pypi) | 2,288.533 | 516.024 | 2,422.693 | 1,436.277 | 7,743.391 | 21.600 | 19,822 | 1,007 | | Mem0 | 8,270.874 | 186.354 | 7,638.827 | 1,897.980 | 1,739.246 | 26.324 | 45,407 | 1,093 | #### Performance metrics backbone: `gpt-4o-mini`, judge model: `gpt-4o-mini` | Method | Overall ↑ | Multi | Open | Single | Temp | | :--- | :---: | :---: | :---: | :---: | :---: | | FullText | 73.83 | 68.79 | 56.25 | 86.56 | 50.16 | | NaiveRAG | 63.64 | 55.32 | 47.92 | 70.99 | 56.39 | | A-MEM | 64.16 | 56.03 | 31.25 | 72.06 | 60.44 | | MemoryOS(eval) | 58.25 | 56.74 | 45.83 | 67.06 | 40.19 | | MemoryOS(pypi) | 54.87 | 52.13 | 43.75 | 63.97 | 36.76 | | Mem0 | 36.49 | 30.85 | 34.38 | 38.41 | 37.07 | | Mem0(api) | 61.69 | 56.38 | 43.75 | 66.47 | 59.19 | | Mem0-g(api) | 60.32 | 54.26 | 39.58 | 65.99 | 57.01 | backbone: `gpt-4o-mini`, judge model: `qwen2.5-32b-instruct` | Method | Overall ↑ | Multi | Open | Single | Temp | | :--- | :---: | :---: | :---: | :---: | :---: | | FullText | 73.18 | 68.09 | 54.17 | 86.21 | 49.22 | | NaiveRAG | 63.12 | 53.55 | 50.00 | 71.34 | 53.89 | | A-MEM | 60.71 | 53.55 | 32.29 | 69.08 | 53.58 | | MemoryOS(eval) | 61.04 | 64.18 | 40.62 | 70.15 | 40.50 | | MemoryOS(pypi) | 55.91 | 52.48 | 41.67 | 66.35 | 35.83 | | Mem0 | 37.01 | 31.91 | 37.50 | 38.53 | 37.38 | | Mem0(api) | 61.69 | 54.26 | 46.88 | 67.66 | 57.01 | | Mem0-g(api) | 59.48 | 55.32 | 42.71 | 65.04 | 53.58 | backbone: `qwen3-30b-a3b-instruct-2507`, judge model: `gpt-4o-mini` | Method | Overall ↑ | Multi | Open | Single | Temp | | :--- | :---: | :---: | :---: | :---: | :---: | | FullText | 74.87 | 69.86 | 57.29 | 87.40 | 51.71 | | NaiveRAG | 66.95 | 62.41 | 57.29 | 76.81 | 47.98 | | A-MEM | 56.10 | 57.45 | 43.75 | 67.90 | 27.73 | | MemoryOS(eval) | 61.04 | 62.77 | 51.04 | 72.29 | 33.02 | | MemoryOS(pypi) | 51.30 | 52.48 | 40.62 | 61.59 | 26.48 | | Mem0 | 43.31 | 42.91 | 46.88 | 46.37 | 34.58 | | Mem0(api) | 61.69 | 54.26 | 46.88 | 67.66 | 57.01 | | Mem0-g(api) | 59.48 | 55.32 | 42.71 | 65.04 | 53.58 | backbone: `qwen3-30b-a3b-instruct-2507`, judge model: `qwen2.5-32b-instruct` | Method | Overall ↑ | Multi | Open | Single | Temp | | :--- | :---: | :---: | :---: | :---: | :---: | | FullText | 74.35 | 68.09 | 63.54 | 86.33 | 51.71 | | NaiveRAG | 64.68 | 60.28 | 52.08 | 75.62 | 43.61 | | A-MEM | 54.81 | 56.74 | 39.58 | 67.42 | 24.61 | | MemoryOS(eval) | 59.81 | 63.12 | 48.96 | 70.51 | 32.09 | | MemoryOS(pypi) | 51.95 | 55.67 | 39.58 | 61.47 | 27.41 | | Mem0 | 43.25 | 45.04 | 46.88 | 45.78 | 33.96 | | Mem0(api) | 61.69 | 54.26 | 46.88 | 67.66 | 57.01 | | Mem0-g(api) | 59.48 | 55.32 | 42.71 | 65.04 | 53.58 | ## ⚙️ Configuration All behaviors of LightMem are controlled via the BaseMemoryConfigs configuration class. Users can customize aspects like pre-processing, memory extraction, retrieval strategy, and update mechanisms by providing a custom configuration. #### Key Configuration Options (Usage) | Option | Default | Usage (allowed values and behavior) | | :--- | :--- | :--- | | `pre_compress` | `False` | True / False. If True, input messages are pre-compressed using the `pre_compressor` configuration before being stored. This reduces storage and indexing cost but may remove fine-grained details. If False, messages are stored without pre-compression. | | `pre_compressor` | `None` | dict / object. Configuration for the pre-compression component (`PreCompressorConfig`) with fields like `model_name` (e.g., `llmlingua-2`, `entropy_compress`) and `configs` (model-specific parameters). Effective only when `pre_compress=True`. | | `topic_segment` | `False` | True / False. Enables topic-based segmentation of long conversations. When True, long conversations are split into topic segments and each segment can be indexed/stored independently (requires `topic_segmenter`). When False, messages are stored sequentially. | | `precomp_topic_shared`| `False` | True / False. If True, pre-compression and topic segmentation can share intermediate results to avoid redundant processing. May improve performance but requires careful configuration to avoid cross-topic leakage. | | `topic_segmenter` | `None` | dict / object. Configuration for topic segmentation (`TopicSegmenterConfig`), including `model_name` and `configs` (segment length, overlap, etc.). Used when `topic_segment=True`. | | `messages_use` | `'user_only'` | `'user_only'` / `'assistant_only'` / `'hybrid'`. Controls which messages are used to generate metadata and summaries: `user_only` uses user inputs, `assistant_only` uses assistant responses, `hybrid` uses both. Choosing `hybrid` increases processing but yields richer context. | | `metadata_generate` | `True` | True / False. If True, metadata such as keywords and entities are extracted and stored to support attribute-based and filtered retrieval. If False, no metadata extraction occurs. | | `text_summary` | `True` | True / False. If True, a text summary is generated and stored alongside the original text (reduces retrieval cost and speeds review). If False, only the original text is stored. Summary quality depends on `memory_manager`. | | `memory_manager` | `MemoryManagerConfig()` | dict / object. Controls the model used to generate summaries and metadata (`MemoryManagerConfig`), e.g., `model_name` (`openai`, `ollama`, etc.) and `configs`. Changing this affects summary style, length, and cost. | | `extract_threshold` | `0.5` | float (0.0 - 1.0). Threshold used to decide whether content is important enough to be extracted as metadata or highlight. Higher values (e.g., 0.8) mean more conservative extraction; lower values (e.g., 0.2) extract more items (may increase noise). | | `index_strategy` | `None` | `'embedding'` / `'context'` / `'hybrid'` / `None`. Determines how memories are indexed: 'embedding' uses vector-based indexing (requires embedders/retriever) for semantic search; 'context' uses text-based/contextual retrieval (requires context_retriever) for keyword/document similarity; and 'hybrid' combines context filtering and vector reranking for robustness and higher accuracy. | | `text_embedder` | `None` | dict / object. Configuration for text embedding model (`TextEmbedderConfig`) with `model_name` (e.g., `huggingface`) and `configs` (batch size, device, embedding dim). Required when `index_strategy` or `retrieve_strategy` includes `'embedding'`. | | `multimodal_embedder` | `None` | dict / object. Configuration for multimodal/image embedder (`MMEmbedderConfig`). Used for non-text modalities. | | `history_db_path` | `os.path.join(lightmem_dir, "history.db")` | str. Path to persist conversation history and lightweight state. Useful to restore state across restarts. | | `retrieve_strategy` | `'embedding'` | `'embedding'` / `'context'` / `'hybrid'`. Strategy used at query time to fetch relevant memories. Pick based on data and query type: semantic queries -> `'embedding'`; keyword/structured queries -> `'context'`; mixed -> `'hybrid'`. | | `context_retriever` | `None` | dict / object. Configuration for context-based retriever (`ContextRetrieverConfig`), e.g., `model_name='BM25'` and `configs` like `top_k`. Used when `retrieve_strategy` includes `'context'`. | | `embedding_retriever` | `None` | dict / object. Vector store configuration (`EmbeddingRetrieverConfig`), e.g., `model_name='qdrant'` and connection/index params. Used when `retrieve_strategy` includes `'embedding'`. | | `summary_retriever` | `None` | dict / object. Configuration for summary-specific vector store (`EmbeddingRetrieverConfig`). When configured, summaries are stored in a separate collection for hierarchical retrieval. Used in StructMem mode to store and retrieve session/topic summaries independently from detailed memories. | | `update` | `'offline'` | `'online'` / `'offline'`. `'offline'`: batch or scheduled updates to save cost and aggregate changes — this is the fully supported mode with complete functionality. `'online'`: reserved for future development (currently a no-op placeholder; memory will not be persisted when this mode is set). | | `kv_cache` | `False` | True / False. If True, attempt to precompute and persist model KV caches to accelerate repeated LLM calls (requires support from the LLM runtime and may increase storage). Uses `kv_cache_path` to store cache. | | `kv_cache_path` | `os.path.join(lightmem_dir, "kv_cache.db")` | str. File path for KV cache storage when `kv_cache=True`. | | `graph_mem` | `False` | True / False. When True, some memories will be organized as a graph (nodes and relationships) to support complex relation queries and reasoning. Requires additional graph processing/storage. | | `extraction_mode` | `'flat'` | `'flat'` / `'event'`. Memory extraction mode: `'flat'` extracts factual entries as independent units suitable for general knowledge retention; `'event'` extracts event-level structures with both factual and relational components, preserving temporal bindings and causal relationships. Use `'event'` for narrative-heavy or time-sensitive scenarios. | | `version` | `'v1.1'` | str. Configuration/API version. Only change if you know compatibility implications. | | `logging` | `'None'` | dict / object. Configuration for logging enabled. | **(Option) BoundMem Configuration:** BoundMem tag fallback is intentionally opt-in and is not enabled by `BaseMemoryConfigs` by default. The following are parameters related to the BoundMem plugin in the main functions, which can be added as needed: | Function | Parameter / Behavior | Notes | | --- | --- | --- | | `add_memory()` | `boundmem_tags` | Tags newly created memories before insertion. Accepts a string or tag list. | | `retrieve()` | `boundmem_tags` | Filters retrieved memories by overlap with the current tags. | | `retrieve()` | `boundmem_drop_untagged` | Keeps untagged legacy memories by default; set `True` to drop them. | | `retrieve()` | returned memory text | Internal tag prefixes are stripped before results are returned. | | `resolve_tags()` | `strategy="hard"` | Uses caller-provided `hard_tags`. | | `resolve_tags()` | `strategy="soft"` | Uses `environment_tag_fn` with `query`, `history`, `known_tags`, and optional `metadata`. | | `resolve_tags()` | `known_tags` | Caller-maintained tag list; returned together with newly resolved tags. | | `tag_text()` / `strip_tags()` | string-level helpers | Add or remove the internal tag prefix for custom integrations. | | `filter_by_tags()` | raw retriever-result helper | Keeps memories with overlapping tags; accepts custom `tag_match_fn`. | | Matching rule | default matcher | A memory is kept if it shares at least one tag with current tags. | ## 🏆 Contributors <table> <tr> <td align="center" width="120"> <a href="https://github.com/JizhanFang"> <img src="https://avatars.githubusercontent.com/JizhanFang?v=4" width="80" style="border-radius:50%" alt="JizhanFang"/> <br /> <sub><b>JizhanFang</b></sub> </a> </td> <td align="center" width="120"> <a href="https://github.com/Xinle-Deng"> <img src="https://avatars.githubusercontent.com/Xinle-Deng?v=4" width="80" style="border-radius:50%" alt="Xinle-Deng"/> <br /> <sub><b>Xinle-Deng</b></sub> </a> </td> <td align="center" width="120"> <a href="https://github.com/Xubqpanda"> <img src="https://avatars.githubusercontent.com/Xubqpanda?v=4" width="80" style="border-radius:50%" alt="Xubqpanda"/> <br /> <sub><b>Xubqpanda</b></sub> </a> </td> <td align="center" width="120"> <a href="https://github.com/HaomingX"> <img src="https://avatars.githubusercontent.com/HaomingX?v=4" width="80" style="border-radius:50%" alt="HaomingX"/> <br /> <sub><b>HaomingX</b></sub> </a> </td> <td align="center" width="120"> <a href="https://github.com/453251"> <img src="https://avatars.githubusercontent.com/453251?v=4" width="80" style="border-radius:50%" alt="453251"/> <br /> <sub><b>453251</b></sub> </a> </td> <td align="center" width="120"> <a href="https://github.com/James-TYQ"> <img src="https://avatars.githubusercontent.com/James-TYQ?v=4" width="80" style="border-radius:50%" alt="James-TYQ"/> <br /> <sub><b>James-TYQ</b></sub> </a> </td> <td align="center" width="120"> <a href="https://github.com/evy568"> <img src="https://avatars.githubusercontent.com/evy568?v=4" width="80" style="border-radius:50%" alt="evy568"/> <br /> <sub><b>evy568</b></sub> </a> </td> <td align="center" width="120"> <a href="https://github.com/Norah-Feathertail"> <img src="https://avatars.githubusercontent.com/Norah-Feathertail?v=4" width="80" style="border-radius:50%" alt="Norah-Feathertail"/> <br /> <sub><b>Norah-Feathertail</b></sub> </a> </td> <td align="center" width="120"> <a href="https://github.com/TongjiCst"> <img src="https://avatars.githubusercontent.com/TongjiCst?v=4" width="80" style="border-radius:50%" alt="TongjiCst"/> <br /> <sub><b>TongjiCst</b></sub> </a> </td> </tr> </table> We welcome contributions from the community! If you'd like to contribute, please fork the repository and submit a pull request. For major changes, please open an issue first to discuss what you would like to change. <span id='related'/> ## 🔗 Related Projects <div align="center"> <table> <tr> <td align="center" width="150"> <a href="https://github.com/mem0ai/mem0"> <img src="https://avatars.githubusercontent.com/mem0ai" width="80" style="border-radius:50%" alt="Mem0"/> <br /> <sub><b>Mem0</b></sub> </a> </td> <td align="center" width="150"> <a href="https://github.com/MemTensor/MemOS"> <img src="https://avatars.githubusercontent.com/MemTensor" width="80" style="border-radius:50%" alt="MemOS"/> <br /> <sub><b>Memos</b></sub> </a> </td> <td align="center" width="150"> <a href="https://github.com/getzep/zep"> <img src="https://avatars.githubusercontent.com/getzep" width="80" style="border-radius:50%" alt="Zep"/> <br /> <sub><b>Zep</b></sub> </a> </td> <td align="center" width="150"> <a href="https://github.com/Mirix-AI/MIRIX"> <img src="https://avatars.githubusercontent.com/Mirix-AI" width="80" style="border-radius:50%" alt="MIRIX"/> <br /> <sub><b>MIRIX</b></sub> </a> </td> <td align="center" width="150"> <a href="https://github.com/NevaMind-AI/memU"> <img src="https://avatars.githubusercontent.com/NevaMind-AI" width="80" style="border-radius:50%" alt="MemU"/> <br /> <sub><b>MemU</b></sub> </a> </td> <td align="center" width="150"> <a href="https://github.com/memodb-io/memobase"> <img src="https://avatars.githubusercontent.com/memodb-io" width="80" style="border-radius:50%" alt="Memobase"/> <br /> <sub><b>Memobase</b></sub> </a> </td> </tr> </table> </div>

AI Agents Knowledge Bases & RAG
917 Github Stars
SkillNet
Open Source

SkillNet

<div align="center"> <a href="http://skillnet.openkg.cn/"> <img src="images/skillnet.png" width="200" alt="SkillNet Logo"> </a> <p><strong>Open Infrastructure for Creating, Evaluating, and Connecting AI Agent Skills</strong></p> <p> Search 500,000+ community skills · One-line install · Auto-create from repos / docs / logs<br/> 5-dimension quality scoring · Semantic relationship graph </p> [![PyPI version](https://badge.fury.io/py/skillnet-ai.svg)](https://pypi.org/project/skillnet-ai/) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Python 3.9+](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/) [![arXiv](https://img.shields.io/badge/arXiv-b5212f.svg?logo=arxiv)](https://arxiv.org/abs/2603.04448) [![Hugging Face](https://img.shields.io/badge/%F0%9F%A4%97%20Hugging%20Face-FFD21E)](https://huggingface.co/blog/xzwnlp/skillnet) [![Website](https://img.shields.io/badge/🌐_Website-skillnet.openkg.cn-0078D4.svg)](http://skillnet.openkg.cn/) <!-- <p align="center"> <a href="#-quick-start">Installation</a> • <a href="#-python-sdk">Python SDK</a> • <a href="#-cli-reference">CLI</a> • <a href="https://arxiv.org/abs/2603.04448">Paper</a> • <a href="http://skillnet.openkg.cn/">Website</a> • <a href="https://huggingface.co/blog/xzwnlp/skillnet">HuggingFace</a> • <a href="#-contributing">Contributing</a> • <a href="https://x.com/_akhaliq/status/2030024322308342160" target="_blank">Featured By AK</a> </p> --> </div> <h5 align="center"> ⭐ If you like our project, please give us a star on GitHub for the latest updates!</h5> --- **SkillNet** is an open-source platform that treats AI agent skills as first-class, shareable packages — like npm for AI capabilities. It provides end-to-end tooling to **search**, **install**, **create**, **evaluate**, and **organize** skills, so agents can learn from the community and continuously grow. - We conducted experiments on ALFWorld, WebShop, and ScienceWorld. Reproduction scripts are provided [here](https://github.com/zjunlp/SkillNet/tree/main/experiments). ![graph-ezgif com-optimize](https://github.com/user-attachments/assets/1d27d046-48a1-4ab2-a6f5-58c8fa07a134) ## 📢 News - **🤖 [2026-03-26] JiuwenClaw × SkillNet Integrated!** — [JiuwenClaw](https://github.com/openJiuwen-ai/jiuwenclaw) now natively integrates SkillNet as its built-in skill marketplace. One-click search and install curated skills. [View Guide →](./examples/JiuwenClaw/README.md) - **🔌 [2026-03-12] SkillNet MCP Server Released!** — We've launched the Model Context Protocol (MCP) integration (maintained by [CycleChain](https://github.com/CycleChain), special thanks for this great contribution!). [Learn more →](#-model-context-protocol-mcp-integration) - **📄 [2026-03-04] SkillNet Technical Report Released!** — We've published the comprehensive SkillNet Technical Report, covering the system architecture, automated creation pipeline, multi-dimensional evaluation methodology, and the released open-source toolkits. [View Report →](https://arxiv.org/abs/2603.04448) - **🦞 [2026-02-23] OpenClaw Integration Released!** — SkillNet is now available as a built-in skill for [OpenClaw](https://github.com/openclaw/openclaw). One command to install, zero config to use. The agent automatically searches, downloads, creates, evaluates, and analyzes skills on your behalf. [Get started →](#-openclaw-integration) ## ✨ Key Features | Feature | Description | | :-------------------------------------- | :---------------------------------------------------------------------------------------------------------------------- | | 🔍&nbsp;**Search** | Find skills via keyword match or AI semantic search across 500+ curated skills | | 📦&nbsp;**One&#8209;Line&nbsp;Install** | `skillnet download <url>` — grab any skill from GitHub in seconds | | ✨&nbsp;**Auto&#8209;Create** | Convert GitHub repos, PDFs/PPTs/Word docs, conversation logs, or text prompts into structured skill packages using LLMs | | 📊&nbsp;**5&#8209;D&nbsp;Evaluation** | Score skills on **Safety · Completeness · Executability · Maintainability · Cost‑Awareness** | | 🕸️&nbsp;**Skill&nbsp;Graph** | Auto-discover `similar_to` · `belong_to` · `compose_with` · `depend_on` links between skills | --- ## 📖 Table of Contents - [Quick Start](#-quick-start) - [REST API](#-rest-api) - [Python SDK](#-python-sdk) - [CLI Reference](#-cli-reference) - [Configuration](#configuration) - [Example: Scientific Discovery](#-example-scientific-discovery) - [Use SkillNet in Code Agents](#-use-skillnet-in-code-agents) - [OpenClaw Integration](#-openclaw-integration) - [Model Context Protocol (MCP)](#-model-context-protocol-mcp-integration) - [Contributing](#-contributing) - [Citation](#-citation) --- ## 🚀 Quick Start ```bash pip install skillnet-ai ``` Or using `uv`: ```bash uv venv source .venv/bin/activate uv pip install skillnet-ai ``` ```python from skillnet_ai import SkillNetClient client = SkillNetClient() # No API key needed for search & download # Search for skills results = client.search(q="pdf", limit=5) print(results[0].skill_name, results[0].stars) # Install a skill client.download(url=results[0].skill_url, target_dir="./my_skills") ``` **🌐 SkillNet Web** — Search, download individual skills, and explore curated skill collections through the [SkillNet website](http://skillnet.openkg.cn/). <div align="center"> https://github.com/user-attachments/assets/9f9d35b0-36fd-4d7d-a072-39afa380b241 </div> **🤖 OpenClaw + SkillNet** — See SkillNet in action with [OpenClaw](https://github.com/openclaw/openclaw). The agent automatically searches, creates, evaluates, and analyzes skills on your behalf. [Learn more →](#-openclaw-integration) <div align="center"> https://github.com/user-attachments/assets/9d49a00c-827d-47a4-8954-0e6b977ca547 </div> --- ## 🌐 REST API The SkillNet search API is free, public, and requires no authentication. ```bash # Keyword search curl "http://api-skillnet.openkg.cn/v1/search?q=pdf&sort_by=stars&limit=5" # Semantic search curl "http://api-skillnet.openkg.cn/v1/search?q=reading%20charts&mode=vector&threshold=0.8" ``` <details> <summary><b>📡 Full Parameter Reference</b></summary> **Endpoint:** `GET http://api-skillnet.openkg.cn/v1/search` | Parameter | Type | Default | Description | | :---------- | :----- | :--------- | :------------------------------------------------- | | `q` | string | _required_ | Search query (keywords or natural language) | | `mode` | string | `keyword` | `keyword` (fuzzy match) or `vector` (semantic AI) | | `category` | string | — | Filter: Development, AIGC, Research, Science, etc. | | `limit` | int | `10` | Results per page (max 50) | | `page` | int | `1` | Page number _(keyword mode only)_ | | `min_stars` | int | `0` | Minimum star count _(keyword mode only)_ | | `sort_by` | string | `stars` | `stars` or `recent` _(keyword mode only)_ | | `threshold` | float | `0.8` | Similarity threshold 0.0–1.0 _(vector mode only)_ | **Response:** ```json { "data": [ { "skill_name": "pdf-extractor-v1", "skill_description": "Extracts text and tables from PDF documents.", "author": "openkg-team", "stars": 128, "skill_url": "https://...", "category": "Productivity" } ], "meta": { "query": "pdf", "mode": "keyword", "total": 1, "limit": 10 }, "success": true } ``` </details> --- ## 🐍 Python SDK ### Initialize ```python from skillnet_ai import SkillNetClient client = SkillNetClient( api_key="sk-...", # Required for create / evaluate / analyze # base_url="...", # Optional: custom LLM endpoint # github_token="ghp-..." # Optional: for private repos ) ``` ### Search ```python # Keyword search results = client.search(q="pdf", limit=10, min_stars=5, sort_by="stars") # Semantic search results = client.search(q="analyze financial PDF reports", mode="vector", threshold=0.85) if results: print(f"{results[0].skill_name} ⭐{results[0].stars}") ``` ### Install ```python local_path = client.download( url="https://github.com/anthropics/skills/tree/main/skills/skill-creator", target_dir="./my_skills" ) ``` ### Create Convert diverse sources into structured skill packages with a single call: ```python # From conversation logs / execution traces client.create(trajectory_content="User: rename .jpg to .png\nAgent: Done.", output_dir="./skills") # From GitHub repository client.create(github_url="https://github.com/zjunlp/DeepKE", output_dir="./skills") # From office documents (PDF / PPT / Word) client.create(office_file="./guide.pdf", output_dir="./skills") # From natural language prompt client.create(prompt="A skill for web scraping article titles", output_dir="./skills") ``` ### Evaluate Score any skill across 5 quality dimensions. Accepts local paths or GitHub URLs. ```python result = client.evaluate( target="https://github.com/anthropics/skills/tree/main/skills/algorithmic-art" ) # Returns: { "safety": {"level": "Good", "reason": "..."}, "completeness": {...}, ... } ``` ### Analyze Relationships Map the connections between skills in a local directory — outputs `similar_to`, `belong_to`, `compose_with`, and `depend_on` edges. ```python relationships = client.analyze(skills_dir="./my_skills") for rel in relationships: print(f"{rel['source']} --[{rel['type']}]--> {rel['target']}") # PDF_Parser --[compose_with]--> Text_Summarizer ``` --- ## 💻 CLI Reference The CLI ships with `pip install skillnet-ai` and offers the same features with rich terminal output. | Command | Description | Example | | :--------- | :--------------------- | :--------------------------------------- | | `search` | Find skills | `skillnet search "pdf" --mode vector` | | `download` | Install a skill | `skillnet download <url> -d ./skills` | | `create` | Create from any source | `skillnet create log.txt --model gpt-4o` | | `evaluate` | Quality report | `skillnet evaluate ./my_skill` | | `analyze` | Relationship graph | `skillnet analyze ./my_skills` | > Use `skillnet <command> --help` for full options. ### Search ```bash skillnet search "pdf" skillnet search "analyze financial reports" --mode vector --threshold 0.85 skillnet search "visualization" --category "Development" --sort-by stars --limit 10 ``` ### Install ```bash skillnet download https://github.com/anthropics/skills/tree/main/skills/algorithmic-art skillnet download <url> -d ./my_agent/skills skillnet download <private_url> --token <your_github_token> # Use a mirror for faster downloads in restricted networks skillnet download <url> --mirror https://ghfast.top/ ``` ### Create ```bash # From trajectory file skillnet create ./logs/trajectory.txt -d ./generated_skills # From GitHub repo skillnet create --github https://github.com/owner/repo # From office document (PDF, PPT, Word) skillnet create --office ./docs/guide.pdf # From prompt skillnet create --prompt "A skill for extracting tables from images" ``` ### Evaluate ```bash skillnet evaluate https://github.com/anthropics/skills/tree/main/skills/algorithmic-art skillnet evaluate ./my_skills/web_search skillnet evaluate ./my_skills/tool --category "Development" --model gpt-4o ``` ### Analyze ```bash skillnet analyze ./my_agent_skills skillnet analyze ./my_agent_skills --no-save # print only, don't write file skillnet analyze ./my_agent_skills --model gpt-4o ``` --- ## <a id="configuration"></a>⚙️ Configuration ### Environment Variables | Variable | Required For | Default | | :--------------- | :--------------------------------- | :-------------------------- | | `API_KEY` | `create` · `evaluate` · `analyze` | — | | `BASE_URL` | Custom LLM endpoint | `https://api.openai.com/v1` | | `GITHUB_TOKEN` | Private repos / higher rate limits | — | | `SKILLNET_MODEL` | Default LLM model for all commands | `gpt-4o` | | `GITHUB_MIRROR` | Faster downloads in restricted networks | — | > `search` and `download` (public repos) work without any credentials. > > **Recommended mirror:** [`https://ghfast.top/`](https://ghfast.top/) — set `GITHUB_MIRROR` or pass `--mirror` to speed up downloads in restricted networks. **Linux / macOS:** ```bash export API_KEY="sk-..." export BASE_URL="https://..." # optional ``` **Windows PowerShell:** ```powershell $env:API_KEY = "sk-..." $env:BASE_URL = "https://..." # optional ``` --- ## 🔬 Example: Scientific Discovery A complete end-to-end demo showing how an AI Agent uses SkillNet to autonomously plan and execute a complex scientific workflow — from raw scRNA-seq data to a cancer target validation report. ![science2](https://github.com/user-attachments/assets/5b65865a-312a-4dd7-ae80-ee1f968e2702) <table> <tr><td>1️⃣</td><td><b>Task</b></td><td>User provides a goal: "Analyze scRNA-seq data to find cancer targets"</td></tr> <tr><td>2️⃣</td><td><b>Plan</b></td><td>Agent decomposes into: Data → Mechanism → Validation → Report</td></tr> <tr><td>3️⃣</td><td><b>Discover</b></td><td><code>client.search()</code> finds <em>cellxgene-census</em>, <em>kegg-database</em>, etc.</td></tr> <tr><td>4️⃣</td><td><b>Evaluate</b></td><td>Skills are quality-gated via <code>client.evaluate()</code> before use</td></tr> <tr><td>5️⃣</td><td><b>Execute</b></td><td>Skills run sequentially to produce a final discovery report</td></tr> </table> 👉 **[Try the Interactive Demo](http://skillnet.openkg.cn/)** (Website → Scenarios → Science) &nbsp;|&nbsp; 📓 **[View Notebook](https://github.com/zjunlp/SkillNet/blob/main/examples/scientific_workflow_demo.ipynb)** --- ## 🤖 Use SkillNet in Code Agents SkillNet itself is packaged as a portable agent skill at [`skills/skillnet/`](https://github.com/zjunlp/SkillNet/tree/main/skills/skillnet). Install this folder into your code agent's local skills directory, then the agent can search, download, create, evaluate, and organize skills during coding tasks. https://github.com/user-attachments/assets/ae6020d9-6846-4672-84ce-fa9c8057e92b <details> <summary><b>Claude Code</b></summary> Claude Code discovers user skills from `~/.claude/skills/` and project skills from `.claude/skills/`. Install as a user skill: ```bash git clone https://github.com/zjunlp/SkillNet.git cd SkillNet mkdir -p ~/.claude/skills cp -R skills/skillnet ~/.claude/skills/skillnet ``` Or install as a project-local skill: ```bash mkdir -p .claude/skills cp -R /path/to/SkillNet/skills/skillnet .claude/skills/skillnet ``` Restart Claude Code or start a new session, then try: ```text Use SkillNet to search for a docker skill and summarize the top result. ``` </details> <details> <summary><b>Codex</b></summary> Codex discovers user skills from `$CODEX_HOME/skills`. If `CODEX_HOME` is not set, use `~/.codex/skills`. ```bash git clone https://github.com/zjunlp/SkillNet.git cd SkillNet CODEX_HOME="${CODEX_HOME:-$HOME/.codex}" mkdir -p "$CODEX_HOME/skills" cp -R skills/skillnet "$CODEX_HOME/skills/skillnet" ``` Restart Codex or start a new session, then try: ```text Use $skillnet to search for a LangGraph skill before planning this task. ``` </details> --- ## 🤖 OpenClaw Integration SkillNet integrates with [OpenClaw](https://github.com/openclaw/openclaw) as a built-in, lazy-loaded skill. Once installed, your agent automatically: - **Searches** existing skills before starting complex tasks - **Creates** new skills from repos, documents, or completed work - **Evaluates & analyzes** your local library for quality and inter-skill relationships > Community skills guide execution → successful outcomes become new skills → periodic analysis keeps the library clean. <details> <summary><b>📡 Full Usage Reference</b></summary> ### 📥 Installation **Prerequisites:** [OpenClaw](https://github.com/openclaw/openclaw) installed (default workspace: `~/.openclaw/workspace`) **Option A — CLI:** ```bash npm i -g clawhub clawhub install skillnet --workdir ~/.openclaw/workspace openclaw gateway restart ``` **Option B — Via OpenClaw chat:** ``` Install the skillnet skill from ClawHub. ``` ### ⚙️ Configuration The same three parameters (`API_KEY`, `BASE_URL`, `GITHUB_TOKEN`) apply here — see [Configuration](#configuration) for details. In OpenClaw, you can pre-configure them in `openclaw.json` so the agent uses them silently — no prompts, no interruptions. If not configured, the agent only asks when a command actually needs the value, injects it for that single call, and never pollutes the global environment. **Recommended: pre-configure in `openclaw.json`**: ```json { "skills": { "entries": { "skillnet": { "enabled": true, "apiKey": "sk-REPLACE_ME", "env": { "BASE_URL": "https://api.openai.com/v1", "GITHUB_TOKEN": "ghp_REPLACE_ME" } } } } } ``` ### 🧪 Quick Verification In your OpenClaw chat, try: **No credentials needed:** ``` Search SkillNet for a "docker" skill and summarize the top result. ``` **Requires API key:** ``` Create a skill from this GitHub repo: https://github.com/owner/repo (then evaluate it). ``` > The skill source is also available at [`skills/skillnet/`](skills/skillnet/) for reference. </details> --- ## 🔌 Model Context Protocol (MCP) Integration The **SkillNet MCP Server** (maintained by [CycleChain](https://github.com/CycleChain)) is a high-performance bridge that enables AI agents (such as Claude Desktop, Cursor, Antigravity and Windsurf) to interact with the SkillNet ecosystem using the [Model Context Protocol](https://modelcontextprotocol.io/). It empowers agents to autonomously search, download, create, and evaluate 500,000+ specialized skills directly within your IDE or desktop environment. <details> <summary><b>📡 Full Usage Reference</b></summary> ### Installation Options #### 1. Source Build (Node.js & Python) Ideal for users who want to run the server locally with existing dependencies. ```bash git clone https://github.com/CycleChain/skillnet-mcp cd skillnet-mcp npm install && npm run build ``` #### 2. Docker (Dependency-free) The most robust way to run the server using the official image from [Docker Hub](https://hub.docker.com/r/fmdogancan/skillnet-mcp). ```bash docker pull fmdogancan/skillnet-mcp:latest ``` ### Quick Configuration (Claude Desktop) Add the following to your `claude_desktop_config.json`: #### Option A: Docker (Recommended) ```json { "mcpServers": { "skillnet": { "command": "docker", "args": ["run", "-i", "--rm", "fmdogancan/skillnet-mcp:latest"], "env": { "API_KEY": "your_api_key_here" } } } } ``` #### Option B: Build Locally If you prefer to build the image yourself from the source: ```bash docker build -t skillnet-mcp-local . ``` _(Then, replace `fmdogancan/skillnet-mcp:latest` with `skillnet-mcp-local` in the JSON config above)_ #### Option C: Source Build ```json { "mcpServers": { "skillnet": { "command": "node", "args": ["/absolute/path/to/skillnet-mcp/build/index.js"], "env": { "API_KEY": "your_api_key_here" } } } } ``` > **Note:** `search_skills` and `download_skill` tools do not require an API key. An `API_KEY` is only required for `create`, `evaluate`, and `analyze` features. ### Supported Environment Variables * `API_KEY`: Your API key * `GITHUB_TOKEN`: GitHub token for private repositories </details> --- ## 🤝 Contributing Contributions of all kinds are welcome! Whether it's fixing a typo, adding a feature, or sharing a new skill — every contribution counts. 1. **Fork** the repository 2. **Create** a feature branch (`git checkout -b feat/amazing-feature`) 3. **Commit** your changes (`git commit -m 'feat: add amazing feature'`) 4. **Push** to the branch (`git push origin feat/amazing-feature`) 5. **Open** a Pull Request 📤 **[Contribute skills](http://skillnet.openkg.cn/)** (Website → Contribute → Submit via URL / Upload Local Skill / Batch Upload Skills) You can also [open an Issue](https://github.com/zjunlp/SkillNet/issues) to report bugs or suggest features. --- ## 📚 Citation If you find this work useful, please kindly ⭐ the repo and cite our paper! ```bibtex @misc{liang2026skillnetcreateevaluateconnect, title={SkillNet: Create, Evaluate, and Connect AI Skills}, author={Yuan Liang and Ruobin Zhong and Haoming Xu and Chen Jiang and Yi Zhong and Runnan Fang and Jia-Chen Gu and Shumin Deng and Yunzhi Yao and Mengru Wang and Shuofei Qiao and Xin Xu and Tongtong Wu and Kun Wang and Yang Liu and Zhen Bi and Jungang Lou and Yuchen Eleanor Jiang and Hangcheng Zhu and Gang Yu and Haiwen Hong and Longtao Huang and Hui Xue and Chenxi Wang and Yijun Wang and Zifei Shan and Xi Chen and Zhaopeng Tu and Feiyu Xiong and Xin Xie and Peng Zhang and Zhengke Gui and Lei Liang and Jun Zhou and Chiyu Wu and Jin Shang and Yu Gong and Junyu Lin and Changliang Xu and Hongjie Deng and Wen Zhang and Keyan Ding and Qiang Zhang and Fei Huang and Ningyu Zhang and Jeff Z. Pan and Guilin Qi and Haofen Wang and Huajun Chen}, year={2026}, eprint={2603.04448}, archivePrefix={arXiv}, primaryClass={cs.AI}, url={https://arxiv.org/abs/2603.04448}, } ```

AI Agents Knowledge Bases & RAG
1K Github Stars
SkillX
Open Source

SkillX

<div align="center"> <h1 align="center"> 👉 SkillX 👈 </h1> <b>SkillX: Automatically Constructing Skill Knowledge Bases for Agents</b> [![Awesome](https://awesome.re/badge.svg)](https://github.com/zjunlp/SKillX) [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT) ![](https://img.shields.io/github/last-commit/zjunlp/SKillX?color=green) <!-- <p align="center"> <a href="https://arxiv.org/abs/2502.15589">📄arXiv</a> • <a href="https://x.com/zxlzr/status/1894729164609208338">𝕏 Blog</a> • <a href="https://huggingface.co/collections/zjunlp/SKillX-67f9faaaa518f2e00b17386b">🤗 Huggingface</a> </p> --> </div> ## Table of Contents - 👀[Overview](#overview) - 🔧[Installation](#installation) - 🏃[Quick Start](#quick-start) - 🎁[Acknowledgement](#acknowledgement) - 🚩[Citation](#citation) ## 📖 Overview **SkillX** is a fully automated framework that constructs a **reusable, plug-and-play skill knowledge base** for LLM agents from experience. Instead of storing raw trajectories, workflows, or loosely structured reflections, SkillX distills agent experience into a **three-level skill hierarchy**: - **Planning Skills** for high-level task organization - **Functional Skills** for reusable tool-based subroutines - **Atomic Skills** for execution-oriented tool usage patterns Built with a strong backbone agent, SkillX produces a transferable skill library that can be directly plugged into weaker base agents and new environments. Across challenging long-horizon, user-interactive benchmarks such as **AppWorld**, **BFCL-v3**, and **τ2-Bench**, SkillX consistently improves both **task success** and **execution efficiency**. <div align="center" style="width: 100%;"> <img src="assets/overview.png" alt="Case GIF" style="width: 100%; max-width: 100%; height: auto;"> </div> --- ## Data Formats ### Trajectory Input (JSONL) SkillX expects trajectories in the following schema: ```json { "trajectory_id": "traj_001", "task_id": "task_001", "user_task": "How many songs are in my Spotify library?", "task_history": [ {"role": "system", "content": "You are a helpful assistant..."}, {"role": "assistant", "content": "I'll help you count..."}, {"role": "user", "content": "Output:\n```\n{\"songs\": 150}\n```"} ], "reward": 1.0, "metadata": {} } ``` ## 🤖 Key Features ### Hierarchical Multi-Level Skill Design SkillX transforms raw trajectories into a structured three-tier skill space: - **Planning Skills** capture high-level decomposition and ordering - **Functional Skills** represent reusable multi-step tool subroutines - **Atomic Skills** encode practical tool usage constraints and patterns ### Fully Automated Skill KB Construction SkillX provides an end-to-end automated pipeline that: - rolls out agents on training tasks, - extracts reusable skills from successful trajectories, - consolidates and filters low-quality skills, - and builds a reusable **plug-and-play skill knowledge base**. ### Iterative Skill Refinement SkillX continuously improves the skill library through: - **skill merging** for consolidating redundant behaviors, - **quality filtering** for removing brittle or hallucinated skills, - and **iterative updates** that add, modify, or keep skills based on execution feedback. ### Exploratory Skill Expansion Beyond seed demonstrations, SkillX proactively discovers new skills by: - identifying under-used and failure-prone tools, - guiding environment exploration, - synthesizing new tasks from exploratory trajectories, - and expanding skill coverage beyond the original training distribution. ### Plug-and-Play Transfer Across Agents The resulting skill library can be directly injected into different base agents, enabling **strong-to-weak transfer** without retraining the underlying model. ### Better Performance and Efficiency SkillX consistently improves: - **task success rate** on challenging benchmarks, - **execution efficiency** by reducing unnecessary exploration and tool misuse, - and **generalization** through structured, reusable experience abstraction. --- ## 📊 Highlights - **~10% absolute improvement** for weaker base agents on multiple benchmarks - Consistent gains on **AppWorld**, **BFCL-v3**, and **τ2-Bench** - Stronger transferability than trajectory-based, workflow-based, and memory-based baselines - Improved **execution efficiency** with fewer redundant steps - Effective even when the skill library is built by a stronger model and used by weaker ones --- ## 🧠 Why SkillX? Existing experience-learning methods often suffer from: - **Isolated learning**: agents repeatedly rediscover similar behaviors - **Weak transferability**: raw trajectories and reflections often do not generalize well - **Capability bottlenecks**: self-extracted experience is limited by the agent’s own strength SkillX addresses these issues by building a **structured skill knowledge base** that is: - **reusable across tasks** - **transferable across agents** - **lightweight to retrieve** - **easy to inject into prompts** - **more robust than long-context progressive skill formats** --- ## 🏗️ Method Overview SkillX consists of three core components: ### 1. Multi-Level Skills Extraction From successful trajectories, SkillX automatically extracts: - **Planning skills**: concise, reusable task plans - **Functional skills**: reusable tool-composition procedures - **Atomic skills**: tool-specific usage guidance, constraints, and failure notes ### 2. Iterative Skills Refinement SkillX improves library quality through: - **Skills Merge**: cluster and consolidate similar skills - **Skills Filter**: remove non-portable, hallucinated, or invalid skills - **Skills Update**: add, modify, or keep skills across iterations ### 3. Exploratory Skills Expansion SkillX expands beyond observed demonstrations by: - guiding exploration toward under-covered tools and failure modes, - synthesizing new tasks from exploration, - and rerunning extraction + refinement to grow the skill library. --- ## 📈 Main Results SkillX improves agentic performance across multiple LLM backbones and benchmarks. ### Representative gains - On **Qwen3-32B**, SkillX brings **around 10-point improvements** on several benchmarks - On **Kimi-K2-Instruct-0905**, SkillX yields clear gains especially on **AppWorld** - On **GLM-4.6**, SkillX still improves performance and execution efficiency despite the model already being strong ### Benchmarks - **AppWorld** - **BFCL-v3** - **τ2-Bench** ### Key takeaway SkillX outperforms strong experience-learning baselines such as: - **A-Mem** - **AWM** - **ExpeL** - **No-memory** This shows that **how experience is represented** matters as much as, or more than, where it comes from. --- ## 🔍 What Makes SkillX Different? Compared with prior experience formats: - **Raw trajectories** are verbose and difficult to transfer - **Insights/reflections** are often too abstract - **Workflows** may miss low-level tool constraints - **Claude-style skills** rely on long-context progressive disclosure and complex environment support In contrast, SkillX offers: - **hierarchical, itemized, reusable skills** - **one-time prompt injection** - **lightweight retrieval** - **strong transfer across agents and environments** --- ## 🚀 Use Cases SkillX is especially useful for: - **tool-using LLM agents** - **long-horizon task execution** - **interactive application environments** - **cross-agent knowledge transfer** - **building reusable agent skill libraries from experience** --- ## 🧪 Benchmarks Used ### AppWorld A realistic ecosystem of apps and APIs for long-horizon agent execution. ### BFCL-v3 A challenging benchmark for multi-turn function calling and tool use. ### τ2-Bench A user-interactive benchmark focused on conversational tool-using agents. --- ## 📦 Planned Release We will publicly release: - the **SkillX codebase** - the **automatically constructed skill knowledge base** - and supporting resources for skill extraction, refinement, and retrieval --- ## 🙏 Acknowledgement We deeply appreciate the invaluable effort contributed by our dedicated team of developers, supportive users, and esteemed industry partners. - [Ant Digital Technologies, Ant Group](https://intl.antdigital.com/en) ## 📚 Citation If you find this work helpful, please consider citing: ```bibtex @article{wang2026skillx, author = {Chenxi Wang and Zhuoyun Yu and Xin Xie and Wuguannan Yao and Runnan Fang and Shuofei Qiao and Kexin Cao and Guozhou Zheng and Xiang Qi and Peng Zhang and Shumin Deng}, title = {SkillX: Automatically Constructing Skill Knowledge Bases for Agents}, year = {2026}, eprint = {2604.04804}, archivePrefix = {arXiv}, primaryClass = {cs.CL}, url = {https://arxiv.org/abs/2604.04804} } ``` --- ## 🙏 Acknowledgement This repository builds upon code from ReMe and AgentEvolver. The baseline implementations are adapted from AMEM, AWM, and Expel. We sincerely thank all contributors for their outstanding work!

ML Frameworks Knowledge Bases & RAG
218 Github Stars