Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -90,13 +90,20 @@ class RAGSystem:
|
|
| 90 |
)
|
| 91 |
|
| 92 |
# Initialize model and tokenizer
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
self.tokenizer = AutoTokenizer.from_pretrained(
|
| 94 |
self.model_name,
|
|
|
|
| 95 |
trust_remote_code=True
|
| 96 |
)
|
| 97 |
|
| 98 |
self.model = AutoModelForCausalLM.from_pretrained(
|
| 99 |
self.model_name,
|
|
|
|
| 100 |
torch_dtype=torch.float16,
|
| 101 |
trust_remote_code=True,
|
| 102 |
device_map="auto"
|
|
|
|
| 90 |
)
|
| 91 |
|
| 92 |
# Initialize model and tokenizer
|
| 93 |
+
# Get HuggingFace token
|
| 94 |
+
hf_token = os.environ.get('HUGGINGFACE_TOKEN') or os.environ.get('HF_TOKEN')
|
| 95 |
+
if not hf_token:
|
| 96 |
+
raise ValueError("No Hugging Face token found. Please set HUGGINGFACE_TOKEN in your environment variables")
|
| 97 |
+
|
| 98 |
self.tokenizer = AutoTokenizer.from_pretrained(
|
| 99 |
self.model_name,
|
| 100 |
+
token=hf_token, # Add token here
|
| 101 |
trust_remote_code=True
|
| 102 |
)
|
| 103 |
|
| 104 |
self.model = AutoModelForCausalLM.from_pretrained(
|
| 105 |
self.model_name,
|
| 106 |
+
token=hf_token, # Add token here
|
| 107 |
torch_dtype=torch.float16,
|
| 108 |
trust_remote_code=True,
|
| 109 |
device_map="auto"
|