Package: sammo
SAMMO (📘User Guide)A flexible, easy-to-use library for running and optimizing prompts for Large Language Models (LLMs).How to Get StartedGo to theuser guidefor examples, how-tos, and API reference.Install library onlypipinstallsammoInstall and run tutorialsPrerequisitesPython 3.11+poetryinstalled (pipx install poetryrecommended)The following commands will install sammo and jupyter dependencies in a virtualenv and launch jupyter notebook.# clone sammo to a local directorygitclonehttps://github.com/microsoft/sammo.gitcdsammo# optional: have poetry create a virtualenv in project folder rather than in its cache dirpoetryconfigvirtualenvs.in-projecttrue--local# install sammo and dev dependencies (including jupyter) in the project venvpoetryinstall--withdev# launch jupyter notebook and open tutorials directorypoetryrunjupyternotebook--notebook-dirdocs/tutorialsOr, try thelive demo on Binder.Use CasesSAMMO is designed to supportEfficient 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 buildInteractive, agent-based LLM applications (→ check outAutoGen)Interactive, production-ready LLM applications (→ check outLangChain)ExampleThis is extending thechat dialog example from Guidanceby running queries in parallel.runner=OpenAIChat(model_id="gpt-3.5-turbo",api_config=API_CONFIG)expert_names=GenerateText(Template("I want a response to the following question:""{{input}}\n""Name 3 world-class experts (past or present) who would be great at answering this? Don't answer the question yet."),system_prompt="You are a helpful and terse assistant.",randomness=0,max_tokens=300,)joint_answer=GenerateText("Great, now please answer the question as if these experts had collaborated in writing a joint anonymous answer.",history=expert_names,randomness=0,max_tokens=500,)questions=["How can I be more productive?","What will AI look like in 10 years?","How do we end world hunger?",]print(Output(joint_answer).run(runner,questions))LicenceThis project is licensed underMIT.AuthorsSAMMOwas written byTobias Schnabel.ContributingThis 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, visithttps://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 theMicrosoft Open Source Code of Conduct.
For more information see theCode of Conduct FAQor
contactopencode@microsoft.comwith any additional questions or comments.