Update app.py
Browse files
app.py
CHANGED
@@ -2,12 +2,15 @@ import os
|
|
2 |
import gradio as gr
|
3 |
import torch
|
4 |
import spaces
|
|
|
5 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
6 |
|
7 |
# Load model and tokenizer if a GPU is available
|
8 |
if torch.cuda.is_available():
|
9 |
-
model_id = "
|
|
|
10 |
model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto", trust_remote_code=True)
|
|
|
11 |
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
|
12 |
else:
|
13 |
raise EnvironmentError("CUDA device not available. Please run on a GPU-enabled environment.")
|
|
|
2 |
import gradio as gr
|
3 |
import torch
|
4 |
import spaces
|
5 |
+
from peft import PeftModel
|
6 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
7 |
|
8 |
# Load model and tokenizer if a GPU is available
|
9 |
if torch.cuda.is_available():
|
10 |
+
model_id = "allenai/OLMo-7B-Instruct"
|
11 |
+
adapters_name = "yilunzhao/olmo-finetuned"
|
12 |
model = AutoModelForCausalLM.from_pretrained(model_id, device_map="auto", trust_remote_code=True)
|
13 |
+
model = PeftModel.from_pretrained(model, adapters_name)
|
14 |
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
|
15 |
else:
|
16 |
raise EnvironmentError("CUDA device not available. Please run on a GPU-enabled environment.")
|