Skip to main content

Use `outlines` generators with Haystack.

Project description

outlines-haystack

PyPI - Version PyPI - Python Version PyPI - License

Code style: black Ruff

GH Actions Tests pre-commit.ci status


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.

-- Outlines docs

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
  • Text: simply generate text
  • Choices: ⚠️ coming soon
  • 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 transformers models.

JSON Generation

>>> from enum import Enum
>>> 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",
...     sampling_algorithm_kwargs={"temperature": 0.5},
... )
>>> generator.warm_up()
>>> generator.run(prompt="Create a user profile with the fields name, last_name")
{'structured_replies': [{'name': 'John', 'last_name': 'Doe'}]}

Text Generation

>>> generator = TransformersTextGenerator(
...     model_name="microsoft/Phi-3-mini-4k-instruct",
...     device="cuda",
...     sampling_algorithm_kwargs={"temperature": 0.5},
... )
>>> generator.warm_up()
>>> generator.run(prompt="What is the capital of Italy?")
{'replies': ['\n\n# Answer\nThe capital of Italy is Rome.']}

License

outlines-haystack is distributed under the terms of the MIT license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

outlines_haystack-0.1.0.tar.gz (20.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

outlines_haystack-0.1.0-py3-none-any.whl (15.6 kB view details)

Uploaded Python 3

File details

Details for the file outlines_haystack-0.1.0.tar.gz.

File metadata

  • Download URL: outlines_haystack-0.1.0.tar.gz
  • Upload date:
  • Size: 20.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for outlines_haystack-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4a8cd445a1ef3c4e91cac49f7fc2637083e1c1e8ba77bb112b7e5507d6c9cfed
MD5 72cff8e8ff8c5ddca8d459a96e55beed
BLAKE2b-256 23f44519921c247f87ffca7e5d630aef93e936f5293008a1d47cb62f5ecc96cd

See more details on using hashes here.

Provenance

The following attestation bundles were made for outlines_haystack-0.1.0.tar.gz:

Publisher: publish.yml on EdAbati/outlines-haystack

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file outlines_haystack-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for outlines_haystack-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6b9b8903010298eaea3c11a0e3cdc66bdb4bed001c63aaffd9fac7791a39da65
MD5 7c093dc46ce4bbd18a8bb16bdd984ab3
BLAKE2b-256 55cadc21e77579b3beb61ab6eb7f7ca6f65d691ff8593282e202fe4adf7563de

See more details on using hashes here.

Provenance

The following attestation bundles were made for outlines_haystack-0.1.0-py3-none-any.whl:

Publisher: publish.yml on EdAbati/outlines-haystack

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page