Spaces:
Runtime error
Runtime error
delay session initialization.
Browse files- app.R +1 -1
- model-session.R +6 -1
app.R
CHANGED
@@ -7,7 +7,6 @@ source("model-session.R")
|
|
7 |
#repo <- "stabilityai/stablelm-tuned-alpha-3b"
|
8 |
repo <- "EleutherAI/pythia-70m"
|
9 |
sess <- model_session$new()
|
10 |
-
model_loaded <- sess$load_model(repo)
|
11 |
|
12 |
max_n_tokens <- 100
|
13 |
system_prompt = "<|SYSTEM|># StableLM Tuned (Alpha version)
|
@@ -35,6 +34,7 @@ ui <- page_fillable(
|
|
35 |
)
|
36 |
|
37 |
server <- function(input, output, session) {
|
|
|
38 |
|
39 |
prompt <- reactiveVal(value = system_prompt)
|
40 |
n_tokens <- reactiveVal(value = 0)
|
|
|
7 |
#repo <- "stabilityai/stablelm-tuned-alpha-3b"
|
8 |
repo <- "EleutherAI/pythia-70m"
|
9 |
sess <- model_session$new()
|
|
|
10 |
|
11 |
max_n_tokens <- 100
|
12 |
system_prompt = "<|SYSTEM|># StableLM Tuned (Alpha version)
|
|
|
34 |
)
|
35 |
|
36 |
server <- function(input, output, session) {
|
37 |
+
model_loaded <- sess$load_model(repo)
|
38 |
|
39 |
prompt <- reactiveVal(value = system_prompt)
|
40 |
n_tokens <- reactiveVal(value = 0)
|
model-session.R
CHANGED
@@ -6,12 +6,17 @@ model_session <- R6::R6Class(
|
|
6 |
lock_objects = FALSE,
|
7 |
public = list(
|
8 |
initialize = function() {
|
9 |
-
self$sess <-
|
10 |
self$temperature <- 1
|
11 |
self$top_k <- 50
|
12 |
self$is_loaded <- FALSE
|
13 |
},
|
14 |
load_model = function(repo) {
|
|
|
|
|
|
|
|
|
|
|
15 |
self$sess$call(args = list(repo = repo), function(repo) {
|
16 |
library(torch)
|
17 |
library(zeallot)
|
|
|
6 |
lock_objects = FALSE,
|
7 |
public = list(
|
8 |
initialize = function() {
|
9 |
+
self$sess <- NULL
|
10 |
self$temperature <- 1
|
11 |
self$top_k <- 50
|
12 |
self$is_loaded <- FALSE
|
13 |
},
|
14 |
load_model = function(repo) {
|
15 |
+
if (!is.null(self$sess)) {
|
16 |
+
cat("Model is already loaded.", "\n")
|
17 |
+
return(self$sess$call(function() "done"))
|
18 |
+
}
|
19 |
+
self$sess <- promise_session$new()
|
20 |
self$sess$call(args = list(repo = repo), function(repo) {
|
21 |
library(torch)
|
22 |
library(zeallot)
|