Giter Club home page Giter Club logo

clusterllm's Introduction

CLUSTERLLM: Large Language Models as a Guide for Text Clustering

This is the official PyTorch implementation of paper CLUSTERLLM: Large Language Models as a Guide for Text Clustering (EMNLP2023).

Install

pip install -r requirements.txt

Datasets

Download zip file here and unzip.

Steps to run perspective experiments

1. Original embeddings

cd perspective/2_finetune
bash scripts/get_embedding.sh

The embeddings are produced in each folder of datasets. It will also save the clustering measures. Details instructions see bash script. E5 embeddings are produced with scripts/get_embedding_e5.sh.

2. Sample triplets

cd perspective/1_predict_triplet
bash scripts/triplet_sampling.sh

Sampled triplets will be produced in perspective/1_predict_triplet/sampled_triplet_results. Details instructions see bash script.

3. Predict triplets

First replace the openai keys in perspective/1_predict_triplet/scripts/predict_triplet.sh.

cd perspective/1_predict_triplet
bash scripts/predict_triplet.sh

Predicted triplets will be in perspective/1_predict_triplet/predicted_triplet_results. Details instructions see bash script.

4. Convert triplets

This step only converts the format.

cd perspective/2_finetune
bash scripts/convert_triplet.sh
bash scripts/convert_triplet_self.sh

Converted triplets will be in perspective/2_finetune/converted_triplet_results. Details instructions see bash script.

5. Finetune

cd perspective/2_finetune
bash scripts/finetune.sh

Finetuned model will be in perspective/2_finetune/checkpoints. Details instructions see bash script.

6. Finetune

cd perspective/2_finetune
bash scripts/get_embedding.sh

This time, switch to checkpoints. Clustering measures will be saved into checkpoint folder.

Steps to run granularity experiments

1. Sample pairs

cd granularity
bash scripts/sample_pairs.sh

Sampled pairs will be saved in sampled_pair_results.

[optional] Sample pairs for prompt

4 pairs will be sampled as in-context examples.

cd granularity
bash scripts/sample_pairs_for_prompt.sh

2. Predict pairs

First replace the openai keys in granularity/scripts/predict_pairs.sh.

cd granularity
bash scripts/predict_pairs.sh

Predicted pairs will be in granularity/predicted_pair_results. Also specify prompt_file to sampled the prompt.

3. Predict cluster num

cd granularity
bash scripts/predict_num_clusters.sh

Details instructions see bash script.

OUR MODIFICATION

I have reduced the run for the whole pipeline into 2 bash scrips.

First, run create_output_folders.sh once to create a list of emptied folder to store ouput of each step in the pipeline:

bash create_output_folders.sh

Then run the pipeline,

bash run_file.sh -i 3 -e 4

For the first run, please run the pipeline with a small number of epoch and iteration to test the pipline. The default iteration (-i) is 6 and epoch (-e) is 30.

IMPORTANT

Please run these 2 files in ClusterLLM or else the path's references in the bash files gonna be incorrect. For example:

cd ClusterLLM
bash run_file.sh

Citation

@misc{zhang2023clusterllm,
      title={ClusterLLM: Large Language Models as a Guide for Text Clustering}, 
      author={Yuwei Zhang and Zihan Wang and Jingbo Shang},
      year={2023},
      eprint={2305.14871},
      archivePrefix={arXiv},
      primaryClass={cs.CL}
}

Thanks

Some of the code was adapted from:

Contact

Yuwei Zhang [email protected]

clusterllm's People

Contributors

minimum2106 avatar quanhephia avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.