gated model
Browse files
app.py
CHANGED
@@ -1,7 +1,16 @@
|
|
|
|
1 |
import gradio as gr
|
2 |
import torch
|
3 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
4 |
from trl import AutoModelForCausalLMWithValueHead
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
# Set device and dtype
|
7 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
|
|
1 |
+
import os
|
2 |
import gradio as gr
|
3 |
import torch
|
4 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
5 |
from trl import AutoModelForCausalLMWithValueHead
|
6 |
+
from huggingface_hub import login
|
7 |
+
|
8 |
+
# Set your Hugging Face token as an environment variable
|
9 |
+
# You can also use os.environ["HUGGINGFACE_TOKEN"] = "your_token_here" in your code
|
10 |
+
# But using environment variables outside the code is more secure
|
11 |
+
|
12 |
+
# Authenticate with Hugging Face
|
13 |
+
login(token=os.environ.get("LA_NAME"))
|
14 |
|
15 |
# Set device and dtype
|
16 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|