pratikshahp
commited on
Update hf_guardrail.py
Browse files- hf_guardrail.py +4 -1
hf_guardrail.py
CHANGED
@@ -1,9 +1,12 @@
|
|
1 |
from transformers import pipeline
|
2 |
import os
|
|
|
|
|
|
|
|
|
3 |
|
4 |
# Initialize Hugging Face pipeline for text classification or question-answering task
|
5 |
model_name = "meta-llama/Meta-Llama-Guard-3-8B" # Use a safety guard model or choose a suitable Hugging Face model
|
6 |
-
hf_token = os.getenv('HF_TOKEN')
|
7 |
|
8 |
# Load the Hugging Face model and tokenizer for safety checking (using Hugging Face's `pipeline` API)
|
9 |
safety_model = pipeline('text-generation', model=model_name, use_auth_token=hf_token)
|
|
|
1 |
from transformers import pipeline
|
2 |
import os
|
3 |
+
from dotenv import load_dotenv
|
4 |
+
|
5 |
+
load_dotenv()
|
6 |
+
hf_token = os.getenv('HF_TOKEN')
|
7 |
|
8 |
# Initialize Hugging Face pipeline for text classification or question-answering task
|
9 |
model_name = "meta-llama/Meta-Llama-Guard-3-8B" # Use a safety guard model or choose a suitable Hugging Face model
|
|
|
10 |
|
11 |
# Load the Hugging Face model and tokenizer for safety checking (using Hugging Face's `pipeline` API)
|
12 |
safety_model = pipeline('text-generation', model=model_name, use_auth_token=hf_token)
|