raoufjat commited on
Commit
8e8cf31
·
verified ·
1 Parent(s): d7671ef

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -30
app.py CHANGED
@@ -1,30 +1,8 @@
1
-
2
- import gradio as gr
3
- from datasets import load_dataset
4
-
5
-
6
- # Load the dataset
7
- dataset = load_dataset("mohres/The_Arabic_E-Book_Corpus")
8
- def filter_arabic_novels():
9
- # Select only rows containing novel-like words
10
- filtered_data = dataset['train'].filter(lambda x: "رواية" in x['text'])
11
- return filtered_data
12
-
13
-
14
- # Function to display the first row text
15
- def get_first_text():
16
- try:
17
- return dataset['train'][0]['text']
18
- except Exception as e:
19
- return str(e)
20
-
21
-
22
- # Create a Gradio Interface
23
- interface = gr.Interface(
24
- fn=lambda: filter_arabic_novels()[0]['text'], # Only show first filtered sample
25
- inputs=[],
26
- outputs="text",
27
- )
28
-
29
- # Launch the interface
30
- interface.launch()
 
1
+ # Use a pipeline as a high-level helper
2
+ from transformers import pipeline
3
+
4
+ messages = [
5
+ {"role": "user", "content": "Who are you?"},
6
+ ]
7
+ pipe = pipeline("text-generation", model="Ruqiya/Fine-Tuning-Gemma-2b-it-for-Arabic")
8
+ pipe(messages)