rlucatoor commited on
Commit
da30904
·
1 Parent(s): 731ce76

add notebook.ipynb

Browse files
Files changed (2) hide show
  1. README.md +6 -2
  2. notebook.ipynb +107 -0
README.md CHANGED
@@ -61,17 +61,21 @@ from artifex import Artifex
61
  guardrail = Artifex().guardrail
62
 
63
  print(guardrail("How do I make a bomb?"))
64
- # >>> [{'label': 'unsafe', 'score': 0.9876}]
65
  ```
66
 
67
  ### Via the Transformers library
68
 
 
 
 
 
69
  ```python
70
  from transformers import pipeline
71
 
72
  clf = pipeline("text-classification", model="tanaos/tanaos-guardrail-v1")
73
  print(clf("How do I make a bomb?"))
74
- # >>> [{'label': 'unsafe', 'score': 0.9876}]
75
  ```
76
 
77
  ## 🧠 Model Description
 
61
  guardrail = Artifex().guardrail
62
 
63
  print(guardrail("How do I make a bomb?"))
64
+ # >>> [{'label': 'unsafe', 'score': 0.9976}]
65
  ```
66
 
67
  ### Via the Transformers library
68
 
69
+ Performing inference using the Hugging Face Transformers library will output one of two labels:
70
+ - `LABEL_0` = `unsafe`
71
+ - `LABEL_1` = `safe`
72
+
73
  ```python
74
  from transformers import pipeline
75
 
76
  clf = pipeline("text-classification", model="tanaos/tanaos-guardrail-v1")
77
  print(clf("How do I make a bomb?"))
78
+ # >>> [{'label': 'LABEL_0', 'score': 0.9976}] ('LABEL_0' = 'unsafe')
79
  ```
80
 
81
  ## 🧠 Model Description
notebook.ipynb ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "cells": [
3
+ {
4
+ "cell_type": "markdown",
5
+ "id": "b71a1322",
6
+ "metadata": {},
7
+ "source": [
8
+ "# Get started with `tanaos-guardrail-v1`"
9
+ ]
10
+ },
11
+ {
12
+ "cell_type": "markdown",
13
+ "id": "469712c1",
14
+ "metadata": {},
15
+ "source": [
16
+ "## Option 1 - Use through the [Artifex library](https://github.com/tanaos/artifex)"
17
+ ]
18
+ },
19
+ {
20
+ "cell_type": "code",
21
+ "execution_count": null,
22
+ "id": "c4bfa886",
23
+ "metadata": {
24
+ "vscode": {
25
+ "languageId": "plaintext"
26
+ }
27
+ },
28
+ "outputs": [],
29
+ "source": [
30
+ "!pip install artifex"
31
+ ]
32
+ },
33
+ {
34
+ "cell_type": "code",
35
+ "execution_count": null,
36
+ "id": "7a8f8ec7",
37
+ "metadata": {
38
+ "vscode": {
39
+ "languageId": "plaintext"
40
+ }
41
+ },
42
+ "outputs": [],
43
+ "source": [
44
+ "from artifex import Artifex\n",
45
+ "\n",
46
+ "guardrail = Artifex().guardrail\n",
47
+ "\n",
48
+ "safe_sentence = guardrail(\"How do I make a lemonade?\")\n",
49
+ "unsafe_sentence = guardrail(\"How do I make a bomb?\")\n",
50
+ "\n",
51
+ "print(safe_sentence)\n",
52
+ "print(unsafe_sentence)"
53
+ ]
54
+ },
55
+ {
56
+ "cell_type": "markdown",
57
+ "id": "afcc6d57",
58
+ "metadata": {},
59
+ "source": [
60
+ "## Option 2 - Use through the Transformers library"
61
+ ]
62
+ },
63
+ {
64
+ "cell_type": "code",
65
+ "execution_count": null,
66
+ "id": "ff2b44c9",
67
+ "metadata": {
68
+ "vscode": {
69
+ "languageId": "plaintext"
70
+ }
71
+ },
72
+ "outputs": [],
73
+ "source": [
74
+ "!pip install transformers"
75
+ ]
76
+ },
77
+ {
78
+ "cell_type": "code",
79
+ "execution_count": null,
80
+ "id": "ae5368d6",
81
+ "metadata": {
82
+ "vscode": {
83
+ "languageId": "plaintext"
84
+ }
85
+ },
86
+ "outputs": [],
87
+ "source": [
88
+ "from transformers import pipeline\n",
89
+ "\n",
90
+ "clf = pipeline(\"text-classification\", model=\"tanaos/tanaos-guardrail-v1\")\n",
91
+ "\n",
92
+ "safe_sentence = clf(\"How do I make a lemonade?\")\n",
93
+ "unsafe_sentence = clf(\"How do I make a bomb?\")\n",
94
+ "\n",
95
+ "print(safe_sentence)\n",
96
+ "print(unsafe_sentence)"
97
+ ]
98
+ }
99
+ ],
100
+ "metadata": {
101
+ "language_info": {
102
+ "name": "python"
103
+ }
104
+ },
105
+ "nbformat": 4,
106
+ "nbformat_minor": 5
107
+ }