Git Product home page Git Product logo

llm-text-summarization's Introduction

LLM-based Text Summarization: Novice to Maestro πŸš€

A comprehensive guide and codebase for text summarization harnessing the capabilities of Large Language Models (LLMs). Delve deep into techniques, from chunking to clustering, and maximize the potential of LLMs like GPT-3.5 and GPT-4.

πŸ“„ Article: I highly recommend reading this article before diving into the code.

Architecture

Full_Architecture

πŸš€ Getting Started

  1. Clone the Repository
  2. Install Dependencies:
    python3 -m pip install -r requirements.txt
  3. Install Spacy's English Dataset:
    python3 -m spacy download en_core_web_sm
  4. Set Up OpenAI API Key:
    export OPENAI_API_KEY='sk-...'
  5. Configure IO: Navigate to src/config.yaml and update the input_file and output_file parameters under io_config.
  6. File Handling: For the input file, only .txt is accepted. For the output, .json is preferred. Place the input file in the input folder. The generated summary will be in the output folder.
  7. Run the Program:
    cd src/
    python3 main.py

πŸ›  Understanding the config.yaml File

  • summary_type_token_limit: Determines how to categorize the input text: short, medium, or long.
  • sentence_splitter: Adjust approx_total_doc_tokens. Keep it around 1000 for medium-sized texts and up to 6000 for longer texts.
  • cod: Configuration for Chain of Density (CoD) prompting.
  • map_reduce: To further condense the final summary with CoD, set final_dense to true.
  • cluster_summarization: Adjust num_closest_points_per_cluster (max value: 3) for the top-k best chunks. Vary num_clusters (hyper-parameter for k-means) to optimize results.
  • Remaining configs are self-explanatory.

πŸ“‹ Output JSON Format

The output JSON comprises:

{
    "summary": "Descriptive final summary...",
    "keywords": ["Keyword1", "Keyword2", "..."],
    "metadata": {
        "total_tokens": 3625,
        "total_cost": 0.082,
        "total_time": 86.23
    }
}
  • summary: The final summary output
  • keywords: important keywords and phrases
  • metadata: Provides total time (in seconds) taken to execute your summary, total cost (in USD) for openai, and total token counts in the whole process

❀️ If this repository helps, please star ⭐, and share βœ”οΈ!
If you also found the article informative and think it could be beneficial to others, I'd be grateful if you could like πŸ‘, follow πŸ‘‰, and shareβœ”οΈ the piece with others.
Happy coding!

llm-text-summarization's People

Contributors

ritun16 avatar

Stargazers

Manuel Morales avatar Peter Knobloch avatar  avatar  avatar  avatar Kleo_Karap avatar Titusz avatar Fabio "Draco" Fonseca avatar  avatar Ramsey avatar Thi2bo avatar Eric G. Suchanek, Ph.D. avatar Chaitanya Bagul avatar Himanshu Chaturvedi avatar Victor Wang avatar  avatar Miary Andria avatar Aashutosh Karale avatar Richy Chen avatar Rushabh Patel avatar  avatar Tyger_the_mbert avatar meditator avatar Jeff Carpenter avatar  avatar 62316e avatar Shuqian Ye avatar Jagger avatar Cioclea Doru Octavian avatar Denys avatar Yazin avatar  avatar song avatar  avatar

Watchers

 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.