Releases: dottxt-ai/outlines
Outlines v1.2.0
What's Changed
- Remove dead link to VLM example from examples index by @laitifranz in #1685
- Fix: JSON schema union types (type arrays) fail with 'type must be a string' error by @brightlikethelight in #1675
- Update docs with OpenRouter guide by @Oni-giri in #1691
- Fix broken wheel builds caused by ambiguous packaging instructions by @neilmehta24 in #1690
- Support different backends on top of outlines_core by @RobinPicard in #1689
- Import fix in base.py by @Oni-giri in #1703
- Upgrade outlines-core to 0.2.11 and remove experimental CFG code by @RobinPicard in #1700
New Contributors
- @laitifranz made their first contribution in #1685
- @brightlikethelight made their first contribution in #1675
- @Oni-giri made their first contribution in #1691
Full Changelog: 1.1.1...1.2.0
Outlines v1.1.1
What's Changed
- Set add_generation_template to True in chat formatting for Transformers by @RobinPicard in #1684
Full Changelog: 1.1.0...1.1.1
Outlines v1.1.0
What's Changed
- Create the inputs module and modify the treatment of multimodal inputs by @RobinPicard in #1677
- Create the Chat input and add it to the models by @RobinPicard in #1680
- Misc doc fixes by @RobinPicard in #1683
- Remove deprecated features from v0 by @RobinPicard in #1682
Full Changelog: 1.0.4...1.1.0
Outlines v1.0.4
What's Changed
- Create Choice output type by @RobinPicard in #1671
- Add the ensure_ascii parameter to JsonSchema by @RobinPicard in #1672
- Add a batch method to models by @RobinPicard in #1674
- Fix error tokenizer arg for transformers models' generate method by @RobinPicard in #1679
Full Changelog: 1.0.3...1.0.4
Outlines 1.0.3
What's Changed
- Add llm.txt file by @rlouf in #1661
- Fix nightly tests (remove Slack alert causing troubles) by @RobinPicard in #1660
- Fix error with additionalProperties for the OpenAI model by @RobinPicard in #1668
- Add the AsyncOllama model by @RobinPicard in #1669
Full Changelog: 1.0.2...1.0.3
Outlines 1.0.2
What's Changed
- Fix typos in getting started guide by @ganglike248 in #1644
- Move VLM guide and remove Docker CI Action by @rlouf in #1643
- Fix example typo in README by @rlouf in #1650
- Add testing and documentation for vision input for VLLM model by @RobinPicard in #1648
- Add support for vision input for the Ollama model by @RobinPicard in #1647
- Add setup example for local server by @rlouf in #1646
- Add IPv4, UUID4, and Hex String Types by @jacobmarks in #1655
- Fix the FastAPI example by @rlouf in #1662
New Contributors
- @ganglike248 made their first contribution in #1644
- @jacobmarks made their first contribution in #1655
Full Changelog: 1.0.1...1.0.2
Outlines 1.0.1
What's Changed
- Fix broken links in the README by @RobinPicard in #1625
- Fix the broken links in the home page of the documentation by @RobinPicard in #1628
- Fix typos across the codebase by @sukrucildirr in #1631
- Update the documentation content and styling by @rlouf in #1636
New Contributors
- @sukrucildirr made their first contribution in #1631
Full Changelog: 1.0.0...1.0.1
Outlines v1.0.0
Why a new major version?
The v1 intends on making Outlines more closely focused on constrained generation. To do so, we delegate a wider range of tasks to the users and inference libraries. On top of making Outlines leaner, this design provides more flexibility to the users and let them use interfaces they are already familiar with.
Our approach is inspired by the unix best practices β each element does one thing well, and we compose those functional elements.
As this new version deprecates some previously available features of Outlines, we have written a migration guide that gives detailed information on how to upgrade your v0 code to v1.
Deprecated
All deprecated features listed below will be removed in version 1.1.0. Until then, a warning will be displayed with information on how to migrate your code to v1.
- The model loader functions from the
models
module (transformers
,openai
, etc.) have been deprecated. They are replaced by equivalent functions prefixed withfrom_
such asfrom_transformers
,from_openai
, etc. The new loader functions accept different arguments compared to the old ones. They now typically require an instance of an engine/client from the associated inference library. This change was made to avoid duplicating inference library logic and to give users more control over inference engine/client initialization.
Documentation
# v0
from outlines import models
from transformers import BertForSequenceClassification, BertTokenizer
model = models.transformers(
model_name="prajjwal1/bert-tiny",
model_class=BertForSequenceClassification,
tokenizer_class=BertTokenizer,
model_kwargs={"use_cache": False},
tokenizer_kwargs={"model_max_length": 512},
)
# v1
import outlines
from transformers import BertForSequenceClassification, BertTokenizer
hf_model = BertForSequenceClassification.from_pretrained("prajjwal1/bert-tiny", use_cache=False)
hf_tokenizer = BertTokenizer.from_pretrained("prajjwal1/bert-tiny", model_max_length=512)
model = outlines.from_transformers(hf_model, hf_tokenizer)
- The
generate
module and the associated functions (json
,choice
β¦) have been deprecated. They are replaced by theGenerator
constructor. While you had to select the right generate function for your output type, you can now provide any output type supported by Outlines to the uniqueGenerator
object.
Documentation
# v0
from pydantic import BaseModel
from outlines import generate, models
class Character(BaseModel):
name: str
model = models.openai("gpt-4o")
generator = generate.json(model, Character)
# v1
from openai import OpenAI
from pydantic import BaseModel
from outlines import Generator, from_openai
class Character(BaseModel):
name: str
model = from_openai(OpenAI())
generator = Generator(model, Character)
- The
TransformersVision
model has been deprecated. It's replaced byTransformersMultiModal
, which is more general as it supports additional input types beyond images, such as audio. When calling it, instead of providing the prompt and image assets separately, both should now be included in a single dictionary. The model is loaded withfrom_transformers
just like theTransformers
model, but the second argument must be a processor instead of a tokenizer.
Documentation
# v0
from io import BytesIO
from urllib.request import urlopen
from PIL import Image
from transformers import LlavaForConditionalGeneration
from outlines import models, generate
def img_from_url(url):
img_byte_stream = BytesIO(urlopen(url).read())
return Image.open(img_byte_stream).convert("RGB")
model = models.transformers_vision(
model_name="trl-internal-testing/tiny-LlavaForConditionalGeneration",
model_class=LlavaForConditionalGeneration,
)
generator = generate.text(model)
result = generator(
"Describe the image <image>",
img_from_url("https://upload.wikimedia.org/wikipedia/commons/2/25/Siam_lilacpoint.jpg")
)
# v1
from io import BytesIO
from urllib.request import urlopen
from PIL import Image
from transformers import LlavaForConditionalGeneration, AutoProcessor
import outlines
def img_from_url(url):
img_byte_stream = BytesIO(urlopen(url).read())
return Image.open(img_byte_stream).convert("RGB")
model = outlines.from_transformers(
LlavaForConditionalGeneration.from_pretrained("trl-internal-testing/tiny-LlavaForConditionalGeneration"),
AutoProcessor.from_pretrained("trl-internal-testing/tiny-LlavaForConditionalGeneration")
)
image = img_from_url("https://upload.wikimedia.org/wikipedia/commons/2/25/Siam_lilacpoint.jpg")
result = model({"text": "Describe the image <image>", "images": image})
-
The
Exllamav2
model has been deprecated without replacement because its interface is not fully compatible with Outlines. We had to implement cumbersome patching to make it work, so we decided to remove it entirely. -
The
function
module and the associatedFunction
class have been deprecated. They are replaced by theApplication
class, which serves a similar purpose toFunction
. There are two notable differences: anApplication
is not initialized with a model (a model must be provided when calling the object), and template variables must be provided in a dictionary instead of as keyword arguments when calling theApplication
.
Documentation
# v0
from pydantic import BaseModel
from outlines import Function, Template
class Character(BaseModel):
name: str
template = Template.from_string("Create a {{ gender }} character.")
fn = Function(template, Character, "hf-internal-testing/tiny-random-GPTJForCausalLM")
response = fn(gender="female")
# v1
from pydantic import BaseModel
from outlines import Application, Template, from_transformers
from transformers import AutoModelForCausalLM, AutoTokenizer
class Character(BaseModel):
name: str
model = from_transformers(
AutoModelForCausalLM.from_pretrained("microsoft/Phi-3-mini-4k-instruct"),
AutoTokenizer.from_pretrained("microsoft/Phi-3-mini-4k-instruct")
)
template = Template.from_string("Create a {{ gender }} character.")
app = Application(template, Character)
response = app(model, {"gender": "female"})
- The
samplers
module and the associated objects (multinomial
,greedy
β¦) have been deprecated. You should now use the inference arguments specific to the inference library your model is based on to control the sampling.
# v0
from outlines import generate, models, samplers
model = models.transformers("microsoft/Phi-3-mini-4k-instruct")
generator = generate.text(model, samplers.beam_search(2))
response = generator("Write a short story about a cat", max_tokens=10)
# v1
from outlines import Generator, from_transformers
from transformers import AutoModelForCausalLM, AutoTokenizer
model = from_transformers(
AutoModelForCausalLM.from_pretrained("microsoft/Phi-3-mini-4k-instruct"),
AutoTokenizer.from_pretrained("microsoft/Phi-3-mini-4k-instruct")
)
response = model("Write a short story about a cat", num_beams=2)
- The
load_lora
methods on theVLLM
andLlamaCpp
models have been deprecated. You should now load through theLlama
instance provided when initializing the model in the case of theLlamaCpp
model, and provide it as a keyword argument when calling the model in the case of theVLLM
model.
# v0
from outlines import models
from vllm import LLM
model = models.vllm("erwanf/gpt2-mini")
model.load_lora("path/to/lora/file")
response = model("Write a short story about a cat.")
#v1
from outlines import from_vllm
from vllm import LLM
from vllm.lora.request import LoRARequest
model = from_vllm(
LLM("microsoft/Phi-3-mini-4k-instruct")
)
lora_request = LoRARequest("path/to/lora/file", 1, "path/to/lora/file")
response = model("Write a short story about a cat.", lora_request=lora_request)
Modified
Some objects are maintained, but their interface or behavior has been modified.
- The interface of
Model
classes (Transformers
,OpenAI
, etc.) has been significantly modified. Models can now be called directly with a prompt and an output type without having to create a generator first. Additionally, all models have astream
method that can be invoked directly by the user.
Documentation
# v0
from pydantic import BaseModel
from outlines import generate, models
class Character(BaseModel):
name: str
model = models.openai("gpt-4o")
generator = generate.json(model, Character)
result = generator("Create a character")
# v1
from openai import OpenAI
from pydantic import BaseModel
from outlines import from_openai
class Character(BaseModel):
name: str
model = from_openai(OpenAI(), "gpt-4o")
result = model("Create a character", Character)
- The interface of the
__init__
method of theOpenAI
model class has been modified. While it previously accepted a client and anOpenAIConfig
object instance, it now accepts a client and a model name. The inference arguments from the config object should now be specified when calling the model to more closely align with the OpenAI Python library's functionality. If you provide anOpenAIConfig
instance when initializing the model, a deprecation warning will appear and your model will behave like a v0 model.
We recommend using thefrom_openai
function instead of initializing models directly.
[Documentation](https://dottxt-ai.gith...
Outlines v0.2.3
What's Changed
- JSON schema error when using OpenAI with Pydantic model by @derfred in #1472
- Tweak version commands in bug_report.yml by @nchammas in #1476
- Fix capitalization in installation.md by @cpfiffer in #1488
- Remove all issue templates except bug reports by @rlouf in #1496
- Update the logo by @rlouf in #1521
New Contributors
Full Changelog: 0.2.2...0.2.3
Outlines v0.2.2
What's Changed
- Update prompt templating documentation by @rlouf in #1448
- Format files and fix numerous
mypy
warnings, thanks toruff
by @yvan-sraka in #1470 - Remove
pre-commit
runtime dependency by @yvan-sraka in #1468 - Improve the regex DSL (replace
|
byeither
and introduce new quantifiers) by @rlouf in #1463
Full Changelog: 0.2.1...0.2.2