-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
outlines/README.md at main · outlines-dev/outlines #762
Labels
ai-platform
model hosts and APIs
llm
Large Language Models
programming-languages
Topics related to programming languages and their features.
prompt
Collection of llm prompts and notes
prompt-engineering
Developing and optimizing prompts to efficiently use language models for various applications and re
source-code
Code snippets
Comments
irthomasthomas
added
ai-platform
model hosts and APIs
llm
Large Language Models
programming-languages
Topics related to programming languages and their features.
prompt
Collection of llm prompts and notes
prompt-engineering
Developing and optimizing prompts to efficiently use language models for various applications and re
source-code
Code snippets
labels
Mar 16, 2024
This was referenced Mar 16, 2024
1 task
1 task
1 task
This was referenced Jul 30, 2024
Open
This was referenced Aug 9, 2024
Open
This was referenced Aug 16, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
ai-platform
model hosts and APIs
llm
Large Language Models
programming-languages
Topics related to programming languages and their features.
prompt
Collection of llm prompts and notes
prompt-engineering
Developing and optimizing prompts to efficiently use language models for various applications and re
source-code
Code snippets
Title: outlines/README.md at main · outlines-dev/outlines
Description:
Outlines 〰️
Robust (structured) text generation.
🙏 Help us by answering the developer survey 🙏
Made with ❤👷️ by the team at .txt.
Looking for an API that returns valid JSON? Give .json a try ✨
First time here? Go to our setup guide
Features
outlinesdev/outlines
!Outlines 〰 has new releases and features coming every week. Make sure to ⭐ star and 👀 watch this repository, follow @dottxtai to stay up to date!
Structured generation
The first step towards reliability of systems that include large language models
is to ensure that there is a well-defined interface between their output and
user-defined code. Outlines provides ways to control the generation of
language models to make their output more predictable.
Multiple choices
You can reduce the completion to a choice between multiple possibilities:
Type constraint
You can instruct the model to only return integers or floats:
Efficient regex-structured generation
Outlines also comes with fast regex-structured generation. In fact, the
choice
andformat
functions above all use regex-structured generation under thehood:
Unlike other libraries, regex-structured generation in Outlines is almost as fast
as non-structured generation.
Efficient JSON generation following a Pydantic model
Outlines 〰 allows to guide the generation process so the output is guaranteed to follow a JSON schema or Pydantic model:
The method works with union types, optional types, arrays, nested schemas, etc. Some field constraints are not supported yet, but everything else should work.
Efficient JSON generation following a JSON Schema
Sometimes you just want to be able to pass a JSON Schema instead of a Pydantic model. We've got you covered:
Using context-free grammars to guide generation
Formal grammars rule the world, and Outlines makes them rule LLMs too. You can pass any context-free grammar in the EBNF format and Outlines will generate an output that is valid to this grammar:
This was a very simple grammar, and you can use
outlines.generate.cfg
to generate syntactically valid Python, SQL, and much more than this. Any kind of structured text, really. All you have to do is search for "X EBNF grammar" on the web, and take a look at the Outlinesgrammars
module.Open functions
Outlines can infer the structure of the output from the signature of a function. The result is a dictionary, and can be passed directly to the function using the usual dictionary expansion syntax
**
:A great advantage of passing functions directly to specify the structure is that the structure of the LLM will change with the function's definition. No need to change the code at several places!
Prompting
Building prompts can get messy. Outlines makes it easier to write and manage
prompts by encapsulating templates inside "template functions".
These functions make it possible to neatly separate the prompt logic from the
general program logic; they can be imported from other modules and libraries.
Template functions require no superfluous abstraction, they use the Jinja2
templating engine to help build complex prompts in a concise manner:
Join us
Suggested labels
The text was updated successfully, but these errors were encountered: