Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge upstream #2

Open
wants to merge 297 commits into
base: main
Choose a base branch
from
Open

merge upstream #2

wants to merge 297 commits into from

Conversation

francislabountyjr
Copy link
Member

No description provided.

navster888 and others added 30 commits April 20, 2024 18:24
Make the code render as Python.
Fixes #856

The code this PR removes introduces an artificial and erroneous loop
transition in every final state that is always traversed, regardless of
the generation.

The comment doesn't make sense in my opinion, as the `if` above just
handles exactly this case.

Removing this piece of code fixes the bug that surfaced in the upgrade
of outlines in the vLLM integration.
Fixes #823

This comment details the issues error:
#823 (comment)

The reproduction code provided results in a json schema with
`OneOf[pets]`:

```
class Model(BaseModel):
    pet: Union[Cat, Dog] = Field(..., discriminator='pet_type')
```

Before this PR: `OneOf` uses negative lookaheads to assert that only one
schema member is included. This is illegal in `interegular`, more
details available here:
#456

After `OneOf` uses or-joined non-capturing groups which don't have the
same issues with `interegular`.
In the outlines docs, we have the example
```python
import outlines

def my_tool(arg1: str, arg2: int):
    """Tool description.

    The rest of the docstring
    """
    pass

@outlines.prompt
def tool_prompt(question, tool):
    """{{ question }}

    COMMANDS
    1. {{ tool | name }}: {{ tool | description }}, args: {{ tool | args }}

    {{ tool | source }}
    """

prompt = tool_prompt("Can you do something?", my_tool)
print(prompt)
```
However, when I tried running this code, it did not work because the
`args` filter used in `{{ tool | args }}` was not implemented. I
implemented the `args` filter so now this example works.

Now the args filter will output all of the arguments with the type
annotations and default values (if they are provided).
Example:
```python
from typing import List

def foo(x, y: str, z: List[int]=[1, 2, 3]):
    pass

@outlines.prompt
def tool_prompt(fn):
    """My args: {{ fn | args }}"""

prompt = tool_prompt(foo)
print(prompt)
```
which outputs
```python
My args: x, y: str, z: List[int] = [1, 2, 3]
```
Fix #838


06d5654
erroneously disallowed parenthesis in strings. This PR allows
parenthesis in strings.
EdAbati and others added 30 commits December 21, 2024 14:19
Hi, Thank you for this great library!

It seems that the docstrings are not rendered correctly in the docs. I
think we should explicitly set the `docstring_style` because [it
defaults to
`"google"`](https://mkdocstrings.github.io/python/usage/configuration/docstrings/#docstring_style)
but outlines is using numpy.

Before:
![Screenshot 2024-12-16 at 23 00
26](https://github.com/user-attachments/assets/c752ee3d-519e-4098-b943-3aab43c8af25)
After:
![Screenshot 2024-12-16 at 23 00
41](https://github.com/user-attachments/assets/5b5f524b-6921-4dbe-994d-72c079e677bc)


There seem to be other issues in the docstrings:
- for example
[`Properties`](https://github.com/dottxt-ai/outlines/blob/main/outlines/models/openai.py#L23)
should be
[`Attributes`](https://numpydoc.readthedocs.io/en/latest/format.html#parameters)
- only openai and transformers models are present in the [api
reference](https://github.com/dottxt-ai/outlines/blob/main/docs/api/models.md)

I'm happy to make followup PRs for those.

Please let me know if I missed something, I couldn't find related
issues/PRs.
Use `is` and `is not` for type comparisons, or `isinstance()` for isinstance checks
the old library structure has not been updated to reflect the present one.
Before this commit, when you ran pytest -k specific_test, it spawned dozens of the same skipped warnings message on stdout... IMHO, that was not ideal ^^

Bug introduced in d32dfde
Allow giving custom filters to the prompt decorator

```
def reverses: str) -> str:
    return s[::-1]

@prompt(filters={ 'reverse': reverse })
def reverse_prompt(text):
    '''{{ text | reverse }}'''

prompt = reverse_prompt("Hello")

print(prompt)
>>> "olleH"
```
There's an extra `outlines.generate` row in the feature matrix docs. This removes it.

I also modified the markdown syntax for one header to use ** rather than __, consistent with the rest of the table.
We have noticing the following error with a recent version of outlines
when used with MLX:
```
TypeError: argument 'token_id': 'float' object cannot be interpreted as an integer

At:
  /.../outlines_core/fsm/guide.py(294): get_next_state
  /.../outlines/processors/structured.py(101): process_logits
  /.../outlines/processors/base_logits_processor.py(90): __call__
```

The issue is that the MLX array of tokens, which are integers, are being
force-converted to floats, even though outlines expects an integer
array. This is because all MLX arrays are being converted to `float32`,
even when it's not necessarily appropriate, like in this case. Looking
at the [commented
link](https://ml-explore.github.io/mlx/build/html/usage/numpy.html#pytorch),
the advice was to convert to `float32` only for `bfloat16`, because
numpy does not support `bfloat16`. Now the MLX `_to_torch`
implementation matches the other array libraries, none of the other
libraries are being force-casted to float
The existing README has underwhelming or incorrect results (Example is
underwhelming #1347) due to lack of templating for instruct models.

This adds special tokens for each instruct model call, as well as
provide comments on how to obtain/produce special tokens.

---------

Co-authored-by: Victoria Terenina <[email protected]>
This PR aims at integrating support of the `genson` package (in
`generate.json`) to be able to use dynamic json schema generation as
proposed in #1383.
Also add instructions about different outlines "flavors"!

Co-authored-by: Cameron Pfiffer <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.