OpenAI GPT-3 API: How to extend length of the TL;DR output?
Asked Answered
C

1

6

I'd like to produce a 3-6 sentence summary from a 2-3 page article, using OpenAI's TLDR. I've pasted the article text but the output seems to stay between 1 and 2 sentences only.

Clownery answered 7/9, 2022 at 1:53 Comment(0)
L
1

Options to get a 3-sentence summary for a given prompt

There are multiple options how you can tell the OpenAI API you want a 3-sentence summary:

  • Option 1: Write TL;DR in 3 sentences (7 tokens)
  • Option 2: TL;DR 3 sentences (5 tokens)
  • Option 3: Write summary in 3 sentences (5 tokens)
  • Option 4: Summary 3 sentences (3 tokens)

Note: I used the Tokenizer to calculate the number of tokens.

All of the above will return a 3-sentence summary.

Choose Option 4

Why? Because you pay for every token you use. Therefore, Option 4 will cost the least.

What's more? If you write TL;DR you'll burn 3 tokens which is the same as if you write Summary 3 sentences. In other words, it costs you the same, but you get a 3-sentence summary if you write Summary 3 sentences.

Also, don't forget to set the max_tokens parameter high enough so the OpenAI API can return 3 sentences.

An example

Let's take an example from the official OpenAI website.

Prompt:

A neutron star is the collapsed core of a massive supergiant star, which 
had a total mass of between 10 and 25 solar masses, possibly more if the 
star was especially metal-rich.[1] Neutron stars are the smallest and 
densest stellar objects, excluding black holes and hypothetical white 
holes, quark stars, and strange stars.[2] Neutron stars have a radius on 
the order of 10 kilometres (6.2 mi) and a mass of about 1.4 solar masses. 
[3] They result from the supernova explosion of a massive star, combined 
with gravitational collapse, that compresses the core past white dwarf star 
density to that of atomic nuclei.
    
Summary 3 sentences

Completion:

Neutron stars are the smallest and densest stellar objects, with a radius of about 10 kilometres and a mass of 1.4 solar masses. They are formed from the supernova explosion of a massive star, which had a total mass between 10-25 solar masses, combined with gravitational collapse to compress the core beyond white dwarf density. As such, neutron stars represent the collapsed cores of massive supergiant stars.

Literary answered 5/1, 2023 at 11:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.