Skip to content

Semantic textual similarity model #26

Description

@rlucatoor

What is a Semantic Textual Similarity model

A Semantic Textual Similarity model takes two pieces of text as input and returns a similarity score indicating to which extent the texts have the same meaning.

What needs to be done

Implement a Semantic Textual Similarity model that exposes the following public methods:

.train() method:

.train(output_path: Optional[str] = None, num_samples: int = config.DEFAULT_SYNTHEX_DATAPOINT_NUM, num_epochs: int = 3)

The method should train the model to return a similarity score between 0 and 1 indicating to which extent two pieces of text are paraphrases of each other.

.__call__(text_1: str, text_2: str, paraphrase_threshold: float = 0.6)

The model should return a dictionary with two fields:

  • score: a similarity score between 0 and 1, where 1 indicates that the texts are identical and 0 indicates no similarity.
  • is_paraphrase: a boolean indicating whether the two texts are paraphrases of each other, based on the provided paraphrase_threshold.

For instance, given the inputs:

__call__(
    "The quick brown fox jumps over the lazy dog.",
    "A fast dark-colored fox leaps above a sleepy canine.",
    paraphrase_threshold=0.6
)

The model might return:

{
    "score": 0.75,
    "is_paraphrase": True
}

.load(model_path: str)

Loads a pre-trained Semantic Textual Similarity model from the specified path.

Metadata

Metadata

Assignees

No one assigned

    Labels

    new modelRequest for a new model implementation

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions