Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,45 +1,49 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
-
#
|
| 5 |
-
generator = pipeline("text-generation", model="
|
| 6 |
|
| 7 |
-
#
|
| 8 |
def generate_text(prompt):
|
| 9 |
-
results = generator(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
return results[0]['generated_text']
|
| 11 |
|
| 12 |
# Gradio arayüzü
|
| 13 |
iface = gr.Interface(
|
| 14 |
-
fn=generate_text,
|
| 15 |
-
inputs="text",
|
| 16 |
outputs="text",
|
| 17 |
title="Metin Tamamlama",
|
| 18 |
-
description="
|
| 19 |
)
|
| 20 |
|
| 21 |
-
# Uygulamayı çalıştır
|
| 22 |
iface.launch()
|
| 23 |
|
| 24 |
-
import gradio as gr
|
| 25 |
from transformers import pipeline
|
| 26 |
|
| 27 |
-
# Türkçe
|
| 28 |
-
|
| 29 |
|
| 30 |
-
#
|
| 31 |
-
def
|
| 32 |
-
|
| 33 |
-
return
|
| 34 |
|
| 35 |
-
# Gradio
|
| 36 |
iface = gr.Interface(
|
| 37 |
-
fn=
|
| 38 |
-
inputs="text",
|
| 39 |
outputs="text",
|
| 40 |
-
title="Türkçe
|
| 41 |
-
description="
|
| 42 |
)
|
| 43 |
|
| 44 |
-
# Uygulamayı çalıştır
|
| 45 |
iface.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
+
# Daha güçlü bir model kullanma (GPT-2)
|
| 5 |
+
generator = pipeline("text-generation", model="gpt2")
|
| 6 |
|
| 7 |
+
# Daha iyi sonuçlar için parametreler
|
| 8 |
def generate_text(prompt):
|
| 9 |
+
results = generator(
|
| 10 |
+
prompt,
|
| 11 |
+
max_length=50, # Tamamlanan metnin maksimum uzunluğu
|
| 12 |
+
num_return_sequences=1, # Çıktı sayısı
|
| 13 |
+
temperature=0.7, # Daha yaratıcı veya kesin sonuçlar
|
| 14 |
+
top_k=50, # En olası 50 kelime arasında seçim
|
| 15 |
+
top_p=0.9 # Cümle üretiminde "çekim" kullanımı
|
| 16 |
+
)
|
| 17 |
return results[0]['generated_text']
|
| 18 |
|
| 19 |
# Gradio arayüzü
|
| 20 |
iface = gr.Interface(
|
| 21 |
+
fn=generate_text,
|
| 22 |
+
inputs="text",
|
| 23 |
outputs="text",
|
| 24 |
title="Metin Tamamlama",
|
| 25 |
+
description="Daha doğru sonuçlar için GPT-2 ile metin tamamlama."
|
| 26 |
)
|
| 27 |
|
|
|
|
| 28 |
iface.launch()
|
| 29 |
|
|
|
|
| 30 |
from transformers import pipeline
|
| 31 |
|
| 32 |
+
# Türkçe metin tamamlama modeli
|
| 33 |
+
generator = pipeline("text-generation", model="ai-forever/mGPT")
|
| 34 |
|
| 35 |
+
# Tamamlama işlevi
|
| 36 |
+
def generate_text(prompt):
|
| 37 |
+
results = generator(prompt, max_length=50, num_return_sequences=1)
|
| 38 |
+
return results[0]['generated_text']
|
| 39 |
|
| 40 |
+
# Gradio uygulaması
|
| 41 |
iface = gr.Interface(
|
| 42 |
+
fn=generate_text,
|
| 43 |
+
inputs="text",
|
| 44 |
outputs="text",
|
| 45 |
+
title="Türkçe Metin Tamamlama",
|
| 46 |
+
description="Türkçe bir metin tamamlama modeli."
|
| 47 |
)
|
| 48 |
|
|
|
|
| 49 |
iface.launch()
|