TaoZhen1110 / CAT-LLM

20 stars 6 forks source link

CAT-LLM: Style-enhanced Large Language Models with TextStyle Definition for Chinese Article-style Transfer

CAT_LLM_Framework

Introduction

The CAT-LLM framework addresses the challenge of text style transfer in Chinese long texts, a field that has seen limited research compared to English sentence-level style transfer. Leveraging the capabilities of Large Language Models (LLMs), CAT-LLM integrates a bespoke Text Style Definition (TSD) module. This module comprehensively analyzes text features at both the word and sentence levels, ensuring the LLMs can accurately transfer the style of Chinese articles without compromising content integrity. Experimental results demonstrate CAT-LLM's superior performance in transfer accuracy and content preservation, showcasing its broad applicability across various LLMs. The framework introduces a novel evaluation paradigm by creating parallel datasets from five distinct Chinese articles, enhancing the accuracy of performance evaluation.

Installation

Before using CAT-LLM:

  1. Ensure you have Python 3.8.0+
  2. Install the required packages:

    pip install -r requirements.txt

How to Run the Project

  1. Run Style Definition Script: Execute the All style Definition.py script to initialize and configure the text style definitions required for the model. This script sets up the necessary parameters for style transfer.

    python All_style_Definition.py
  2. Run the Main Program: After setting up the style definitions, you need to execute various Python scripts located in the Models folder. For example, to run the CAT+gpt3.5.py script located in the Models/GPT-3.5 folder, use the following command:

    python Models/GPT-3.5/CAT+gpt3.5.py
  3. Calculate Content Preservation: After computing the transfer accuracy, you need to calculate the content preservation by executing the Content_preserve.py script:

    python Content_preserve.py

Project Structure

The project is organized into several key directories and modules. Here's an overview of the project structure:

CAT-LLM/
├── Models/                                      # Style generation model based on various LLMs.
│ ├── Baichuan/
│ ├── ChatGLM/
│ └── GPT3.5/
├── TST_sentence                                 # Store TST_sentence classification models.
├── data                                         # Store six books.
│ ├── 1/                                         # Fortress Besieged
│ ├── 2/                                         # The Scream
│ ├── 3/                                         # The Fifteen Year of the Wanli Era
│ ├── 4/                                         # Four Generations Under One Roof
│ ├── 5/                                         # The Family Instruction of Zeng Guofan
│ └── 6/                                         # The Three Body Problem
├── generated_text                               # Experiment generated text.
├── human_evaluation                             # Assessment results by human experts.
├── sentence_word_define_dataset                 # Store sentence_word_define_dataset.
├── stylishless_text                             # Stylishless text and LLM prompt.
├── ACC_BLEU_BERT                                # Store BLEU_BERT metrics.
├── All_style_define                             # Store TSD module.
└── Content_preserve                             # Store Content_preserve code.

Citation

@article{tao2024cat,
  title={CAT-LLM: Prompting Large Language Models with Text Style Definition for Chinese Article-style Transfer},
  author={Tao, Zhen and Xi, Dinghao and Li, Zhiyu and Tang, Liumin and Xu, Wei},
  journal={arXiv preprint arXiv:2401.05707},
  year={2024}
}