|
import gradio as gr |
|
import pandas as pd |
|
|
|
|
|
def process_data(task_name, model_name, pooling_method, input_text, file=None): |
|
|
|
if file: |
|
df = pd.read_csv(file.name) |
|
output = f"Processed {len(df)} rows from uploaded file using task: {task_name}, model: {model_name}, pooling: {pooling_method}." |
|
dataframe_output = df.head().to_html() |
|
else: |
|
lines = input_text.split("\n") |
|
output = f"Processed {len(lines)} rows of text using task: {task_name}, model: {model_name}, pooling: {pooling_method}." |
|
dataframe_output = "<p>No file uploaded. DataFrame preview unavailable.</p>" |
|
|
|
return output, dataframe_output, "File processing completed." |
|
|
|
|
|
with gr.Blocks() as interface: |
|
gr.Markdown("# TransDis-CreativityAutoAssessment") |
|
gr.Markdown( |
|
"Two-Phase Fine-tuned BERTは、bert-base-japaneseモデルに基づいた自動評価システムで、日本語の多用途タスク(AUT)における創造性と適切性を評価するために使用されます(論文はこちら:https://link.springer.com/article/xx.xxxx/sxxxxx-xxx-xxxx-x)。" |
|
"プロンプトと回答のデータを入力してください。データは1行ごとに用途を記述し、カンマで区切ってください。" |
|
"データは、デモのようにテキストボックスに直接入力するか、カンマ区切りのCSV形式ファイルまたはxlsx形式ファイルをアップロードすることで入力できます。" |
|
"評価に使用するモデルは、Two-Phase Fine-tuned BERT の他に One-phase BERT もあり、いずれも日本語にのみ対応しています。" |
|
"Two-phase BERTは、低い現実性の回答に対して創造性評価を最適化しており、適切性と創造性の両方を評価できます。" |
|
"一方、One-phase BERTは、AUT回答の創造性のみを評価します。" |
|
"Pooling方法としてcls-poolingを使用することをお勧めします。" |
|
"エラーが発生した場合は、データを簡略化し、行数を減らして試してください。" |
|
"それでも解決しない場合は、入力形式が誤っている可能性があるため、CSVとして保存し直してアップロードをお試しください。" |
|
"このシステムはHuggingFaceが提供する無料サーバーを使用しており、計算にはCPUのみを使用するため、処理速度が遅い場合があります。" |
|
"このスペースをあなたのアカウントにコピー(推奨)し、ハードウェアをアップグレードすることで処理速度を向上させることが可能です。" |
|
"その他のサポートやバグ報告については、[email protected]までご連絡ください。" |
|
"\n\n" |
|
"Two-Phase Fine-tuned BERT is an automatic evaluation system based on the bert-base-japanese model, designed to evaluate creativity and appropriateness in Japanese alternative uses task (AUT) (see the paper at https://link.springer.com/article/xx.xxxx/sxxxxx-xxx-xxxx-x)." |
|
"Enter the data consisting of prompts and responses, with one usage per line, separated by commas." |
|
"You can input the data directly into the text box as shown in the demos, or upload a comma-separated CSV file or an xlsx file as input." |
|
"The models available for evaluation also include One-phase Fine-tuned BERT except for Two-phase Fine-tuned BERT, both of which are applicable only to Japanese." |
|
"Two-phase BERT is optimized for creativity scoring for responses with low practicality and can evaluate both appropriateness and creativity." |
|
"On the other hand, One-phase BERT is designed solely for evaluating creativity in AUT responses." |
|
"We recommend using cls-pooling as the pooling method." |
|
" If an error occurs, try simplifying your data by reducing the number of rows." |
|
"If this doesn’t resolve the issue, the input format may be incorrect. Please try saving the data again as a comma-separated CSV file before uploading it." |
|
"This system uses the free servers provided by HuggingFace, which only support CPU processing, so it may run slowly." |
|
"You can copy this space to your account (recommended) and choose upgraded hardware to improve processing speed." |
|
"For further assistance or to report bugs, please contact [email protected]." |
|
"\n\n" |
|
"Reference: Wang, S., ..., (2025). Enhancing Creativity Evaluation in Divergent Thinking: A Two-phase Fine-tuned BERT Incorporating Appropriateness Supervision. https://doi.org/xx.xxxx/sxxxxx-xxx-xxxxx-x" |
|
) |
|
|
|
|
|
with gr.Row(): |
|
with gr.Column(): |
|
task_dropdown = gr.Dropdown( |
|
label="Task Name", |
|
choices=["Creativity", "Appropriateness"], |
|
value="Creativity" |
|
) |
|
model_dropdown = gr.Dropdown( |
|
label="Model Name", |
|
choices=[ |
|
"One-phase Fine-tuned BERT", |
|
"Two-phase Fine-tuned BERT"], |
|
value="Two-phase Fine-tuned BERT" |
|
) |
|
pooling_dropdown = gr.Dropdown( |
|
label="Pooling", |
|
choices=["mean", "cls"], |
|
value="cls" |
|
) |
|
text_input = gr.Textbox( |
|
label="Text Input", |
|
lines=10, |
|
placeholder="Enter text data here..." |
|
) |
|
file_input = gr.File( |
|
label="Input File", |
|
type="filepath", |
|
file_types=[".csv", ".xlsx"] |
|
) |
|
with gr.Column(): |
|
output_box = gr.Textbox(label="Output", lines=5, interactive=False) |
|
dataframe_output = gr.HTML(label="DataFrame Preview") |
|
file_output = gr.Textbox(label="Output File Status", interactive=False) |
|
|
|
|
|
submit_button = gr.Button("Submit") |
|
submit_button.click( |
|
process_data, |
|
inputs=[task_dropdown, model_dropdown, pooling_dropdown, text_input, file_input], |
|
outputs=[output_box, dataframe_output, file_output] |
|
) |
|
|
|
|
|
|
|
interface.launch() |
|
|
|
|