Spaces:
Sleeping
Sleeping
Commit
·
514ce55
1
Parent(s):
f3e59d7
huggingface login?
Browse files- app.py +7 -3
- requirements.txt +2 -1
app.py
CHANGED
@@ -4,11 +4,15 @@ import uuid
|
|
4 |
import gradio as gr
|
5 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
6 |
import torch
|
|
|
|
|
|
|
|
|
7 |
|
8 |
# Load model and tokenizer
|
9 |
model_name = "meta-llama/Meta-Llama-3.1-8B-Instruct"
|
10 |
-
tokenizer = AutoTokenizer.from_pretrained(model_name)
|
11 |
-
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.float16, device_map="auto")
|
12 |
|
13 |
def chat_with_model(messages):
|
14 |
input_ids = tokenizer.encode(str(messages), return_tensors="pt").to(model.device)
|
@@ -41,4 +45,4 @@ def main():
|
|
41 |
demo.launch()
|
42 |
|
43 |
if __name__ == "__main__":
|
44 |
-
main()
|
|
|
4 |
import gradio as gr
|
5 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
6 |
import torch
|
7 |
+
from huggingface_hub import login
|
8 |
+
|
9 |
+
# Authenticate with Hugging Face
|
10 |
+
login()
|
11 |
|
12 |
# Load model and tokenizer
|
13 |
model_name = "meta-llama/Meta-Llama-3.1-8B-Instruct"
|
14 |
+
tokenizer = AutoTokenizer.from_pretrained(model_name, use_auth_token=True)
|
15 |
+
model = AutoModelForCausalLM.from_pretrained(model_name, torch_dtype=torch.float16, device_map="auto", use_auth_token=True)
|
16 |
|
17 |
def chat_with_model(messages):
|
18 |
input_ids = tokenizer.encode(str(messages), return_tensors="pt").to(model.device)
|
|
|
45 |
demo.launch()
|
46 |
|
47 |
if __name__ == "__main__":
|
48 |
+
main()
|
requirements.txt
CHANGED
@@ -1,2 +1,3 @@
|
|
1 |
transformers
|
2 |
-
torch
|
|
|
|
1 |
transformers
|
2 |
+
torch
|
3 |
+
huggingface_hub
|