from transformers import pipeline

generator = pipeline(
    'text-generation',
    model="heegyu/ajoublue-gpt2-medium-summarization"
)

generation_args = dict(
    no_repeat_ngram_size=4,
    # eos_token_id=generator.tokenizer.eos_token_id
    max_length=1024,
    do_sample=False,
    num_beams=4,
    early_stopping=True
)

def summarize(doc):
    print(doc)
    prompt = f"๋‚ด์šฉ: {doc}\n์š”์•ฝ: "
    output = generator(prompt, **generation_args)[0]['generated_text']
    output = output[len(prompt):]
    print(output)

doc = """์–ธ๋‹ˆ. ํ โ€•.โ€ ๊ทธ์˜ ์ž…์—์„œ๋Š” ์—ฌ๋Ÿฌ ํ•ด ์ „์— ๋ถ€๋ฆฌ๋˜ ์–ด๋ฆฌ๊ด‘์˜ ์†Œ๋ฆฌ๊นŒ์ง€ ๋‚˜์™”๋‹ค. ํ˜•์€ ๋™์ƒ์„ ๋ณด์•˜๋‹ค. ํ˜•์˜ ๋ˆˆ์—๋„ ์›ƒ์Œ์ด ์žˆ์—ˆ๋‹ค. โ€œ์‚ด๋ฆผํ•˜๊ธฐ๊ฐ€ ๊ณคํ•˜์ง€?โ€ โ€œ๊ณคํ•˜๊ธฐ์•ผ.โ€ โ€œ๊ณคํ•˜๋Š๋‹ˆ๋ผ. ๋ชธ์ด ๊ณคํ•˜๋‹ค๋Š” ๊ฒƒ๋ณด๋‹ค ๋งˆ์Œ์ด ๊ณคํ•˜๋Š๋‹ˆ๋ผ. ๋งˆ์Œ์„ ๊ผญ ๊ฒฐ๋ฐ• ํ•œ ๊ฒƒ๊ฐ™์ด.โ€ ํ˜„์ˆ™์ด๋Š” ๊ทธ ๋ง์„ ์ˆ˜๊ณ ํ•˜์˜€๋‹ค. ๋™์‹œ์— ์•„์ง๊ป ๊ทธ๋‹ค์ง€ ๋Š๊ปด ๋ณธ ์ ์ด ์—†๋˜ โ€˜์‚ด๋ฆผ์‚ด์ดโ€™ ์— ๋Œ€ํ•œ ์ž๊ธฐ์˜ ๊ฒƒ์ด ๋œป๋ฐ–์— ์–ด๋ ต๊ณ  ์ปธ์—ˆ๋˜ ๊ฒƒ์„ ๊นจ๋‹ฌ์•˜๋‹ค. ๋ฐ” ๋Š˜๋ฐฉ์„ โ€• ๊ด€๋Œ€ํ•œ ๋‚จํŽธ๊ณผ ๊ฐ„๋‹จํ•œ ์‚ด๋ฆผ๊ณผ ๊ฐ€์ •์— ๋Œ€ํ•œ ์ „๊ถŒ์„ ์žก๊ณ  ์žˆ๋˜ ํ˜„ ์ˆ™์ด๊ฐ€ ์ด๋ก ์ƒ์œผ๋กœ ๋ณด์ž๋ฉด ๋‹น์—ฐํžˆ ์•ˆ ๋Š๋‚„ ๋ฐ”์˜ โ€˜์กฐ์‹ฌโ€™์ด ๋œป๋ฐ–์— ์ปธ๋˜ ๊ฒƒ ์„ ํ˜„์ˆ™์ด๋Š” ์ฒ˜์Œ์œผ๋กœ ์•Œ์•˜๋‹ค. ๊ทธ๊ฒƒ์€ ๋ฐ”๋Š˜๋ฐฉ์„์— ์•‰๋Š” ๊ฒƒ๊ณผ ๊ฐ™์€ ์ข…๋ฅ˜์˜ โ€˜์กฐ์‹ฌโ€™ ์ด์—ˆ์—ˆ๋‹ค. ๋งˆ์Œ์˜ ๋ฌด์žฅ(ๆญฆ่ฃ)์„ ์ž ์‹œ๋„ ๋Œ๋Ÿฌ ๋†“์„ ์ƒˆ๊ฐ€ ์—†์„ ์ด๋งŒ์น˜ ์กฐ๋งˆ์กฐ๋งˆํ•˜๊ณ  ์กฐ์‹ฌ์„ฑ์Šค๋Ÿฝ๋˜ ์‚ด๋ฆผ์ด์—ˆ์—ˆ๋‹ค. ํ•˜๋ฃจ์˜ ์Šค๋ฌผ๋„ค ์‹œ๊ฐ„์„ ๋Š˜ ๋งˆ์Œ์˜ ๋ฌด์žฅ์„ ๋‹จ๋‹จํžˆ ํ•˜๊ณ  ๊ทธ ๋ฌด์žฅ์„ ์ž ์‹œ๋„ ํ’€์–ด ๋ณธ ์ ์ด ์—†์—ˆ๋‹ค. โ€˜ํ›Œ๋ฅญํ•œ ์‚ฌ ๋žŒโ€™ ์ด๋ผ๋Š” ๋น„ํ‰์— ๋Œ€ํ•˜์—ฌ๋Š” ๋์—†๋Š” ์• ์ฐฉ์„ ๊ฐ€์ง€๊ณ  ์žˆ๋Š” ํ˜„์ˆ™์ด๋Š” ์ž๊ธฐ์˜ ์˜จ๊ฐ– ์ง€ํ˜œ๋ฅผ ๋‹คํ•˜์—ฌ ์ด ์ด๋ฆ„์—์„œ ๋ฒ—์–ด๋‚˜์ง€ ์•Š์œผ๋ ค ํ•˜์˜€๋‹ค. ๊ทธ๊ฒƒ์€ ๊ทน๋„๋กœ ๊ธด์žฅ๋œ ๋งˆ์Œ์ด์—ˆ์—ˆ๋‹ค. ๊ทธ๋ฆฌ๊ณ  ๊ทธ๋Š” ์˜คํžˆ๋ ค ์ด ๊ธด์žฅ์—์„œ ์ฆ๊ฑฐ์›€๊ณผ ์œ ์พŒํ•จ์„ ๋ฐœ๊ฒฌํ•˜๋Š” ๊ฒƒ์ด์—ˆ์—ˆ๋‹ค. ์˜ค๋Š˜ ๊ฐ‘์ž๊ธฐ ํ˜•์—๊ฒŒ์„œ โ€˜๋งˆ์Œ์ด ๊ณคํ•˜๊ฒ ๋‹คโ€™๋Š” ์œ„๋กœ๋ฅผ ๋ฐ›์„ ์ ์— ํ˜„์ˆ™์ด๋Š” ์•„์ง๊ป ๋Š๊ปด ๋ณด์ง€ ์•Š์•˜๋˜ ๊ทธ โ€˜๊ณคํ•จโ€™์ด ๋œป๋ฐ–์— ์ปธ๋˜ ๋ฐ ์˜คํžˆ๋ ค ๋œป๋ฐ–์ด๋ผ๋Š” ์ƒ๊ฐ๊นŒ์ง€ ๋‚œ ๊ฒƒ์ด์—ˆ์—ˆ๋‹ค. ์ธ์ˆ™์ด๋Š” ์›ƒ์Œ์ด ์„ž์ธ ํ•œ์ˆจ์„ ์‰ฌ์—ˆ๋‹ค."""
# ์ •๋‹ต: "ํ˜„์ˆ™์ด๋Š” ํ˜•์—๊ฒŒ ์œ„๋กœ๋ฅผ ๋ฐ›์„ ์ ์— ์‚ด๋ฆผ์‚ด์ด์— ๋Œ€ํ•œ ์–ด๋ ค์›€์„ ๊นจ๋‹ฌ์•˜๊ณ  ๊ณคํ•จ์ด๋ผ๋Š” ๋œป๋ฐ–์˜ ์ƒ๊ฐ๊นŒ์ง€ ๋‚˜์„œ ์›ƒ์Œ์ด ์„ž์ธ ํ•œ์ˆจ์„ ์‰ฌ์—ˆ๋‹ค."
# ์˜ˆ์ธก: ํ˜„์ˆ™์ด๋Š” ์กฐ์‹ฌ์„ฑ์ด ๋œป๋ฐ–์— ์ปธ๋‹ค๋Š” ๊ฒƒ์„ ์ฒ˜์Œ์œผ๋กœ ์•Œ์•˜๋‹ค.
summarize(doc)

doc = "๋ฏธ๊ตญ๊ณผ ์ค‘๊ตญ์˜ ๊ฐˆ๋“ฑ์ด ๊ณณ๊ณณ์—์„œ ๋ถˆ๊ฑฐ์ง€๊ณ  ์žˆ๋‹ค.\n  ๋‚จ์ค‘๊ตญํ•ด์—์„  ๋ฌด๋ ฅ ์ถฉ๋Œ๋งˆ์ € ๋ฒŒ์–ด์งˆ ๊ธฐ์„ธ๋‹ค.\n  ์ด๋Ÿฐ ๊ฐˆ๋“ฑ์„ ํ‹ˆํƒ€ '๋„ฅ์ŠคํŠธ ์ฐจ์ด๋‚˜'๋ฅผ ๊ฟˆ๊พธ๋Š” ๋‚˜๋ผ๋“ค์˜ ์›€์ง์ž„๋„ ๋นจ๋ผ์ง€๊ณ  ์žˆ๋‹ค.\n    ๊ฐ€์žฅ ๋ˆˆ์— ๋„๋Š” ๊ณณ์€ ๋ฒ ํŠธ๋‚จ์ด๋‹ค.\n   ๋ช‡ ๋…„ ์ „๋ถ€ํ„ฐ '๋„ฅ์ŠคํŠธ ์ฐจ์ด๋‚˜'๋กœ ๋ถ€์ƒํ•ด ์˜จ ๋ฒ ํŠธ๋‚จ์€ ๋ฏธ์ค‘ ๋ฌด์—ญ์ „์Ÿ์˜ ์ตœ๋Œ€ ์ˆ˜ํ˜œ๊ตญ ์ค‘ ํ•˜๋‚˜๋กœ ๊ผฝํžˆ๋Š” ๊ณณ์ด๋‹ค.\n  ์• ํ”Œ์ด ๋ฒ ํŠธ๋‚จ์œผ๋กœ ์ƒ์‚ฐ๊ณต์žฅ์„ ์˜ฎ๊ธฐ๊ณ  ์žˆ๊ณ  LG์ „์ž, ํ€„์ปด ๋“ฑ ๋‹ค๋ฅธ ๊ธ€๋กœ๋ฒŒ ๊ธฐ์—…๋“ค๋„ ๊ฐ€์„ธํ•˜๊ณ  ์žˆ๋‹ค.\n    ๋ฌด์—‡๋ณด๋‹ค ํ™œ๊ธฐ๋ฅผ ๋งž์€ ๊ฑด ์˜๋ฅ˜์‚ฐ์—…์ด๋‹ค.\n  ์‚ฌ์šฐ์Šค์ฐจ์ด๋‚˜๋ชจ๋‹ํฌ์ŠคํŠธ(SCMP)๋Š” ์ตœ๊ทผ ๋ณด๋„์—์„œ \"๋ช‡ ๊ฐœ์›” ์ „๊นŒ์ง€๋งŒ ํ•ด๋„ ๋ฏธ๊ตญ์— ์˜๋ฅ˜ ์ œํ’ˆ์„ ๊ฐ€์žฅ ๋งŽ์ด ์ˆ˜์ถœํ•˜๋Š” ๋‚˜๋ผ๋Š” ์ค‘๊ตญ์ด์—ˆ์ง€๋งŒ, ๋ฒ ํŠธ๋‚จ์ด ๋น ๋ฅด๊ฒŒ ์น˜๊ณ  ์˜ฌ๋ผ์˜ค๊ณ  ์žˆ๋‹ค\"๊ณ  ์„ค๋ช…ํ–ˆ๋‹ค.\n  ์ค‘๊ตญ ์ œํ’ˆ์ด ์—ฌ์ „ํžˆ ์ œ์ผ ์ž˜ ํŒ”๋ฆฌ๊ณ ๋Š” ์žˆ์ง€๋งŒ \"์‚ด์•„๋‚จ๊ธฐ ์œ„ํ•œ ๋ชธ๋ถ€๋ฆผ\"์œผ๋กœ ๊ฐ€๊ฒฉ์„ ํฌ๊ฒŒ ๋‚ฎ์ถ˜ ํƒ“์ด๋ž€ ๋ถ„์„์ด๋‹ค.\n    ๋ฒ ํŠธ๋‚จ์˜ ๊ฒฝ์Ÿ๋ ฅ์€ ์ ์  ๋” ์ปค์งˆ ๊ฒƒ์œผ๋กœ ๋ณด์ธ๋‹ค.\n  ์œ ๋Ÿฝ์—ฐํ•ฉ(EU)๊ณผ ์ž์œ ๋ฌด์—ญํ˜‘์ •(8์›” ๋ฐœํšจ)์„ ๋งบ์€ ๋ฐ๋‹ค, ์™ธ๊ตญ์ธ ์ง์ ‘ ํˆฌ์ž๋„ ๊ธ‰์†ํžˆ ๋Š˜๊ณ  ์žˆ์–ด์„œ๋‹ค.\n    ์ด ๋‚˜๋ผ์˜ ์ตœ๋Œ€ ๊ฐ•์ ์€ ์ Š์€ ์ธ๊ตฌ๊ฐ€ ๋งŽ๊ณ  ๋ฏธ๊ตญ๊ณผ ์šฐํ˜ธ์ ์ธ ๊ด€๊ณ„๋ฅผ ๋งบ๊ณ  ์žˆ๋‹จ ์ ์ด๋‹ค.\n  ์ •์น˜์ ์œผ๋กœ๋„ ๋น„๊ต์  ์•ˆ์ •๋ผ ์žˆ๋‹ค.\n  ๋ฏธ์ค‘ ๊ฐˆ๋“ฑ์ด ๋ณธ๊ฒฉํ™”ํ•œ ์ง€๋‚œํ•ด๋ถ€ํ„ฐ \"๋ฒ ํŠธ๋‚จ์ด ํ™ฉ๊ธˆ๊ธฐ๋ฅผ ๋งž๊ณ  ์žˆ๋‹ค\"(์›Œ์‹ฑํ„ดํฌ์ŠคํŠธ)๋Š” ๋ถ„์„์ด ๋‚˜์˜จ ์ด์œ ๋‹ค.\n     ๋˜ ๋‹ค๋ฅธ ์•„์‹œ์•„ ๊ตญ๊ฐ€ ์ธ๋„๋„ ์ด ๊ธฐํšŒ๋ฅผ ๋†“์น˜์ง€ ์•Š์œผ๋ ค ํ•œ๋‹ค.\n    ๊ตญ๊ฒฝ ๋ฌธ์ œ๋กœ ์ค‘๊ตญ๊ณผ ๊ฐˆ๋“ฑ์„ ๋นš๊ณ  ์žˆ๋Š” ์ธ๋„๋Š” ๊ฑฐ๋Œ€ํ•œ ์ž๊ตญ ์‹œ์žฅ์„ ๋ฌด๊ธฐ๋กœ ์ค‘๊ตญ ๊ธฐ์—…๋“ค์„ ์••๋ฐ•ํ•˜๋Š” ํ•œํŽธ, ์ด์ฐธ์— '๋„ฅ์ŠคํŠธ ์ฐจ์ด๋‚˜' ์ž๋ฆฌ๋„ ๊ฟฐ์ฐจ๊ฒ ๋‹จ ์•ผ์‹ฌ์„ ๋‚ด๋ณด์ด๊ณ  ์žˆ๋‹ค.\n    ์ตœ๊ทผ ํ•œ๊ตญ์€ํ–‰์€ ๋ณด๊ณ ์„œ๋ฅผ ๋‚ด๊ณ  \"๋ฏธ๊ตญ๊ณผ์˜ ๊ณต์กฐ๊ฐ€ ๊ฐ•ํ™”ํ• ์ˆ˜๋ก ์ธ๋„์˜ ๊ธ€๋กœ๋ฒŒ ์ƒ์‚ฐ๊ธฐ์ง€ ์—ญํ• ์€ ๋”์šฑ ์ปค์งˆ ๊ฒƒ\"์ด๋ผ๊ณ  ๋ถ„์„ํ–ˆ๋‹ค.\n  ์ค‘๊ตญ๋ณด๋‹ค ๋‚ฎ์€ ์ธ๊ฑด๋น„ ๋“ฑ์„ ๋‚ด์„ธ์›Œ '์„ธ๊ณ„์˜ ๊ณต์žฅ'์„ ๋…ธ๋ฆฌ๊ณ  ์žˆ๋‹จ ์–˜๊ธฐ๋‹ค.\n    ๊ฐ€์žฅ ์ด๋ชฉ์„ ๋„๋Š” ๊ฑด ๊ธ€๋กœ๋ฒŒ IT ๊ธฐ์—…๋“ค๊ณผ์˜ ํ˜‘๋ ฅ์ด๋‹ค.\n  ์ตœ๊ทผ ๊ตฌ๊ธ€์ด ์ธ๋„์— 100์–ต ๋‹ฌ๋Ÿฌ(์•ฝ 12์กฐ ์›) ํˆฌ์ž ๊ณ„ํš์„ ๋ฐํ˜”๊ณ , ์•„๋งˆ์กด๊ณผ ํ€„์ปด, ํŽ˜์ด์Šค๋ถ๋„ ์ธ๋„์— ํˆฌ์ž๋ฅผ ์ง„ํ–‰ํ•˜๊ณ  ์žˆ๋‹ค.\n     ์ค‘๊ตญ๊ณผ ๊ฐ€๊นŒ์šด ์•„์‹œ์•„ ๊ตญ๊ฐ€๋“ค๋งŒ ์ด๋Ÿฐ ๊ฒƒ์ด ์•„๋‹ˆ๋‹ค.\n    ๋ฏธ๊ตญ๊ณผ ์ด์›ƒํ•œ ์ค‘๋ฏธ ๊ตญ๊ฐ€ ๋ฉ•์‹œ์ฝ”๋Š” ๋ฏธ์ค‘ ๋ฌด์—ญ์ „์Ÿ์ด ์‹œ์ž‘๋  ๋•Œ๋ถ€ํ„ฐ '๋„ฅ์ŠคํŠธ ์ฐจ์ด๋‚˜'๋ฅผ ๋…ธ๋ ค์˜จ ๊ตญ๊ฐ€๋‹ค.\n    ์ตœ๊ทผ ๋กœ์ดํ„ฐํ†ต์‹ ์€ \"์•„์ดํฐ ๋“ฑ์„ ์œ„ํƒ ์ƒ์‚ฐํ•˜๋Š” ๋Œ€๋งŒ ํญ์Šค์ฝ˜๊ณผ ํŽ˜๊ฐ€ํŠธ๋ก ์ด ๋ฉ•์‹œ์ฝ”์— ๊ณต์žฅ์„ ์ง“๋Š” ์ผ์„ ๊ฒ€ํ† ํ•˜๊ณ  ์žˆ๋‹ค\"๊ณ  ๋‹จ๋… ๋ณด๋„ํ–ˆ๋‹ค.\n  ํญ์Šค์ฝ˜์€ ์ค‘๊ตญ ์ฒญ๋‘, ์„ ์ „ ๋“ฑ์— ๊ณต์žฅ์„ ๋‘๊ณ  130๋งŒ ๋ช…์„ ๊ณ ์šฉํ•˜๊ณ  ์žˆ๋Š” ์—…์ฒด๋‹ค."
# ์ •๋‹ต: "๋ฒ ํŠธ๋‚จ์ด ์• ํ”Œ ๋ฐ ๊ธ€๋กœ๋ฒŒ ๊ธฐ์—…์˜ ์ƒ์‚ฐ๊ณต์žฅ ์ด์ „์„ ๊ธฐ์ ์œผ๋กœ ๋ฏธ์ค‘ ๋ฌด์—ญ์ „์Ÿ์˜ ํ‹ˆ์ƒˆ์—์„œ ๋„ฅ์ŠคํŠธ ์ฐจ์ด๋‚˜๋ฅผ ๊ฟˆ๊พธ๋ฉฐ ๊ฒฝ์Ÿ๋ ฅ์„ ํ‚ค์šฐ๊ณ  ์žˆ๋‹ค."
# ์˜ˆ์ธก: ๋‚จ์ค‘๊ตญํ•ด์—์„œ ๋ฌด๋ ฅ ์ถฉ๋Œ์ด ๋ฒŒ์–ด์งˆ ๊ธฐ์„ธ์ธ ๋ฏธ๊ตญ๊ณผ ์ค‘๊ตญ์˜ ๊ฐˆ๋“ฑ์„ ํ‹ˆํƒ€ ๋ฒ ํŠธ๋‚จ์ด ๋„ฅ์ŠคํŠธ ์ฐจ์ด๋‚˜๋ฅผ ๊ฟˆ๊พธ๊ณ  ์žˆ๋‹ค.
summarize(doc)
Downloads last month
17
Inference Examples
This model does not have enough activity to be deployed to Inference API (serverless) yet. Increase its social visibility and check back later, or deploy to Inference Endpoints (dedicated) instead.

Space using heegyu/ajoublue-gpt2-medium-summarization 1

Collection including heegyu/ajoublue-gpt2-medium-summarization