Einstein Platform Services

Create a French Model

In this walkthrough, you use the Einstein Intent API to create a French model to route support cases. You can then use the model to analyze text and infer what the user wants to accomplish. You use the French case routing sample .csv file that we make available to you.

Step by Step: Create a French Model

Step 1: Get a Token

A valid JWT token is required to make API calls.

  1. Sign up for an account. Follow the steps in What You Need to Call the API to sign up for an Einstein Platform Services account and download your private key file. If you already have an account, you can skip this step.

  2. Find your key file. If you already created an account, locate the einstein_platform.pem file that you downloaded as part of that process. This file contains your private key.

  3. Install cURL. You use the cURL command-line tool throughout the following walkthrough. The tool is installed by default on Linux and OSX. If you don’t already have it installed, download it from https://curl.haxx.se/download.html. Alternatively, you can use Postman to make API calls.

  4. Get a token. The Einstein Intent API uses the OAuth 2.0 JWT bearer token flow for authorization. Use the token page to upload your key file and generate a JWT token.

Step 2: Create a Dataset

  1. Replace <TOKEN> with your JWT token, and run the following command from the command line. This command:
    • Creates a dataset called Dataset de Routage de Cas from the specified .csv file by accessing the file via a URL. If you leave out the name parameter, the dataset name defaults to the name of the file: case_routing_intent_fr.
    • Creates five labels as specified in the .csv file.
    • Creates 150 examples.
curl -X POST -H "Authorization: Bearer <TOKEN>" -H "Cache-Control: no-cache" -H "Content-Type: multipart/form-data" -F "name=Dataset de Routage de Cas" -F "path=http://einstein.ai/text/case_routing_intent_fr.csv" -F "language=fr" -F "type=text-intent"  https://api.einstein.ai/v2/language/datasets/upload

This call is asynchronous, so the response looks like this JSON.

{
  "id": 1020389,
  "name": "Dataset de Routage de Cas",
  "createdAt": "2020-03-16T17:54:51.000+0000",
  "updatedAt": "2020-03-16T17:54:51.000+0000",
  "labelSummary": {
    "labels": []
  },
  "totalExamples": 0,
  "available": false,
  "statusMsg": "UPLOADING",
  "type": "text-intent",
  "language": "fr",
  "numOfDuplicates": 0,
  "object": "dataset"
}
  1. To verify that the data has been loaded, make a call to get the dataset. Replace <TOKEN> with your JWT token, and replace <DATASET_ID> with the ID of the dataset that you created.
curl -X GET -H "Authorization: Bearer <TOKEN>" -H "Cache-Control: no-cache" https://api.einstein.ai/v2/language/datasets/<DATASET_ID>

The results look something like this JSON. You know the dataset is ready when available is true and statusMsg is SUCCEEDED. You can see that the response also returns the language field.

{
  "id": 1020389,
  "name": "Dataset de Routage de Cas",
  "createdAt": "2020-03-16T17:54:51.000+0000",
  "updatedAt": "2020-03-16T17:54:51.000+0000",
  "labelSummary": {
    "labels": [
      {
        "id": 104866,
        "datasetId": 1020389,
        "name": "Informations d'Expédition",
        "numExamples": 30
      },
      {
        "id": 104867,
        "datasetId": 1020389,
        "name": "Facturation",
        "numExamples": 24
      },
      {
        "id": 104868,
        "datasetId": 1020389,
        "name": "Opportunité de Vente",
        "numExamples": 44
      },
      {
        "id": 104869,
        "datasetId": 1020389,
        "name": "Changement de Commande",
        "numExamples": 26
      },
      {
        "id": 104870,
        "datasetId": 1020389,
        "name": "Aide Mot de Passe",
        "numExamples": 25
      }
    ]
  },
  "totalExamples": 149,
  "totalLabels": 5,
  "available": true,
  "statusMsg": "SUCCEEDED",
  "type": "text-intent",
  "language": "fr",
  "numOfDuplicates": 1,
  "object": "dataset"
}

Step 3: Train the Dataset to Create a Model

  1. In the following command, replace <TOKEN> with your JWT token, and replace <DATASET_ID> with the ID of the dataset that you created, and run the command.
curl -X POST -H "Authorization: Bearer <TOKEN>" -H "Cache-Control: no-cache" -F "name=Modèle de Routage de Cas" -F "algorithm=multilingual-intent" -F "datasetId=<DATASET_ID>" https://api.einstein.ai/v2/language/train

The response looks like this JSON.

{
  "datasetId": 1020389,
  "datasetVersionId": 0,
  "name": "Modèle de Routage de Cas",
  "status": "QUEUED",
  "progress": 0,
  "createdAt": "2020-03-16T17:54:51.000+0000",
  "updatedAt": "2020-03-16T17:54:51.000+0000",
  "modelId": "EIN6TP2LJYUOAW44EH3VH2Z4DU",
  "learningRate": 0,
  "epochs": 0,
  "queuePosition": 1,
  "modelType": "text-intent",
  "algorithm": "multilingual-intent",
  "language": "fr",
  "object": "training",
  "trainParams": null,
  "trainStats": null
}
  1. Use the modelId to make this call and get the training status. Replace <TOKEN> with your JWT token, and replace MODEL_ID with the ID of the model that you created.
curl -X GET -H "Authorization: Bearer <TOKEN>" -H "Cache-Control: no-cache" https://api.einstein.ai/v2/language/train/<MODEL_ID>

The training status response looks like this JSON. When status is SUCCEEDED, it means the training was successful, and the model is ready for predictions.

{
  "datasetId": 1020389,
  "datasetVersionId": 15667,
  "name": "Modèle de Routage de Cas",
  "status": "SUCCEEDED",
  "progress": 1,
  "createdAt": "2020-03-16T17:54:51.000+0000",
  "updatedAt": "2020-03-16T17:54:51.000+0000",
  "modelId": "EIN6TP2LJYUOAW44EH3VH2Z4DU",
  "learningRate": 0,
  "epochs": 1000,
  "modelType": "text-intent",
  "algorithm": "multilingual-intent",
  "language": "fr",
  "object": "training",
  "trainParams": null,
  "trainStats": {
    "labels": 5,
    "examples": 149,
    "averageF1": 0.8880952380952379,
    "totalTime": "00:04:16:861",
    "transforms": null,
    "trainingTime": "00:04:16:280",
    "earlyStopping": true,
    "lastEpochDone": 64,
    "modelSaveTime": "00:00:00:262",
    "testSplitSize": 25,
    "trainSplitSize": 124,
    "datasetLoadTime": "00:00:00:581",
    "preProcessStats": null,
    "postProcessStats": null
  }
}

Step 4: Send Text for Prediction

Now your model is ready to go. To test it, send some text in for prediction. This cURL call takes the modelId of the model from which you want to return a prediction and the text string to analyze. In this case, the string in English is, “I would like to buy a soccer jersey.”

  1. Replace <TOKEN> with your JWT token, and replace <MODEL_ID> with the ID of your model. Then run the command.
curl -X POST -H "Authorization: Bearer <TOKEN>" -H "Cache-Control: no-cache" -H "Content-Type: multipart/form-data" -F "modelId=<MODEL_ID>" -F "document=Je voudrais acheter un maillot de foot"  https://api.einstein.ai/v2/language/intent

The response looks like this JSON. The model predicts that the text indicates that the user is interested in buying something, so the model returns Opportunité de Vente (Sales Opportunity) as the top probability.

Your app can then use this information to route the case to the correct department or sales person.

{
  "probabilities": [
    {
      "probability": 0.95638543,
      "label": "Opportunité de Vente"
    },
    {
      "probability": 0.02187803,
      "label": "Changement de Commande"
    },
    {
      "probability": 0.01103622,
      "label": "Informations d'Expédition"
    },
    {
      "probability": 0.008903132,
      "label": "Facturation"
    },
    {
      "probability": 0.0017971398,
      "label": "Aide Mot de Passe"
    }
  ],
  "object": "predictresponse"
}

Updated 4 months ago

Create a French Model


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.