Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -20,6 +20,7 @@ ROLE_TOKENS = {
|
|
| 20 |
|
| 21 |
CONTEXT_SIZE = 4000
|
| 22 |
ENABLE_GPU = True
|
|
|
|
| 23 |
|
| 24 |
# Create a lock object
|
| 25 |
lock = threading.Lock()
|
|
@@ -50,7 +51,7 @@ model = None
|
|
| 50 |
model_path = snapshot_download(repo_id=repo_name, allow_patterns=model_name) + '/' + model_name
|
| 51 |
app.logger.info('Model path: ' + model_path)
|
| 52 |
|
| 53 |
-
def init_model(context_size, enable_gpu=False, gpu_layer_number=
|
| 54 |
global model
|
| 55 |
|
| 56 |
if model is not None:
|
|
@@ -83,7 +84,7 @@ def init_model(context_size, enable_gpu=False, gpu_layer_number=83):
|
|
| 83 |
)
|
| 84 |
return model
|
| 85 |
|
| 86 |
-
init_model(CONTEXT_SIZE, ENABLE_GPU,
|
| 87 |
|
| 88 |
def get_message_tokens(model, role, content):
|
| 89 |
message_tokens = model.tokenize(content.encode("utf-8"))
|
|
@@ -138,7 +139,7 @@ def handler_change_context_size():
|
|
| 138 |
stop_generation = True
|
| 139 |
|
| 140 |
new_size = int(request.args.get('size', CONTEXT_SIZE))
|
| 141 |
-
init_model(new_size, enable_gpu=ENABLE_GPU)
|
| 142 |
|
| 143 |
return Response('Size changed', content_type='text/plain')
|
| 144 |
|
|
|
|
| 20 |
|
| 21 |
CONTEXT_SIZE = 4000
|
| 22 |
ENABLE_GPU = True
|
| 23 |
+
GPU_LAYERS = 83
|
| 24 |
|
| 25 |
# Create a lock object
|
| 26 |
lock = threading.Lock()
|
|
|
|
| 51 |
model_path = snapshot_download(repo_id=repo_name, allow_patterns=model_name) + '/' + model_name
|
| 52 |
app.logger.info('Model path: ' + model_path)
|
| 53 |
|
| 54 |
+
def init_model(context_size, enable_gpu=False, gpu_layer_number=35):
|
| 55 |
global model
|
| 56 |
|
| 57 |
if model is not None:
|
|
|
|
| 84 |
)
|
| 85 |
return model
|
| 86 |
|
| 87 |
+
init_model(CONTEXT_SIZE, ENABLE_GPU, GPU_LAYERS)
|
| 88 |
|
| 89 |
def get_message_tokens(model, role, content):
|
| 90 |
message_tokens = model.tokenize(content.encode("utf-8"))
|
|
|
|
| 139 |
stop_generation = True
|
| 140 |
|
| 141 |
new_size = int(request.args.get('size', CONTEXT_SIZE))
|
| 142 |
+
init_model(new_size, enable_gpu=ENABLE_GPU, GPU_LAYERS)
|
| 143 |
|
| 144 |
return Response('Size changed', content_type='text/plain')
|
| 145 |
|