GPT3 for Organization: Privacy check to avoid information leakage
GPT-3 can be a powerful tool for employees in an organization like banking as it can assist them in performing their daily tasks more efficiently and accurately. However, it is important to ensure that the use of GPT-3 does not result in any information leakage or privacy violations. A prompt checker can be used to filter sensitive information like bank account numbers and IDs from being shared with GPT-3.
Here’s a simple program that can act as a GPT-3 prompt checker to ensure that no user information such as account numbers, bank numbers, or IDs are shared with ChatGPT:
import re
import openai
# Define regular expressions for patterns to be avoided
patterns_to_avoid = [
r'\d{10}', # 10-digit numbers (e.g. phone numbers)
r'\b\d{16}\b', # 16-digit numbers (e.g. credit card numbers)
r'\b\d{9}\b', # 9-digit numbers (e.g. social security numbers)
r'account\s*no', # Phrases containing "account no"
r'bank\s*no', # Phrases containing "bank no"
r'id' # Phrases containing "id"
]
def check_prompt(prompt):
"""
Checks if the prompt contains any user information that should be avoided
"""
for pattern in patterns_to_avoid:
match = re.search(pattern, prompt, re.IGNORECASE)
if match:
return False
return True
openai.api_key = "YOUR_API_KEY"
prompt = input("Enter your prompt: ")
if check_prompt(prompt):
response = openai.Completion.create(
engine="davinci",
prompt=prompt,
max_tokens=60
)
print(response.choices[0].text)
else:
print("Your prompt contains user information and cannot be used.")
Organizations can also build a wrapper that will ensure all the prompts and user details are logged into the internal system for audit purposes.
Python that logs each prompt sent by the user and the response received from GPT-3:
import openai
import logging
openai.api_key = "YOUR_API_KEY"
logging.basicConfig(filename='my_logs.log', level=logging.INFO,
format='%(asctime)s - %(message)s', datefmt='%d-%b-%y %H:%M:%S')
def generate_response(prompt):
response = openai.Completion.create(
engine="davinci",
prompt=prompt,
max_tokens=100,
n=1,
stop=None,
temperature=0.7,
)
logging.info(f"Prompt: {prompt}")
logging.info(f"Response: {response.choices[0].text}")
return response.choices[0].text
Overall, GPT-3 can be a useful tool for employees in a banking organization to improve their productivity, accuracy, and decision-making. However, it is important to ensure that the use of GPT-3 is aligned with the organization’s privacy and security policies and that employees are trained on how to use GPT-3 in a responsible and ethical manner.