DSPy: The framework for programming—not prompting—language models
Python
docs: remove n=5 assumption from modules tutorial example (#9380)
Maxime Rivestadf2db056709
diff --git a/docs/docs/learn/programming/modules.md b/docs/docs/learn/programming/modules.mdindex 548fdea7a..8ad51766a 100644--- a/docs/docs/learn/programming/modules.md+++ b/docs/docs/learn/programming/modules.md@@ -38,7 +38,7 @@ TrueWhen we declare a module, we can pass configuration keys to it.-Below, we'll pass `n=5` to request five completions. We can also pass `temperature` or `max_len`, etc.+Below, we'll pass a simple config key like `temperature`. You can also pass other generation keys like `max_tokens`.Let's use `dspy.ChainOfThought`. In many cases, simply swapping `dspy.ChainOfThought` in place of `dspy.Predict` improves quality.@@ -46,21 +46,17 @@ Let's use `dspy.ChainOfThought`. In many cases, simply swapping `dspy.ChainOfThoquestion = "What's something great about the ColBERT retrieval model?"# 1) Declare with a signature, and pass some config.-classify = dspy.ChainOfThought('question -> answer', n=5)+classify = dspy.ChainOfThought('question -> answer', temperature=0.7)# 2) Call with input argument.response = classify(question=question)-# 3) Access the outputs.-response.completions.answer+# 3) Access the output.+response.answer```**Possible Output:**```text-['One great thing about the ColBERT retrieval model is its superior efficiency and effectiveness compared to other models.',- 'Its ability to efficiently retrieve relevant information from large document collections.',- 'One great thing about the ColBERT retrieval model is its superior performance compared to other models and its efficient use of pre-trained language models.',- 'One great thing about the ColBERT retrieval model is its superior efficiency and accuracy compared to other models.',- 'One great thing about the ColBERT retrieval model is its ability to incorporate user feedback and support complex queries.']+'One great thing about the ColBERT retrieval model is its superior efficiency and effectiveness compared to other models.'```Let's discuss the output object here. The `dspy.ChainOfThought` module will generally inject a `reasoning` before the output field(s) of your signature.@@ -77,19 +73,6 @@ Reasoning: We can consider the fact that ColBERT has shown to outperform other sAnswer: One great thing about the ColBERT retrieval model is its superior efficiency and effectiveness compared to other models.```-This is accessible whether we request one or many completions.--We can also access the different completions as a list of `Prediction`s or as several lists, one for each field.--```python-response.completions[3].reasoning == response.completions.reasoning[3]-```-**Output:**-```text-True-```--## What other DSPy modules are there? How can I use them?The others are very similar. They mainly change the internal behavior with which your signature is implemented!