KakaoBrain KoGPT (Korean Generative Pre-trained Transformer)

Overview

KoGPT

KakaoBrain Github: kogpt huggingface: KoGPT-6B License: Apache 2.0 License: CC BY-NC-ND 4.0

Model Descriptions

KoGPT6B-ryan1.5b

Hyperparameter Value
6,166,502,400
28
4,096
16,384
16
256
2,048
64,512
Positional Encoding Rotary Position Embedding (RoPE)
RoPE Dimensions 64

Hardware requirements

GPU

The following is the recommended minimum GPU hardware guidance for a handful of example KoGPT.

  • half-precision requires NVIDIA GPUS based on Volta, Turing or Ampere
  • 32GB GPU RAM in the required minimum memory size

Usage

prompt

python -m kogpt --help
usage: KoGPT inference [-h] [--model MODEL] [--revision {KoGPT6B-ryan1.5b}]
                       [--device {cpu,cuda}] [-d]

KakaoBrain Korean(hangul) Generative Pre-Training Model

optional arguments:
  -h, --help            show this help message and exit
  --model MODEL         huggingface repo (default:kakaobrain/kogpt)
  --revision {KoGPT6B-ryan1.5b}
  --device {cpu,cuda}   (default:cuda)
  -d, --debug
python -m kogpt
prompt> 인간처럼 생각하고, 행동하는 '지능'을 통해 인류가 이제까지 풀지 못했던
temperature(0.8)> 
max_length(128)> 64
인간처럼 생각하고, 행동하는 '지능'을 통해 인류가 이제까지 풀지 못했던 문제의 해답을 찾을 수 있을 것이다. 과학기술이 고도로 발달한 21세기를 살아갈 우리 아이들에게 가장 필요한 것은 사고력 훈련이다. 사고력 훈련을 통해, 세상

prompt>  
...

python

import torch
from transformers import AutoTokenizer, AutoModelForCausalLM 

tokenizer = AutoTokenizer.from_pretrained(
  'kakaobrain/kogpt', revision='KoGPT6B-ryan1.5b',
  bos_token='[BOS]', eos_token='[EOS]', unk_token='[UNK]', pad_token='[PAD]', mask_token='[MASK]'
)
model = AutoModelForCausalLM.from_pretrained(
  'kakaobrain/kogpt', revision='KoGPT6B-ryan1.5b',
  pad_token_id=tokenizer.eos_token_id,
  torch_dtype=torch.float16, low_cpu_mem_usage=True
).to(device='cuda', non_blocking=True)
_ = model.eval()

prompt = '인간처럼 생각하고, 행동하는 \'지능\'을 통해 인류가 이제까지 풀지 못했던'
with torch.no_grad():
  tokens = tokenizer.encode(prompt, return_tensors='pt').to(device='cuda', non_blocking=True)
  gen_tokens = model.generate(tokens, do_sample=True, temperature=0.8, max_length=64)
  generated = tokenizer.batch_decode(gen_tokens)[0]
  
print(generated)  # print: 인간처럼 생각하고, 행동하는 '지능'을 통해 인류가 이제까지 풀지 못했던 문제의 해답을 찾을 수 있을 것이다. 과학기술이 고도로 발달한 21세기를 살아갈 우리 아이들에게 가장 필요한 것은 사고력 훈련이다. 사고력 훈련을 통해, 세상

Experiments

In-context Few-Shots

Models #params NSMC (Acc.) YNAT (F1) KLUE-STS (F1)
HyperCLOVA[1] 1.3B 83.9 58.7 60.9
HyperCLOVA[1] 6.9B 83.8 67.5 59.3
HyperCLOVA[1] 13.0B 87.9 67.9 60.0
HyperCLOVA[1] 39.0B 88.0 71.4 61.6
HyperCLOVA[1] 82.0B 88.2 72.7 65.1
Ours 6.0B 87.8 78.0 64.3

Finetuning / P-Tuning

Models #params method NSMC (Acc.) KorSTS(spearman)
SKT-AI/KoGPT-2 2.0[2] 125M finetuning 93.3 78.4
SKT-AI/KoGPT-2 Trinity[3] 1.2B finetuning 93.2 83.4
HyperCLOVA[1] 1.3B p-tuning 91.7 -
HyperCLOVA[1] 39.0B p-tuning 93.0 -
Ours 135M finetuning 95.1 83.0
Ours 6.0B finetuning 95.7 85.3

We conducted this experiments using [4], with same hyperparameters.

Limitations

KakaoBrain KoGPT was trained on rayn dataset, a dataset known to contain profanity, lewd, political changed, and other harsh language. Therefore, KoGPT can generate socially unacceptable texts. As with all language models, It is difficult to predict in advance how KoGPT will response to particular prompts and offensive content without warning.

Primarily Korean: koGPT is primarily trained on Korean texts, and is best for classifying, searching, summarizing or generating such texts. KoGPT by default perform worse on inputs that are different from the data distribution it is trained on, including non-Korean as well as specific dialects of Korean that are not well represented in the training data.

Citation

If you apply this library or model to any project and research, please cite our code:

@misc{kakaobrain2021kogpt,
  title         = {KoGPT: KakaoBrain Korean(hangul) Generative Pre-trained Transformer}
  author        = {Ildoo Kim and Gunsoo Han and Jiyeon Ham and Woonhyuk Baek},
  year          = {2021},
  howpublished  = {\url{https://github.com/kakaobrain/kogpt}},
}

Contact

This is released as an open source in the hope that it will be helpful to many research institutes and startups for research purposes. We look forward to contacting us from various places who wish to cooperate with us.

[email protected]

License

The source code of KakaoBrain KoGPT are licensed under Apache 2.0 License.
The pretrained wieghts of KakaoBrain KoGPT are licensed under CC-BY-NC-ND 4.0 License License.

카카오브레인 KoGPT소스코드(source code)Apache 2.0 라이선스 하에 공개되어 있습니다.
카카오브레인 KoGPT사전학습된 가중치(pretrained weights)CC-BY-NC-ND 4.0 라이선스 라이선스 하에 공개되어 있습니다.
모델 및 코드, 사전학습된 가중치를 사용할 경우 라이선스 내용을 준수해 주십시오. 라이선스 전문은 Apache 2.0, LICENSE.cc-by-nc-nd-4.0 파일에서 확인하실 수 있습니다.

References

[1] HyperCLOVA: Kim, Boseop, et al. "What changes can large-scale language models bring? intensive study on hyperclova: Billions-scale korean generative pretrained transformers." arXiv preprint arXiv:2109.04650 (2021).
[2] SKT-AI/KoGPT-2 2.0: "SKT-AI/KoGPT2: Korean GPT-2 pretrained cased (KoGPT2)." https://github.com/SKT-AI/KoGPT2 (2021).
[3] SKT-AI/KoGPT-2 Trinity: "Ko-GPT-Trinity 1.2B." https://huggingface.co/skt/ko-gpt-trinity-1.2B-v0.5 (2021).
[4] KoGPT2-subtasks: "KoGPT2 v2.0 한국어 평가 모듈" https://github.com/haven-jeon/KoGPT2-subtasks (2021).

Comments
  • 모델의 생성 결과물의 독성(Toxicity)에 관하여

    모델의 생성 결과물의 독성(Toxicity)에 관하여

    안녕하세요, KoGPT 모델의 놀라운 성능을 확인하고, 두 가지 제안을 드리고 싶은 것이 있어 issue 를 열게 되었습니다.

    현재 README.md 에서는 아래와 같이 영문으로 모델의 생성 결과물이 충분히 독성을 띨 수 있음을 명시하고 계신 것으로 보입니다.

    KakaoBrain KoGPT was trained on rayn dataset, a dataset known to contain profanity, lewd, political changed, and other harsh language. Therefore, KoGPT can generate socially unacceptable texts. As with all language models, It is difficult to predict in advance how KoGPT will response to particular prompts and offensive content without warning.
    

    두 가지 제안을 드리고 싶습니다.

    (1) License 에 대해서는 한국어로도 병기해 주신 것처럼, Limitations 에 대해서도 한국어로 병기해 주시면 어떨지 제안드립니다. 여지껏 공개된 모델 중 가장 강력한 성능을 지닌 것으로 보이고, 그만큼 모델 활용 과정에서 마주칠 수 있는 여러 위험한 상황에 대해 한국어 화자들이 좀더 인지할 수 있도록, 한국어로도 명시해 주실 수 있을지요?

    (2) 모델에 대한 if kakao 영상에서 모델 활용 과정에서 발생할 수 있는 여러 가지 윤리적 위험성에 대해 말씀해주시는 지점이 있었습니다. 몇 가지 특수한 prompt로 KoGPT를 사용해 보니 (제 주관적으로 느끼기에) 상당히 높은 수위의 offensive content를 생성해내는 것을 보면서 다소 염려가 됩니다. 전례를 알지 못하여 구체적인 제안을 드리기 좀 어렵지만, [email protected] 이외에, 공개하신 모델의 독성(Toxicity)이 특히 잘 드러나는 prompt들에 관한 정보를 사후적으로라도 수집/연구/정제를 하는 창구를 별도로 열어주시는 것이 가능하실지요?

    enhancement 
    opened by combacsa 4
  • torch_dtype=torch.float16  옵션은 잘 동작하고 있습니까? 모델 전처리를 통하여 메모리 요구량을 낮출 수 있습니다.

    torch_dtype=torch.float16 옵션은 잘 동작하고 있습니까? 모델 전처리를 통하여 메모리 요구량을 낮출 수 있습니다.

    안녕하세요

    우선 모델의 공개에 대하여 진심으로 감사 드립니다. 세부 내용중에 보면 다음과 같은 내용이 있습니다.

    GPU The following is the recommended minimum GPU hardware guidance for a handful of example KoGPT.

    half-precision requires NVIDIA GPUS based on Volta, Turing or Ampere 32GB GPU RAM in the required minimum memory size

    하지만 모델의 파라메터 사이즈와 자료형을 생각할때 물리적인 용량은 대략 12Gb 근처로 생각됩니다. 그리고 실제 공개하여주신 모델 파일의 tensor 타입은 fp32로 저장되어 있는것으로 보입니다.

    실제 gpu의 로딩 시점에 볼때 torch_dtype=torch.float16 구성과 관계없이 fp32로 로딩이 이루어지고 있고 그로인하여 많은 gpu 메모리를 할당합니다.

    아래와 같은 간단한 스크립트를 통하여 모델의 메모리 요구량을 절반 수준으로 줄일 수 있습니다. 제가 언급한 이슈가 연산에 영향이 있었다면 속도도 대폭 개선될 것 입니다.

    import torch
    from transformers import AutoTokenizer, AutoModelForCausalLM
    
    path = "/home/noah/.cache/huggingface/transformers/1386e39caf0b158682709eb063f0231e03f868a0f87846c1eb777a79f161f87d.ce4d05ebacaac5ad33896c20e5373d786588147616bced327805834cb4beaf8f"
    
    model = torch.load(path)
    
    for i in model:
        t = model.get(i).dtype
        if (t == torch.float32):
            print (t)
            model[i] = model.get(i).half()
            
    torch.save(model, './fp16.pth')
    
    스크린샷 2021-11-19 오후 12 47 35 bug enhancement 
    opened by go-noah 3
  • 여러 개의 작은 GPU로 대형 모델을 분할하여 실행할 수 있도록 model parallelism 적용

    여러 개의 작은 GPU로 대형 모델을 분할하여 실행할 수 있도록 model parallelism 적용

    모델을 사용해 보려 했는데 원래 코드 실행 시 GPU가 하나밖에 활용되지 않아서 보통 메모리가 16GB 미만인 컨슈머 레벨 GPU로는 구동이 불가능함을 발견했습니다. 이러한 환경을 위해 모델을 여러 GPU에 나눠서 올릴 수 있는 옵션 --model_parallel을 추가한 수정 버전을 만들어 사용했는데, 이를 여기에 공유드립니다. 이 옵션을 주면 10GB 수준의 GPU 4개로 full-precision 모델 구동이 가능합니다. Possibly fix #19.

    hacktoberfest-accepted 
    opened by cosine0 2
  •  텍스트를 분류, 검색, 요약 코드에 대한 간단한 예제 코드 혹시 업로드 가능하실까요!?

    텍스트를 분류, 검색, 요약 코드에 대한 간단한 예제 코드 혹시 업로드 가능하실까요!?

    안녕하세요!! 딥러닝을 열심히 배우고 있는 학생입니다..!

    README에 생성 코드는 너무 상세하게 작성되어 있어서... 너무 잘 구현해 봤습니다.!

    README를 쭉 일어 보니 모델이 텍스트 분류 요약 검색에 대해 특화가 되어 있다고 하는데... 예제 코드를 보고 공부를 하고 싶은데 .. 어떻게 해야 할지 감이 안 잡혀서 염치 불구하고 이슈 올려봅니다!!

    멋진 모델을 공개해주신 카카오 브래인 분들에게 감사를 표하며!!

    documentation example 
    opened by Aramir94 2
  • Unable to load weights from pytorch checkpoint file

    Unable to load weights from pytorch checkpoint file

    안녕하세요, 먼저 이렇게 좋은 연구 결과를 오픈해주셔서 감사합니다!

    README에 있는 python 코드를 아래와 같이 실행 하다가 에러가 발생하였습니다.

    float16 버전은 정상 작동을 확인하였습니다. 혹시 float32 버전은 다른 방식으로 로딩을 해야할까요?

    from transformers import AutoTokenizer, AutoModelForCausalLM 
    
    vFLOAT16 = False
    model_name = 'kakaobrain/kogpt'
    revision = 'KoGPT6B-ryan1.5b' + ('-float16' if vFLOAT16 else '')
    
    tokenizer = AutoTokenizer.from_pretrained(
      model_name, revision=revision,
      bos_token='[BOS]', eos_token='[EOS]', unk_token='[UNK]', pad_token='[PAD]', mask_token='[MASK]'
    )
    
    model = AutoModelForCausalLM.from_pretrained(
      model_name, revision=revision,
      pad_token_id=tokenizer.eos_token_id,
      torch_dtype='auto', low_cpu_mem_usage=True,
    ).to(device='cuda', non_blocking=True)
    model.eval()
    
    Traceback (most recent call last):
      File "/home/ihl7029/anaconda3/envs/test-env/lib/python3.10/site-packages/transformers/modeling_utils.py", line 399, in load_state_dict
        return torch.load(checkpoint_file, map_location="cpu")
      File "/home/ihl7029/anaconda3/envs/test-env/lib/python3.10/site-packages/torch/serialization.py", line 705, in load
        with _open_zipfile_reader(opened_file) as opened_zipfile:
      File "/home/ihl7029/anaconda3/envs/test-env/lib/python3.10/site-packages/torch/serialization.py", line 242, in __init__
        super(_open_zipfile_reader, self).__init__(torch._C.PyTorchFileReader(name_or_buffer))
    RuntimeError: PytorchStreamReader failed reading zip archive: failed finding central directory
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/home/ihl7029/anaconda3/envs/test-env/lib/python3.10/site-packages/transformers/modeling_utils.py", line 403, in load_state_dict
        if f.read().startswith("version"):
      File "/home/ihl7029/anaconda3/envs/test-env/lib/python3.10/codecs.py", line 322, in decode
        (result, consumed) = self._buffer_decode(data, self.errors, final)
    UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 64: invalid start byte
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "/home/ihl7029/works/kogpt.py", line 13, in <module>
        model = AutoModelForCausalLM.from_pretrained(
      File "/home/ihl7029/anaconda3/envs/test-env/lib/python3.10/site-packages/transformers/models/auto/auto_factory.py", line 463, in from_pretrained
        return model_class.from_pretrained(
      File "/home/ihl7029/anaconda3/envs/test-env/lib/python3.10/site-packages/transformers/modeling_utils.py", line 2182, in from_pretrained
        state_dict = load_state_dict(resolved_archive_file)
      File "/home/ihl7029/anaconda3/envs/test-env/lib/python3.10/site-packages/transformers/modeling_utils.py", line 415, in load_state_dict
        raise OSError(
    OSError: Unable to load weights from pytorch checkpoint file for '/home/ihl7029/.cache/huggingface/hub/models--kakaobrain--kogpt/snapshots/2ba50fcfde0792e92bec63e039e5f57bf3cd55b4/pytorch_model.bin' at '/home/ihl7029/.cache/huggingface/hub/models--kakaobrain--kogpt/snapshots/2ba50fcfde0792e92bec63e039e5f57bf3cd55b4/pytorch_model.bin'. If you tried to load a PyTorch model from a TF 2.0 checkpoint, please set from_tf=True.
    
    opened by Holim0711 1
  • Evaluation issue with downstream evaluation codes

    Evaluation issue with downstream evaluation codes

    We have been reported to have issues with our downstream evaluation due to issues such as the following link. https://github.com/haven-jeon/KoGPT2-subtasks/pull/1

    We investigated the range that affects the problem, and it was confirmed that there was only a problem with the NSMC finetuning accuracy among the following evaluation tables.

    | Models | #params | method | NSMC (Acc.) | KorSTS(spearman) | |:--------------------------|--------:|:-------------|------------:|-----------------:| | SKT-AI/KoGPT-2 2.0[2] | 125M | finetuning | 93.3 | 78.4 | | SKT-AI/KoGPT-2 Trinity[3] | 1.2B | finetuning | 93.2 | 83.4 | | HyperCLOVA[1] | 1.3B | p-tuning | 91.7 | - | | HyperCLOVA[1] | 39.0B | p-tuning | 93.0 | - | | Ours | 6.0B | finetuning | 95.7 | 85.3 |

    We plan to share the evaluation results that solved the problem as soon as possible.

    bug evaluation 
    opened by wbaek 1
  • Can I access to 135M Model instead of 6B Model?

    Can I access to 135M Model instead of 6B Model?

    In README.md, I saw the result of Ours 135M model. However, in hugging face, I can only see the 6B Model which is too big for me.

    Is there 135M model in public?

    opened by L0Z1K 1
  • mac m1에서  cpu 실행시 half() 오류

    mac m1에서 cpu 실행시 half() 오류

    https://github.com/kakaobrain/pororo/issues/11 처럼

    m1에서 cpu로 실행시 추론 단계에서 문장을 입력하면 RuntimeError: "LayerNormKernelImpl" not implemented for 'Half' 오류가 뜨는 것 같습니다.

    wontfix 
    opened by dharana77 1
  • KeyError: 'gptj' 문제에 대해서

    KeyError: 'gptj' 문제에 대해서

    안녕하세요. 예제를 돌려 보려고 했는데 아래에 에러가 발생해서요.

    현재 pytorch==1.10.0, transformers==4.2.2 사용하고 있습니다. huggingface transformers 패키지 버전이 낮아서 발생하는 문제일까요?

    Traceback (most recent call last): File "inference.py", line 8, in <module> bos_token='[BOS]', eos_token='[EOS]', unk_token='[UNK]', pad_token='[PAD]', mask_token='[MASK]') File "/anaconda3/envs/pytorch/lib/python3.7/site-packages/transformers/models/auto/tokenization_auto.py", line 352, in from_pretrained config = AutoConfig.from_pretrained(pretrained_model_name_or_path, **kwargs) File "/anaconda3/envs/pytorch/lib/python3.7/site-packages/transformers/models/auto/configuration_auto.py", line 363, in from_pretrained config_class = CONFIG_MAPPING[config_dict["model_type"]] KeyError: 'gptj'

    opened by jin8 1
  • 135M 모델은 오픈계획이 없으신가요?

    135M 모델은 오픈계획이 없으신가요?

    안녕하세요. 커뮤니티 보고 찾아서 들어왔습니다. 우선 내부 연구중인 결과물을 많은 사람들이 활용할 수 있게 오픈해 주심에 감사드립니다.

    다름이 아니라 RTX A6000 이 있어서 다행히도 32GB 최소 사양에는 만족하나, 실생활 레벨에서 쓰려고 하면 좀더 작은 파라메터의 모델이 효과적일 것 같습니다.

    벤치마크 올리신걸 보니 135M 모델이 있고, 6B 모델에 근접한 성능인 것 같은데 135M 모델은 오픈하실 계획이 없으신지 하여 문의드립니다.

    question 
    opened by rippertnt 1
  • Bugfix : Prompt Inference 실행시, 모델의 device setting이 flag와 맞지 않는 버그 해결

    Bugfix : Prompt Inference 실행시, 모델의 device setting이 flag와 맞지 않는 버그 해결

    버그 발생 상황

    GPU 환경에서 기존의 코드를 동작시킬 때 아래와 같은 에러가 발생합니다.

    RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cpu and cuda:0! (when checking argument for argument index in method wrapper__index_select)
    

    해결 방법

    위의 에러가 발생하는 원인은 KoGPTInference 클래스의 생성자가 호출될 때 입력 받은 device 변수를 통해 GPT 모델의 device가 설정되지 않아 발생하는 문제로 보입니다. 따라서, 아래와 같은 코드를 추가하여 문제를 해결하였습니다.

    class KoGPTInference:
        def __init__(
                self,
                pretrained_model_name_or_path: Optional[Union[str, os.PathLike]],
                revision: str = 'KoGPT6B-ryan1.5b-float16',
                device: str = 'cuda',
                model_parallel: bool = False,
        ):
    
               ...
    
                self.model = GPTJForCausalLM.from_pretrained(
                      pretrained_model_name_or_path,  revision=revision,
                      pad_token_id=self.tokenizer.eos_token_id,
                      torch_dtype='auto', low_cpu_mem_usage=True
                  ).to(device)
    
               ...
    
    
    opened by Se-Hun 0
  • 새로운 소설, 새로운 소설을 써야한다. 무명작가로 지금까지 순수소설 몇 편을 써봤지만 이렇다 할 재미를 보지 못했다. 아내와 아이들이 나를 쳐다보고 있다. 몇 개의 알바를 다니고 임시직 직장을 다녀 쥐꼬리만 한 수입봉투를 떨리는 손으로 아내의 눈치를 보며 건네 주어 살림에 보태 보았지만 이렇다할 직장도 얻지 못하고 몇 년째 글쓰기에만 매달려 있다. 이번에도 실패하면 이젠 글쓰기도 영영 끝이다. 장르 소설을 써보자. 요즘은 순수소설보다 장르소설이 대세라고 한다. 더 인기가 많고 수입도 괜찮다고.

    새로운 소설, 새로운 소설을 써야한다. 무명작가로 지금까지 순수소설 몇 편을 써봤지만 이렇다 할 재미를 보지 못했다. 아내와 아이들이 나를 쳐다보고 있다. 몇 개의 알바를 다니고 임시직 직장을 다녀 쥐꼬리만 한 수입봉투를 떨리는 손으로 아내의 눈치를 보며 건네 주어 살림에 보태 보았지만 이렇다할 직장도 얻지 못하고 몇 년째 글쓰기에만 매달려 있다. 이번에도 실패하면 이젠 글쓰기도 영영 끝이다. 장르 소설을 써보자. 요즘은 순수소설보다 장르소설이 대세라고 한다. 더 인기가 많고 수입도 괜찮다고.

        새로운 소설, 새로운 소설을 써야한다. 무명작가로 지금까지 순수소설 몇 편을 써봤지만 이렇다 할 재미를 보지 못했다. 아내와 아이들이 나를 쳐다보고 있다. 몇 개의 알바를 다니고 임시직 직장을 다녀 쥐꼬리만 한 수입봉투를 떨리는 손으로 아내의 눈치를 보며 건네 주어 살림에 보태 보았지만 이렇다할 직장도 얻지 못하고 몇 년째 글쓰기에만 매달려 있다. 이번에도 실패하면 이젠 글쓰기도 영영 끝이다. 장르 소설을 써보자. 요즘은 순수소설보다 장르소설이 대세라고 한다. 더 인기가 많고 수입도 괜찮다고.
    

    그런데 어떤 소설을 쓸 것인가? 그게 문제다. 풍부한 에피소드를 만들어낼 수 있는 소재, 독자들에게 관심을 끌 수 있는 이야기, 그게 대체 무엇일까?

    Originally posted by @whyleeee in https://github.com/kakaobrain/kogpt/issues/23#issuecomment-1288035889

    opened by whyleeee 0
  • m1에서 model call 결과값에서 null 발생

    m1에서 model call 결과값에서 null 발생

    기존에 있는 예제 코드에서 아래와 같이 일부 수정 해서 동작 했을때 null 값이 나오는 에러가 발생 합니다.

    import torch from transformers import AutoTokenizer, AutoModelForCausalLM

    device = torch.device("mps")

    tokenizer = AutoTokenizer.from_pretrained( "kakaobrain/kogpt", revision="KoGPT6B-ryan1.5b-float16", bos_token="[BOS]", eos_token="[EOS]", unk_token="[UNK]", pad_token="[PAD]", mask_token="[MASK]", ) model = AutoModelForCausalLM.from_pretrained( "kakaobrain/kogpt", revision="KoGPT6B-ryan1.5b", pad_token_id=tokenizer.eos_token_id, torch_dtype="auto", low_cpu_mem_usage=True, ).to(device=device, non_blocking=True) _ = model.eval()

    prompt = "인간처럼 생각하고, 행동하는 '지능'을 통해 인류가 이제까지 풀지 못했던" with torch.no_grad(): # tokens = tokenizer.encode(prompt, return_tensors="pt").to(device=device, non_blocking=True) inputs = tokenizer(prompt, return_tensors="pt") print(inputs) inputs = {k: v.to(device=device, non_blocking=True) for k, v in inputs.items()} # gen_tokens = model.generate(**inputs, do_sample=True, temperature=0.8, max_length=32, top_k=8) gen_tokens = model(**inputs) print(gen_tokens) generated = tokenizer.batch_decode(gen_tokens)

    print(generated)

    print: 인간처럼 생각하고, 행동하는 '지능'을 통해 인류가 이제까지 풀지 못했던 문제의 해답을 찾을 수 있을 것이다. 과학기술이 고도로 발달한 21세기를 살아갈 우리 아이들에게 가장 필요한 것은 사고력 훈련이다. 사고력 훈련을 통해, 세상

    결과는 아래와 같습니다.

    'input_ids': tensor([[ 6577, 1290, 1032, 12519, 118, 2243, 385, 378, 882, 6261, 113, 387, 1132, 5321, 402, 2092, 841, 2182, 404, 993, 551, 726]]), 'token_type_ids': tensor([[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]), 'attention_mask': tensor([[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]])}

    CausalLMOutputWithPast(loss=None, logits=tensor([[[nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], ..., [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan], [nan, nan, nan, ..., nan, nan, nan]]], device='mps:0'), past_key_values=((tensor([[[[nan, nan, nan, ..., nan, nan, nan],

    tokenizer까지는 잘 되는데 model에서 결과가 이상하게 나오네요

    해당 사항 문의 드립니다.

    opened by nuri428 0
Releases(KoGPT6B-ryan1.5b)
Owner
Kakao Brain
Kakao Brain Corp.
Kakao Brain
基于pytorch+bert的中文事件抽取

pytorch_bert_event_extraction 基于pytorch+bert的中文事件抽取,主要思想是QA(问答)。 要预先下载好chinese-roberta-wwm-ext模型,并在运行时指定模型的位置。

西西嘛呦 31 Nov 30, 2022
超轻量级bert的pytorch版本,大量中文注释,容易修改结构,持续更新

bert4pytorch 2021年8月27更新: 感谢大家的star,最近有小伙伴反映了一些小的bug,我也注意到了,奈何这个月工作上实在太忙,更新不及时,大约会在9月中旬集中更新一个只需要pip一下就完全可用的版本,然后会新添加一些关键注释。 再增加对抗训练的内容,更新一个完整的finetune

muqiu 317 Dec 18, 2022
Russian GPT3 models.

Russian GPT-3 models (ruGPT3XL, ruGPT3Large, ruGPT3Medium, ruGPT3Small) trained with 2048 sequence length with sparse and dense attention blocks. We also provide Russian GPT-2 large model (ruGPT2Larg

Sberbank AI 1.6k Jan 05, 2023
Prompt tuning toolkit for GPT-2 and GPT-Neo

mkultra mkultra is a prompt tuning toolkit for GPT-2 and GPT-Neo. Prompt tuning injects a string of 20-100 special tokens into the context in order to

61 Jan 01, 2023
多语言降噪预训练模型MBart的中文生成任务

mbart-chinese 基于mbart-large-cc25 的中文生成任务 Input source input: text + /s + lang_code target input: lang_code + text + /s Usage token_ids_mapping.jso

11 Sep 19, 2022
HiFi-GAN: Generative Adversarial Networks for Efficient and High Fidelity Speech Synthesis

HiFi-GAN: Generative Adversarial Networks for Efficient and High Fidelity Speech Synthesis Jungil Kong, Jaehyeon Kim, Jaekyoung Bae In our paper, we p

Jungil Kong 1.1k Jan 02, 2023
Which Apple Keeps Which Doctor Away? Colorful Word Representations with Visual Oracles

Which Apple Keeps Which Doctor Away? Colorful Word Representations with Visual Oracles (TASLP 2022)

Zhuosheng Zhang 3 Apr 14, 2022
Official implementation of Meta-StyleSpeech and StyleSpeech

Meta-StyleSpeech : Multi-Speaker Adaptive Text-to-Speech Generation Dongchan Min, Dong Bok Lee, Eunho Yang, and Sung Ju Hwang This is an official code

min95 169 Jan 05, 2023
This is Assignment1 code for the Web Data Processing System.

This is a Python program to Entity Linking by processing WARC files. We recognize entities from web pages and link them to a Knowledge Base(Wikidata).

3 Dec 04, 2022
Unet-TTS: Improving Unseen Speaker and Style Transfer in One-shot Voice Cloning

Unet-TTS: Improving Unseen Speaker and Style Transfer in One-shot Voice Cloning English | 中文 ❗ Now we provide inferencing code and pre-training models

164 Jan 02, 2023
Princeton NLP's pre-training library based on fairseq with DeepSpeed kernel integration 🚃

This repository provides a library for efficient training of masked language models (MLM), built with fairseq. We fork fairseq to give researchers mor

Princeton Natural Language Processing 92 Dec 27, 2022
Unofficial Python library for using the Polish Wordnet (plWordNet / Słowosieć)

Polish Wordnet Python library Simple, easy-to-use and reasonably fast library for using the Słowosieć (also known as PlWordNet) - a lexico-semantic da

Max Adamski 12 Dec 23, 2022
Labelling platform for text using distant supervision

With DataQA, you can label unstructured text documents using rule-based distant supervision.

245 Aug 05, 2022
This project converts your human voice input to its text transcript and to an automated voice too.

Human Voice to Automated Voice & Text Introduction: In this project, whenever you'll speak, it will turn your voice into a robot voice and furthermore

Hassan Shahzad 3 Oct 15, 2021
A Non-Autoregressive Transformer based TTS, supporting a family of SOTA transformers with supervised and unsupervised duration modelings. This project grows with the research community, aiming to achieve the ultimate TTS.

A Non-Autoregressive Transformer based TTS, supporting a family of SOTA transformers with supervised and unsupervised duration modelings. This project grows with the research community, aiming to ach

Keon Lee 237 Jan 02, 2023
justCTF [*] 2020 challenges sources

justCTF [*] 2020 This repo contains sources for justCTF [*] 2020 challenges hosted by justCatTheFish. TLDR: Run a challenge with ./run.sh (requires Do

justCatTheFish 25 Dec 27, 2022
GNES enables large-scale index and semantic search for text-to-text, image-to-image, video-to-video and any-to-any content form

GNES is Generic Neural Elastic Search, a cloud-native semantic search system based on deep neural network.

GNES.ai 1.2k Jan 06, 2023
Tools, wrappers, etc... for data science with a concentration on text processing

Rosetta Tools for data science with a focus on text processing. Focuses on "medium data", i.e. data too big to fit into memory but too small to necess

207 Nov 22, 2022
Implementation of "Adversarial purification with Score-based generative models", ICML 2021

Adversarial Purification with Score-based Generative Models by Jongmin Yoon, Sung Ju Hwang, Juho Lee This repository includes the official PyTorch imp

15 Dec 15, 2022
A fast and easy implementation of Transformer with PyTorch.

FasySeq FasySeq is a shorthand as a Fast and easy sequential modeling toolkit. It aims to provide a seq2seq model to researchers and developers, which

宁羽 7 Jul 18, 2022