Spaces:
Runtime error
Runtime error
ebru.zltn@yahoo.com
commited on
Commit
·
247c95d
1
Parent(s):
ad8b1a6
adding files in the model
Browse files
app.py
CHANGED
|
@@ -2,20 +2,14 @@ import os
|
|
| 2 |
import gradio as gr
|
| 3 |
from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
|
| 4 |
|
| 5 |
-
|
| 6 |
-
hf_token = os.environ.get("hf_token")
|
| 7 |
|
| 8 |
-
# Daha küçük, açık ve güçlü model
|
| 9 |
-
model_id = "mistralai/Mistral-7B-Instruct-v0.2"
|
| 10 |
-
|
| 11 |
-
# Tokenizer ve model yükleme
|
| 12 |
tokenizer = AutoTokenizer.from_pretrained(model_id, token=hf_token)
|
| 13 |
model = AutoModelForCausalLM.from_pretrained(model_id, token=hf_token, device_map="auto")
|
| 14 |
|
| 15 |
-
# Text generation pipeline
|
| 16 |
pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)
|
| 17 |
|
| 18 |
-
# Fonksiyon
|
| 19 |
def bust_myth(statement):
|
| 20 |
prompt = f"""
|
| 21 |
You are a cultural myth-busting assistant.
|
|
@@ -29,7 +23,6 @@ Statement: "{statement}"
|
|
| 29 |
result = pipe(prompt, max_new_tokens=300, temperature=0.7)[0]["generated_text"]
|
| 30 |
return result
|
| 31 |
|
| 32 |
-
# Gradio arayüzü
|
| 33 |
gr.Interface(
|
| 34 |
fn=bust_myth,
|
| 35 |
inputs=gr.Textbox(label="Enter a cultural or world belief", lines=3, placeholder="E.g. All Canadians live in igloos."),
|
|
|
|
| 2 |
import gradio as gr
|
| 3 |
from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
|
| 4 |
|
| 5 |
+
model_id = "mistralai/Mistral-7B-Instruct-v0.3"
|
| 6 |
+
hf_token = os.environ.get("hf_token") # Space Secret olarak tanımladın
|
| 7 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
tokenizer = AutoTokenizer.from_pretrained(model_id, token=hf_token)
|
| 9 |
model = AutoModelForCausalLM.from_pretrained(model_id, token=hf_token, device_map="auto")
|
| 10 |
|
|
|
|
| 11 |
pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)
|
| 12 |
|
|
|
|
| 13 |
def bust_myth(statement):
|
| 14 |
prompt = f"""
|
| 15 |
You are a cultural myth-busting assistant.
|
|
|
|
| 23 |
result = pipe(prompt, max_new_tokens=300, temperature=0.7)[0]["generated_text"]
|
| 24 |
return result
|
| 25 |
|
|
|
|
| 26 |
gr.Interface(
|
| 27 |
fn=bust_myth,
|
| 28 |
inputs=gr.Textbox(label="Enter a cultural or world belief", lines=3, placeholder="E.g. All Canadians live in igloos."),
|