Home

Awesome

summarizers

PyPI version GitHub

Installation

pip install summarizers
<br>

Usage

1. Create Summarizers

>>> from summarizers import Summarizers
>>> summ = Summarizers()
>>> from summarizers import Summarizers
>>> summ = Summarizers('normal')  # <-- default.
>>> summ = Summarizers('paper')
>>> summ = Summarizers('patent')
>>> from summarizers import Summarizers
>>> summ = Summarizers('normal', device='cuda')
<br>

2. Basic Summarization

>>> contents = """
Tunip is the Octonauts' head cook and gardener. 
He is a Vegimal, a half-animal, half-vegetable creature capable of breathing on land as well as underwater. 
Tunip is very childish and innocent, always wanting to help the Octonauts in any way he can. 
He is the smallest main character in the Octonauts crew.
"""
>>> summ(contents)
'Tunip is a Vegimal, a half-animal, half-vegetable creature'
<br>

3. Query focused Summarization

>>> summ(contents, query="main character of Octonauts")
'Tunip is the smallest main character in the Octonauts crew.'
<br>

3. Abstractive QA (Auto Question Detection)

>>> summ(contents, query="What is Vegimal?")
'Half-animal, half-vegetable'
>>> summ(contents, query="SOME_QUERY", question_detection=False)
<br>

4. Prompt based Summarization

>>> summ(contents, prompt="Q:Who is Tunip? A:")
"Q:Who is Tunip? A: Tunip is the Octonauts' head"
<br>

5. Query focused Summarization with Prompt

>>> summ(contents, query="personality of Tunip", prompt="Tunip is very")
"Tunip is very childish and innocent, always wanting to help the Octonauts."
<br>

6. Options for Decoding Strategy

>>> summ(
...     contents=contents,
...     num_beams=10,
...     top_k=30,
...     top_p=0.85,
...     no_repeat_ngram_size=3,      
...     length_penalty=1.2,
... )

<br>

License

Copyright 2021 Hyunwoong Ko.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.