Use `outlines` generators with Haystack.
Project description
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
- 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
transformersmodels.
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4a8cd445a1ef3c4e91cac49f7fc2637083e1c1e8ba77bb112b7e5507d6c9cfed
|
|
| MD5 |
72cff8e8ff8c5ddca8d459a96e55beed
|
|
| BLAKE2b-256 |
23f44519921c247f87ffca7e5d630aef93e936f5293008a1d47cb62f5ecc96cd
|
Provenance
The following attestation bundles were made for outlines_haystack-0.1.0.tar.gz:
Publisher:
publish.yml on EdAbati/outlines-haystack
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
outlines_haystack-0.1.0.tar.gz -
Subject digest:
4a8cd445a1ef3c4e91cac49f7fc2637083e1c1e8ba77bb112b7e5507d6c9cfed - Sigstore transparency entry: 158926848
- Sigstore integration time:
-
Permalink:
EdAbati/outlines-haystack@3b162482a8e0d3b081b6239abfd845460995cfd8 -
Branch / Tag:
refs/tags/0.1.0 - Owner: https://github.com/EdAbati
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@3b162482a8e0d3b081b6239abfd845460995cfd8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file outlines_haystack-0.1.0-py3-none-any.whl.
File metadata
- Download URL: outlines_haystack-0.1.0-py3-none-any.whl
- Upload date:
- Size: 15.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6b9b8903010298eaea3c11a0e3cdc66bdb4bed001c63aaffd9fac7791a39da65
|
|
| MD5 |
7c093dc46ce4bbd18a8bb16bdd984ab3
|
|
| BLAKE2b-256 |
55cadc21e77579b3beb61ab6eb7f7ca6f65d691ff8593282e202fe4adf7563de
|
Provenance
The following attestation bundles were made for outlines_haystack-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on EdAbati/outlines-haystack
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
outlines_haystack-0.1.0-py3-none-any.whl -
Subject digest:
6b9b8903010298eaea3c11a0e3cdc66bdb4bed001c63aaffd9fac7791a39da65 - Sigstore transparency entry: 158926849
- Sigstore integration time:
-
Permalink:
EdAbati/outlines-haystack@3b162482a8e0d3b081b6239abfd845460995cfd8 -
Branch / Tag:
refs/tags/0.1.0 - Owner: https://github.com/EdAbati
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@3b162482a8e0d3b081b6239abfd845460995cfd8 -
Trigger Event:
push
-
Statement type: