-
Notifications
You must be signed in to change notification settings - Fork 593
Add backward compatibility with v0 #1518
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
Add backward compatibility with v0 #1518
Conversation
c318b9b
to
a96ab23
Compare
a96ab23
to
7c8bbd9
Compare
I like the thorough explanation in the warning messages. I'm not sure what is going on with the coverage, is everything tested? Also, before merging we should do a smoke test to make sure the deeplearning.ai notebooks can run with this branch. |
First -- I have no additional comments. Remi mentioned all the ones I would have. I tried a few examples and the deprecation warnings are comprehensive and very clear about what should be changed. Extremely good work here! I'll also running smoke tests on the DLAI notebook. The warnings are fine actually because all the notebooks disable warning printouts, so everyone should be able to run things as normal if they copy the code over to a v1 outlines install. Otherwise the course pins the course to The code generator = outlines.generate.json(
model,
Person,
sampler = outlines.samplers.greedy()
) yields the error ---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
Cell In[4], line 1
----> 1 from utils import track_logits
3 generator = outlines.generate.json(
4 model,
5 Person,
6 sampler = outlines.samplers.greedy()
7 )
9 # Add tools to track token probabilities as they are generated
File [~/dottxt/outlines/SC-DotTxt-Outlines-C1/L4/utils.py:16](http://server.languid.ai:8080/lab/tree/SC-DotTxt-Outlines-C1/L4/SC-DotTxt-Outlines-C1/L4/utils.py#line=15)
13 from numpy.typing import NDArray
14 import matplotlib.pyplot as plt
---> 16 from outlines.processors.base_logits_processor import OutlinesLogitsProcessor, Array
18 if TYPE_CHECKING:
19 from outlines.generate import Generator
ImportError: cannot import name 'Array' from 'outlines.processors.base_logits_processor' ([/home/cameron/dottxt/outlines/outlines/processors/base_logits_processor.py](http://server.languid.ai:8080/lab/tree/SC-DotTxt-Outlines-C1/L4/outlines/processors/base_logits_processor.py)) |
d58a35f
to
2aeca4a
Compare
2aeca4a
to
8b88746
Compare
I've added a lot of tests to increase our coverage |
The exllamav2 tests require nvcc>11, which is a pain to upgrade. I may have to defer it to another time. |
Update on this error:
This is due to some custom code I have in the DeepLearning.ai notebooks that does a bunch of weird stuff to the logit processor. This code is very much a bandaid and wasn't really intended to be production code. That code was sort of formalized here, but it needs more work on the interface and shifting it to use the new v1 interface. We might be able to just let this one go, especially because it's more of a perk feature than anything else. I flagged it as experimental in the videos so I'm less worried. |
The next error I found is this one here, due to changes in the regex DSL: from outlines.types import sentence, digit
from outlines.types.dsl import to_regex
# Write between 1-3 Sentences
reasoning = "Reasoning: " + sentence.repeat(1,2)
# Answer in 1-4 digits
answer = "So the answer is: " + digit.repeat(1,4)
to_regex(reasoning + "\n" + answer) Error: ---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[18], line 5
2 from outlines.types.dsl import to_regex
4 # Write between 1-3 Sentences
----> 5 reasoning = "Reasoning: " + sentence.repeat(1,2)
6 # Answer in 1-4 digits
7 answer = "So the answer is: " + digit.repeat(1,4)
AttributeError: 'Regex' object has no attribute 'repeat' |
This is a change that's already in the |
Yeah, that stuff is used in DLAI. |
The objective of this PR is to make the v1 of Outlines backward compatible with the current v0.
We want users to still be able to run their code as long as they were using the regular high-level API (some objects have been deleted and are not supported anymore). For the general approach, I tried to do the following:
OpenAI
model)v0_legacy
directory)Things this PR does:
OpenAI
model to support the__ini__
signature of both the v0 and v1 version. In case of a v0 initialization, the methods of the instance call alegacy_instance
attribute that implements the legacy interfacegenerate
functions (text
,regex
,json
...): they now return aGeneratorV0Adapter
that stores a v1 generator while providing the expected interface of v0I have not testes the exllamav2 model yet as it requires having a GPU. If someone could try running the tests for it that would be nice