Skip to content

Commit e143bd2

Browse files
committed
1
1 parent 1d4edec commit e143bd2

File tree

1 file changed

+30
-23
lines changed

1 file changed

+30
-23
lines changed

docs/building-blocks/1-language_models.md

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ For example, to use OpenAI language models, you can do it as follows.
1818
gpt3_turbo = dspy.OpenAI(model='gpt-3.5-turbo-1106', max_tokens=300)
1919
dspy.configure(lm=gpt3_turbo)
2020
```
21-
22-
['Hello! How can I assist you today?']
21+
**Output:**
22+
```text
23+
['Hello! How can I assist you today?']
24+
```
2325

2426
## Directly calling the LM.
2527

@@ -43,9 +45,10 @@ qa = dspy.ChainOfThought('question -> answer')
4345
response = qa(question="How many floors are in the castle David Gregory inherited?")
4446
print(response.answer)
4547
```
46-
47-
The castle David Gregory inherited has 7 floors.
48-
48+
**Output:**
49+
```text
50+
The castle David Gregory inherited has 7 floors.
51+
```
4952

5053
## Using multiple LMs at once.
5154

@@ -67,10 +70,11 @@ with dspy.context(lm=gpt4_turbo):
6770
response = qa(question="How many floors are in the castle David Gregory inherited?")
6871
print('GPT-4-turbo:', response.answer)
6972
```
70-
71-
GPT-3.5: The castle David Gregory inherited has 7 floors.
72-
GPT-4-turbo: The number of floors in the castle David Gregory inherited cannot be determined with the information provided.
73-
73+
**Output:**
74+
```text
75+
GPT-3.5: The castle David Gregory inherited has 7 floors.
76+
GPT-4-turbo: The number of floors in the castle David Gregory inherited cannot be determined with the information provided.
77+
```
7478

7579
## Tips and Tricks.
7680

@@ -87,12 +91,14 @@ qa = dspy.ChainOfThought('question -> answer', n=5)
8791
response = qa(question="How many floors are in the castle David Gregory inherited?")
8892
response.completions.answer
8993
```
90-
91-
["The specific number of floors in David Gregory's inherited castle is not provided here, so further research would be needed to determine the answer.",
92-
'The castle David Gregory inherited has 4 floors.',
93-
'The castle David Gregory inherited has 5 floors.',
94-
'David Gregory inherited 10 floors in the castle.',
95-
'The castle David Gregory inherited has 5 floors.']
94+
**Output:**
95+
```text
96+
["The specific number of floors in David Gregory's inherited castle is not provided here, so further research would be needed to determine the answer.",
97+
'The castle David Gregory inherited has 4 floors.',
98+
'The castle David Gregory inherited has 5 floors.',
99+
'David Gregory inherited 10 floors in the castle.',
100+
'The castle David Gregory inherited has 5 floors.']
101+
```
96102

97103
If you just call `qa(...)` in a loop with the same input, it will always
98104
return the same value! That\'s by design.
@@ -105,13 +111,14 @@ for idx in range(5):
105111
response = qa(question="How many floors are in the castle David Gregory inherited?", config=dict(temperature=0.7+0.0001*idx))
106112
print(f'{idx+1}.', response.answer)
107113
```
108-
109-
1. The specific number of floors in David Gregory's inherited castle is not provided here, so further research would be needed to determine the answer.
110-
2. It is not possible to determine the exact number of floors in the castle David Gregory inherited without specific information about the castle's layout and history.
111-
3. The castle David Gregory inherited has 5 floors.
112-
4. We need more information to determine the number of floors in the castle David Gregory inherited.
113-
5. The castle David Gregory inherited has a total of 6 floors.
114-
114+
**Output:**
115+
```text
116+
1. The specific number of floors in David Gregory's inherited castle is not provided here, so further research would be needed to determine the answer.
117+
2. It is not possible to determine the exact number of floors in the castle David Gregory inherited without specific information about the castle's layout and history.
118+
3. The castle David Gregory inherited has 5 floors.
119+
4. We need more information to determine the number of floors in the castle David Gregory inherited.
120+
5. The castle David Gregory inherited has a total of 6 floors.
121+
```
115122

116123
## Remote LMs.
117124

@@ -138,7 +145,7 @@ You need to host these models on your own GPU(s). Below, we include pointers for
138145

139146
5. `dspy.ChatModuleClient` (experimental): [How do I install and use MLC?](/api/hosting_language_models_locally/MLC)
140147

141-
If there are other clients you want added, let us know!
148+
If there are other clients you want added, let us know or open a PR! Read the doc page on how to create a new LM client.
142149

143150

144151
<!-- TODO: Usage examples for these all.

0 commit comments

Comments
 (0)