Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,22 +1,18 @@
|
|
1 |
import gradio as gr
|
2 |
-
from transformers import
|
3 |
|
4 |
-
#
|
5 |
-
model_name = "
|
6 |
-
|
|
|
7 |
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
fn=transcribe_audio,
|
15 |
-
|
16 |
-
inputs=gr.Audio(type="filepath"),
|
17 |
-
outputs="text",
|
18 |
-
title="Darija Audio Transcription",
|
19 |
-
description="Upload an audio file in Darija to get the transcription."
|
20 |
-
)
|
21 |
|
|
|
|
|
22 |
iface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
3 |
|
4 |
+
# Charger le modèle et le tokenizer
|
5 |
+
model_name = "jondurbin/airoboros-gpt-3.5-turbo-100k-7b"
|
6 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
7 |
+
model = AutoModelForCausalLM.from_pretrained(model_name)
|
8 |
|
9 |
+
# Fonction pour générer des réponses
|
10 |
+
def generate_response(input_text):
|
11 |
+
inputs = tokenizer.encode(input_text, return_tensors="pt")
|
12 |
+
outputs = model.generate(inputs, max_length=150)
|
13 |
+
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
14 |
+
return response
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
+
# Interface Gradio
|
17 |
+
iface = gr.Interface(fn=generate_response, inputs="text", outputs="text", title="GPT-3.5 Turbo Chatbot")
|
18 |
iface.launch()
|