import gradio as gr import paddlehub as hub ernie_zeus = hub.Module(name='ernie_zeus') def inference(task: str, text: str, min_dec_len: int = 2, seq_len: int = 512, topp: float = 0.9, penalty_score: float = 1.0): func = getattr(ernie_zeus, task) try: result = func(text, min_dec_len, seq_len, topp, penalty_score) return result except Exception as error: return str(error) title = "ERNIE-Zeus" description = "ERNIE-Zeus model, which supports Chinese text generates task." css = """ .gradio-container { font-family: 'IBM Plex Sans', sans-serif; } .gr-button { color: white; border-color: black; background: black; } input[type='range'] { accent-color: black; } .dark input[type='range'] { accent-color: #dfdfdf; } .container { max-width: 730px; margin: auto; padding-top: 1.5rem; } .details:hover { text-decoration: underline; } .gr-button { white-space: nowrap; } .gr-button:focus { border-color: rgb(147 197 253 / var(--tw-border-opacity)); outline: none; box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000); --tw-border-opacity: 1; --tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color); --tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(3px var(--tw-ring-offset-width)) var(--tw-ring-color); --tw-ring-color: rgb(191 219 254 / var(--tw-ring-opacity)); --tw-ring-opacity: .5; } .footer { margin-bottom: 45px; margin-top: 35px; text-align: center; border-bottom: 1px solid #e5e5e5; } .footer>p { font-size: .8rem; display: inline-block; padding: 0 10px; transform: translateY(10px); background: white; } .dark .footer { border-color: #303030; } .dark .footer>p { background: #0b0f19; } .prompt h4{ margin: 1.25em 0 .25em 0; font-weight: bold; font-size: 115%; } """ block = gr.Blocks(css=css) examples = [ [ 'text_summarization', '在芬兰、瑞典提交“入约”申请近一个月来,北约成员国内部尚未对此达成一致意见。与此同时,俄罗斯方面也多次对北约“第六轮扩张”发出警告。据北约官网显示,北约秘书长斯托尔滕贝格将于本月12日至13日出访瑞典和芬兰,并将分别与两国领导人进行会晤。', 4, 512, 0.0, 1.0 ], [ 'copywriting_generation', '芍药香氛的沐浴乳', 32, 512, 0.9, 1.2 ], [ 'novel_continuation', '昆仑山可以说是天下龙脉的根源,所有的山脉都可以看作是昆仑的分支。这些分出来的枝枝杈杈,都可以看作是一条条独立的龙脉。', 2, 512, 0.9, 1.2 ], [ 'answer_generation', '杜鹃花怎么养?', 2, 512, 0.9, 1.2 ], [ 'couplet_continuation', '天增岁月人增寿', 2, 512, 0.9, 1.0 ], [ 'composition_generation', '诚以养德,信以修身', 128, 512, 0.9, 1.2 ], [ 'text_cloze', '她有着一双[MASK]的眼眸。', 1, 512, 0.9, 1.0 ], ] with block: gr.HTML( """
ERNIE-Zeus is a state-of-the-art Chinese text generates model.