Code Monkey home page Code Monkey logo

Comments (1)

ratsgo avatar ratsgo commented on July 19, 2024

안녕하세요 @kimtaehyuk1 님, 답이 너무 늦었습니다.
다음과 같이 수행하면 배치 인퍼런스를 수행할 수 있습니다.

from transformers import GPT2LMHeadModel
model = GPT2LMHeadModel.from_pretrained(
    "skt/kogpt2-base-v2",
)
model.eval()

from transformers import PreTrainedTokenizerFast
tokenizer = PreTrainedTokenizerFast.from_pretrained(
    "skt/kogpt2-base-v2",
    eos_token="</s>",
)

inputs = tokenizer(["안녕하세요", "반갑습니다"], return_tensors="pt") # 이 부분에 배치로 인퍼런스할 문장을 리스트로 입력
generated_ids = model.generate(
        inputs['input_ids'],
        do_sample=True,
        min_length=10,
        max_length=50,
        repetition_penalty=1.5,
        no_repeat_ngram_size=3,
        temperature=0.9,
        top_k=50,
        top_p=0.92,
)

for instance in generated_ids:
  print(tokenizer.decode([el.item() for el in instance]) + "\n\n")

위의 수행 결과 예시는 다음과 같습니다.

안녕하세요"라고 말한 뒤 "제가 뭘 할 수 있겠나. 그건 제가 판단할 일이고 우리가 잘 안다"고 말했다.
그러자 박지원 민주당 원내대표는 지난 13일 자신의 페이스북에 올린 글에서 "이런 식으로 가면 이 나라의 미래가


반갑습니다 ᄏ
#오늘의하루<unk></d> 어제 점심 먹으러 나가서
맛있고 다양한 스시 먹을 수 있는 맛집을 찾았어요!
점심은 주로 근처와 가까운 곳에서 먹는것을 추천해용...


from nlpbook.

Related Issues (20)

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.