Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,6 +2,7 @@ import gradio as gr
|
|
| 2 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 3 |
import random
|
| 4 |
from datasets import load_dataset
|
|
|
|
| 5 |
|
| 6 |
title = "Ask Rick a Question"
|
| 7 |
description = """
|
|
@@ -11,9 +12,13 @@ The bot was trained to answer questions based on Rick and Morty dialogues. Ask R
|
|
| 11 |
|
| 12 |
article = "Check out [the original Rick and Morty Bot](https://huggingface.co/spaces/kingabzpro/Rick_and_Morty_Bot) that this demo is based off of."
|
| 13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
-
tokenizer = AutoTokenizer.from_pretrained("./")
|
| 16 |
-
model = AutoModelForCausalLM.from_pretrained("./")
|
| 17 |
|
| 18 |
dataset = load_dataset("allenai/sciq")
|
| 19 |
random_test_samples = dataset["test"].select(random.sample(range(0, len(dataset["test"])), 10))
|
|
|
|
| 2 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 3 |
import random
|
| 4 |
from datasets import load_dataset
|
| 5 |
+
import os
|
| 6 |
|
| 7 |
title = "Ask Rick a Question"
|
| 8 |
description = """
|
|
|
|
| 12 |
|
| 13 |
article = "Check out [the original Rick and Morty Bot](https://huggingface.co/spaces/kingabzpro/Rick_and_Morty_Bot) that this demo is based off of."
|
| 14 |
|
| 15 |
+
model_id = "google/gemma-2b"
|
| 16 |
+
tokenizer = AutoTokenizer.from_pretrained(model_id, token=os.environ.get("HF_TOKEN"))
|
| 17 |
+
base_model = AutoModelForCausalLM.from_pretrained(model_id, token=os.environ.get("HF_TOKEN"))
|
| 18 |
+
|
| 19 |
+
model = PeftModel.from_pretrained(base_model, "./")
|
| 20 |
+
model = model.merge_and_unload()
|
| 21 |
|
|
|
|
|
|
|
| 22 |
|
| 23 |
dataset = load_dataset("allenai/sciq")
|
| 24 |
random_test_samples = dataset["test"].select(random.sample(range(0, len(dataset["test"])), 10))
|