Hugging Face 홈페이지
pip 명령어를 이용하여 간단히 관련 라이브러리를 쉽게 설치할 수 있음# 핵심 라이브러리를 한꺼번에 설치
pip install huggingface_hub datasets transformers
from transformers import AutoTokenizer, AutoModelForCausalLM
model_name = "gpt2"
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(model_name)
question = "What is Data Analysis?"
input_ids = tokenizer.encode(question, return_tensors="pt")
output = model.generate(input_ids, max_length=60, num_return_sequences=1)
answer = tokenizer.decode(output[0], skip_special_tokens=True)
print(answer)
# What is Data Analysis?
# Data analysis is a process of analyzing data to determine the best way to analyze it.
*이 글은 제로베이스 데이터 취업 스쿨의 강의 자료 일부를 발췌하여 작성되었습니다.