OpenMined / SyferText

A privacy preserving NLP framework

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Implement secure label delivery for `Doc` via `DocPointer`

AlanAboudib opened this issue · comments

Context

When a PySyft classifier is deployed within a SyferText pipeline, and used for inference in SMPC model, on a remote string.

Problem

The predicted label in this case is a PySyft AdditiveSharedTensor (AST) that only the concerned worker (the data owner) has the right to decrypt, aka, call the .get() method on the AST vector.

Details

In order to do this, the output prediction should be sent to the worker, which will decrypt it in turn.

This should be done through a method in DocPointer that could be called set_predicted_class().

This is an example of how this method could be called:

doct_ptr.set_predicted_class(mode = 'mpc', 
                             attribute_name = 'sentiment', 
                             class_value = <PySyft AST tensor>, 
                             class_names = {0: 'negative', 1: 'positive})

This method should call a method with the same name in the Doc class where the real logic should be implemented.

The predicted classes should be saved as a Doc custom attribute accessible by calling:

doc._.<attribute_name>

where attribute_name is the one chosen when calling set_predicted_class().

class_value: should be an integer or a PySyft additive shared tensor holding the integer label.
class_names: is used to map the integer label to a name that will be stored to doc._.<attribute_name>

Where to push your PR?

Any PR referencing this issue should be made to branch syfertext_0.1.0

@bicycleman15 I suggest you work on this issue separately (Not include it in your GSoC PR)