Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,20 @@
|
|
|
|
|
|
1 |
import re
|
2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
# Function to clean and truncate the generated text after encountering unwanted content
|
5 |
def clean_and_truncate_text(text):
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline, AutoModelForCausalLM, AutoTokenizer
|
3 |
import re
|
4 |
+
|
5 |
+
# Load the fine-tuned model from Hugging Face Hub
|
6 |
+
model_name = "redietmolla/amharic_qa_fine_tuned_llama_model"
|
7 |
+
model = AutoModelForCausalLM.from_pretrained(model_name)
|
8 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
9 |
+
|
10 |
+
# Set up the text generation pipeline
|
11 |
+
text_generation_pipeline = pipeline(
|
12 |
+
task="text-generation",
|
13 |
+
model=model,
|
14 |
+
tokenizer=tokenizer,
|
15 |
+
max_length=300
|
16 |
+
)
|
17 |
+
|
18 |
|
19 |
# Function to clean and truncate the generated text after encountering unwanted content
|
20 |
def clean_and_truncate_text(text):
|