outlines-haystack
Table of Contents
🛠️ Installation
pip install outlines-haystack
📃 Description
Outlines is a Python library that allows you to use Large Language Model in a simple and robust way (with structured generation). It is built by .txt.
This library allow you to use outlines generators in your Haystack pipelines!
This library currently supports the following generators:
- JSON: generate a JSON object with a given schema
- Choices: generate text from a list of options. Useful for classification tasks!
- Text: simply generate text
- Regex: ⚠️ coming soon
- Format: ⚠️ coming soon
- Grammar: ⚠️ coming soon
outlines supports a wide range of models and frameworks, we are currently supporting:
💻 Usage
[!TIP] See the Example Notebooks for complete examples.
All below examples only use the
transformersmodels.
JSON Generation
>>> from pydantic import BaseModel
>>> from outlines_haystack.generators.transformers import TransformersJSONGenerator
>>> class User(BaseModel):
... name: str
... last_name: str
>>> generator = TransformersJSONGenerator(
... model_name="microsoft/Phi-3-mini-4k-instruct",
... schema_object=User,
... device="cuda",
... )
>>> generator.warm_up()
>>> generator.run(prompt="Create a user profile with the fields name, last_name")
{'structured_replies': ['{"name": "John", "last_name": "Doe"}']}
Choice Generation
>>> from outlines_haystack.generators.transformers import TransformersChoiceGenerator
>>> generator = TransformersChoiceGenerator(
... model_name="microsoft/Phi-3-mini-4k-instruct",
... choices=["Positive", "Negative"],
... device="cuda",
... )
>>> generator.warm_up()
>>> generator.run(prompt="Classify the following statement: 'I love pizza'")
{'choice': 'Positive'}
Text Generation
[!TIP] While
outlinessupports classic text generation, it excels at structured generation. For text generation, consider using Haystack's built-in text generators that offer more features.
>>> from outlines_haystack.generators.transformers import TransformersTextGenerator
>>> generator = TransformersTextGenerator(
... model_name="microsoft/Phi-3-mini-4k-instruct",
... device="cuda",
... )
>>> generator.warm_up()
>>> generator.run(prompt="What is the capital of Italy?")
{'replies': ['The capital of Italy is Rome.']}
License
outlines-haystack is distributed under the terms of the MIT license.
Metadata
Release files for outlines-haystack 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| outlines_haystack-1.0.0.tar.gz | 11.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| outlines_haystack-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 28.7 kB
Release files / outlines_haystack-1.0.0.tar.gz
| Download URL | outlines_haystack-1.0.0.tar.gz |
|---|---|
| Size | 11.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f24326a69e5d29b1083db2a57e1c597db670c31d4fe90c04a8e5e9579e5d3a9b
|
|
BLAKE2b-256 checksum How to use checksums |
8e4b0e6c50f890e2a4e9f2246e99a7dbb25a3ab80bd882da3c57c7651ef8c599
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 23, 2026.
Transparency logRelease files / outlines_haystack-1.0.0-py3-none-any.whl
| Download URL | outlines_haystack-1.0.0-py3-none-any.whl |
|---|---|
| Size | 17.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bd039a37b82c510eadf6370114b1cad6a7da1be929639eae4a377833407aed63
|
|
BLAKE2b-256 checksum How to use checksums |
94cf48a87885e9e7ee30fe07b164d15b94a1818c931d3da59f27828f1053568d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Feb 23, 2026.
Transparency log