Spaces:
Runtime error
Runtime error
File size: 1,267 Bytes
5a16046 f91be04 5a16046 805bdde 7bfcd48 ca6a060 805bdde 5a16046 805bdde f91be04 5a16046 a6693d6 5a16046 805bdde 7bfcd48 5a16046 805bdde 7bfcd48 |
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 |
import gradio as gr
from confidence import run_nli
DESCRIPTION = """\
# Llama Chatbot with confidence scores 🩺
This space shows that we can teach LLMs to express how confident they are in their answers.
Since we can only access free CPUs, we use a tiny Llama ([TinyLlama-1.1B](https://huggingface.co./PY007/TinyLlama-1.1B-Chat-v0.3)) as the chatbot and an [NLI model](https://github.com/potsawee/selfcheckgpt) to get scores. <br/>
💯 There will be a score between 0 and 1 after each sentence, and a higher value means the sentence is more factual.<br/>
⏳ It takes 150-300s to process each query, and we limit the token numbers of answers for saving time.
"""
def greet(query, history):
results = run_nli(query, sample_size=3)
return results
#return "this is the result"
sample_list = [
"Tell me something about Albert Einstein, e.g., a short bio with birth date and birth place",
"Tell me something about Lihu Chen, e.g., a short bio with birth date and birth place",
"How tall is the Eiffel Tower?"
]
iface = gr.ChatInterface(
fn=greet,
stop_btn=None,
examples=sample_list,
cache_examples=True
)
with gr.Blocks() as demo:
gr.Markdown(DESCRIPTION)
iface.render()
#gr.Markdown(LICENSE)
demo.launch() |