ebru.zltn@yahoo.com commited on
Commit
5f8c6e2
·
1 Parent(s): a2cb3c1

adding files in the model

Browse files
Files changed (1) hide show
  1. app.py +30 -0
app.py ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
3
+
4
+ model_id = "meta-llama/Llama-3.1-8B-Instruct"
5
+
6
+ tokenizer = AutoTokenizer.from_pretrained(model_id)
7
+ model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto")
8
+ pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)
9
+
10
+ def bust_myth(statement):
11
+ prompt = f"""
12
+ You are a cultural myth-busting assistant.
13
+ Your task is to:
14
+ 1. Determine if the following statement is true, false, or partially true.
15
+ 2. If it's a misconception, explain why it's incorrect.
16
+ 3. Provide the correct information with a short cultural context.
17
+
18
+ Statement: "{statement}"
19
+ """
20
+ result = pipe(prompt, max_new_tokens=300, temperature=0.7)[0]["generated_text"]
21
+ return result
22
+
23
+ gr.Interface(
24
+ fn=bust_myth,
25
+ inputs=gr.Textbox(label="Enter a cultural or world belief", lines=3, placeholder="E.g. All Canadians live in igloos."),
26
+ outputs="text",
27
+ title="🌍 World Fact & Misconception Buster",
28
+ description="Enter a statement about a country, culture, or people. The AI will fact-check and explain it."
29
+ ).launch()
30
+