Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -2,14 +2,21 @@ import gradio as gr
|
|
2 |
import torch
|
3 |
from transformers import AutoModelForCausalLM, AutoTokenizer, AutoModel
|
4 |
from transformers import StoppingCriteria, StoppingCriteriaList, TextIteratorStreamer
|
|
|
5 |
from threading import Thread
|
6 |
|
7 |
# Loading the tokenizer and model from Hugging Face's model hub.
|
8 |
# model_name_or_path = "TinyLlama/TinyLlama-1.1B-Chat-v1.0"
|
9 |
model_name_or_path = "Flmc/DISC-MedLLM"
|
10 |
-
tokenizer = AutoTokenizer.from_pretrained(model_name_or_path,trust_remote_code=True)
|
11 |
# model = AutoModelForCausalLM.from_pretrained(model_name,trust_remote_code=True)
|
12 |
-
model = AutoModel.from_pretrained(model_name_or_path, trust_remote_code=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
# using CUDA for an optimal experience
|
15 |
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
|
|
2 |
import torch
|
3 |
from transformers import AutoModelForCausalLM, AutoTokenizer, AutoModel
|
4 |
from transformers import StoppingCriteria, StoppingCriteriaList, TextIteratorStreamer
|
5 |
+
from transformers.generation.utils import GenerationConfig
|
6 |
from threading import Thread
|
7 |
|
8 |
# Loading the tokenizer and model from Hugging Face's model hub.
|
9 |
# model_name_or_path = "TinyLlama/TinyLlama-1.1B-Chat-v1.0"
|
10 |
model_name_or_path = "Flmc/DISC-MedLLM"
|
11 |
+
# tokenizer = AutoTokenizer.from_pretrained(model_name_or_path,trust_remote_code=True)
|
12 |
# model = AutoModelForCausalLM.from_pretrained(model_name,trust_remote_code=True)
|
13 |
+
# model = AutoModel.from_pretrained(model_name_or_path, trust_remote_code=True)
|
14 |
+
|
15 |
+
|
16 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name_or_path, use_fast=False, trust_remote_code=True)
|
17 |
+
model = AutoModelForCausalLM.from_pretrained(model_name_or_path, device_map="auto", torch_dtype=torch.float16, trust_remote_code=True)
|
18 |
+
model.generation_config = GenerationConfig.from_pretrained(model_name_or_path)
|
19 |
+
|
20 |
|
21 |
# using CUDA for an optimal experience
|
22 |
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|