Update README.md
Browse files
README.md
CHANGED
|
@@ -61,21 +61,27 @@ A **fast, accurate Small Language Model (SLM)** that detects secrets in code bef
|
|
| 61 |
```python
|
| 62 |
from transformers import pipeline
|
| 63 |
|
|
|
|
| 64 |
classifier = pipeline(
|
| 65 |
"text-classification",
|
| 66 |
model="hypn05/secrets-sentinel"
|
| 67 |
)
|
| 68 |
|
| 69 |
-
#
|
| 70 |
-
|
| 71 |
-
"password='supersecret123'", #
|
| 72 |
-
"api_key = 'sk-1234567890abc'", #
|
| 73 |
-
"print('Hello, world!')", #
|
| 74 |
-
"def calculate_sum(a, b):", #
|
| 75 |
-
]
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
```
|
| 80 |
|
| 81 |
## Advanced Usage
|
|
|
|
| 61 |
```python
|
| 62 |
from transformers import pipeline
|
| 63 |
|
| 64 |
+
# Load the pipeline with the secrets detection model
|
| 65 |
classifier = pipeline(
|
| 66 |
"text-classification",
|
| 67 |
model="hypn05/secrets-sentinel"
|
| 68 |
)
|
| 69 |
|
| 70 |
+
# Define the input examples
|
| 71 |
+
inputs = [
|
| 72 |
+
"password='supersecret123'", # Expected: Secret
|
| 73 |
+
"api_key = 'sk-1234567890abc'", # Expected: Secret
|
| 74 |
+
"print('Hello, world!')", # Expected: Safe
|
| 75 |
+
"def calculate_sum(a, b):", # Expected: Safe
|
| 76 |
+
]
|
| 77 |
+
|
| 78 |
+
# Run the classifier on the inputs
|
| 79 |
+
results = classifier(inputs)
|
| 80 |
+
|
| 81 |
+
# Print the actual input string and the result ("Secret" if LABEL_1, else "Safe")
|
| 82 |
+
for input_text, result in zip(inputs, results):
|
| 83 |
+
label = "Secret" if result['label'] == "LABEL_1" else "Safe"
|
| 84 |
+
print(f"{label} | {input_text}")
|
| 85 |
```
|
| 86 |
|
| 87 |
## Advanced Usage
|