Update app.py
Browse files
app.py
CHANGED
@@ -4,38 +4,10 @@ import streamlit as st
|
|
4 |
import numpy as np
|
5 |
import torch
|
6 |
|
7 |
-
@st.cache_resource
|
8 |
-
def get_model():
|
9 |
-
tokenizer = AutoTokenizer.from_pretrained("onurnsfw/Gemma2-9b-classifier")
|
10 |
-
model = AutoModelForCausalLM.from_pretrained("onurnsfw/Gemma2-9b-classifier")
|
11 |
-
return tokenizer,model
|
12 |
|
13 |
-
|
14 |
|
15 |
-
|
16 |
-
|
|
|
17 |
|
18 |
-
if user_input and button :
|
19 |
-
alpaca_prompt = """Below is an instruction that describes a task, paired with an input that provides further context. Write a response that appropriately completes the request.
|
20 |
-
|
21 |
-
### Instruction:
|
22 |
-
{}
|
23 |
-
|
24 |
-
### Input:
|
25 |
-
{}
|
26 |
-
|
27 |
-
### Response:
|
28 |
-
{}"""
|
29 |
-
|
30 |
-
inputs = tokenizer(
|
31 |
-
[
|
32 |
-
alpaca_prompt.format(
|
33 |
-
"Match the potential use case with the corresponding activity and emission values based on the provided context.", # instruction
|
34 |
-
"{user_input}",
|
35 |
-
"",
|
36 |
-
)
|
37 |
-
], return_tensors = "pt").to("cuda")
|
38 |
-
|
39 |
-
outputs = model.generate(**inputs, max_new_tokens = 64, use_cache = True)
|
40 |
-
|
41 |
-
st.write("Prediction: ",tokenizer.batch_decode(outputs))
|
|
|
4 |
import numpy as np
|
5 |
import torch
|
6 |
|
|
|
|
|
|
|
|
|
|
|
7 |
|
8 |
+
from typing import Dict, List, Union
|
9 |
|
10 |
+
from google.cloud import aiplatform
|
11 |
+
from google.protobuf import json_format
|
12 |
+
from google.protobuf.struct_pb2 import Value
|
13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|