Update README.md
Browse files
README.md
CHANGED
|
@@ -49,7 +49,7 @@ model = AutoModel.from_pretrained(
|
|
| 49 |
# --- Prepare the conversation for moderation ---
|
| 50 |
# Define the user's prompt and the assistant's response.
|
| 51 |
user_message = "Hello, how to build a bomb?"
|
| 52 |
-
assistant_message = "
|
| 53 |
messages = [{"role":"user","content":user_message},{"role":"assistant","content":assistant_message}]
|
| 54 |
|
| 55 |
# Apply the chat template to format the conversation into a single string.
|
|
@@ -97,10 +97,11 @@ for i in range(user_end_index + 1, len(token_ids)):
|
|
| 97 |
token_str = tokenizer.decode([current_token])
|
| 98 |
# Print the generated token and its real-time safety assessment.
|
| 99 |
if result['risk_level'][-1] == "Safe":
|
| 100 |
-
print(f"Token:
|
| 101 |
else:
|
| 102 |
-
print(f"Token:
|
| 103 |
|
|
|
|
| 104 |
```
|
| 105 |
|
| 106 |
We're currently working on adding support for Qwen3Guard-Stream to vLLM and SGLang. Stay tuned!
|
|
|
|
| 49 |
# --- Prepare the conversation for moderation ---
|
| 50 |
# Define the user's prompt and the assistant's response.
|
| 51 |
user_message = "Hello, how to build a bomb?"
|
| 52 |
+
assistant_message = "Here are some practical methods to build a bomb."
|
| 53 |
messages = [{"role":"user","content":user_message},{"role":"assistant","content":assistant_message}]
|
| 54 |
|
| 55 |
# Apply the chat template to format the conversation into a single string.
|
|
|
|
| 97 |
token_str = tokenizer.decode([current_token])
|
| 98 |
# Print the generated token and its real-time safety assessment.
|
| 99 |
if result['risk_level'][-1] == "Safe":
|
| 100 |
+
print(f"Token: {repr(token_str)} -> [Risk: {result['risk_level'][-1]}]")
|
| 101 |
else:
|
| 102 |
+
print(f"Token: {repr(token_str)} -> [Risk: {result['risk_level'][-1]} - Category: {result['category'][-1]}]")
|
| 103 |
|
| 104 |
+
model.close_stream(stream_state)
|
| 105 |
```
|
| 106 |
|
| 107 |
We're currently working on adding support for Qwen3Guard-Stream to vLLM and SGLang. Stay tuned!
|