outlines 0.1.dev0__tar.gz → 0.1.13__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (263) hide show
  1. outlines-0.1.13/.github/ISSUE_TEMPLATE/bug_report.yml +87 -0
  2. outlines-0.1.13/.github/ISSUE_TEMPLATE/config.yml +4 -0
  3. outlines-0.1.13/.github/ISSUE_TEMPLATE/doc_request.md +21 -0
  4. outlines-0.1.13/.github/ISSUE_TEMPLATE/feature_request.md +27 -0
  5. outlines-0.1.13/.github/ISSUE_TEMPLATE/improvement.yml +34 -0
  6. outlines-0.1.13/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md +23 -0
  7. outlines-0.1.13/.github/scripts/build_sdist_and_wheel.sh +22 -0
  8. outlines-0.1.13/.github/workflows/asv_benchmark_pr.yml +68 -0
  9. outlines-0.1.13/.github/workflows/build_documentation.yml +23 -0
  10. outlines-0.1.13/.github/workflows/publish_documentation.yml +53 -0
  11. outlines-0.1.13/.github/workflows/release_docker.yml +36 -0
  12. outlines-0.1.13/.github/workflows/release_pypi.yaml +27 -0
  13. outlines-0.1.13/.github/workflows/tests.yml +109 -0
  14. outlines-0.1.13/.gitignore +14 -0
  15. outlines-0.1.13/.pre-commit-config.yaml +33 -0
  16. outlines-0.1.13/.readthedocs.yaml +15 -0
  17. outlines-0.1.13/Dockerfile +17 -0
  18. outlines-0.1.13/LICENSE +201 -0
  19. outlines-0.1.13/PKG-INFO +503 -0
  20. outlines-0.1.13/README.md +418 -0
  21. outlines-0.1.13/benchmarks/asv.conf.json +20 -0
  22. outlines-0.1.13/benchmarks/bench_cfg_guide.py +64 -0
  23. outlines-0.1.13/benchmarks/bench_json_schema.py +77 -0
  24. outlines-0.1.13/benchmarks/bench_processors.py +131 -0
  25. outlines-0.1.13/benchmarks/bench_regex_guide.py +40 -0
  26. outlines-0.1.13/benchmarks/common.py +8 -0
  27. outlines-0.1.13/docs/api/guide.md +1 -0
  28. outlines-0.1.13/docs/api/index.md +1 -0
  29. outlines-0.1.13/docs/api/json_schema.md +1 -0
  30. outlines-0.1.13/docs/api/models.md +3 -0
  31. outlines-0.1.13/docs/api/parsing.md +1 -0
  32. outlines-0.1.13/docs/api/prompts.md +1 -0
  33. outlines-0.1.13/docs/api/regex.md +1 -0
  34. outlines-0.1.13/docs/api/samplers.md +1 -0
  35. outlines-0.1.13/docs/assets/images/dottxt.png +0 -0
  36. outlines-0.1.13/docs/assets/images/logits_processing_diagram.svg +157 -0
  37. outlines-0.1.13/docs/assets/images/logo-simple.png +0 -0
  38. outlines-0.1.13/docs/assets/images/logo-square.png +0 -0
  39. outlines-0.1.13/docs/assets/images/logo-square.svg +124 -0
  40. outlines-0.1.13/docs/assets/images/logo.png +0 -0
  41. outlines-0.1.13/docs/assets/images/logo.svg +134 -0
  42. outlines-0.1.13/docs/assets/images/normal_computing.jpg +0 -0
  43. outlines-0.1.13/docs/blog/.authors.yml +5 -0
  44. outlines-0.1.13/docs/blog/assets/4000_stars.png +0 -0
  45. outlines-0.1.13/docs/blog/index.md +1 -0
  46. outlines-0.1.13/docs/blog/posts/roadmap-2024.md +91 -0
  47. outlines-0.1.13/docs/community/belonging.png +0 -0
  48. outlines-0.1.13/docs/community/contribute.md +132 -0
  49. outlines-0.1.13/docs/community/examples.md +19 -0
  50. outlines-0.1.13/docs/community/feedback.md +81 -0
  51. outlines-0.1.13/docs/community/index.md +12 -0
  52. outlines-0.1.13/docs/community/versioning.md +26 -0
  53. outlines-0.1.13/docs/cookbook/atomic_caption.md +189 -0
  54. outlines-0.1.13/docs/cookbook/chain_of_density.md +125 -0
  55. outlines-0.1.13/docs/cookbook/chain_of_thought.md +138 -0
  56. outlines-0.1.13/docs/cookbook/classification.md +103 -0
  57. outlines-0.1.13/docs/cookbook/dating_profiles.md +229 -0
  58. outlines-0.1.13/docs/cookbook/deploy-using-bentoml.md +224 -0
  59. outlines-0.1.13/docs/cookbook/deploy-using-cerebrium.md +121 -0
  60. outlines-0.1.13/docs/cookbook/deploy-using-modal.md +198 -0
  61. outlines-0.1.13/docs/cookbook/earnings-reports.md +278 -0
  62. outlines-0.1.13/docs/cookbook/extract_event_details.md +34 -0
  63. outlines-0.1.13/docs/cookbook/extract_event_details.py +46 -0
  64. outlines-0.1.13/docs/cookbook/extraction.md +87 -0
  65. outlines-0.1.13/docs/cookbook/images/chain_of_density.png +0 -0
  66. outlines-0.1.13/docs/cookbook/images/coding_structure_diagram.png +0 -0
  67. outlines-0.1.13/docs/cookbook/images/knowledge-graph-extraction.png +0 -0
  68. outlines-0.1.13/docs/cookbook/images/nvidia-income.png +0 -0
  69. outlines-0.1.13/docs/cookbook/images/simtom.png +0 -0
  70. outlines-0.1.13/docs/cookbook/images/trader-joes-receipt.jpg +0 -0
  71. outlines-0.1.13/docs/cookbook/index.md +18 -0
  72. outlines-0.1.13/docs/cookbook/knowledge_graph_extraction.md +155 -0
  73. outlines-0.1.13/docs/cookbook/models_playing_chess.md +88 -0
  74. outlines-0.1.13/docs/cookbook/qa-with-citations.md +255 -0
  75. outlines-0.1.13/docs/cookbook/react_agent.md +273 -0
  76. outlines-0.1.13/docs/cookbook/read-pdfs.md +376 -0
  77. outlines-0.1.13/docs/cookbook/receipt-digitization.md +296 -0
  78. outlines-0.1.13/docs/cookbook/simtom.md +129 -0
  79. outlines-0.1.13/docs/cookbook/structured_generation_workflow.md +215 -0
  80. outlines-0.1.13/docs/index.md +8 -0
  81. outlines-0.1.13/docs/installation.md +38 -0
  82. outlines-0.1.13/docs/licence.md +34 -0
  83. outlines-0.1.13/docs/logos/amazon.png +0 -0
  84. outlines-0.1.13/docs/logos/apple.png +0 -0
  85. outlines-0.1.13/docs/logos/best_buy.png +0 -0
  86. outlines-0.1.13/docs/logos/canoe.png +0 -0
  87. outlines-0.1.13/docs/logos/cisco.png +0 -0
  88. outlines-0.1.13/docs/logos/dassault_systems.png +0 -0
  89. outlines-0.1.13/docs/logos/databricks.png +0 -0
  90. outlines-0.1.13/docs/logos/datadog.png +0 -0
  91. outlines-0.1.13/docs/logos/dbt_labs.png +0 -0
  92. outlines-0.1.13/docs/logos/gladia.jpg +0 -0
  93. outlines-0.1.13/docs/logos/harvard.png +0 -0
  94. outlines-0.1.13/docs/logos/hf.png +0 -0
  95. outlines-0.1.13/docs/logos/johns_hopkins.png +0 -0
  96. outlines-0.1.13/docs/logos/meta.png +0 -0
  97. outlines-0.1.13/docs/logos/mit.png +0 -0
  98. outlines-0.1.13/docs/logos/mount_sinai.png +0 -0
  99. outlines-0.1.13/docs/logos/nvidia.png +0 -0
  100. outlines-0.1.13/docs/logos/nyu.png +0 -0
  101. outlines-0.1.13/docs/logos/safran.png +0 -0
  102. outlines-0.1.13/docs/logos/salesforce.png +0 -0
  103. outlines-0.1.13/docs/logos/shopify.png +0 -0
  104. outlines-0.1.13/docs/logos/smithsonian.png +0 -0
  105. outlines-0.1.13/docs/logos/tinder.png +0 -0
  106. outlines-0.1.13/docs/logos/upenn.png +0 -0
  107. outlines-0.1.13/docs/overrides/home.html +151 -0
  108. outlines-0.1.13/docs/overrides/main.html +1 -0
  109. outlines-0.1.13/docs/quickstart.md +228 -0
  110. outlines-0.1.13/docs/reference/functions.md +1 -0
  111. outlines-0.1.13/docs/reference/generation/cfg.md +154 -0
  112. outlines-0.1.13/docs/reference/generation/choices.md +16 -0
  113. outlines-0.1.13/docs/reference/generation/creating_grammars.md +99 -0
  114. outlines-0.1.13/docs/reference/generation/custom_fsm_ops.md +37 -0
  115. outlines-0.1.13/docs/reference/generation/format.md +23 -0
  116. outlines-0.1.13/docs/reference/generation/generation.md +216 -0
  117. outlines-0.1.13/docs/reference/generation/json.md +105 -0
  118. outlines-0.1.13/docs/reference/generation/regex.md +27 -0
  119. outlines-0.1.13/docs/reference/generation/structured_generation_explanation.md +54 -0
  120. outlines-0.1.13/docs/reference/generation/types.md +83 -0
  121. outlines-0.1.13/docs/reference/index.md +15 -0
  122. outlines-0.1.13/docs/reference/models/exllamav2.md +15 -0
  123. outlines-0.1.13/docs/reference/models/llamacpp.md +230 -0
  124. outlines-0.1.13/docs/reference/models/mlxlm.md +93 -0
  125. outlines-0.1.13/docs/reference/models/models.md +56 -0
  126. outlines-0.1.13/docs/reference/models/openai.md +204 -0
  127. outlines-0.1.13/docs/reference/models/tgi.md +3 -0
  128. outlines-0.1.13/docs/reference/models/transformers.md +148 -0
  129. outlines-0.1.13/docs/reference/models/transformers_vision.md +115 -0
  130. outlines-0.1.13/docs/reference/models/vllm.md +235 -0
  131. outlines-0.1.13/docs/reference/prompting.md +403 -0
  132. outlines-0.1.13/docs/reference/samplers.md +178 -0
  133. outlines-0.1.13/docs/reference/serve/lmstudio.md +89 -0
  134. outlines-0.1.13/docs/reference/serve/vllm.md +73 -0
  135. outlines-0.1.13/docs/reference/text.md +86 -0
  136. outlines-0.1.13/docs/stylesheets/extra.css +149 -0
  137. outlines-0.1.13/docs/welcome.md +183 -0
  138. outlines-0.1.13/environment.yml +23 -0
  139. outlines-0.1.13/examples/babyagi.py +167 -0
  140. outlines-0.1.13/examples/beam-cloud/README.md +5 -0
  141. outlines-0.1.13/examples/beam-cloud/app.py +39 -0
  142. outlines-0.1.13/examples/bentoml/.bentoignore +5 -0
  143. outlines-0.1.13/examples/bentoml/bentofile.yaml +9 -0
  144. outlines-0.1.13/examples/bentoml/import_model.py +24 -0
  145. outlines-0.1.13/examples/bentoml/requirements.txt +5 -0
  146. outlines-0.1.13/examples/bentoml/service.py +78 -0
  147. outlines-0.1.13/examples/cerebrium/cerebrium.toml +26 -0
  148. outlines-0.1.13/examples/cerebrium/main.py +43 -0
  149. outlines-0.1.13/examples/cfg.py +89 -0
  150. outlines-0.1.13/examples/dating_profile.py +176 -0
  151. outlines-0.1.13/examples/llamacpp_example.py +44 -0
  152. outlines-0.1.13/examples/llamacpp_processor.py +50 -0
  153. outlines-0.1.13/examples/math_generate_code.py +41 -0
  154. outlines-0.1.13/examples/meta_prompting.py +168 -0
  155. outlines-0.1.13/examples/modal_example.py +81 -0
  156. outlines-0.1.13/examples/parsing.py +106 -0
  157. outlines-0.1.13/examples/pick_odd_one_out.py +43 -0
  158. outlines-0.1.13/examples/react.py +77 -0
  159. outlines-0.1.13/examples/sampling.ipynb +401 -0
  160. outlines-0.1.13/examples/self_consistency.py +82 -0
  161. outlines-0.1.13/examples/simulation_based_inference.ipynb +370 -0
  162. outlines-0.1.13/examples/transformers_integration.py +25 -0
  163. outlines-0.1.13/examples/vllm_integration.py +30 -0
  164. outlines-0.1.13/mkdocs.yml +183 -0
  165. outlines-0.1.13/outlines/__init__.py +22 -0
  166. outlines-0.1.13/outlines/_version.py +16 -0
  167. outlines-0.1.13/outlines/base.py +299 -0
  168. outlines-0.1.13/outlines/caching.py +179 -0
  169. outlines-0.1.13/outlines/fsm/__init__.py +0 -0
  170. outlines-0.1.13/outlines/fsm/guide.py +276 -0
  171. outlines-0.1.13/outlines/fsm/json_schema.py +83 -0
  172. outlines-0.1.13/outlines/fsm/parsing.py +1127 -0
  173. outlines-0.1.13/outlines/fsm/types.py +81 -0
  174. outlines-0.1.13/outlines/function.py +117 -0
  175. outlines-0.1.13/outlines/generate/__init__.py +8 -0
  176. outlines-0.1.13/outlines/generate/api.py +609 -0
  177. outlines-0.1.13/outlines/generate/cfg.py +54 -0
  178. outlines-0.1.13/outlines/generate/choice.py +59 -0
  179. outlines-0.1.13/outlines/generate/format.py +47 -0
  180. outlines-0.1.13/outlines/generate/fsm.py +31 -0
  181. outlines-0.1.13/outlines/generate/generator.py +312 -0
  182. outlines-0.1.13/outlines/generate/json.py +115 -0
  183. outlines-0.1.13/outlines/generate/regex.py +59 -0
  184. outlines-0.1.13/outlines/generate/text.py +50 -0
  185. outlines-0.1.13/outlines/grammars/arithmetic.lark +18 -0
  186. outlines-0.1.13/outlines/grammars/common.lark +83 -0
  187. outlines-0.1.13/outlines/grammars/json.lark +19 -0
  188. outlines-0.1.13/outlines/grammars.py +14 -0
  189. outlines-0.1.13/outlines/models/__init__.py +19 -0
  190. outlines-0.1.13/outlines/models/exllamav2.py +357 -0
  191. outlines-0.1.13/outlines/models/llamacpp.py +407 -0
  192. outlines-0.1.13/outlines/models/mlxlm.py +242 -0
  193. outlines-0.1.13/outlines/models/openai.py +297 -0
  194. outlines-0.1.13/outlines/models/tokenizer.py +31 -0
  195. outlines-0.1.13/outlines/models/transformers.py +458 -0
  196. outlines-0.1.13/outlines/models/transformers_vision.py +138 -0
  197. outlines-0.1.13/outlines/models/vllm.py +227 -0
  198. outlines-0.1.13/outlines/processors/__init__.py +7 -0
  199. outlines-0.1.13/outlines/processors/base_logits_processor.py +159 -0
  200. outlines-0.1.13/outlines/processors/structured.py +244 -0
  201. outlines-0.1.13/outlines/prompts.py +324 -0
  202. outlines-0.1.13/outlines/py.typed +0 -0
  203. outlines-0.1.13/outlines/samplers.py +354 -0
  204. outlines-0.1.13/outlines/serve/__init__.py +0 -0
  205. outlines-0.1.13/outlines/serve/serve.py +139 -0
  206. outlines-0.1.13/outlines/types/__init__.py +4 -0
  207. outlines-0.1.13/outlines/types/airports.py +11 -0
  208. outlines-0.1.13/outlines/types/countries.py +19 -0
  209. outlines-0.1.13/outlines/types/email.py +11 -0
  210. outlines-0.1.13/outlines/types/isbn.py +12 -0
  211. outlines-0.1.13/outlines/types/locales.py +21 -0
  212. outlines-0.1.13/outlines/types/phone_numbers.py +16 -0
  213. outlines-0.1.13/outlines/types/zip_codes.py +13 -0
  214. outlines-0.1.13/outlines.egg-info/PKG-INFO +503 -0
  215. outlines-0.1.13/outlines.egg-info/SOURCES.txt +256 -0
  216. outlines-0.1.13/outlines.egg-info/requires.txt +76 -0
  217. outlines-0.1.13/pyproject.toml +174 -0
  218. outlines-0.1.13/requirements-doc.txt +9 -0
  219. outlines-0.1.13/setup.cfg +13 -0
  220. outlines-0.1.13/tests/__init__.py +0 -0
  221. outlines-0.1.13/tests/cfg_samples/arithmetic/lots_of_ops.arithmetic.test +1 -0
  222. outlines-0.1.13/tests/cfg_samples/arithmetic/simple_math.arithmetic.test +1 -0
  223. outlines-0.1.13/tests/cfg_samples/json/outlines.generate.samplers.mypy.json.test +372 -0
  224. outlines-0.1.13/tests/cfg_samples/json/simple_fruit.json.test +20 -0
  225. outlines-0.1.13/tests/cfg_samples/json/simple_fruit_no_indent.json.test +1 -0
  226. outlines-0.1.13/tests/conftest.py +17 -0
  227. outlines-0.1.13/tests/fsm/partial_python.lark +314 -0
  228. outlines-0.1.13/tests/fsm/test_cfg_guide.py +457 -0
  229. outlines-0.1.13/tests/fsm/test_guide.py +467 -0
  230. outlines-0.1.13/tests/fsm/test_json_schema.py +78 -0
  231. outlines-0.1.13/tests/fsm/test_parsing.py +307 -0
  232. outlines-0.1.13/tests/fsm/test_types.py +29 -0
  233. outlines-0.1.13/tests/generate/__init__.py +0 -0
  234. outlines-0.1.13/tests/generate/conftest.py +66 -0
  235. outlines-0.1.13/tests/generate/test_api.py +33 -0
  236. outlines-0.1.13/tests/generate/test_generate.py +423 -0
  237. outlines-0.1.13/tests/generate/test_generator.py +497 -0
  238. outlines-0.1.13/tests/generate/test_integration_exllamav2.py +363 -0
  239. outlines-0.1.13/tests/generate/test_integration_llamacpp.py +374 -0
  240. outlines-0.1.13/tests/generate/test_integration_transformers.py +569 -0
  241. outlines-0.1.13/tests/generate/test_integration_transformers_vision.py +116 -0
  242. outlines-0.1.13/tests/generate/test_integration_vllm.py +243 -0
  243. outlines-0.1.13/tests/models/test_mlxlm.py +100 -0
  244. outlines-0.1.13/tests/models/test_openai.py +125 -0
  245. outlines-0.1.13/tests/models/test_tokenizer.py +8 -0
  246. outlines-0.1.13/tests/models/test_transformers.py +117 -0
  247. outlines-0.1.13/tests/processors/test_base_processor.py +80 -0
  248. outlines-0.1.13/tests/test_base.py +275 -0
  249. outlines-0.1.13/tests/test_cache.py +190 -0
  250. outlines-0.1.13/tests/test_function.py +133 -0
  251. outlines-0.1.13/tests/test_grammars.py +31 -0
  252. outlines-0.1.13/tests/test_prompts.py +422 -0
  253. outlines-0.1.13/tests/test_samplers.py +277 -0
  254. outlines-0.1.13/tests/test_types.py +103 -0
  255. outlines-0.1.dev0/PKG-INFO +0 -14
  256. outlines-0.1.dev0/outlines/_version.py +0 -4
  257. outlines-0.1.dev0/outlines.egg-info/PKG-INFO +0 -14
  258. outlines-0.1.dev0/outlines.egg-info/SOURCES.txt +0 -7
  259. outlines-0.1.dev0/pyproject.toml +0 -31
  260. outlines-0.1.dev0/setup.cfg +0 -4
  261. {outlines-0.1.dev0/outlines → outlines-0.1.13/benchmarks}/__init__.py +0 -0
  262. {outlines-0.1.dev0 → outlines-0.1.13}/outlines.egg-info/dependency_links.txt +0 -0
  263. {outlines-0.1.dev0 → outlines-0.1.13}/outlines.egg-info/top_level.txt +0 -0
@@ -0,0 +1,87 @@
1
+ # Issue template inspired by NumPy's excellent template:
2
+ # https://github.com/numpy/numpy/edit/main/.github/ISSUE_TEMPLATE/bug-report.yml
3
+ name: 🐞 Bug report
4
+ description: Create a bug report to help us reproduce and fix it.
5
+ title: "<Please write a descriptive title>"
6
+ labels: ["bug"]
7
+
8
+ body:
9
+ - type: markdown
10
+ attributes:
11
+ value: >-
12
+ Thank you for taking the time to file a bug report. First, carefully read
13
+ the following before everything else:
14
+
15
+ - Does your issue only arise in a library that uses Outlines? If so,
16
+ submit your issue to this library's issue tracker.
17
+ - Did you check the issue tracker for open and closed issues that may be
18
+ related to your bug?
19
+
20
+ - type: textarea
21
+ attributes:
22
+ label: "Describe the issue as clearly as possible:"
23
+ validations:
24
+ required: true
25
+
26
+ - type: textarea
27
+ attributes:
28
+ label: "Steps/code to reproduce the bug:"
29
+ description: >
30
+ A short code example that reproduces the problem/missing feature. It
31
+ should be self-contained, i.e., can be copy-pasted into the Python
32
+ interpreter or run as-is via `python myproblem.py`.
33
+ placeholder: |
34
+ import outlines
35
+
36
+ << your code here >>
37
+ render: python
38
+ validations:
39
+ required: true
40
+
41
+ - type: textarea
42
+ attributes:
43
+ label: "Expected result:"
44
+ description: >
45
+ Please describe what you expect the above example to output.
46
+ placeholder: |
47
+ << the expected result here >>
48
+ render: shell
49
+ validations:
50
+ required: true
51
+
52
+ - type: textarea
53
+ attributes:
54
+ label: "Error message:"
55
+ description: >
56
+ Please include the full error message, if any.
57
+ placeholder: |
58
+ << Full traceback starting from `Traceback: ...` >>
59
+ render: shell
60
+
61
+ - type: textarea
62
+ attributes:
63
+ label: "Outlines/Python version information:"
64
+ description: |
65
+ Please run the following code and paste the output here.
66
+ python -c "from outlines import _version; print(_version.__version__)"
67
+ python -c "import sys; print('Python', sys.version)"
68
+ pip freeze
69
+ value: |
70
+ Version information
71
+ <details>
72
+ ```
73
+ (command output here)
74
+ ```
75
+ </details>
76
+ validations:
77
+ required: true
78
+
79
+ - type: textarea
80
+ attributes:
81
+ label: "Context for the issue:"
82
+ description: |
83
+ Please explain how this issue affects your work or why it should be prioritized.
84
+ placeholder: |
85
+ << your explanation here >>
86
+ validations:
87
+ required: false
@@ -0,0 +1,4 @@
1
+ contact_links:
2
+ - name: 🤔 Questions & Help
3
+ url: https://github.com/dottxt-ai/outlines/discussions/new
4
+ about: "If you have a question about how to use Outlines, please start a discussion."
@@ -0,0 +1,21 @@
1
+ ---
2
+ name: 📚 Documentation
3
+ about: Help with documentation improvements.
4
+ title: ''
5
+ labels: ''
6
+ assignees: ''
7
+ ---
8
+
9
+ ### Documentation request
10
+
11
+ Documentation is a high priority for outlines. If you would like to see something added to the documentation, please help us out by:
12
+
13
+ - Checking to see if the documentation does not already exist.
14
+ - Providing a detailed explanation of what you'd like to understand better.
15
+ - Highlighting any specific difficulties you ran into.
16
+
17
+ ### Are you willing to open a PR?
18
+
19
+ Tell us whether you are willing to submit a PR for this yourself, we'd greatly appreciate it!
20
+
21
+ Thanks for contributing!
@@ -0,0 +1,27 @@
1
+ ---
2
+ name: 🚀 New feature
3
+ about: Request a new feature.
4
+ title: ''
5
+ labels: ''
6
+ assignees: ''
7
+ ---
8
+
9
+ Before suggesting a new feature, please make sure this hasn't already been suggested by searching through the past issues and the PR tracker.
10
+
11
+ ### Presentation of the new feature
12
+
13
+ Assume that we know nothing about this feature. Please give us as much information as possible so we can judge it fairly. That includes (but is not limited to):
14
+ - Academic article
15
+ - Blog posts
16
+ - Implementations
17
+ - Personnal experience with the feature
18
+
19
+ ### Where does it fit in Outlines?
20
+
21
+ Please explain to us why you are suggesting this feature for integration in Outlines.
22
+
23
+ ### Are you willing to open a PR?
24
+
25
+ Tell us whether you are willing to add the feature yourself, and if so if you can share a design plan. **You may be challenged.**
26
+
27
+ Thanks for contributing!
@@ -0,0 +1,34 @@
1
+ name: ✨ Improvement
2
+ description: Propose an improvement to Outlines.
3
+ title: "<Description of the proposed change>"
4
+ labels: "enhancement"
5
+
6
+ body:
7
+ - type: markdown
8
+ attributes:
9
+ value: >-
10
+ Before suggesting an improvement, please make sure this hasn't already been suggested by searching through the past issues and the PR tracker.
11
+
12
+ ## Current behavior
13
+
14
+ - type: textarea
15
+ attributes:
16
+ label: "What behavior of the library made you think about the improvement?"
17
+ placeholder: |
18
+ Sample code with the current behavior
19
+
20
+ - type: markdown
21
+ attributes:
22
+ value: >-
23
+ ## Desired behavior
24
+
25
+ - type: textarea
26
+ attributes:
27
+ label: "How would you like it to behave?"
28
+ placeholder: |
29
+ Sample code with the desired behavior
30
+
31
+ - type: markdown
32
+ attributes:
33
+ value: >-
34
+ **Be aware that your proposal may be challenged.** Outlines has strong design principles that we are committed to stick to. If there is an alternative way to achieve what you would like, we will let you know.
@@ -0,0 +1,23 @@
1
+ # 🚧 Thank you for opening a PR!
2
+
3
+ A few important guidelines and requirements before we can merge your PR:
4
+
5
+ - [ ] We should be able to understand what the PR does from its title only;
6
+ - [ ] There is a high-level description of the changes;
7
+ - [ ] *If I add a new feature*, there is an [issue][issues] discussing it already;
8
+ - [ ] There are links to *all* the relevant issues, discussions and PRs;
9
+ - [ ] The branch is rebased on the latest `main` commit;
10
+ - [ ] **Commit messages** follow these [guidelines][git-guidelines];
11
+ - [ ] One commit per logical change;
12
+ - [ ] The code respects the current **naming conventions**;
13
+ - [ ] Docstrings follow the [numpy style guide][docstring-guidelines];
14
+ - [ ] `pre-commit` is installed and configured on your machine, and you ran it before opening the PR;
15
+ - [ ] There are tests covering the changes;
16
+ - [ ] The documentation is up-to-date;
17
+
18
+ Consider opening a **Draft PR** if your work is still in progress but you would
19
+ like some feedback from other contributors.
20
+
21
+ [issues]: https://github.com/dottxt-ai/outlines/issues
22
+ [git-guidelines]: https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
23
+ [docstring-guidelines]: https://numpydoc.readthedocs.io/en/latest/format.html
@@ -0,0 +1,22 @@
1
+ #!/bin/bash
2
+
3
+ # Build sdist and wheel
4
+ python -m pip install -U pip
5
+ python -m pip install build
6
+ python -m build
7
+
8
+ # Check sdist install and imports
9
+ mkdir -p test-sdist
10
+ cd test-sdist
11
+ python -m venv venv-sdist
12
+ venv-sdist/bin/python -m pip install ../dist/outlines-*.tar.gz
13
+ venv-sdist/bin/python -c "import outlines"
14
+ cd ..
15
+
16
+ # Check wheel install and imports
17
+ mkdir -p test-wheel
18
+ cd test-wheel
19
+ python -m venv venv-wheel
20
+ venv-wheel/bin/python -m pip install ../dist/outlines-*.whl
21
+ venv-wheel/bin/python -c "import outlines"
22
+ cd ..
@@ -0,0 +1,68 @@
1
+ name: Benchmark PR
2
+
3
+ on:
4
+ push:
5
+ pull_request:
6
+ types: [synchronize, labeled]
7
+ workflow_dispatch:
8
+ env:
9
+ PYTHON_VERSION: "3.10"
10
+ WORKING_DIR: ${{ github.workspace }}/benchmarks
11
+ BENCHMARKS_OUTPUT: ${{ github.workspace }}/benchmarks_output
12
+
13
+ permissions:
14
+ contents: read
15
+
16
+ # Cancels all previous workflow runs for pull requests that have not completed.
17
+ concurrency:
18
+ # The concurrency group contains the workflow name and the branch name for pull requests
19
+ # or the commit hash for any other events.
20
+ group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
21
+ cancel-in-progress: true
22
+
23
+ jobs:
24
+ benchmark-pr:
25
+ runs-on: ubuntu-latest
26
+ if: ${{ contains(github.event.pull_request.labels.*.name, 'run-benchmarks') || github.ref == 'refs/heads/main' }}
27
+
28
+ defaults:
29
+ run:
30
+ working-directory: ${{ env.WORKING_DIR }}
31
+
32
+ steps:
33
+
34
+ - name: Checkout repository
35
+ uses: actions/checkout@v3
36
+ with:
37
+ fetch-depth: 0
38
+
39
+ - name: Set up Python
40
+ uses: actions/setup-python@v4
41
+ with:
42
+ python-version: ${{ env.PYTHON_VERSION }}
43
+
44
+ - name: Install dependencies
45
+ run: |
46
+ python -m pip install --upgrade pip
47
+ pip install asv virtualenv lf-asv-formatter
48
+
49
+ - name: Create ASV machine config file
50
+ run: asv machine --machine gh-runner --yes
51
+
52
+ - name: Run Benchmarks - `PR HEAD` vs `main`
53
+ run: |
54
+ # prepare main branch for comparison
55
+ git remote add upstream https://github.com/${{ github.repository }}.git
56
+ git fetch upstream main
57
+
58
+ # Run benchmarks, allow errors, they will be caught in the next step
59
+ asv continuous upstream/main HEAD \
60
+ --no-stats --interleave-rounds -a repeat=3 || true
61
+
62
+ - name: BENCHMARK RESULTS
63
+ run: |
64
+ asv compare --factor=1.1 --no-stats --split upstream/main HEAD | tee ${{ env.BENCHMARKS_OUTPUT }}
65
+ if grep -q "Benchmarks that have got worse" "${{ env.BENCHMARKS_OUTPUT }}"; then
66
+ echo "Performance degradation detected!"
67
+ exit 1
68
+ fi
@@ -0,0 +1,23 @@
1
+ name: Build the documentation
2
+
3
+ on:
4
+ pull_request:
5
+ branches: [main]
6
+ workflow_dispatch:
7
+
8
+ jobs:
9
+ build:
10
+ name: Build
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - uses: actions/checkout@v4
14
+ - uses: actions/setup-python@v4
15
+ with:
16
+ python-version: "3.10"
17
+
18
+ - name: Build the documentation
19
+ env:
20
+ GOOGLE_ANALYTICS_KEY: ${{ secrets.GOOGLE_ANALYTICS_KEY }}
21
+ run: |
22
+ pip install -r requirements-doc.txt
23
+ mkdocs build
@@ -0,0 +1,53 @@
1
+ name: Publish the documentation
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ push:
6
+ branches:
7
+ - main
8
+ release:
9
+ types:
10
+ - created
11
+
12
+ permissions:
13
+ contents: write
14
+
15
+ jobs:
16
+ deploy:
17
+ runs-on: ubuntu-latest
18
+ steps:
19
+ - uses: actions/checkout@v4
20
+ with:
21
+ fetch-depth: 0
22
+ - uses: actions/setup-python@v4
23
+ with:
24
+ python-version: 3.x
25
+ - run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
26
+ - uses: actions/cache@v3
27
+ with:
28
+ key: mkdocs-material-${{ env.cache_id }}
29
+ path: .cache
30
+ restore-keys: |
31
+ mkdocs-material-
32
+ - run: pip install -r requirements-doc.txt
33
+ - run: mkdocs build
34
+
35
+ - name: Set up Git
36
+ run: |
37
+ git config user.name ${{ github.actor }}
38
+ git config user.email ${{ github.actor }}@users.noreply.github.com
39
+
40
+ - name: Publish Tag as latest
41
+ env:
42
+ GOOGLE_ANALYTICS_KEY: ${{ secrets.GOOGLE_ANALYTICS_KEY }}
43
+ if: github.event_name == 'release'
44
+ run: |
45
+ mike deploy --push --update-aliases ${{ github.ref_name }} latest
46
+ mike set-default --push latest
47
+
48
+ - name: Publish main as unstable
49
+ env:
50
+ GOOGLE_ANALYTICS_KEY: ${{ secrets.GOOGLE_ANALYTICS_KEY }}
51
+ if: github.event_name == 'push'
52
+ run: |
53
+ mike deploy --push --update-aliases ${{ github.ref_name }} unstable
@@ -0,0 +1,36 @@
1
+ name: Release Docker
2
+
3
+ on:
4
+ release:
5
+ types:
6
+ - created
7
+ workflow_dispatch:
8
+ inputs:
9
+ release_tag:
10
+ description: 'Release Tag (for manual dispatch)'
11
+ required: false
12
+ default: 'latest'
13
+ jobs:
14
+ release-job:
15
+ name: Build and publish on Docker Hub
16
+ runs-on: ubuntu-latest
17
+ environment: release
18
+ steps:
19
+ - name: Checkout
20
+ uses: actions/checkout@v4
21
+ - name: Log in to Docker Hub
22
+ uses: docker/login-action@v3
23
+ with:
24
+ username: ${{ secrets.DOCKERHUB_USERNAME }}
25
+ password: ${{ secrets.DOCKERHUB_TOKEN }}
26
+ - name: Build and push Docker image
27
+ uses: docker/build-push-action@v5
28
+ with:
29
+ push: true
30
+ tags: |
31
+ outlinesdev/outlines:latest
32
+ outlinesdev/outlines:${{ github.event.release.tag_name || github.event.inputs.release_tag }}
33
+ build-args: |
34
+ BUILDKIT_CONTEXT_KEEP_GIT_DIR=true
35
+ - name: Clean docker cache
36
+ run: docker system prune --all --force
@@ -0,0 +1,27 @@
1
+ name: Release PyPi
2
+
3
+ on:
4
+ release:
5
+ types:
6
+ - created
7
+ jobs:
8
+ release-job:
9
+ name: Build and publish on PyPi
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - name: Checkout
13
+ uses: actions/checkout@v2
14
+ - name: Set up Python
15
+ uses: actions/setup-python@v2
16
+ with:
17
+ python-version: "3.10"
18
+ - name: Build SDist and Wheel
19
+ run: ./.github/scripts/build_sdist_and_wheel.sh
20
+ - name: Check that the package version matches the Release name
21
+ run: |
22
+ grep -Rq "^Version: ${GITHUB_REF:10}$" outlines.egg-info/PKG-INFO
23
+ - name: Publish to PyPi
24
+ uses: pypa/gh-action-pypi-publish@v1.4.2
25
+ with:
26
+ user: __token__
27
+ password: ${{ secrets.PYPI_TOKEN }}
@@ -0,0 +1,109 @@
1
+ name: Tests
2
+
3
+ on:
4
+ pull_request:
5
+ branches: [main]
6
+ push:
7
+ branches: [main]
8
+
9
+ jobs:
10
+ style:
11
+ name: Check the code style
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - uses: actions/checkout@v3
15
+ - uses: actions/setup-python@v4
16
+ with:
17
+ python-version: "3.10"
18
+ - uses: pre-commit/action@v3.0.0
19
+
20
+ tests:
21
+ name: Run the tests
22
+ runs-on: ubuntu-latest
23
+ strategy:
24
+ matrix:
25
+ python-version: ["3.10"]
26
+ steps:
27
+ - uses: actions/checkout@v3
28
+ - name: Set up Python ${{ matrix.python-version }}
29
+ uses: actions/setup-python@v4
30
+ with:
31
+ python-version: ${{ matrix.python-version }}
32
+ - name: Set up test environment
33
+ run: |
34
+ python -m pip install --upgrade pip
35
+ pip install -e .[test]
36
+ - name: Create matrix id
37
+ id: matrix-id
38
+ env:
39
+ MATRIX_CONTEXT: ${{ toJson(matrix) }}
40
+ run: |
41
+ echo $MATRIX_CONTEXT
42
+ export MATRIX_ID=`echo $MATRIX_CONTEXT | md5sum | cut -c 1-32`
43
+ echo $MATRIX_ID
44
+ echo "::set-output name=id::$MATRIX_ID"
45
+ - name: Run tests
46
+ run: |
47
+ pytest -x --cov=outlines
48
+ env:
49
+ COVERAGE_FILE: .coverage.${{ steps.matrix-id.outputs.id }}
50
+ - name: Upload coverage data
51
+ uses: actions/upload-artifact@v4
52
+ with:
53
+ name: coverage-data
54
+ path: .coverage.*
55
+ if-no-files-found: ignore
56
+ include-hidden-files: true
57
+ # TODO FIXME: This is only using the last run
58
+ overwrite: true
59
+
60
+ coverage:
61
+ name: Combine & check coverage.
62
+ needs: tests
63
+ runs-on: ubuntu-latest
64
+
65
+ steps:
66
+ - uses: actions/checkout@v3
67
+ with:
68
+ fetch-depth: 0
69
+
70
+ - uses: actions/setup-python@v4
71
+ with:
72
+ cache: pip
73
+ python-version: "3.11"
74
+
75
+ - name: Set up environment
76
+ run: |
77
+ pip install --upgrade "coverage[toml]>=5.1" diff-cover
78
+
79
+ - uses: actions/download-artifact@v4
80
+ with:
81
+ name: coverage-data
82
+
83
+ - name: Fetch main for coverage diff
84
+ run: |
85
+ git fetch --no-tags --prune origin main
86
+
87
+ - name: Combine coverage & fail if it's <100%.
88
+ run: |
89
+ python -m coverage combine
90
+ python -m coverage html --skip-covered --skip-empty
91
+ python -m coverage xml
92
+ diff-cover coverage.xml --markdown-report=coverage.md --fail-under=100 || (cat coverage.md >> $GITHUB_STEP_SUMMARY && exit 1)
93
+
94
+ - name: Upload HTML report if check failed.
95
+ uses: actions/upload-artifact@v4
96
+ with:
97
+ name: html-report
98
+ path: htmlcov
99
+ # TODO FIXME: This is only using the last run
100
+ overwrite: true
101
+ if: ${{ failure() }}
102
+
103
+ build-wheel:
104
+ name: Build Wheel and Test SDist
105
+ runs-on: ubuntu-latest
106
+ steps:
107
+ - uses: actions/checkout@v3
108
+ - name: Build SDist and Wheel
109
+ run: ./.github/scripts/build_sdist_and_wheel.sh
@@ -0,0 +1,14 @@
1
+ *.egg-info
2
+ __pycache__
3
+ *_version.py
4
+ docs/build
5
+ .coverage
6
+ .idea/
7
+ *.gguf
8
+ .venv
9
+ benchmarks/results
10
+ .python-version
11
+
12
+ # Remove doc build folders
13
+ .cache/
14
+ build/
@@ -0,0 +1,33 @@
1
+ repos:
2
+ - repo: https://github.com/pre-commit/pre-commit-hooks
3
+ rev: v4.4.0
4
+ hooks:
5
+ - id: check-merge-conflict
6
+ - id: debug-statements
7
+ - id: end-of-file-fixer
8
+ - id: trailing-whitespace
9
+ - repo: https://github.com/pycqa/isort
10
+ rev: 5.12.0
11
+ hooks:
12
+ - id: isort
13
+ args: [--profile, black]
14
+ - repo: https://github.com/asottile/pyupgrade
15
+ rev: v3.3.1
16
+ hooks:
17
+ - id: pyupgrade
18
+ args: [--py37-plus]
19
+ - repo: https://github.com/pycqa/flake8
20
+ rev: 6.0.0
21
+ hooks:
22
+ - id: flake8
23
+ - repo: https://github.com/psf/black
24
+ rev: 23.3.0
25
+ hooks:
26
+ - id: black
27
+ - repo: https://github.com/pre-commit/mirrors-mypy
28
+ rev: v1.2.0
29
+ hooks:
30
+ - id: mypy
31
+ args: [--allow-redefinition]
32
+ exclude: ^examples/
33
+ additional_dependencies: [types-tqdm, types-Pillow]
@@ -0,0 +1,15 @@
1
+ version: 2
2
+
3
+ python:
4
+ version: "3.8"
5
+ install:
6
+ - method: pip
7
+ path: .
8
+ extra_requirements:
9
+ - rtd
10
+ - requirements: requirements-doc.txt
11
+
12
+ sphinx:
13
+ builder: html
14
+ configuration: docs/source/conf.py
15
+ fail_on_warning: true
@@ -0,0 +1,17 @@
1
+ FROM python:3.10
2
+
3
+ WORKDIR /outlines
4
+
5
+ RUN pip install --upgrade pip
6
+
7
+ # Copy necessary build components
8
+ COPY pyproject.toml .
9
+ COPY outlines ./outlines
10
+
11
+ # Install outlines and outlines[serve]
12
+ # .git required by setuptools-scm
13
+ RUN --mount=source=.git,target=.git,type=bind \
14
+ pip install --no-cache-dir .[serve]
15
+
16
+ # https://dottxt-ai.github.io/outlines/reference/vllm/
17
+ ENTRYPOINT ["python3", "-m", "outlines.serve.serve"]