File size: 2,024 Bytes
c7e50b8
 
 
5fb39b0
c7e50b8
5fb39b0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c7e50b8
5fb39b0
 
 
 
 
 
c7e50b8
 
5fb39b0
 
 
 
 
 
c7e50b8
 
5fb39b0
 
c7e50b8
 
 
 
 
5fb39b0
 
c7e50b8
 
 
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
import gradio as gr
import pandas as pd
import random
from transformers import DebertaV2Tokenizer, DebertaV2Model

# Importing and setting up a DeBERTa v2 model (for demonstration)
tokenizer = DebertaV2Tokenizer.from_pretrained('microsoft/deberta-v2-xlarge')
model = DebertaV2Model.from_pretrained('microsoft/deberta-v2-xlarge')

# Hardcoded sample data
data = {
    "QueryID": [
        "Tastemade _16_46", "MyChart _23_23", "USPS MOBILE _20_10", 
        "The Washington Post Classic _21_20", "QuickBooks Accounting: Invoicing & Expenses _9_40"
    ],
    "Segment": [
        "Some common applications are to target adverti...",
        "The security of your information and data whil...",
        "If you still have concerns about cookies, you ...",
        "cookies help us and third parties understand ...",
        "Under certain conditions, more fully described..."
    ]
}

df = pd.DataFrame(data)

# Fake predictions for demonstration
fake_predictions = {
    "Tastemade _16_46": "Irrelevant",
    "MyChart _23_23": "Irrelevant",
    "USPS MOBILE _20_10": "Irrelevant",
    "The Washington Post Classic _21_20": "Irrelevant",
    "QuickBooks Accounting: Invoicing & Expenses _9_40": "Irrelevant",
    # ... Add more mappings if needed
}

def preprocess_data(segment):
    # Sample preprocessing steps (not actually applied in fake prediction)
    tokenized_input = tokenizer(segment, return_tensors="pt", padding='max_length', truncation=True, max_length=512)
    # Normally, you would pass this through the model, but here we're just simulating
    return tokenized_input

def predict(query_id):
    # Simulate a model prediction
    segment = df[df['QueryID'] == query_id]['Segment'].iloc[0]
    processed_data = preprocess_data(segment)  # Preprocessing (for show)
    response = fake_predictions.get(query_id, "Unknown QueryID")
    return response

iface = gr.Interface(
    fn=predict,
    inputs=gr.inputs.Dropdown(list(df['QueryID'].unique()), label="Select QueryID"),
    outputs="text"
)

iface.launch()