Limitations and Risks in Embeddings

Limitations and Risks in Embeddings

There are various limitations and risks in embeddings. These limitations help us to make our model more accurate compared to others.

Zero-Shot Classification 

For zero-shot classification, embeddings are useful in place of labeled training data. We incorporate the class name or a succinct description for each class. We compare a piece of new text’s embedding to all the class embeddings in order to categorize it in a zero-shot fashion, and we then predict the class with the greatest resemblance.

 

from openai.embeddings_utils import cosine_similarity, get_embedding
 
df= df[df.Score!=3]
df['sentiment'] = df.Score.replace({1:'negative', 2:'negative', 4:'positive', 5:'positive'})
 
labels = ['negative', 'positive']
label_embeddings = [get_embedding(label, model=model) for label in labels]
 
def label_score(review_embedding, label_embeddings):
   return cosine_similarity(review_embedding, label_embeddings[1]) - cosine_similarity(review_embedding, label_embeddings[0])
 
prediction = 'positive' if label_score('Sample Review', label_embeddings) > 0 else 'negative'

In some situations, OpenAI embedding models may be unreliable or socially risky. They may even get harmful if no mitigations are taken.

 

Social Bias

Limitation: The models represent social biases as stereotypes or unfavorable attitudes against particular populations.

Running the SEAT (May et al., 2019) and Winogender (Rudinger et al., 2018) benchmarks allowed us to identify bias in our models. When applied to gendered names, regional names, and some preconceptions, these standards determine whether models include implicit biases using a total of 7 tests.

For instance, we discovered that our models more strongly correlate negative stereotypes with black women.

(a) European American names with a good feeling as compared to African American names.

These benchmarks have various limitations, including the possibility that they won’t apply to your specific use case. The fact is that they only test for a very narrow range of potential social biases.

These tests should be done for your individual use cases as they are preliminary. These findings should not be interpreted as a complete characterization of the phenomena for your use case, but rather as proof of its presence.

 

English Only 

For standard English that we frequently encounter on the Internet, models are the most trustworthy. It’s possible that our models don’t do well with local or group dialects.

Common NLP systems don’t perform as well on African American English as they do on American English as a whole, according to research (Blodgett & O’Connor, 2017). Similar to how they might not function well on the Internet. OpenAI models might also have trouble with English dialects or usages.

 

Classification using the embedding features

OpenAI tries to categorize the precise number of stars for a review into 5 buckets, ranging from 1 to 5 stars, rather than having the system predict a value anywhere between 1 and 5.

 

After training, the model is substantially better at predicting 1 and 5-star reviews than it is at predicting reviews with 2-4 ratings, which are probably the result of more severe sentiment expression.

 

from sklearn.ensemble import RandomForestClassifier
from sklearn.metrics import classification_report, accuracy_score
 
clf = RandomForestClassifier(n_estimators=100)
clf.fit(X_train, y_train)
preds = clf.predict(X_test)

 

 

Also Read: OpenAI API Libraries 

Reference: OpenAI API 

 

 

Share this post

Leave a Reply

Your email address will not be published. Required fields are marked *