Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Llama Recipes
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mirrored_repos
MachineLearning
meta-llama
Llama Recipes
Commits
98fcc538
Unverified
Commit
98fcc538
authored
1 year ago
by
Hamid Shojanazeri
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Plain Diff
Add option to enable Llamaguard content safety check in chat_completion (#354)
parents
d89a02fe
ed3e11e9
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
examples/chat_completion/chat_completion.py
+2
-0
2 additions, 0 deletions
examples/chat_completion/chat_completion.py
with
2 additions
and
0 deletions
examples/chat_completion/chat_completion.py
+
2
−
0
View file @
98fcc538
...
@@ -35,6 +35,7 @@ def main(
...
@@ -35,6 +35,7 @@ def main(
enable_sensitive_topics
:
bool
=
False
,
# Enable check for sensitive topics using AuditNLG APIs
enable_sensitive_topics
:
bool
=
False
,
# Enable check for sensitive topics using AuditNLG APIs
enable_saleforce_content_safety
:
bool
=
True
,
# Enable safety check woth Saleforce safety flan t5
enable_saleforce_content_safety
:
bool
=
True
,
# Enable safety check woth Saleforce safety flan t5
use_fast_kernels
:
bool
=
False
,
# Enable using SDPA from PyTorch Accelerated Transformers, make use Flash Attention and Xformer memory-efficient kernels
use_fast_kernels
:
bool
=
False
,
# Enable using SDPA from PyTorch Accelerated Transformers, make use Flash Attention and Xformer memory-efficient kernels
enable_llamaguard_content_safety
:
bool
=
False
,
**
kwargs
**
kwargs
):
):
if
prompt_file
is
not
None
:
if
prompt_file
is
not
None
:
...
@@ -90,6 +91,7 @@ def main(
...
@@ -90,6 +91,7 @@ def main(
safety_checker
=
get_safety_checker
(
enable_azure_content_safety
,
safety_checker
=
get_safety_checker
(
enable_azure_content_safety
,
enable_sensitive_topics
,
enable_sensitive_topics
,
enable_saleforce_content_safety
,
enable_saleforce_content_safety
,
enable_llamaguard_content_safety
,
)
)
# Safety check of the user prompt
# Safety check of the user prompt
safety_results
=
[
check
(
dialogs
[
idx
][
0
][
"
content
"
])
for
check
in
safety_checker
]
safety_results
=
[
check
(
dialogs
[
idx
][
0
][
"
content
"
])
for
check
in
safety_checker
]
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment