Giter Site home page Giter Site logo

baoguangsheng / bart-rewriters Goto Github PK

View Code? Open in Web Editor NEW
13.0 2.0 1.0 648 KB

Code base for "A General Contextualized Rewriting Framework for Text Summarization"

License: MIT License

Python 97.31% C++ 0.61% Cuda 1.41% Cython 0.41% Shell 0.26%

bart-rewriters's Introduction

BART Rewriters

This code is for our paper A General Contextualized Rewriting Framework for Text Summarization.

Python Version: Python3.7.10

Package Requirements: torch==1.9.0 tensorboardX numpy==1.21.6

Framework: Our model and experiments are built upon fairseq v0.10.2.

Before running the scripts, please install the dependencies by:

    bash setup.sh

Before evaluating BART-Rewriter, please follow the readme file under folder bert_extractors to download previous BERT extractor models.

(Notes: We train our models on 2 Tesla V100.)

Option 1: play with the trained Models

  1. Download the prepared data and trained models. Unzip the files into folder exp_test.

  2. Evaluate the models:

    # BART-Rewriter (Rewriter with external sentence extractor)
    CUDA_VISIBLE_DEVICES=0 bash exp_rewriter/test-rewriter.sh exp_test rewriter bertext
    
    # BART-JointSR (Rewriter with joint internal sentence selector)
    CUDA_VISIBLE_DEVICES=0 bash exp_rewriter/test-rewriter.sh exp_test jointsr none

Option 2: train the models from scratch

Prepare data:

  1. Preprocess CNN/Dialy Mail.

    Follow the instruction to convert the data into tokenized stories:

    cnn-dailymail/cnn_stories_tokenized/
    cnn-dailymail/dm_stories_tokenized/
  1. Preprocess and binarize for our model:
    # BART-Rewriter (Rewriter with external sentence extractor)
    bash exp_rewriter/prepare-data.sh exp_test large rewriter

    # BART-JointSR (Rewriter with joint internal sentence selector)
    bash exp_rewriter/prepare-data.sh exp_test large jointsr

Train the model:

    # BART-Rewriter (Rewriter with external sentence extractor)
    CUDA_VISIBLE_DEVICES=0,1 bash exp_rewriter/run-bart-large.sh exp_test rewriter

    # BART-JointSR (Rewriter with joint internal sentence selector)
    CUDA_VISIBLE_DEVICES=0,1 bash exp_rewriter/run-bart-large.sh exp_test jointsr

Evaluate the model:

    # BART-Rewriter (Rewriter with external sentence extractor)
    CUDA_VISIBLE_DEVICES=0 bash exp_rewriter/test-rewriter.sh exp_test rewriter bertext
    
    # BART-JointSR (Rewriter with joint internal sentence selector)
    CUDA_VISIBLE_DEVICES=0 bash exp_rewriter/test-rewriter.sh exp_test jointsr none

bart-rewriters's People

Contributors

baoguangsheng avatar

Stargazers

 avatar  avatar Hwq avatar Dawn avatar Lian Junhong avatar jay avatar  avatar  avatar  avatar zeeeyang avatar  avatar Yotam avatar Bing Han avatar

Watchers

 avatar Kostas Georgiou avatar

Forkers

beenasamuel

bart-rewriters's Issues

Missing documentation

Thank you very much this repository is great!
I was able to use your sample data but I'm not sure what should I do next..
Assuming I have a long text file, what are the steps to rewrite it?
Looks like if I will just replace "test.source" content with mine, it won't be the right thing to do.

Please help me understand the steps to convert my text file.

Thanks

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.