|
19 | 19 | - [The Guarded Nondeterminism Pattern](#guarded-nondeterminism) |
20 | 20 | - [Chapter 9: Interoperability with Other Frameworks](#chapter-9-interoperability-with-other-frameworks) |
21 | 21 | - [Chapter 10: Prompt Engineering for Mellea](#chapter-10-prompt-engineering-for-m) |
22 | | - - [Custom Templates](#custom--templates) |
| 22 | + - [Custom Templates](#custom-templates) |
23 | 23 | - [Appendix: Contributing to Melles](#appendix-contributing-to-mellea) |
24 | 24 |
|
25 | 25 | ## Chapter 1: What Is Generative Programming |
@@ -311,7 +311,7 @@ final_options = { |
311 | 311 |
|
312 | 312 | ### Conclusion |
313 | 313 |
|
314 | | -We have now worked up from a simple "Hello, World" example to our first generative programming design pattern: **Instruct - Validate - Reapir (IVR)**. |
| 314 | +We have now worked up from a simple "Hello, World" example to our first generative programming design pattern: **Instruct - Validate - Repair (IVR)**. |
315 | 315 |
|
316 | 316 | When LLMs work well, the software developer experiences the LLM as a sort of oracle that can handle most any input and produce a sufficiently desirable output. When LLMs do not work at all, the software developer experiences the LLM as a naive markov chain that produces junk. In both cases, the LLM is just sampling from a distribution. |
317 | 317 |
|
@@ -419,7 +419,7 @@ def summarize_contract(contract_text: str) -> str: |
419 | 419 |
|
420 | 420 | @generative |
421 | 421 | def summarize_short_story(story: str) -> str: |
422 | | - """Summarize a short story, with one paragraph on plot and one paragraph on braod themes.""" |
| 422 | + """Summarize a short story, with one paragraph on plot and one paragraph on broad themes.""" |
423 | 423 | ``` |
424 | 424 |
|
425 | 425 | ```python |
@@ -542,7 +542,7 @@ else: |
542 | 542 | print("Summary lacks a structured conclusion.") |
543 | 543 | ``` |
544 | 544 |
|
545 | | -Without these Hoare-style contracts, the only way to ensure composition is to couple the libraries, either by rewriting `summarize_meeting` to conform to `propose_business_decision`, or adding Requirements to `propose_business_decision` that may silently fail if unmet. These approahces can work, but require tight coupling between these two otherwise loosely couple libraries. |
| 545 | +Without these Hoare-style contracts, the only way to ensure composition is to couple the libraries, either by rewriting `summarize_meeting` to conform to `propose_business_decision`, or adding Requirements to `propose_business_decision` that may silently fail if unmet. These approaches can work, but require tight coupling between these two otherwise loosely coupled libraries. |
546 | 546 |
|
547 | 547 | With contracts, we **decouple** the libraries without sacrificing safe dynamic composition, by moving the coupling logic into pre- and post-condition checks. This is another LLM-native software engineering pattern: **guarded nondeterminism**. |
548 | 548 |
|
@@ -743,7 +743,7 @@ Let's see how Stembolt MFG Corporation can use tuned LoRAs to implement the Auto |
743 | 743 |
|
744 | 744 | ### Training the aLoRA Adapter |
745 | 745 |
|
746 | | -Mellea provides a command-line interface for training [LoRA](https://arxiv.org/abs/2106.09685) or [aLoRA](https://github.com/IBM/alora) adapters. Classical LoRAs must re-process our entire context, which can get experience for quick checks happening within an inner loop (such as requirement checking). The aLoRA method allows us adapt a base LLM to new tasks, and then run the adapter with minimal compute overhead. The adapters are fast to train and fast to switch between. |
| 746 | +Mellea provides a command-line interface for training [LoRA](https://arxiv.org/abs/2106.09685) or [aLoRA](https://github.com/IBM/activated-lora) adapters. Classical LoRAs must re-process our entire context, which can get expensive for quick checks happening within an inner loop (such as requirement checking). The aLoRA method allows us to adapt a base LLM to new tasks, and then run the adapter with minimal compute overhead. The adapters are fast to train and fast to switch between. |
747 | 747 |
|
748 | 748 | We will train a lightweight adapter with the `m alora train` command on this small dataset: |
749 | 749 |
|
@@ -781,7 +781,7 @@ While training adapters, you can easily tuning the hyper-parameters as below: |
781 | 781 |
|
782 | 782 | ### Upload to Hugging Face (Optional) |
783 | 783 |
|
784 | | -To share or reuse the trained adapter by using the `m alora upload` command to publish your trained adapter: |
| 784 | +To share or reuse the trained adapter, use the `m alora upload` command to publish your trained adapter: |
785 | 785 |
|
786 | 786 | ```bash |
787 | 787 | m alora upload ./checkpoints/alora_adapter \ |
@@ -823,7 +823,7 @@ backend.add_alora( |
823 | 823 | ) |
824 | 824 | ``` |
825 | 825 |
|
826 | | -In the above arguments, `path_or_model_id` refers to the model checkpoint which got from last step, i.e., `m alora train` process. |
| 826 | +In the above arguments, `path_or_model_id` refers to the model checkpoint from last step, i.e., the `m alora train` process. |
827 | 827 |
|
828 | 828 | > [!NOTE] |
829 | 829 | > The `generation_prompt` passed to your `backend.add_alora` call should exactly match the prompt used for training. |
@@ -908,7 +908,7 @@ m = mellea.MelleaSession( |
908 | 908 | ) |
909 | 909 | ``` |
910 | 910 |
|
911 | | -The `SimpleContext` -- which is the only context we have used so far -- is a context manager that resets the chat message history on each model call. That is, the model's context is entirely determined by the current Component. Mellea also provides a `LinearContext`, which behaves like a chat history. We can use the LinearContext to interact with cat hmodels: |
| 911 | +The `SimpleContext` -- which is the only context we have used so far -- is a context manager that resets the chat message history on each model call. That is, the model's context is entirely determined by the current Component. Mellea also provides a `LinearContext`, which behaves like a chat history. We can use the LinearContext to interact with chat models: |
912 | 912 |
|
913 | 913 | ```python |
914 | 914 | # file: https://github.com/generative-computing/mellea/blob/main/docs/examples/tutorial/context_example.py#L1-L5 |
@@ -1216,7 +1216,7 @@ def serve( |
1216 | 1216 | ) |
1217 | 1217 | ``` |
1218 | 1218 |
|
1219 | | -the `m serve` command then subsequently takes this funcition and runs a server that is openai compatible. For more information, please have a look at [this file](./examples/tutorial/m_serve_example.py) for how to write an `m serve` compatible program. To run the example: |
| 1219 | +the `m serve` command then subsequently takes this function and runs a server that is openai compatible. For more information, please have a look at [this file](./examples/tutorial/m_serve_example.py) for how to write an `m serve` compatible program. To run the example: |
1220 | 1220 |
|
1221 | 1221 | ```shell |
1222 | 1222 | m serve docs/examples/tutorial/m_serve_example.py |
@@ -1254,7 +1254,7 @@ It also contains either of the following fields |
1254 | 1254 | By writing a new template and/or changing the TemplateRepresentation of a component you can customize the textual representation. You can also customize based on the model. |
1255 | 1255 |
|
1256 | 1256 | #### Choosing a Template |
1257 | | -Assuming a component's TemplateRepresentation contains a `template_order` field, the default TemplateFormatter grabs the relevant template by looing at the following places in order for each template in the `template_order`: |
| 1257 | +Assuming a component's TemplateRepresentation contains a `template_order` field, the default TemplateFormatter grabs the relevant template by looking at the following places in order for each template in the `template_order`: |
1258 | 1258 | 1. the formatter's cached templates if the template has been looked up recently |
1259 | 1259 | 2. the formatter's specified template path |
1260 | 1260 | 3. the package that the object getting formatted is from (either 'mellea' or some third party package) |
|
0 commit comments