Update app.py
Browse files
app.py
CHANGED
@@ -1,10 +1,13 @@
|
|
|
|
1 |
import spaces
|
2 |
import torch
|
3 |
import transformers
|
4 |
import gradio as gr
|
5 |
|
6 |
-
|
7 |
|
|
|
|
|
8 |
model_id = "meta-llama/Meta-Llama-3.1-8B-Instruct"
|
9 |
|
10 |
pipeline = transformers.pipeline(
|
@@ -12,6 +15,7 @@ pipeline = transformers.pipeline(
|
|
12 |
model=model_id,
|
13 |
model_kwargs={"torch_dtype": torch.bfloat16},
|
14 |
device_map="auto",
|
|
|
15 |
)
|
16 |
|
17 |
@spaces.GPU
|
@@ -21,19 +25,6 @@ def generate_text(input_text):
|
|
21 |
output = pipeline(prompt,
|
22 |
max_new_tokens=256,
|
23 |
)
|
24 |
-
# input_tokens = model.tokenizer(input_text,
|
25 |
-
# return_tensors="np",
|
26 |
-
# return_attention_mask=False,
|
27 |
-
# truncation=True,
|
28 |
-
# max_length=MAX_LENGTH,
|
29 |
-
# padding=False)
|
30 |
-
|
31 |
-
|
32 |
-
# output = model.generate(mx.array(input_tokens['input_ids']),
|
33 |
-
# max_new_tokens=20,
|
34 |
-
# use_cache=True,
|
35 |
-
# return_dict_in_generate=True)
|
36 |
-
|
37 |
return output
|
38 |
|
39 |
|
|
|
1 |
+
import os
|
2 |
import spaces
|
3 |
import torch
|
4 |
import transformers
|
5 |
import gradio as gr
|
6 |
|
7 |
+
from dotenv import load_dotenv
|
8 |
|
9 |
+
load_dotenv()
|
10 |
+
access_token = os.("HF_ACCESS_TOKEN")
|
11 |
model_id = "meta-llama/Meta-Llama-3.1-8B-Instruct"
|
12 |
|
13 |
pipeline = transformers.pipeline(
|
|
|
15 |
model=model_id,
|
16 |
model_kwargs={"torch_dtype": torch.bfloat16},
|
17 |
device_map="auto",
|
18 |
+
token=HF_ACCESS_TOKEN
|
19 |
)
|
20 |
|
21 |
@spaces.GPU
|
|
|
25 |
output = pipeline(prompt,
|
26 |
max_new_tokens=256,
|
27 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
return output
|
29 |
|
30 |
|