outlines


Nameoutlines JSON
Version 0.0.41 PyPI version JSON
download
home_pageNone
SummaryProbabilistic Generative Model Programming
upload_time2024-04-30 13:13:44
maintainerNone
docs_urlNone
authorOutlines Developers
requires_python>=3.8
licenseNone
keywords machine learning deep learning language models structured generation
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <div align="center" style="margin-bottom: 1em;">

# Outlines 〰️

<img src="./docs/assets/images/logo.png" alt="Outlines Logo" width=300></img>

[![.txt Twitter][dottxt-twitter-badge]][dottxt-twitter]
[![Outlines Twitter][outlines-twitter-badge]][outlines-twitter]

[![Contributors][contributors-badge]][contributors]
[![Downloads][downloads-badge]][pypistats]
[![Discord][discord-badge]][discord]


*Robust (structured) text generation.*

Made with ❤👷️ by the team at [.txt](https://dottxt.co).

</div>


``` bash
pip install outlines
```

First time here? Go to our [setup guide](https://outlines-dev.github.io/outlines/welcome)

## Features

- [x] 🤖 [Multiple model integrations](https://outlines-dev.github.io/outlines/installation): OpenAI, transformers, llama.cpp, exllama2, mamba
- [x] 🖍️ Simple and powerful prompting primitives based on the [Jinja templating engine](https://jinja.palletsprojects.com/)
- [x] 🚄 [Multiple choices](#multiple-choices), [type constraints](#type-constraint) and dynamic stopping
- [x] ⚡ Fast [regex-structured generation](#efficient-regex-structured-generation)
- [x] 🔥 Fast [JSON generation](#efficient-json-generation-following-a-pydantic-model) following a JSON schema or a Pydantic model
- [x] 📝 [Grammar-structured generation](#using-context-free-grammars-to-guide-generation)
- [x] 🐍 Interleave completions with loops, conditionals, and custom Python functions
- [x] 💾 Caching of generations
- [x] 🗂️ Batch inference
- [x] 🎲 Sample with the greedy, multinomial and beam search algorithms (and more to come!)
- [x] 🚀 [Serve with vLLM](https://outlines-dev.github.io/outlines/reference/vllm), with official Docker image, [`outlinesdev/outlines`](https://hub.docker.com/r/outlinesdev/outlines)!


Outlines 〰 has new releases and features coming every week. Make sure to ⭐ star and 👀 watch this repository, follow [@dottxtai][twitter] to stay up to date!

## Why should I use structured generation?

* It doesn't add any overhead during inference (cost-free)
* [It speeds up inference](http://blog.dottxt.co/coalescence.html)
* [It improves the performance of base models (GSM8K)](http://blog.dottxt.co/performance-gsm8k.html)
* [It improves the performance of finetuned models (CoNNL)](https://predibase.com/blog/lorax-outlines-better-json-extraction-with-structured-generation-and-lora)

## .txt company

<div align="center">
<img src="./docs/assets/images/dottxt.png" alt="Outlines Logo" width=100></img>
</div>

We started a company to keep pushing the boundaries of structured generation. Learn more about [.txt](https://twitter.com/dottxtai), and  [give our .json API a try](https://h1xbpbfsf0w.typeform.com/to/ZgBCvJHF) if you need a hosted solution ✨

## 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:

``` python
import outlines

model = outlines.models.transformers("mistralai/Mistral-7B-Instruct-v0.2")

prompt = """You are a sentiment-labelling assistant.
Is the following review positive or negative?

Review: This restaurant is just awesome!
"""

generator = outlines.generate.choice(model, ["Positive", "Negative"])
answer = generator(prompt)
```

### Type constraint

You can instruct the model to only return integers or floats:


``` python
import outlines

model = outlines.models.transformers("WizardLM/WizardMath-7B-V1.1")

prompt = "<s>result of 9 + 9 = 18</s><s>result of 1 + 2 = "
answer = outlines.generate.format(model, int)(prompt)
print(answer)
# 3

prompt = "sqrt(2)="
generator = outlines.generate.format(model, float)
answer = generator(prompt, max_tokens=10)
print(answer)
# 1.41421356
```

### Efficient regex-structured generation

Outlines also comes with fast regex-structured generation. In fact, the `choice` and
`format` functions above all use regex-structured generation under the
hood:

``` python
import outlines

model = outlines.models.transformers("mistralai/Mistral-7B-Instruct-v0.2")

prompt = "What is the IP address of the Google DNS servers? "

generator = outlines.generate.text(model)
unstructured = generator(prompt, max_tokens=30)

generator = outlines.generate.regex(
    model,
    r"((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)",
)
structured = generator(prompt, max_tokens=30)

print(unstructured)
# What is the IP address of the Google DNS servers?
#
# Passive DNS servers are at DNS servers that are private.
# In other words, both IP servers are private. The database
# does not contain Chelsea Manning

print(structured)
# What is the IP address of the Google DNS servers?
# 2.2.6.1
```

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](https://json-schema.org/) or [Pydantic model](https://docs.pydantic.dev/latest/):

```python
from enum import Enum
from pydantic import BaseModel, constr

import outlines
import torch


class Weapon(str, Enum):
    sword = "sword"
    axe = "axe"
    mace = "mace"
    spear = "spear"
    bow = "bow"
    crossbow = "crossbow"


class Armor(str, Enum):
    leather = "leather"
    chainmail = "chainmail"
    plate = "plate"


class Character(BaseModel):
    name: constr(max_length=10)
    age: int
    armor: Armor
    weapon: Weapon
    strength: int


model = outlines.models.transformers("mistralai/Mistral-7B-Instruct-v0.2")

# Construct structured sequence generator
generator = outlines.generate.json(model, Character)

# Draw a sample
rng = torch.Generator(device="cuda")
rng.manual_seed(789001)

character = generator("Give me a character description", rng=rng)

print(repr(character))
# Character(name='Anderson', age=28, armor=<Armor.chainmail: 'chainmail'>, weapon=<Weapon.sword: 'sword'>, strength=8)

character = generator("Give me an interesting character description", rng=rng)

print(repr(character))
# Character(name='Vivian Thr', age=44, armor=<Armor.plate: 'plate'>, weapon=<Weapon.crossbow: 'crossbow'>, strength=125)
```

The method works with union types, optional types, arrays, nested schemas, etc. Some field constraints are [not supported yet](https://github.com/outlines-dev/outlines/issues/215), 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:

``` python
import outlines

schema = '''{
    "title": "Character",
    "type": "object",
    "properties": {
        "name": {
            "title": "Name",
            "maxLength": 10,
            "type": "string"
        },
        "age": {
            "title": "Age",
            "type": "integer"
        },
        "armor": {"$ref": "#/definitions/Armor"},
        "weapon": {"$ref": "#/definitions/Weapon"},
        "strength": {
            "title": "Strength",
            "type": "integer"
        }
    },
    "required": ["name", "age", "armor", "weapon", "strength"],
    "definitions": {
        "Armor": {
            "title": "Armor",
            "description": "An enumeration.",
            "enum": ["leather", "chainmail", "plate"],
            "type": "string"
        },
        "Weapon": {
            "title": "Weapon",
            "description": "An enumeration.",
            "enum": ["sword", "axe", "mace", "spear", "bow", "crossbow"],
            "type": "string"
        }
    }
}'''

model = outlines.models.transformers("mistralai/Mistral-7B-Instruct-v0.2")
generator = outlines.generate.json(model, schema)
character = generator("Give me a character description")
```

### 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:

``` python
import outlines

arithmetic_grammar = """
    ?start: expression

    ?expression: term (("+" | "-") term)*

    ?term: factor (("*" | "/") factor)*

    ?factor: NUMBER
           | "-" factor
           | "(" expression ")"

    %import common.NUMBER
"""

model = outlines.models.transformers("WizardLM/WizardMath-7B-V1.1")
generator = outlines.generate.cfg(model, arithmetic_grammar)
sequence = generator("Alice had 4 apples and Bob ate 2. Write an expression for Alice's apples:")

print(sequence)
# (8-2)
```

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 [Outlines `grammars` module](https://github.com/outlines-dev/outlines/tree/main/outlines/grammars).

### 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 `**`:

```python
import outlines


def add(a: int, b: int):
    return a + b

model = outlines.models.transformers("WizardLM/WizardMath-7B-V1.1")
generator = outlines.generate.json(model, add)
result = generator("Return json with two integers named a and b respectively. a is odd and b even.")

print(add(**result))
# 3
```

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:

``` python
import outlines

examples = [
    ("The food was disgusting", "Negative"),
    ("We had a fantastic night", "Positive"),
    ("Recommended", "Positive"),
    ("The waiter was rude", "Negative")
]

@outlines.prompt
def labelling(to_label, examples):
    """You are a sentiment-labelling assistant.

    {% for example in examples %}
    {{ example[0] }} // {{ example[1] }}
    {% endfor %}
    {{ to_label }} //
    """

model = outlines.models.transformers("mistralai/Mistral-7B-Instruct-v0.2")
prompt = labelling("Just awesome", examples)
answer = outlines.generate.text(model)(prompt, max_tokens=100)
```

## Join us

- 💡 **Have an idea?** Come chat with us on [Discord][discord]
- 🔨 **Want to contribute?** Consult our [contribution guide](https://outlines-dev.github.io/outlines/community/contribute/).
- 🐞 **Found a bug?** Open an [issue](https://github.com/outlines-dev/outlines/issues)


## Cite Outlines

```
@article{willard2023efficient,
  title={Efficient Guided Generation for LLMs},
  author={Willard, Brandon T and Louf, R{\'e}mi},
  journal={arXiv preprint arXiv:2307.09702},
  year={2023}
}
```

[contributors]: https://github.com/outlines-dev/outlines/graphs/contributors
[contributors-badge]: https://img.shields.io/github/contributors/outlines-dev/outlines?style=flat-square&logo=github&logoColor=white&color=ECEFF4
[dottxt-twitter]: https://twitter.com/dottxtai
[outlines-twitter]: https://twitter.com/OutlinesOSS
[discord]: https://discord.gg/R9DSu34mGd
[discord-badge]: https://img.shields.io/discord/1182316225284554793?color=81A1C1&logo=discord&logoColor=white&style=flat-square
[downloads-badge]: https://img.shields.io/pypi/dm/outlines?color=89AC6B&logo=python&logoColor=white&style=flat-square
[pypistats]: https://pypistats.org/packages/outlines
[dottxt-twitter-badge]: https://img.shields.io/twitter/follow/dottxtai?style=social
[outlines-twitter-badge]: https://img.shields.io/twitter/follow/OutlinesOSS?style=social

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "outlines",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "machine learning, deep learning, language models, structured generation",
    "author": "Outlines Developers",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/5e/c1/94bfe99a2218916a15188ae74932ba2e5806dd0d63059066e6d4cffa1916/outlines-0.0.41.tar.gz",
    "platform": null,
    "description": "<div align=\"center\" style=\"margin-bottom: 1em;\">\n\n# Outlines \u3030\ufe0f\n\n<img src=\"./docs/assets/images/logo.png\" alt=\"Outlines Logo\" width=300></img>\n\n[![.txt Twitter][dottxt-twitter-badge]][dottxt-twitter]\n[![Outlines Twitter][outlines-twitter-badge]][outlines-twitter]\n\n[![Contributors][contributors-badge]][contributors]\n[![Downloads][downloads-badge]][pypistats]\n[![Discord][discord-badge]][discord]\n\n\n*Robust (structured) text generation.*\n\nMade with \u2764\ud83d\udc77\ufe0f by the team at [.txt](https://dottxt.co).\n\n</div>\n\n\n``` bash\npip install outlines\n```\n\nFirst time here? Go to our [setup guide](https://outlines-dev.github.io/outlines/welcome)\n\n## Features\n\n- [x] \ud83e\udd16 [Multiple model integrations](https://outlines-dev.github.io/outlines/installation): OpenAI, transformers, llama.cpp, exllama2, mamba\n- [x] \ud83d\udd8d\ufe0f Simple and powerful prompting primitives based on the [Jinja templating engine](https://jinja.palletsprojects.com/)\n- [x] \ud83d\ude84 [Multiple choices](#multiple-choices), [type constraints](#type-constraint) and dynamic stopping\n- [x] \u26a1 Fast [regex-structured generation](#efficient-regex-structured-generation)\n- [x] \ud83d\udd25 Fast [JSON generation](#efficient-json-generation-following-a-pydantic-model) following a JSON schema or a Pydantic model\n- [x] \ud83d\udcdd [Grammar-structured generation](#using-context-free-grammars-to-guide-generation)\n- [x] \ud83d\udc0d Interleave completions with loops, conditionals, and custom Python functions\n- [x] \ud83d\udcbe Caching of generations\n- [x] \ud83d\uddc2\ufe0f Batch inference\n- [x] \ud83c\udfb2 Sample with the greedy, multinomial and beam search algorithms (and more to come!)\n- [x] \ud83d\ude80 [Serve with vLLM](https://outlines-dev.github.io/outlines/reference/vllm), with official Docker image, [`outlinesdev/outlines`](https://hub.docker.com/r/outlinesdev/outlines)!\n\n\nOutlines \u3030 has new releases and features coming every week. Make sure to \u2b50 star and \ud83d\udc40 watch this repository, follow [@dottxtai][twitter] to stay up to date!\n\n## Why should I use structured generation?\n\n* It doesn't add any overhead during inference (cost-free)\n* [It speeds up inference](http://blog.dottxt.co/coalescence.html)\n* [It improves the performance of base models (GSM8K)](http://blog.dottxt.co/performance-gsm8k.html)\n* [It improves the performance of finetuned models (CoNNL)](https://predibase.com/blog/lorax-outlines-better-json-extraction-with-structured-generation-and-lora)\n\n## .txt company\n\n<div align=\"center\">\n<img src=\"./docs/assets/images/dottxt.png\" alt=\"Outlines Logo\" width=100></img>\n</div>\n\nWe started a company to keep pushing the boundaries of structured generation. Learn more about [.txt](https://twitter.com/dottxtai), and  [give our .json API a try](https://h1xbpbfsf0w.typeform.com/to/ZgBCvJHF) if you need a hosted solution \u2728\n\n## Structured generation\n\nThe first step towards reliability of systems that include large language models\nis to ensure that there is a well-defined interface between their output and\nuser-defined code. **Outlines** provides ways to control the generation of\nlanguage models to make their output more predictable.\n\n### Multiple choices\n\nYou can reduce the completion to a choice between multiple possibilities:\n\n``` python\nimport outlines\n\nmodel = outlines.models.transformers(\"mistralai/Mistral-7B-Instruct-v0.2\")\n\nprompt = \"\"\"You are a sentiment-labelling assistant.\nIs the following review positive or negative?\n\nReview: This restaurant is just awesome!\n\"\"\"\n\ngenerator = outlines.generate.choice(model, [\"Positive\", \"Negative\"])\nanswer = generator(prompt)\n```\n\n### Type constraint\n\nYou can instruct the model to only return integers or floats:\n\n\n``` python\nimport outlines\n\nmodel = outlines.models.transformers(\"WizardLM/WizardMath-7B-V1.1\")\n\nprompt = \"<s>result of 9 + 9 = 18</s><s>result of 1 + 2 = \"\nanswer = outlines.generate.format(model, int)(prompt)\nprint(answer)\n# 3\n\nprompt = \"sqrt(2)=\"\ngenerator = outlines.generate.format(model, float)\nanswer = generator(prompt, max_tokens=10)\nprint(answer)\n# 1.41421356\n```\n\n### Efficient regex-structured generation\n\nOutlines also comes with fast regex-structured generation. In fact, the `choice` and\n`format` functions above all use regex-structured generation under the\nhood:\n\n``` python\nimport outlines\n\nmodel = outlines.models.transformers(\"mistralai/Mistral-7B-Instruct-v0.2\")\n\nprompt = \"What is the IP address of the Google DNS servers? \"\n\ngenerator = outlines.generate.text(model)\nunstructured = generator(prompt, max_tokens=30)\n\ngenerator = outlines.generate.regex(\n    model,\n    r\"((25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.){3}(25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\",\n)\nstructured = generator(prompt, max_tokens=30)\n\nprint(unstructured)\n# What is the IP address of the Google DNS servers?\n#\n# Passive DNS servers are at DNS servers that are private.\n# In other words, both IP servers are private. The database\n# does not contain Chelsea Manning\n\nprint(structured)\n# What is the IP address of the Google DNS servers?\n# 2.2.6.1\n```\n\nUnlike other libraries, regex-structured generation in Outlines is almost as fast\nas non-structured generation.\n\n### Efficient JSON generation following a Pydantic model\n\nOutlines \u3030 allows to guide the generation process so the output is *guaranteed* to follow a [JSON schema](https://json-schema.org/) or [Pydantic model](https://docs.pydantic.dev/latest/):\n\n```python\nfrom enum import Enum\nfrom pydantic import BaseModel, constr\n\nimport outlines\nimport torch\n\n\nclass Weapon(str, Enum):\n    sword = \"sword\"\n    axe = \"axe\"\n    mace = \"mace\"\n    spear = \"spear\"\n    bow = \"bow\"\n    crossbow = \"crossbow\"\n\n\nclass Armor(str, Enum):\n    leather = \"leather\"\n    chainmail = \"chainmail\"\n    plate = \"plate\"\n\n\nclass Character(BaseModel):\n    name: constr(max_length=10)\n    age: int\n    armor: Armor\n    weapon: Weapon\n    strength: int\n\n\nmodel = outlines.models.transformers(\"mistralai/Mistral-7B-Instruct-v0.2\")\n\n# Construct structured sequence generator\ngenerator = outlines.generate.json(model, Character)\n\n# Draw a sample\nrng = torch.Generator(device=\"cuda\")\nrng.manual_seed(789001)\n\ncharacter = generator(\"Give me a character description\", rng=rng)\n\nprint(repr(character))\n# Character(name='Anderson', age=28, armor=<Armor.chainmail: 'chainmail'>, weapon=<Weapon.sword: 'sword'>, strength=8)\n\ncharacter = generator(\"Give me an interesting character description\", rng=rng)\n\nprint(repr(character))\n# Character(name='Vivian Thr', age=44, armor=<Armor.plate: 'plate'>, weapon=<Weapon.crossbow: 'crossbow'>, strength=125)\n```\n\nThe method works with union types, optional types, arrays, nested schemas, etc. Some field constraints are [not supported yet](https://github.com/outlines-dev/outlines/issues/215), but everything else should work.\n\n### Efficient JSON generation following a JSON Schema\n\nSometimes you just want to be able to pass a JSON Schema instead of a Pydantic model. We've got you covered:\n\n``` python\nimport outlines\n\nschema = '''{\n    \"title\": \"Character\",\n    \"type\": \"object\",\n    \"properties\": {\n        \"name\": {\n            \"title\": \"Name\",\n            \"maxLength\": 10,\n            \"type\": \"string\"\n        },\n        \"age\": {\n            \"title\": \"Age\",\n            \"type\": \"integer\"\n        },\n        \"armor\": {\"$ref\": \"#/definitions/Armor\"},\n        \"weapon\": {\"$ref\": \"#/definitions/Weapon\"},\n        \"strength\": {\n            \"title\": \"Strength\",\n            \"type\": \"integer\"\n        }\n    },\n    \"required\": [\"name\", \"age\", \"armor\", \"weapon\", \"strength\"],\n    \"definitions\": {\n        \"Armor\": {\n            \"title\": \"Armor\",\n            \"description\": \"An enumeration.\",\n            \"enum\": [\"leather\", \"chainmail\", \"plate\"],\n            \"type\": \"string\"\n        },\n        \"Weapon\": {\n            \"title\": \"Weapon\",\n            \"description\": \"An enumeration.\",\n            \"enum\": [\"sword\", \"axe\", \"mace\", \"spear\", \"bow\", \"crossbow\"],\n            \"type\": \"string\"\n        }\n    }\n}'''\n\nmodel = outlines.models.transformers(\"mistralai/Mistral-7B-Instruct-v0.2\")\ngenerator = outlines.generate.json(model, schema)\ncharacter = generator(\"Give me a character description\")\n```\n\n### Using context-free grammars to guide generation\n\nFormal 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:\n\n``` python\nimport outlines\n\narithmetic_grammar = \"\"\"\n    ?start: expression\n\n    ?expression: term ((\"+\" | \"-\") term)*\n\n    ?term: factor ((\"*\" | \"/\") factor)*\n\n    ?factor: NUMBER\n           | \"-\" factor\n           | \"(\" expression \")\"\n\n    %import common.NUMBER\n\"\"\"\n\nmodel = outlines.models.transformers(\"WizardLM/WizardMath-7B-V1.1\")\ngenerator = outlines.generate.cfg(model, arithmetic_grammar)\nsequence = generator(\"Alice had 4 apples and Bob ate 2. Write an expression for Alice's apples:\")\n\nprint(sequence)\n# (8-2)\n```\n\nThis 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 [Outlines `grammars` module](https://github.com/outlines-dev/outlines/tree/main/outlines/grammars).\n\n### Open functions\n\nOutlines 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 `**`:\n\n```python\nimport outlines\n\n\ndef add(a: int, b: int):\n    return a + b\n\nmodel = outlines.models.transformers(\"WizardLM/WizardMath-7B-V1.1\")\ngenerator = outlines.generate.json(model, add)\nresult = generator(\"Return json with two integers named a and b respectively. a is odd and b even.\")\n\nprint(add(**result))\n# 3\n```\n\nA 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!\n\n## Prompting\n\nBuilding prompts can get messy. **Outlines** makes it easier to write and manage\nprompts by encapsulating templates inside \"template functions\".\n\nThese functions make it possible to neatly separate the prompt logic from the\ngeneral program logic; they can be imported from other modules and libraries.\n\nTemplate functions require no superfluous abstraction, they use the Jinja2\ntemplating engine to help build complex prompts in a concise manner:\n\n``` python\nimport outlines\n\nexamples = [\n    (\"The food was disgusting\", \"Negative\"),\n    (\"We had a fantastic night\", \"Positive\"),\n    (\"Recommended\", \"Positive\"),\n    (\"The waiter was rude\", \"Negative\")\n]\n\n@outlines.prompt\ndef labelling(to_label, examples):\n    \"\"\"You are a sentiment-labelling assistant.\n\n    {% for example in examples %}\n    {{ example[0] }} // {{ example[1] }}\n    {% endfor %}\n    {{ to_label }} //\n    \"\"\"\n\nmodel = outlines.models.transformers(\"mistralai/Mistral-7B-Instruct-v0.2\")\nprompt = labelling(\"Just awesome\", examples)\nanswer = outlines.generate.text(model)(prompt, max_tokens=100)\n```\n\n## Join us\n\n- \ud83d\udca1 **Have an idea?** Come chat with us on [Discord][discord]\n- \ud83d\udd28 **Want to contribute?** Consult our [contribution guide](https://outlines-dev.github.io/outlines/community/contribute/).\n- \ud83d\udc1e **Found a bug?** Open an [issue](https://github.com/outlines-dev/outlines/issues)\n\n\n## Cite Outlines\n\n```\n@article{willard2023efficient,\n  title={Efficient Guided Generation for LLMs},\n  author={Willard, Brandon T and Louf, R{\\'e}mi},\n  journal={arXiv preprint arXiv:2307.09702},\n  year={2023}\n}\n```\n\n[contributors]: https://github.com/outlines-dev/outlines/graphs/contributors\n[contributors-badge]: https://img.shields.io/github/contributors/outlines-dev/outlines?style=flat-square&logo=github&logoColor=white&color=ECEFF4\n[dottxt-twitter]: https://twitter.com/dottxtai\n[outlines-twitter]: https://twitter.com/OutlinesOSS\n[discord]: https://discord.gg/R9DSu34mGd\n[discord-badge]: https://img.shields.io/discord/1182316225284554793?color=81A1C1&logo=discord&logoColor=white&style=flat-square\n[downloads-badge]: https://img.shields.io/pypi/dm/outlines?color=89AC6B&logo=python&logoColor=white&style=flat-square\n[pypistats]: https://pypistats.org/packages/outlines\n[dottxt-twitter-badge]: https://img.shields.io/twitter/follow/dottxtai?style=social\n[outlines-twitter-badge]: https://img.shields.io/twitter/follow/OutlinesOSS?style=social\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Probabilistic Generative Model Programming",
    "version": "0.0.41",
    "project_urls": {
        "documentation": "https://outlines-dev.github.io/outlines/",
        "homepage": "https://github.com/outlines-dev/outlines",
        "repository": "https://github.com/outlines-dev/outlines"
    },
    "split_keywords": [
        "machine learning",
        " deep learning",
        " language models",
        " structured generation"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "97ae89e746f13e75907e60e481fc5862f6c4a0050853f6ef8811254d18b35c41",
                "md5": "5205f7ff9f19531d98879414de87a8ba",
                "sha256": "47315ce6998182b24b5012c94c4575c6a7213ddd3f35011c0e05f366022ca1e0"
            },
            "downloads": -1,
            "filename": "outlines-0.0.41-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "5205f7ff9f19531d98879414de87a8ba",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 89406,
            "upload_time": "2024-04-30T13:13:42",
            "upload_time_iso_8601": "2024-04-30T13:13:42.295261Z",
            "url": "https://files.pythonhosted.org/packages/97/ae/89e746f13e75907e60e481fc5862f6c4a0050853f6ef8811254d18b35c41/outlines-0.0.41-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5ec194bfe99a2218916a15188ae74932ba2e5806dd0d63059066e6d4cffa1916",
                "md5": "3ef643c0bbadcfa9cd26a7e5e1a1ddc1",
                "sha256": "6813db6813853fbe843b1f59c3e867e142c404542970189b071ad0cd1480e548"
            },
            "downloads": -1,
            "filename": "outlines-0.0.41.tar.gz",
            "has_sig": false,
            "md5_digest": "3ef643c0bbadcfa9cd26a7e5e1a1ddc1",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 2036510,
            "upload_time": "2024-04-30T13:13:44",
            "upload_time_iso_8601": "2024-04-30T13:13:44.391145Z",
            "url": "https://files.pythonhosted.org/packages/5e/c1/94bfe99a2218916a15188ae74932ba2e5806dd0d63059066e6d4cffa1916/outlines-0.0.41.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-30 13:13:44",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "outlines-dev",
    "github_project": "outlines",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "outlines"
}
        
Elapsed time: 0.33196s