Views
No views yet
1# Import the transformers library
2from transformers import AutoModelForCausalLM, AutoTokenizer
3
4tokenizer = AutoTokenizer.from_pretrained("cateto/korean-gpt-neox-125M")
5
6model = AutoModelForCausalLM.from_pretrained("cateto/korean-gpt-neox-125M")
7
8# Get user input
9user_input = "우리는 앞으로 더나은 미래를"
10
11# Encode the prompt using the tokenizer
12input_ids = tokenizer.encode(user_input, return_tensors="pt")
13
14# Generate chatbot output using the model
15output_ids = model.generate(
16 input_ids,
17 num_beams=4,
18 repetition_penalty=1.5,
19 no_repeat_ngram_size=3
20)
21
22# Decode chatbot output ids as text
23bot_output = tokenizer.decode(output_ids.tolist()[0], skip_special_tokens=True)
24
25# Print chatbot output
26print(f"출력 ## ", bot_output)
27
28# 출력 ## 우리는 앞으로 더나은 미래를 향해 나아갈 수 있다.