Question Answer#


The easiest way to ask a question to a text field and extract the relevant answer is using the ds.question_answer function.

Prior to adding question answering, we will need to make sure to install HuggingFace’s Transformers.

pip install -q transformers[sentencepiece]

You can then run this:

from relevanceai import Client
client = Client()
ds = client.Dataset("ecommerce")
    question="What brand shoes",
    # Easily switch to a different HuggingFace model

For every document, you will get functions and formulas similar to the ones below:

   "_question_": {
      "what-brand-shoes": {
         "answer": "nike", # returns a string response
         "score": 0.98, # confidence of the answer

API Reference#

Add Sentiment to your dataset

class relevanceai.operations.text.sentiment.sentiments.SentimentOps#
get_shap_values(text, sentiment_ind=2, max_number_of_shap_documents=None, min_abs_score=0.1)#

Get SHAP values

class relevanceai.operations.text.sentiment.sentiment_workflow.SentimentWorkflow#

Sentiment workflow

fit_dataset(dataset, input_field, output_field='_sentiment_', log_to_file=True, chunksize=20, workflow_alias='sentiment', notes=None, refresh=False, highlight=False, positive_sentiment_name='positive', max_number_of_shap_documents=None, min_abs_score=0.1)#

Fit on dataset