FlagEmbedding icon indicating copy to clipboard operation
FlagEmbedding copied to clipboard

Enhancement Request for Broader Compatibility with Python Version in Type Annotations

Open wxywb opened this issue 1 year ago • 3 comments

Thanks for your release of new reranker model, but I noticed in https://github.com/FlagOpen/FlagEmbedding/blob/25c30a853d93434724929ac83136cd8dda24291a/FlagEmbedding/flag_reranker.py#L345-L348 Considering that many users and projects still operate on earlier Python versions(below 3.10), I believe adjusting the type hints to use the Union type from the typing module could significantly enhance the library's accessibility and compatibility. For instance:

def compute_score(self, sentence_pairs: Union[List[Tuple[str, str]], Tuple[str, str]], batch_size: int = 16,
                  max_length: int = 512, cutoff_layers: List[int] = None, prompt: str = None,
                  normalize: bool = False) -> Union[float, list[Any], list[Union[float, Any]], list[
    list[Any], list[Union[float, Any]]], Any]:

wxywb avatar Mar 18 '24 08:03 wxywb

Thank you for your suggestion, we will make modifications to this part.

545999961 avatar Mar 18 '24 08:03 545999961

This change seems to have been merged into the master branch, but the latest version(1.2.7) from pypi looks like still be the old one. Do you mind publishing a new version to pypi? @545999961

dcalsky avatar Mar 19 '24 12:03 dcalsky

This change seems to have been merged into the master branch, but the latest version(1.2.7) from pypi looks like still be the old one. Do you mind publishing a new version to pypi? @545999961

Hi, @dcalsky , we have released a new version in pypi.

staoxiao avatar Mar 20 '24 07:03 staoxiao