{"id":8850339,"url":"https://github.com/microsoft/sammo","last_synced_at":"2025-05-14T20:09:21.678Z","repository":{"id":212717594,"uuid":"727460041","full_name":"microsoft/sammo","owner":"microsoft","description":"A library for prompt engineering and optimization (SAMMO = Structure-aware Multi-Objective Metaprompt Optimization)","archived":false,"fork":false,"pushed_at":"2024-12-20T10:20:17.000Z","size":3099,"stargazers_count":660,"open_issues_count":5,"forks_count":35,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-04-06T19:01:32.601Z","etag":null,"topics":["llms","prompt-engineering","prompt-tuning"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/microsoft.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":"SECURITY.md","support":"SUPPORT.md","governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-12-04T22:49:34.000Z","updated_at":"2025-04-04T02:04:30.000Z","dependencies_parsed_at":"2023-12-15T21:00:25.017Z","dependency_job_id":"0d93cf19-e4c9-4d41-a3c6-65dd044b9d31","html_url":"https://github.com/microsoft/sammo","commit_stats":{"total_commits":104,"total_committers":4,"mean_commits":26.0,"dds":0.6153846153846154,"last_synced_commit":"7ad76482f5776ed83f608f39ef9be4b96cab8329"},"previous_names":["microsoft/sammo"],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2Fsammo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2Fsammo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2Fsammo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2Fsammo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/microsoft","download_url":"https://codeload.github.com/microsoft/sammo/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248783314,"owners_count":21160900,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["llms","prompt-engineering","prompt-tuning"],"created_at":"2024-04-30T18:02:54.702Z","updated_at":"2025-04-13T21:21:54.970Z","avatar_url":"https://github.com/microsoft.png","language":"Python","funding_links":[],"categories":["A01_文本生成_文本对话","**Section 2** : Azure OpenAI and Reference Architecture","Python","Building","✂️ Compress Context","Prompt Engineering \u0026 Tooling"],"sub_categories":["大语言对话模型及数据","**Microsoft Azure OpenAI relevant LLM Framework**","Prompt Engineering","Prompt compression"],"readme":"# SAMMO ([📘User 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## 🎉 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\u003c!--start--\u003e\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 \u003c!-- #instr --\u003e\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 (→ check out [AutoGen](https://microsoft.github.io/autogen/))\n- Interactive, production-ready LLM applications (→ check out [LangChain](https://www.langchain.com/))\n\n\u003c!--end--\u003e\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 \u003chttps://cla.opensource.microsoft.com\u003e.\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\u003e) with any additional questions or comments.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicrosoft%2Fsammo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmicrosoft%2Fsammo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicrosoft%2Fsammo/lists"}