InstructPalmyra: Writer에서 Apache 2.0 라이선스로 공개한 LLM

개요

기업용 AI 플랫폼을 개발하고 제공하는 Writer社에서 새롭게 InstructPalmyra 모델을 공개하였습니다.
InstructPalmyra 모델은 Apache 2.0 라이선스로, :hugs:Hugging Face에서 데모 사용 및 모델을 받아 직접 개발해 볼 수 있습니다.

InstructPalmyra-20b 모델 소개

  • InstructPalmyra-20b는 Writer社의 새로운 생성형 AI 모델로, 사용자의 지시에 따라 텍스트를 생성하는 능력을 갖추고 있습니다.
  • 이 모델은 Palmyra-20B을 미세조정한 것으로, 약 70,000건의 지시-답변(instruction-response) 데이터셋을 사용하여 학습되었습니다.
  • 이 모델을 사용하여 사용자의 질문에 대한 답변 생성, 문장 완성, 텍스트 생성 등의 작업을 수행할 수 있습니다.

주요 특징

  • InstructPalmyra-20b는 고성능의 생성능력을 가지고 있어, 복잡한 지시에 따라 정확한 텍스트를 생성할 수 있습니다.
  • 사용자의 지시를 정확하게 이해하고, 그에 따라 적절한 텍스트를 생성하는 것이 이 모델의 주요 목표입니다.

사용 방법

  • 사용자는 간단한 명령어를 통해 InstructPalmyra-20b 모델을 호출하고, 원하는 지시를 입력하여 텍스트를 생성할 수 있습니다.
  • :hugs: Hugging Face의 웹사이트에서는 이 모델을 직접 체험해 볼 수 있는 인터페이스를 제공하고 있습니다.
import torch
from transformers import AutoTokenizer, AutoModelForCausalLM

model_name = "Writer/InstructPalmyra-20b"

tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(
    model_name,
    device_map="auto",
    torch_dtype=torch.float16
)

instruction = "Describe a futuristic device that revolutionizes space travel."


PROMPT_DICT = {
    "prompt_input": (
        "Below is an instruction that describes a task, paired with an input that provides further context. "
        "Write a response that appropriately completes the request\n\n"
        "### Instruction:\n{instruction}\n\n### Input:\n{input}\n\n### Response:"
    ),
    "prompt_no_input": (
        "Below is an instruction that describes a task. "
        "Write a response that appropriately completes the request.\n\n"
        "### Instruction:\n{instruction}\n\n### Response:"
    ),
}

text = (
    PROMPT_DICT["prompt_no_input"].format(instruction=instruction)
    if not input
    else PROMPT_DICT["prompt_input"].format(instruction=instruction, input=input)
)

model_inputs = tokenizer(text, return_tensors="pt").to("cuda")
output_ids = model.generate(
    **model_inputs,
    max_length=256,
)
output_text = tokenizer.batch_decode(output_ids, skip_special_tokens=True)[0]
clean_output = output_text.split("### Response:")[1].strip()

print(clean_output)

더 읽어보기

Writer社 홈페이지

InstructPalmyra-20B 모델

Palmyra-20B 모델