Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] authored and Ankur-singh committed Jan 27, 2025
1 parent cddfa3c commit 3ad7a86
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 2 additions & 3 deletions comps/guardrails/src/polite_guard/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

## Introduction

The Polite Guard Microservice allows AI application developers to ensure that user input and Large Language Model (LLM) outputs remain polite and respectful. By leveraging, [Polite Guard](https://huggingface.co/Intel/polite-guard), a fine-tuned Transformer model for politeness classification, this lightweight guardrails microservice ensures courteous interactions without significantly sacrificing performance, making it suitable for deployment on both Intel Gaudi and Xeon.
The Polite Guard Microservice allows AI application developers to ensure that user input and Large Language Model (LLM) outputs remain polite and respectful. By leveraging, [Polite Guard](https://huggingface.co/Intel/polite-guard), a fine-tuned Transformer model for politeness classification, this lightweight guardrails microservice ensures courteous interactions without significantly sacrificing performance, making it suitable for deployment on both Intel Gaudi and Xeon.

Politeness plays a crucial role in creating a positive and respectful environment. The service classifies text into four categories: *polite*, *somewhat polite*, *neutral*, and *impolite*. Any *impolite* text is rejected, along with a score, ensuring that systems maintain a courteous tone.
Politeness plays a crucial role in creating a positive and respectful environment. The service classifies text into four categories: _polite_, _somewhat polite_, _neutral_, and _impolite_. Any _impolite_ text is rejected, along with a score, ensuring that systems maintain a courteous tone.

More details about the Polite Guard model can be found [here](https://github.com/intel/polite-guard).


## 🚀1. Start Microservice with Python(Option 1)

### 1.1 Install Requirements
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ async def invoke(self, input: str):
"""
response = await asyncio.to_thread(self.polite_pipeline, input)
if response[0]["label"] == "impolite":
return TextDoc(text=f"Violated policies: Impolite (score: {response[0]['score']:0.2f}), please check your input.", downstream_black_list=[".*"])
return TextDoc(
text=f"Violated policies: Impolite (score: {response[0]['score']:0.2f}), please check your input.",
downstream_black_list=[".*"],
)
else:
return TextDoc(text=input)

Expand Down

0 comments on commit 3ad7a86

Please sign in to comment.