معرفی شرکت ها


compcor-1.0.6


Card image cap
تبلیغات ما

مشتریان به طور فزاینده ای آنلاین هستند. تبلیغات می تواند به آنها کمک کند تا کسب و کار شما را پیدا کنند.

مشاهده بیشتر
Card image cap
تبلیغات ما

مشتریان به طور فزاینده ای آنلاین هستند. تبلیغات می تواند به آنها کمک کند تا کسب و کار شما را پیدا کنند.

مشاهده بیشتر
Card image cap
تبلیغات ما

مشتریان به طور فزاینده ای آنلاین هستند. تبلیغات می تواند به آنها کمک کند تا کسب و کار شما را پیدا کنند.

مشاهده بیشتر
Card image cap
تبلیغات ما

مشتریان به طور فزاینده ای آنلاین هستند. تبلیغات می تواند به آنها کمک کند تا کسب و کار شما را پیدا کنند.

مشاهده بیشتر
Card image cap
تبلیغات ما

مشتریان به طور فزاینده ای آنلاین هستند. تبلیغات می تواند به آنها کمک کند تا کسب و کار شما را پیدا کنند.

مشاهده بیشتر

توضیحات

Corpus level similarity measures.
ویژگی مقدار
سیستم عامل -
نام فایل compcor-1.0.6
نام compcor
نسخه کتابخانه 1.0.6
نگهدارنده []
ایمیل نگهدارنده []
نویسنده Language and Conversation, IBM Research AI
ایمیل نویسنده -
آدرس صفحه اصلی https://github.com/IBM/comparing-corpora
آدرس اینترنتی https://pypi.org/project/compcor/
مجوز Apache Software License, Version 2.0, http://www.apache.org/licenses/LICENSE-2.0
# compcor ## TL;DR A python library of similarity measures which allow measuring the perceptual distance between text corpora. You can use compcor to easily calculate the perceptual distance between two sets of sentences using many classical and SOTA metrics. ## About The ability to compare the semantic similarity between text corpora is important in a variety of natural language processing applications. While one can reasonably measure the semantic distance between two individual sentences (e.g., by calculating the cosine distance between the sentence embeddings), measuring the dissimilarity between two text corpora remains a challenge. Corpus-level metrics seek to assess semantic similarity at the group level. Such metrics are essential for measuring how well corpus-based linguistic analysis generalizes from one data-set to another. Specifically, the recent advances in generative language models have led to an increased interest in the study of content similarity between human and generated language, as a mean for comparing the quality of generative models. ## installation: Using python>=3.8: ``` pip install compcor ``` ## Usage To calculate the perceptual distance between two corpora, the raw corpora can be simply provided as a list of strings: ``` setA = ['can you tell me how i would normally say thank you as a french person', 'can you translate hi into spanish for me', 'can you translate milk into spanish for me', 'how can i say thank you very much in chinese', 'how can i thank somebody in italian', 'how could i say twin in chinese', 'how do germans say goodnight','how do i ask about the weather in chinese', 'how do i say hotel in finnish', 'how do i say bathroom in italian'] setB = ['how can i say thank you very much in chinese', 'how can i thank somebody in italian', 'how could i say twin in chinese', 'how do they say tacos in mexico', 'how do they say yes in brazil', 'how do vietnameses people say hello', 'how do you say cat in spanish', 'how do you say dog in spanish', 'how do you say fast in spanish', 'how do you say good bye in french', 'how do you say goodbye in spanish', 'how do you say hello in french', 'how do you say hello in japanese', 'how do you say hello in mexico'] ``` ### Using raw data By calling any metric provided in the package, all metrics return a single scalar capturing the perceptual distance between two corpora: ``` import compcor.corpus_metrics as corpus_metrics distance = corpus_metrics.fid_distance(corpus1=setA, corpus2=setB) ``` In this case the sentences in both sets will be tokenized/embedded inside the function. ### Using embeddings The metrics also accept already-embedded/tokenized corpora, possibly using a custom embedding. ``` distance = corpus_metrics.fid_distance(corpus1=embedA, corpus2=embedB) ``` We provide an embedding and tokanization utility class 'STTokenizerEmbedder' which is a shallow wrapper for the [sentence-transformer](https://www.sbert.net/) SentenceTransformer class. STTokenizerEmbedder implements two simple interfaces 'TextEmbedder' and 'TextTokenizer'. The hugging-face model can be determined using the 'embedding_model_name' parameter. By default, we use the model 'all-MiniLM-L6-v2', but any other hugging-face model can be used. ``` from compcor.text_tokenizer_embedder import STTokenizerEmbedder embedder = STTokenizerEmbedder(embedding_model_name = "all-MiniLM-L12-v2") embedA = embedder.embed_sentences(setA) embedB = embedder.embed_sentences(setB) distance = corpus_metrics.fid_distance(corpus1=embedA, corpus2=embedB) ``` ### Using tokens If the distance operates on the tokens level, the tokenized sentences should be provided instead of the sentence embeddings. ``` tokensA = embedder.tokenize_sentences(setA) tokensB = embedder.tokenize_sentences(setB) distance = corpus_metrics.chi_square_distance(corpus1=tokensA, corpus2=tokensB) print("chi_square_distance={}".format(distance)) #chi_square_distance=0.9987177546738071 ``` ## Full Metric list Given two corpora of strings, we want to calculate the distance between them. `comparing-corpora` provides the following distance metrics. The first metrics operate on a sentence-level embedding, while the last two operate on the token frequencies. | Name |function| representation | description | |---------------------------------------------------|---|----------------|--------------------------------------------------| | Classifier |`classifier_distance`| embbeding | Classifiability between reference and target | | [PR (precision and recall)](https://github.com/clovaai/generative-evaluation-prdc) |`PR_distance`| embbeding | Assessing distributional precision and recall | | IRPR (information-retrieval precision and recall) |`IRPR_distance`| embbeding | Average distance between closest samples pairs | | [DC (density and coverage)](https://github.com/clovaai/generative-evaluation-prdc) |`dc_distance`| embbeding | Estimating manifolds density and coverage | | [MAUVE](https://github.com/krishnap25/mauve) |`mauve_distance`| embbeding | Quality and diversity via divergence frontiers | | FID (Frechet Inception Distance) |`fid_distance`| embbeding | Wasserstein distance between densities | | Chi-squared ($\chi^2$) |`chi_square_distance`| token | Word/Token count comparison | | Zipf |`zipf_distance`| token | Unigram rank-frequency statistics | | t-test |`ttest_distance`| embbeding | T-test p-value on difference in elementwise means | | Medoid |`medoid_distance`| embbeding | Cosine distance between corpora centroids | ## Citation If you use this package for your scientific publication please cite the following work studies the quality, time performance and other properties of most of the metrics in this package. ``` @inproceedings{kour2022measuring, title={Measuring the Measuring Tools: An Automatic Evaluation of Semantic Metrics for Text Corpora}, author={Kour, George and Ackerman, Samuel and Farchi, Eitan and Raz, Orna and Carmeli, Boaz and Anaby-Tavor, Ateret}, booktitle={Proceedings of the 2nd Workshop on Natural Language Generation, Evaluation, and Metrics (GEM 2022)}, publisher = "Association for Computational Linguistics", year={2022} } ```


نیازمندی

مقدار نام
==1.23.0 numpy
==1.9.0 scipy
==1.1.1 scikit-learn
- prdc
- mauve-text
==2.2.1 sentence-transformers


زبان مورد نیاز

مقدار نام
>=3.8 Python


نحوه نصب


نصب پکیج whl compcor-1.0.6:

    pip install compcor-1.0.6.whl


نصب پکیج tar.gz compcor-1.0.6:

    pip install compcor-1.0.6.tar.gz