Ner4Opt: Named Entity Recognition for Optimization
Given an optimization problem in natural language, Ner4Opt extracts optimization related entities from free-form text.
Check out this HugginFace Space Demo to test it yourself 🤗.
The Ner4Opt model (Constraints'24, CPAIOR'23, NeurIPS'22) is trained to detect six named entities:
- CONST_DIR: Constraint direction
- LIMIT: Limit
- OBJ_DIR: Objective direction
- OBJ_NAME: Objective name
- PARAM: Parameter
- VAR: Variable
Here are the details of our pre-trained models and the training procedure. Our pretrained models are hosted on HuggingFace Models.
Quick Start
from ner4opt import Ner4Opt
# Input optimization problem description as free-form text
problem_description = "The Notorious Desk company wants to promote a new brand of wine and wants to market it using a total market budget of $ 87,000 . To do so , the company needs to decide how much to allocate on each of its two advertising channels : ( 1 ) morning TV show and ( 2 ) social media . Each day , it costs the company $ 1,000 and $ 2000 to run advertisement spots on morning TV show and social media respectively . The expected daily reach , based on past ratings , is 15,000 viewers for each morning show spot and 30,000 internet users for a social media spot . The chief marketer knows from her experience that both channels are key to the success of the product launch . She wants to plan at least 4 but no more than 7 morning show spots . In addition , the social media spots needs to be at least 30 due to pricing tier policy . How many times should each of the media channels be used to maximize the reach of the campaign ?"
# Ner4Opt Model with options lexical, lexical_plus, semantic, hybrid (default).
ner4opt = Ner4Opt(model="hybrid")
# Extract a list of dictionaries corresponding to entities found in the given problem description.
# Each dictionary holds keys for the following:
# start (starting character index of the entity), end (ending character index of the entity)
# word (entity), entity_group (entity label) and score (confidence score for the entity)
entities = ner4opt.get_entities(problem_description)
# Output
print("Number of entities found: ", len(entities))
# Example entity output
[
{
'start': 108,
'end': 114,
'word': 'budget',
'entity_group': 'CONST_DIR',
'score': 0.9919970308651846
},
{
'start': 120,
'end': 126,
'word': '87,000',
'entity_group': 'LIMIT',
'score': 0.9993724035912778
},
{ ... },
]
Installation
Ner4Opt requires Python 3.8 and can be installed from PyPI using pip install ner4opt or by building from source
git clone https://github.com/skadio/ner4opt.git
cd ner4opt
pip install .
Testing
To run tests, execute the following from the root folder:
python -m unittest
Citation
If you use Ner4Opt, please cite the following paper:
@article{Kadioglu24,
author = {Serdar Kadioglu, Parag Pravin Dakle, Karthik Uppuluri, Regina Politi, Preethi Raghavan, SaiKrishna Rallabandi, Ravisutha Srinivasamurthy},
title = {Ner4Opt: named entity recognition for optimization modelling from natural language},
journal = {Constraints},
volume = {29},
number = {3-4},
pages = {261--299},
year = {2024},
url = {https://doi.org/10.1007/s10601-024-09376-5},
doi = {10.1007/S10601-024-09376-5}
}
@inproceedings{dakle23,
title = {Ner4Opt: Named Entity Recognition for Optimization Modelling from Natural Language}
author = {Parag Pravin Dakle, Serdar Kadıoğlu, Karthik Uppuluri, Regina Politi, Preethi Raghavan, SaiKrishna Rallabandi, Ravisutha Srinivasamurthy}
journal = {The 20th International Conference on the Integration of Constraint Programming, Artificial Intelligence, and Operations Research (CPAIOR 2023)},
year = {2023}
}
Metadata
Release files for ner4opt 1.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ner4opt-1.0.5.tar.gz | 8.0 MB | Without provenance | Details for ner4opt-1.0.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ner4opt-1.0.5-py3-none-any.whl | Python 3 | none | any | Details for ner4opt-1.0.5-py3-none-any.whl |
Total release size: 16.1 MB
Release files / ner4opt-1.0.5.tar.gz
| Download URL | ner4opt-1.0.5.tar.gz |
|---|---|
| Size | 8.0 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
74e92e59d8a866450461c6bcba6d771b8267f352db6b5eed5bd72594de3c9595
|
|
BLAKE2b-256 checksum How to use checksums |
eee129bff899c393d37122645cfacc1eead3d360fb4ccb6ef56bcbedec052124
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.8.20
|
Release files / ner4opt-1.0.5-py3-none-any.whl
| Download URL | ner4opt-1.0.5-py3-none-any.whl |
|---|---|
| Size | 8.1 MB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
311038ea161907b6c1a3471b9b43b57203ceca7a612c559763f52b506b780135
|
|
BLAKE2b-256 checksum How to use checksums |
e4b0e447ffa43be82f3e995cb6e0e754d4d146aceee17ea223a144efe7d9545b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.8.20
|
Security for ner4opt 1.0.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.