Update app.py
Browse files
app.py
CHANGED
@@ -2,6 +2,7 @@ import gradio as gr
|
|
2 |
|
3 |
import os, sys
|
4 |
from transformers import AutoTokenizer, AutoModelForCausalLM, GenerationConfig, pipeline
|
|
|
5 |
import torch
|
6 |
import spaces
|
7 |
import psutil
|
@@ -13,9 +14,10 @@ REPO_NAME = 'schuler/experimental-JP47D21-KPhi-3-micro-4k-instruct'
|
|
13 |
# How to cache?
|
14 |
@spaces.GPU()
|
15 |
def load_model(repo_name):
|
16 |
-
tokenizer = AutoTokenizer.from_pretrained(
|
17 |
-
|
18 |
-
|
|
|
19 |
# model.to('cuda')
|
20 |
return tokenizer, generator_conf, model
|
21 |
|
|
|
2 |
|
3 |
import os, sys
|
4 |
from transformers import AutoTokenizer, AutoModelForCausalLM, GenerationConfig, pipeline
|
5 |
+
from transformers import LlamaTokenizer
|
6 |
import torch
|
7 |
import spaces
|
8 |
import psutil
|
|
|
14 |
# How to cache?
|
15 |
@spaces.GPU()
|
16 |
def load_model(repo_name):
|
17 |
+
# tokenizer = AutoTokenizer.from_pretrained(REPO_NAME, trust_remote_code=True)
|
18 |
+
tokenizer = LlamaTokenizer.from_pretrained(REPO_NAME, trust_remote_code=True)
|
19 |
+
generator_conf = GenerationConfig.from_pretrained(REPO_NAME)
|
20 |
+
model = AutoModelForCausalLM.from_pretrained(REPO_NAME, trust_remote_code=True, torch_dtype=torch.bfloat16, attn_implementation="eager")
|
21 |
# model.to('cuda')
|
22 |
return tokenizer, generator_conf, model
|
23 |
|