Spaces:
Runtime error
Runtime error
File size: 1,779 Bytes
f4807cc 55464d0 f4807cc 8d37a8d 55464d0 f4807cc 8d37a8d 55464d0 8d37a8d 4e9d310 8d37a8d f4807cc 8d37a8d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
import gradio as gr
from transformers import pipeline
# ๊ฐ์ฑ ๋ถ์ ํ์ดํ๋ผ์ธ ์ด๊ธฐํ
sentiment = pipeline("sentiment-analysis")
# ์ฌ์ฉ์ ์
๋ ฅ์ ๋ํ ๊ฐ์ฑ ๋ถ์ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํํ๋ ํจ์
def get_sentiment(์
๋ ฅ):
# ๊ฐ์ฑ ๋ถ์ ์คํ
return sentiment(์
๋ ฅ)
gr.Interface(fn=ask_question, inputs="์
๋ ฅ", outputs="output", title="Sentiment Analysis", description="").launch()
# import gradio as gr
# from transformers import pipeline
# sentiment = pipeline("sentiment-analysis")
# def get_sentiment(์
๋ ฅ):
# # from transformers import AutoTokenizer, AutoModelForCausalLM
# # model_name = "heegyu/koalpaca-355m"
# # tokenizer = AutoTokenizer.from_pretrained(model_name)
# # tokenizer.truncation_side = "right"
# # model = AutoModelForCausalLM.from_pretrained(model_name)
# return sentiment(์
๋ ฅ)
# def get_response(output):
# context = f"<usr>{context}\n<sys>"
# inputs = tokenizer(
# context,
# truncation=True,
# max_length=512,
# return_tensors="pt")
# generation_args = dict(
# max_length=256,
# min_length=64,
# eos_token_id=2,
# do_sample=True,
# top_p=1.0,
# early_stopping=True
# )
# outputs = model.generate(**inputs, **generation_args)
# response = tokenizer.decode(outputs[0])
# print(context)
# print(response)
# response = response[len(context):].replace("</s>", "")
# return response
# model, tokenizer = get_pipe()
# def ask_question(input_):
# response = get_response(tokenizer, model, input_)
# return response
# gr.Interface(fn=ask_question, inputs="text", outputs="text", title="KoAlpaca-355M", description="ํ๊ตญ์ด๋ก ์ง๋ฌธํ์ธ์.").launch() |