Spaces:
Runtime error
Runtime error
gmerrill
commited on
Commit
·
bd8563e
1
Parent(s):
301ea74
update
Browse files
main.py
CHANGED
@@ -4,6 +4,7 @@ from fastapi.responses import FileResponse
|
|
4 |
from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
|
5 |
import datetime
|
6 |
import json
|
|
|
7 |
import torch
|
8 |
|
9 |
def log(msg):
|
@@ -28,12 +29,18 @@ def get_prompt(user_query: str, functions: list = []) -> str:
|
|
28 |
device : str = "cuda:0" if torch.cuda.is_available() else "cpu"
|
29 |
torch_dtype = torch.float16 if torch.cuda.is_available() else torch.float32
|
30 |
|
|
|
|
|
|
|
31 |
model_id : str = "gorilla-llm/gorilla-openfunctions-v1"
|
32 |
log('AutoTokenizer.from_pretrained ...')
|
33 |
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
34 |
log('AutoModelForCausalLM.from_pretrained ...')
|
35 |
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch_dtype, low_cpu_mem_usage=True)
|
36 |
|
|
|
|
|
|
|
37 |
log('mode.to(device) ...')
|
38 |
model.to(device)
|
39 |
|
|
|
4 |
from transformers import AutoTokenizer, AutoModelForCausalLM, pipeline
|
5 |
import datetime
|
6 |
import json
|
7 |
+
import subprocess
|
8 |
import torch
|
9 |
|
10 |
def log(msg):
|
|
|
29 |
device : str = "cuda:0" if torch.cuda.is_available() else "cpu"
|
30 |
torch_dtype = torch.float16 if torch.cuda.is_available() else torch.float32
|
31 |
|
32 |
+
result = subprocess.run('ls -lh /.cache/huggingface/hub', shell=True, capture_output=True, text=True)
|
33 |
+
log('Cache files: ' + result.stdout)
|
34 |
+
|
35 |
model_id : str = "gorilla-llm/gorilla-openfunctions-v1"
|
36 |
log('AutoTokenizer.from_pretrained ...')
|
37 |
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
38 |
log('AutoModelForCausalLM.from_pretrained ...')
|
39 |
model = AutoModelForCausalLM.from_pretrained(model_id, torch_dtype=torch_dtype, low_cpu_mem_usage=True)
|
40 |
|
41 |
+
result = subprocess.run('ls -lh /.cache/huggingface/hub', shell=True, capture_output=True, text=True)
|
42 |
+
log('Cache files: ' + result.stdout)
|
43 |
+
|
44 |
log('mode.to(device) ...')
|
45 |
model.to(device)
|
46 |
|