Name | lstar_lm JSON |
Version |
0.2.1
JSON |
| download |
home_page | |
Summary | Algorithm for learning DFA from demonstrations, examples, and language. |
upload_time | 2024-02-21 06:01:23 |
maintainer | |
docs_url | None |
author | Marcell Vazquez-Chanlatte |
requires_python | >=3.10,<4.0 |
license | |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# L*LM
[](https://badge.fury.io/py/lstar_lm)
Implementation of L*LM algorithm algorithm. See [project
page](http://lstar-lm.github.io) for details.
**Table of Contents**
- [Installation](#installation)
- [Usage](#usage)
# Installation
If you just need to use `lstar_lm`, you can just run:
`$ pip install lstar_lm`
For developers, note that this project uses the
[poetry](https://poetry.eustace.io/) python package/dependency
management tool. Please familarize yourself with it and then
run:
`$ poetry install`
# Usage
The main entry points for using this library are the `guess_dfa` and
`dfa_search_with_diss` functions.
- `guess_dfa` supports labeled examples and natural language.
- `dfa_search_with_diss` supports labeled examples, natural language, and
demonstrations.
```python
from lstar_lm import guess_dfa
```
An invocation of `guess_dfa` takes the form.
```python
dfa = guess_dfa(
positive = ..., # List of positive examples. Each example is a list of tuples of tokens.
negative = ..., # List of negative examples. Each example is a list of tuples of tokens.
alphabet = ..., # List of (hashable) tokens.
task_description = ..., # String of task description.
allow_unsure = ..., # Whether to allow unsure responses (default True).
random_iters = ..., # Number of random queries to oracle.
active_queries = ..., # Number of active queries to oracle.
use_dfa_identify = ..., # True if use SAT based DFA identification. False uses L* + SAT hybrid.
llm_endpoint = ..., # http endpoint for llama.cpp server (default "http://localhost:8080/completion").
)
```
To learn using demonstrations, one can use `dfa_search_with_diss` to search for low energy DFAs:
```python
search = dfa_search_with_diss(
alphabet = ..., # List of (hashable) tokens.
# ---- Passive identification params ---
positive = ..., # List of positive examples. Each example is a list of tuples of tokens.
negative = ..., # List of negative examples. Each example is a list of tuples of tokens.
# ---- LLM oracle params ----
task_description = ..., # String of task description.
llm_params = ..., # Dictionary of llama.cpp parameters.
llm_query_callback = ..., # Callback sent prompt, response.
llm_endpoint = ..., # http endpoint for llama.cpp server
# (default "http://localhost:8080/completion").
allow_unsure = ..., # Whether to allow LLM to output unsure.
# --- Active learning params ---
random_iters = ..., # Number of random queries to oracle.
active_queries = ..., # Number of active queries to oracle.
use_dfa_identify = ..., # True if use SAT based DFA identification.
# False uses L* + SAT hybrid.
# --- Demonstration learning parameters ---
demonstrations = ..., # List of expert demonstrations
max_diss_iters = ..., # Maximum number of diss iterations.
to_chain = ..., # Converted dfa concept to annotated markov chain given
# a maximum entropy policy. See DISS documentation.
diss_params, # Other DISS parameters to override defaults.
)
mle = min(search, key=lambda _1, _2, metadata: metadata['energy'])
conjectured_examples, concept, metadata = mle
dfa = concept.dfa # Most likely dfa
```
Raw data
{
"_id": null,
"home_page": "",
"name": "lstar_lm",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.10,<4.0",
"maintainer_email": "",
"keywords": "",
"author": "Marcell Vazquez-Chanlatte",
"author_email": "mvc@linux.com",
"download_url": "https://files.pythonhosted.org/packages/66/42/d1c3c665be353e3b3ba2296bbe0cebd0cd46b9276cb54c11a8caf28d2f63/lstar_lm-0.2.1.tar.gz",
"platform": null,
"description": "# L*LM\n\n[](https://badge.fury.io/py/lstar_lm)\n\nImplementation of L*LM algorithm algorithm. See [project\npage](http://lstar-lm.github.io) for details.\n\n\n**Table of Contents**\n\n- [Installation](#installation)\n- [Usage](#usage)\n\n\n# Installation\n\nIf you just need to use `lstar_lm`, you can just run:\n\n`$ pip install lstar_lm`\n\nFor developers, note that this project uses the\n[poetry](https://poetry.eustace.io/) python package/dependency\nmanagement tool. Please familarize yourself with it and then\nrun:\n\n`$ poetry install`\n\n# Usage\n\nThe main entry points for using this library are the `guess_dfa` and\n`dfa_search_with_diss` functions.\n\n- `guess_dfa` supports labeled examples and natural language.\n- `dfa_search_with_diss` supports labeled examples, natural language, and\n demonstrations.\n\n```python\nfrom lstar_lm import guess_dfa\n```\n\nAn invocation of `guess_dfa` takes the form.\n```python\n\n\ndfa = guess_dfa(\n positive = ..., # List of positive examples. Each example is a list of tuples of tokens.\n negative = ..., # List of negative examples. Each example is a list of tuples of tokens.\n alphabet = ..., # List of (hashable) tokens.\n task_description = ..., # String of task description.\n allow_unsure = ..., # Whether to allow unsure responses (default True).\n random_iters = ..., # Number of random queries to oracle.\n active_queries = ..., # Number of active queries to oracle.\n use_dfa_identify = ..., # True if use SAT based DFA identification. False uses L* + SAT hybrid.\n llm_endpoint = ..., # http endpoint for llama.cpp server (default \"http://localhost:8080/completion\").\n)\n```\n\nTo learn using demonstrations, one can use `dfa_search_with_diss` to search for low energy DFAs:\n\n```python\nsearch = dfa_search_with_diss(\n alphabet = ..., # List of (hashable) tokens.\n\n # ---- Passive identification params ---\n positive = ..., # List of positive examples. Each example is a list of tuples of tokens.\n negative = ..., # List of negative examples. Each example is a list of tuples of tokens.\n\n # ---- LLM oracle params ----\n task_description = ..., # String of task description.\n llm_params = ..., # Dictionary of llama.cpp parameters.\n llm_query_callback = ..., # Callback sent prompt, response.\n llm_endpoint = ..., # http endpoint for llama.cpp server\n # (default \"http://localhost:8080/completion\").\n allow_unsure = ..., # Whether to allow LLM to output unsure.\n\n # --- Active learning params ---\n random_iters = ..., # Number of random queries to oracle.\n active_queries = ..., # Number of active queries to oracle.\n use_dfa_identify = ..., # True if use SAT based DFA identification.\n # False uses L* + SAT hybrid.\n\n # --- Demonstration learning parameters ---\n demonstrations = ..., # List of expert demonstrations\n max_diss_iters = ..., # Maximum number of diss iterations.\n to_chain = ..., # Converted dfa concept to annotated markov chain given\n # a maximum entropy policy. See DISS documentation.\n diss_params, # Other DISS parameters to override defaults.\n)\n\n\nmle = min(search, key=lambda _1, _2, metadata: metadata['energy'])\nconjectured_examples, concept, metadata = mle\ndfa = concept.dfa # Most likely dfa\n```\n",
"bugtrack_url": null,
"license": "",
"summary": "Algorithm for learning DFA from demonstrations, examples, and language.",
"version": "0.2.1",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "1fcc1811f198869316de6d72a4816f682de2b29abf57bc9d67d1ffb4a2937c17",
"md5": "08652ecb69955f7e30c01a53f8d35cb4",
"sha256": "9e301fc16ff2dda483faa02d7b9b7e8c9cb7b45742d34221ccb247c41a0c9379"
},
"downloads": -1,
"filename": "lstar_lm-0.2.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "08652ecb69955f7e30c01a53f8d35cb4",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10,<4.0",
"size": 7316,
"upload_time": "2024-02-21T06:01:21",
"upload_time_iso_8601": "2024-02-21T06:01:21.191573Z",
"url": "https://files.pythonhosted.org/packages/1f/cc/1811f198869316de6d72a4816f682de2b29abf57bc9d67d1ffb4a2937c17/lstar_lm-0.2.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "6642d1c3c665be353e3b3ba2296bbe0cebd0cd46b9276cb54c11a8caf28d2f63",
"md5": "808f712db03a0d6d0798d70c6cbe0209",
"sha256": "42d398aed84f84757e38a8011acf982c292e42a90be9812b25d2bafb5357278b"
},
"downloads": -1,
"filename": "lstar_lm-0.2.1.tar.gz",
"has_sig": false,
"md5_digest": "808f712db03a0d6d0798d70c6cbe0209",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10,<4.0",
"size": 5900,
"upload_time": "2024-02-21T06:01:23",
"upload_time_iso_8601": "2024-02-21T06:01:23.058683Z",
"url": "https://files.pythonhosted.org/packages/66/42/d1c3c665be353e3b3ba2296bbe0cebd0cd46b9276cb54c11a8caf28d2f63/lstar_lm-0.2.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-02-21 06:01:23",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "lstar_lm"
}