---
title: Text Classification
slug: text-classification
docTags: 
createdAt: 2023-07-19T04:19:33.549Z
---

The below input parameters are for different attack types. To start working with the APIs, see  [Text Classification](docId\:EOqluV3UxbC2_KALISdBO).

:::hint{type="warning"}
Text classification is an early access with limited functionality. It is not available in AIShield pypi package. For early access, kindly contact [AIShield.Contact@bosch.com](mailto\:AIShield.Contact@bosch.com)
:::

## File upload format

- **Data**: The processed data, ready to be passed to the model for prediction, should be saved in a folder.

[Download sample data](https://aisdocs.blob.core.windows.net/reference/upload/Text/TextClassification/IMDB_Dataset.zip)

- **Model**: The model should be saved in either .h5 or TensorFlow format with full architecture along with token in .pkl format. Also there need to be a base\_model.py file which should load model and token and confire it to give prediction. All Three file base\_model.py, .h5 saved model and .pkl saved token should be zipped in a folder and uploaded.

[Download sample model](https://aisdocs.blob.core.windows.net/reference/upload/Text/TextClassification/nlp_model.zip)

## Common parameters

The below table parameters are common for Extraction Attack type.&#x20;

| Parameter                      | Data type | Description                                                                                                                                                                                      | Remark                                                                                                                                                                                                                                                                                    |
| ------------------------------ | --------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| model\_Id                      | String    | Model\_id received during model registration.<br />We need to provide this model ID in query parameter in URL.                                                                                   | You have to do model registration only once for a model to perform model analysis. This will help you track the no of api call made, and it's success metric.                                                                                                                             |
| **Request Body (Json format)** |           |                                                                                                                                                                                                  |                                                                                                                                                                                                                                                                                           |
| model\_api\_details            | String    | Use model API to train your model instead of uploading the model as a zip file.<br />Yes                                                                                                         | provide this only if use\_model\_api is "yes".                                                                                                                                                                                                                                            |
| Attack\_type                   | String    | You can select the attack type either Blackbox or Greybox.                                                                                                                                       | **Blackbox**: for performing model analysis, no information about model or data will be used.                                              **Greybox**: information about data will be leverage for creation of attack data              **Note:&#x20;**&#x6F;nly 2-5 % of data is needed |
| normalize\_data                | String    | Model trained on Normalized data.                                                                                                                                                                | if model is trained on normalized data, then set this parameter as "yes" else "no".                                                                                                                                                                                                       |
| input\_dimensions              | String    | Provide input dimension of the text (100)                                                                                                                                                        | the parameter should be string in the format.  For example 100.                                                                                                                                                                                                                           |
| number\_of\_attack\_queries    | String    | Number of attack queries that model will be<br />subjected to. e.g. 20000                                                                                                                        | generally Heigher the number of attack queries, better would be the analysis. And it would take more time to process. (Range:  >0 & \<=400000)                                                                                                                                            |
| model\_framework               | String    | Original model is built with tensorflow framework.                                                                                                                                               | curretly supported framework are: tensorflow, scikit-learn, keras. (Option:\[tensorflow])                                                                                                                                                                                                 |
| vulnerability\_threshold       | String    | Number of attack queries that model will be<br />subjected to. e.g, 0.0 - 1                                                                                                                      | Threshold percent of stolen model accuracy<br />at which defense model should be generated<br />(Range :  0.0 - 1)                                                                                                                                                                        |
| defense\_best\_only            | String    | Choose to train your model until it achieves the best results or above 95% accuracy.                                                                                                             | when selected **"yes"**, it will train N number of model and select best model. Ofcourse this will take longer time. If **"no"**, then once defense model accuracy reached above 95% It will stop                                                                                         |
| encryption\_strategy           | Int       | Choose a encryption strategy for you model. if model is uploaded directly as a<br />zip pick 0, 1 if model is encryted as .pyc and<br />uploaded as a zip. Ignore if use\_model\_api is<br />Yes | select 0: pass tensorflow model as it is, select 1: pass encrypted model. It could be .pyc file                                                                                                                                                                                           |



:::hint{type="info"}
To access all sample artifacts, please visit [Artifacts](docId\:iJNEOCXoStabvvrsq11fa).&#x20;

- For specific artifact details,  refer&#x20;
  - Vulnerability Report : [Vulnerability Report](docId\:hL0uT2MWlCBkt8F97fr-W)    &#x20;
  - Sample Attacks : [Sample Attacks](docId:4G1mjM5lQjfm8t5WBVwpr)
  - Defense Report: [Defense Report](docId\:VtzlTtpja2VSF2j0STLSQ)                   &#x20;
  - Defense Model: [Defense Model](docId\:xSbxmZXW4vv14-8NmBF8M)
:::

:::hint{type="info"}
**Note**: For Text classification, supported attack types are - Extraction
:::

