Skip to content

Commit 9b8d106

Browse files
committed
v0.0.2 Test release
1 parent d04cd7e commit 9b8d106

File tree

7 files changed

+85
-46
lines changed

7 files changed

+85
-46
lines changed

.github/python-package-version-test.yml renamed to .github/workflows/python-package-version-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
strategy:
1616
fail-fast: false
1717
matrix:
18-
python-version: ["3.7", "3.8", "3.9", "3.10"]
18+
python-version: ["3.9", "3.10"]
1919

2020
steps:
2121
- uses: actions/checkout@v3
File renamed without changes.

README.md

Lines changed: 19 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
# LangDiversity
22

3-
[![PyPI version](https://badge.fury.io/py/diversity-measures.svg)](LINK_TO_PYPI)
3+
[![PyPI version](https://badge.fury.io/py/langdiversity.svg)](LINK_TO_PYPI)
44
[![Python version](https://img.shields.io/badge/python-3.7%2B-blue)](LINK_TO_PYTHON_VERSION)
5-
[![License](https://img.shields.io/badge/license-MIT-green)](LINK_TO_LICENSE)
5+
[![License](https://img.shields.io/badge/license-BSD%203--Clause-blue)](LICENSE)
66

77
Elevate your language models with insightful diversity metrics.
88

9+
## Links
10+
11+
Paper: https://arxiv.org/abs/2308.11189
12+
13+
Video: https://www.youtube.com/watch?v=BekDOLm6qBI&t=10s&ab_channel=NeuroSymbolic
14+
915
## Table of Contents
1016

1117
- [Introduction](#introduction)
1218
- [Installation](#installation)
13-
- [Quick Start](#quick-start)
14-
- [Documentation](#documentation)
15-
- [Contributing](#contributing)
19+
- [Usage](#usage)
1620
- [Bibtex](#bibtex)
1721
- [License](#license)
1822
- [Contacts](#contacts)
@@ -26,47 +30,25 @@ The primary goal of this project is to assist researchers and developers in anal
2630
## Installation
2731

2832
```bash
29-
pip install diversity-measures
33+
pip install langdiversity
3034
```
3135

32-
## Quick Start
33-
34-
```python
35-
from langdiversity.models import OpenAIModel
36-
from langdiversity.measures import ShannonEntropyMeasure
37-
from langdiversity.utils import PromptSelection
38-
39-
# Initialize the OpenAI model and diversity measure
40-
model = OpenAIModel(openai_api_key="YOUR_OPENAI_API_KEY")
41-
diversity_measure = ShannonEntropyMeasure()
42-
43-
# Use the PromptSelection utility
44-
prompt_selection = PromptSelection(model=model, diversity_measure=diversity_measure)
45-
selected_prompt, selected_diversity = prompt_selection.generate(["Your list of prompts here..."])
46-
47-
print("Selected Prompt:", selected_prompt)
48-
print("Selected Diversity:", selected_diversity)
49-
```
50-
51-
## Documentation
52-
53-
Detailed documentation is available [here]().
54-
55-
## Contributing
36+
## Usage
5637

57-
We welcome contributions! Please see our [contribution guidelines]() for more details.
38+
Detailed documentation is available [here](https://github.com/lab-v2/diversity_package/tree/main/docs/langdiversity_library.md).
5839

5940
## Bibtex
6041

6142
If you used this software in your work please cite our paper
6243

6344
```bibtex
64-
@article{ngu2023diversity,
65-
title={Diversity Measures: Domain-Independent Proxies for Failure in Language Model Queries},
66-
author={Ngu, Noel and Lee, Nathaniel and Shakarian, Paulo},
67-
journal={arXiv preprint arXiv:2308.11189},
68-
year={2023},
69-
url={https://arxiv.org/abs/2308.11189},
45+
@misc{ngu2023diversity,
46+
title={Diversity Measures: Domain-Independent Proxies for Failure in Language Model Queries},
47+
author={Noel Ngu and Nathaniel Lee and Paulo Shakarian},
48+
year={2023},
49+
eprint={2308.11189},
50+
archivePrefix={arXiv},
51+
primaryClass={cs.CL}
7052
}
7153
```
7254

docs/langdiversity_library.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# LangDiversity Python Library
2+
3+
pypi project: https://pypi.org/project/langdiversity/
4+
5+
## Install
6+
7+
```bash
8+
pip install langchain
9+
```
10+
11+
## Usage
12+
13+
Example:
14+
15+
```python
16+
from langdiversity.models import OpenAIModel
17+
from langdiversity.measures import ShannonEntropyMeasure
18+
from langdiversity.utils import PromptSelection
19+
20+
# Initialize the OpenAI model and diversity measure
21+
model = OpenAIModel(openai_api_key="YOUR_OPENAI_API_KEY")
22+
diversity_measure = ShannonEntropyMeasure()
23+
24+
# Use the PromptSelection utility
25+
prompt_selection = PromptSelection(model=model, num_responses=10, diversity_measure=diversity_measure)
26+
27+
# Selects the prompt with the configured diversity measure criteria from the LLM's 10 responses
28+
selected_prompt, selected_measure = prompt_selection.generate(["Your list of prompts here..."])
29+
30+
print("Selected Prompt:", selected_prompt)
31+
print("Selected Measure:", selected_measure)
32+
```
33+
34+
### PromptSelection Paramaters:
35+
36+
- `model`: The language model you want to use. In this example, we're using OpenAI's model.
37+
38+
- `diversity_measure`: The measure of diversity measure you want to use. Here, we're using entropy.
39+
40+
- `num_responses`: The number of responses you want the model to generate for each prompt. Default is 1.
41+
42+
- `selection`: Determines how the best prompt is selected based on its diversity measure. It can be:
43+
44+
- `"min"`: Selects the prompt with the minimum diversity measure. (default)
45+
- `"max"`: Selects the prompt with the maximum diversity measure.
46+
47+
### Output:
48+
49+
- `selected_prompt`: The prompt that meets the specified diversity criteria (either min or max) among the given list of prompts.
50+
- `selected_measure`: The diversity measure of the `selected_prompt` based on the specified diversity measure (e.g., entropy).

langdiversity/utils/prompt_selection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,4 @@ def generate(self, prompts: List[str]):
4444
{"responses": responses, "diversity": diversity, "prompt": prompt}
4545
)
4646

47-
return selected_prompt, selected_diversity, info
47+
return selected_prompt, selected_diversity

requirements.txt

425 Bytes
Binary file not shown.

setup.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
from setuptools import find_packages, setup
22

3+
# Read the contents of README file
4+
from pathlib import Path
5+
this_directory = Path(__file__).parent
6+
long_description = (this_directory / "README.md").read_text()
7+
38
setup(
49
name='langdiversity',
510
packages=find_packages(exclude=['tests']),
6-
version='0.0.1',
11+
version='0.0.2',
712
description='A tool to elevate your language models with insightful diversity metrics.',
8-
author='Noel Ngu, Nathaniel Lee', # change later
9-
author_email='nngu2@asu.edu, nlee51@asu.edu', # change later
10-
url='https://github.com/your_github_username/langdiversity', # change later
13+
long_description=long_description,
14+
long_description_content_type="text/markdown",
15+
author='Noel Ngu, Nathaniel Lee',
16+
author_email='nngu2@asu.edu, nlee51@asu.edu',
17+
url='https://github.com/lab-v2/diversity_package',
1118
license='BSD 3-clause',
1219
install_requires=[
1320
'aiohttp==3.8.5',
@@ -44,10 +51,10 @@
4451
'Development Status :: 3 - Alpha',
4552
'Intended Audience :: Developers',
4653
'License :: OSI Approved :: BSD License',
47-
'Programming Language :: Python :: 3.7',
48-
'Programming Language :: Python :: 3.8',
4954
'Programming Language :: Python :: 3.9',
5055
'Programming Language :: Python :: 3.10',
56+
'Programming Language :: Python :: 3.11',
57+
5158
],
52-
python_requires='>=3.7',
59+
python_requires='>=3.9',
5360
)

0 commit comments

Comments
 (0)