Spaces:
Running
Running
improve interface
Browse files
app.py
CHANGED
@@ -3,25 +3,47 @@ from lettucedetect.models.inference import HallucinationDetector
|
|
3 |
import os
|
4 |
|
5 |
|
6 |
-
title = """# 🙋🏻♂️Welcome to 🌟Tonic's 🥬 LettuceDetect - 🤯🧠 Hallucination Tester 🟢🔴
|
7 |
-
description= """
|
8 |
Powered by `lettucedect-large-modernbert-en-v1` from KRLabsOrg. Detect hallucinations in answers based on context and questions using ModernBERT with 8192-token context support!
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
"""
|
20 |
join_us = """
|
21 |
## Join us:
|
22 |
|
23 |
🌟TeamTonic🌟 is always making cool demos! Join our active builder's 🛠️community 👻
|
24 |
-
[
|
25 |
On 🤗Huggingface: [MultiTransformer](https://huggingface.co/MultiTransformer)
|
26 |
On 🌐Github: [Tonic-AI](https://github.com/tonic-ai) & contribute to🌟 [Data Tonic](https://github.com/multiTonic/thinking-dataset/)
|
27 |
🤗Big thanks to Yuvi Sharma and all the folks at huggingface for the community grant 🤗
|
@@ -100,7 +122,12 @@ with gr.Blocks(
|
|
100 |
gr.Markdown(title)
|
101 |
with gr.Row():
|
102 |
with gr.Group():
|
103 |
-
gr.Markdown(
|
|
|
|
|
|
|
|
|
|
|
104 |
with gr.Column():
|
105 |
gr.Markdown(join_us)
|
106 |
with gr.Row():
|
|
|
3 |
import os
|
4 |
|
5 |
|
6 |
+
title = """# 🙋🏻♂️Welcome to 🌟Tonic's 🥬 LettuceDetect - 🤯🧠 Hallucination Tester 🟢🔴
|
|
|
7 |
Powered by `lettucedect-large-modernbert-en-v1` from KRLabsOrg. Detect hallucinations in answers based on context and questions using ModernBERT with 8192-token context support!
|
8 |
+
"""
|
9 |
+
description2 = """
|
10 |
+
### Model Details
|
11 |
+
- **Model Name**: [lettucedect-large-modernbert-en-v1](https://huggingface.co/KRLabsOrg/lettucedect-large-modernbert-en-v1)
|
12 |
+
- **Organization**: [KRLabsOrg](https://huggingface.co/KRLabsOrg)
|
13 |
+
- **Github**: [https://github.com/KRLabsOrg/LettuceDetect](https://github.com/KRLabsOrg/LettuceDetect)
|
14 |
+
- **Architecture**: ModernBERT (Large) with extended context support up to 8192 tokens
|
15 |
+
- **Task**: Token Classification / Hallucination Detection
|
16 |
+
- **Training Dataset**: [RagTruth](https://huggingface.co/datasets/wandb/RAGTruth-processed)
|
17 |
+
- **Language**: English
|
18 |
+
- **Capabilities**: Detects hallucinated spans in answers, provides confidence scores, and calculates average confidence across detected spans.
|
19 |
+
LettuceDetect excels at processing long documents to determine if an answer aligns with the provided context, making it a powerful tool for ensuring factual accuracy.
|
20 |
+
"""
|
21 |
+
|
22 |
+
howto1 = """
|
23 |
+
### How to Use LettuceDetect Tester
|
24 |
+
1. **Enter a Context**: Provide the source text or document (e.g., "France is a country in Europe..."). This is the factual basis for evaluation.
|
25 |
+
2. **Enter a Question**: Ask something related to the context (e.g., "What is the capital of France?").
|
26 |
+
3. **Enter an Answer**: Input the response you want to check (e.g., "The capital of France is Paris. The population is 69 million.").
|
27 |
+
4. **Press Submit**: Analyze the answer for hallucinations!
|
28 |
+
"""
|
29 |
+
|
30 |
+
howto2 = """
|
31 |
+
### Understanding the Output
|
32 |
+
- **Status**:
|
33 |
+
- 🟢 = No hallucinations detected
|
34 |
+
- 🔴 = Hallucinations detected
|
35 |
+
- ⚪ = Error occurred
|
36 |
+
- **Explanation**: A brief summary of the result.
|
37 |
+
- **Highlighted Answer**: Shows the answer with hallucinated parts in **red**, labeled with confidence scores (e.g., "hallucination (conf: 0.9944)").
|
38 |
+
- **Hallucinated Spans & Confidence**: Lists each hallucinated segment with its confidence score.
|
39 |
+
- **Average Confidence**: Displays the average confidence of all detected hallucinations (e.g., "Average Confidence: 0.9944").
|
40 |
+
Use this tool to ensure your answers are grounded in reality!
|
41 |
"""
|
42 |
join_us = """
|
43 |
## Join us:
|
44 |
|
45 |
🌟TeamTonic🌟 is always making cool demos! Join our active builder's 🛠️community 👻
|
46 |
+
[Join us on Discord](https://discord.gg/n8ytYeh25n)
|
47 |
On 🤗Huggingface: [MultiTransformer](https://huggingface.co/MultiTransformer)
|
48 |
On 🌐Github: [Tonic-AI](https://github.com/tonic-ai) & contribute to🌟 [Data Tonic](https://github.com/multiTonic/thinking-dataset/)
|
49 |
🤗Big thanks to Yuvi Sharma and all the folks at huggingface for the community grant 🤗
|
|
|
122 |
gr.Markdown(title)
|
123 |
with gr.Row():
|
124 |
with gr.Group():
|
125 |
+
gr.Markdown(description2)
|
126 |
+
with gr.Column():
|
127 |
+
gr.Markdown(howto2)
|
128 |
+
with gr.Row():
|
129 |
+
with gr.Group():
|
130 |
+
gr.Markdown(howto1)
|
131 |
with gr.Column():
|
132 |
gr.Markdown(join_us)
|
133 |
with gr.Row():
|