microsoft/sammo

★ 779⑂ 52

A library for prompt engineering and optimization (SAMMO = Structure-aware Multi-Objective Metaprompt Optimization)

About microsoft/sammo

microsoft/sammo is an open-source project on GitHub, mainly written in Python. A library for prompt engineering and optimization (SAMMO = Structure-aware Multi-Objective Metaprompt Optimization) It currently holds 779 stars and 52 forks with 0 open issues, and was last pushed on an unknown date (repository created unknown).

Project Overview

AI Homed tracks it on the AI Prompt Engineering board.

GitHub Repository Details

Repository microsoft/sammo · default branch - · size 0 KB · watchers 0 · source: GitHub REST API and repository README

README

SAMMO (📘User Guide)

Latest PyPI version License: MIT Binder

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

🎉 News

How to Get Started

Go to the user guide for examples, how-tos, and API reference.

Just want to have a quick look? Try the live demo on Binder.

Install library only

pip install sammo

Install and run tutorials

Prerequisites

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.

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.
runner = OpenAIChat(model_id="gpt-3.5-turbo", api_config=API_CONFIG)
PROMPT_IN_MARKDOWN = """

Instructions

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

SAMMO is designed to support

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

Licence

This project is licensed under MIT.

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

@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.

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 .

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. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

GitHub Stars & Activity

779Stars
52Forks
0Open issues
PythonLanguage

GitHub Popularity

GitHub stars779
Forks52
Open issues0
Primary languagePython
License-
Stars gained today0
Created-
Last pushed-

Trending History

Trending statusnot on today's boards

Related AI Projects

1

microsoft / promptflow

Python★ 11,244⑂ 1,123
2

promptslab / Promptify

Python★ 4,635⑂ 364
3
4

hegelai / prompttools

Python★ 3,055⑂ 256
5

Eladlev / AutoPrompt

Python★ 3,019⑂ 264
6

microsoftarchive / promptbench

Python★ 2,821⑂ 222
7

yaojingang / yao-open-prompts

Python★ 2,817⑂ 461
8

YiVal / YiVal

Python★ 2,134⑂ 328

More AI Rankings