sammo


Namesammo JSON
Version 0.3.1 PyPI version JSON
download
home_pagehttps://github.com/microsoft/sammo/
SummaryA flexible, easy-to-use library for running and optimizing prompts for Large Language Models (LLMs).
upload_time2024-11-13 23:44:01
maintainerNone
docs_urlNone
authorTobias Schnabel
requires_python<3.12,>=3.9
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # SAMMO ([πŸ“˜User Guide](https://microsoft.github.io/sammo/))

[![Latest PyPI version](https://img.shields.io/pypi/v/sammo.svg)](https://pypi.python.org/pypi/sammo)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/microsoft/sammo/main?urlpath=tree/docs/tutorials/quickstart.ipynb)

A flexible, easy-to-use library for running and optimizing prompts for Large Language Models (LLMs).

## πŸŽ‰ News
- Nov 13, 2024: Turn Markdown into prompt programs: First version of SAMMO express released
- Nov 1, 2024: Use CSS selectors to query and modify prompt programs!
- Oct 15, 2024: SAMMO now supports structured outputs!

## How to Get Started
Go to the [user guide](https://microsoft.github.io/sammo/) for examples, how-tos, and API reference.

Just want to have a quick look? Try the [live demo on Binder](https://mybinder.org/v2/gh/microsoft/sammo/main?urlpath=tree/docs/tutorials/quickstart.ipynb).

<!--start-->
### Install library only

```bash
pip install sammo
```

### Install and run tutorials

***Prerequisites***
* Python 3.9+

The following commands will install sammo and jupyter and launch jupyter notebook. It's recommended that you create and activate a virtualenv prior to installing packages.

```bash
pip install sammo jupyter

# clone sammo to a local directory
git clone https://github.com/microsoft/sammo.git
cd sammo

# launch jupyter notebook and open tutorials directory
jupyter notebook --notebook-dir docs/tutorials
```

## Example
This example shows how easy it is to optimize a prompt with SAMMO. The full example is in the [user guide](https://microsoft.github.io/sammo/).
```python
runner = OpenAIChat(model_id="gpt-3.5-turbo", api_config=API_CONFIG)
PROMPT_IN_MARKDOWN = """
# Instructions <!-- #instr -->
Convert the following user queries into a SQL query.

# Table
Users:
- user_id (INTEGER, PRIMARY KEY)
- name (TEXT)
- age (INTEGER)
- city (TEXT)

# Complete this
Input: {{{input}}}
Output:
"""

spp = MarkdownParser(PROMPT_IN_MARKDOWN).get_sammo_program()
mutation_operators = BagOfMutators(
    Output(GenerateText(spp)),
    Paraphrase("#instr"),
    Rewrite("#instr", "Make this more verbose.\n\n {{{{text}}}}")
)
prompt_optimizer = BeamSearch(runner, mutation_operators, accuracy)
prompt_optimizer.fit(d_train)
prompt_optimizer.show_report()
```

## Use Cases
![Overview](https://microsoft.github.io/sammo/_images/overview.png)

SAMMO is designed to support
- **Efficient data labeling**: Supports minibatching by packing and parsing multiple datapoints into a single prompt.
- **Prompt prototyping and engineering**: Re-usable components and prompt structures to quickly build and test new prompts.
- **Instruction optimization**: Optimize instructions to do better on a given task.
- **Prompt compression**: Compress prompts while maintaining performance.
- **Large-scale prompt execution**: parallelization
and rate-limiting out-of-the-box so you can run many queries in parallel and at scale without overwhelming the LLM API.

It is less useful if you want to build
- Interactive, agent-based LLM applications (β†’ check out [AutoGen](https://microsoft.github.io/autogen/))
- Interactive, production-ready LLM applications (β†’ check out [LangChain](https://www.langchain.com/))

<!--end-->

## Licence

This project is licensed under [MIT](https://choosealicense.com/licenses/mit/).

To cite this paper, you can use the following BibTeX entry:

```bibtex
@inproceedings{schnabel-neville-2024-symbolic,
    title = "Symbolic Prompt Program Search: A Structure-Aware Approach to Efficient Compile-Time Prompt Optimization",
    author = "Schnabel, Tobias and Neville, Jennifer",
    booktitle = "Findings of the Association for Computational Linguistics: EMNLP 2024",
    year = "2024",
    url = "https://aclanthology.org/2024.findings-emnlp.37",
    pages = "670--686"
}
```

## Authors

`SAMMO` was written by [Tobias Schnabel](mailto:sammo@microsoft.com).

## Contributing

This project welcomes contributions and suggestions.  Most contributions require you to agree to a
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
the rights to use your contribution. For details, visit <https://cla.opensource.microsoft.com>.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide
a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions
provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
contact [opencode@microsoft.com](mailto:opencode@microsoft.com>) with any additional questions or comments.


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/microsoft/sammo/",
    "name": "sammo",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<3.12,>=3.9",
    "maintainer_email": null,
    "keywords": null,
    "author": "Tobias Schnabel",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/17/dd/a50f46a84b878ca08cb88e3f34864e6b9a604c3666fe4adc6a43dc1dfe4a/sammo-0.3.1.tar.gz",
    "platform": null,
    "description": "# SAMMO ([\ud83d\udcd8User Guide](https://microsoft.github.io/sammo/))\n\n[![Latest PyPI version](https://img.shields.io/pypi/v/sammo.svg)](https://pypi.python.org/pypi/sammo)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/microsoft/sammo/main?urlpath=tree/docs/tutorials/quickstart.ipynb)\n\nA flexible, easy-to-use library for running and optimizing prompts for Large Language Models (LLMs).\n\n## \ud83c\udf89 News\n- Nov 13, 2024: Turn Markdown into prompt programs: First version of SAMMO express released\n- Nov 1, 2024: Use CSS selectors to query and modify prompt programs!\n- Oct 15, 2024: SAMMO now supports structured outputs!\n\n## How to Get Started\nGo to the [user guide](https://microsoft.github.io/sammo/) for examples, how-tos, and API reference.\n\nJust want to have a quick look? Try the [live demo on Binder](https://mybinder.org/v2/gh/microsoft/sammo/main?urlpath=tree/docs/tutorials/quickstart.ipynb).\n\n<!--start-->\n### Install library only\n\n```bash\npip install sammo\n```\n\n### Install and run tutorials\n\n***Prerequisites***\n* Python 3.9+\n\nThe following commands will install sammo and jupyter and launch jupyter notebook. It's recommended that you create and activate a virtualenv prior to installing packages.\n\n```bash\npip install sammo jupyter\n\n# clone sammo to a local directory\ngit clone https://github.com/microsoft/sammo.git\ncd sammo\n\n# launch jupyter notebook and open tutorials directory\njupyter notebook --notebook-dir docs/tutorials\n```\n\n## Example\nThis example shows how easy it is to optimize a prompt with SAMMO. The full example is in the [user guide](https://microsoft.github.io/sammo/).\n```python\nrunner = OpenAIChat(model_id=\"gpt-3.5-turbo\", api_config=API_CONFIG)\nPROMPT_IN_MARKDOWN = \"\"\"\n# Instructions <!-- #instr -->\nConvert the following user queries into a SQL query.\n\n# Table\nUsers:\n- user_id (INTEGER, PRIMARY KEY)\n- name (TEXT)\n- age (INTEGER)\n- city (TEXT)\n\n# Complete this\nInput: {{{input}}}\nOutput:\n\"\"\"\n\nspp = MarkdownParser(PROMPT_IN_MARKDOWN).get_sammo_program()\nmutation_operators = BagOfMutators(\n    Output(GenerateText(spp)),\n    Paraphrase(\"#instr\"),\n    Rewrite(\"#instr\", \"Make this more verbose.\\n\\n {{{{text}}}}\")\n)\nprompt_optimizer = BeamSearch(runner, mutation_operators, accuracy)\nprompt_optimizer.fit(d_train)\nprompt_optimizer.show_report()\n```\n\n## Use Cases\n![Overview](https://microsoft.github.io/sammo/_images/overview.png)\n\nSAMMO is designed to support\n- **Efficient data labeling**: Supports minibatching by packing and parsing multiple datapoints into a single prompt.\n- **Prompt prototyping and engineering**: Re-usable components and prompt structures to quickly build and test new prompts.\n- **Instruction optimization**: Optimize instructions to do better on a given task.\n- **Prompt compression**: Compress prompts while maintaining performance.\n- **Large-scale prompt execution**: parallelization\nand rate-limiting out-of-the-box so you can run many queries in parallel and at scale without overwhelming the LLM API.\n\nIt is less useful if you want to build\n- Interactive, agent-based LLM applications (\u2192 check out [AutoGen](https://microsoft.github.io/autogen/))\n- Interactive, production-ready LLM applications (\u2192 check out [LangChain](https://www.langchain.com/))\n\n<!--end-->\n\n## Licence\n\nThis project is licensed under [MIT](https://choosealicense.com/licenses/mit/).\n\nTo cite this paper, you can use the following BibTeX entry:\n\n```bibtex\n@inproceedings{schnabel-neville-2024-symbolic,\n    title = \"Symbolic Prompt Program Search: A Structure-Aware Approach to Efficient Compile-Time Prompt Optimization\",\n    author = \"Schnabel, Tobias and Neville, Jennifer\",\n    booktitle = \"Findings of the Association for Computational Linguistics: EMNLP 2024\",\n    year = \"2024\",\n    url = \"https://aclanthology.org/2024.findings-emnlp.37\",\n    pages = \"670--686\"\n}\n```\n\n## Authors\n\n`SAMMO` was written by [Tobias Schnabel](mailto:sammo@microsoft.com).\n\n## Contributing\n\nThis project welcomes contributions and suggestions.  Most contributions require you to agree to a\nContributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us\nthe rights to use your contribution. For details, visit <https://cla.opensource.microsoft.com>.\n\nWhen you submit a pull request, a CLA bot will automatically determine whether you need to provide\na CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions\nprovided by the bot. You will only need to do this once across all repos using our CLA.\n\nThis project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).\nFor more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or\ncontact [opencode@microsoft.com](mailto:opencode@microsoft.com>) with any additional questions or comments.\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A flexible, easy-to-use library for running and optimizing prompts for Large Language Models (LLMs).",
    "version": "0.3.1",
    "project_urls": {
        "Documentation": "https://microsoft.github.io/sammo/docs/",
        "Homepage": "https://github.com/microsoft/sammo/",
        "Repository": "https://github.com/microsoft/sammo/"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6cdc0131b08512acb362d75c23b55547d1395afa297365b236b03d56dca21572",
                "md5": "6254c71778cfe37ce0d60a32792e3858",
                "sha256": "d2d6ab840a157a6fc17a3889749edd4d803857dcc4b77ac685c05608be2019a1"
            },
            "downloads": -1,
            "filename": "sammo-0.3.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6254c71778cfe37ce0d60a32792e3858",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<3.12,>=3.9",
            "size": 79780,
            "upload_time": "2024-11-13T23:43:59",
            "upload_time_iso_8601": "2024-11-13T23:43:59.669168Z",
            "url": "https://files.pythonhosted.org/packages/6c/dc/0131b08512acb362d75c23b55547d1395afa297365b236b03d56dca21572/sammo-0.3.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "17dda50f46a84b878ca08cb88e3f34864e6b9a604c3666fe4adc6a43dc1dfe4a",
                "md5": "9a3f8deb22dc2c79ce4ecf3eee29242a",
                "sha256": "253b616115e01c1b3a0a09f51a9fa881e5442dd1bc0c99892a9cecc43b1fe6fc"
            },
            "downloads": -1,
            "filename": "sammo-0.3.1.tar.gz",
            "has_sig": false,
            "md5_digest": "9a3f8deb22dc2c79ce4ecf3eee29242a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<3.12,>=3.9",
            "size": 69365,
            "upload_time": "2024-11-13T23:44:01",
            "upload_time_iso_8601": "2024-11-13T23:44:01.030075Z",
            "url": "https://files.pythonhosted.org/packages/17/dd/a50f46a84b878ca08cb88e3f34864e6b9a604c3666fe4adc6a43dc1dfe4a/sammo-0.3.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-13 23:44:01",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "microsoft",
    "github_project": "sammo",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "sammo"
}
        
Elapsed time: 0.42942s