You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/tutorial.md
+7-31Lines changed: 7 additions & 31 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,19 +33,11 @@ Hello, world!
33
33
## Calling an LLM
34
34
35
35
```yaml
36
-
description: Hello world calling a model
37
-
text:
38
-
- Hello,
39
-
- model: watsonx/ibm/granite-34b-code-instruct
40
-
parameters:
41
-
decoding_method: greedy
42
-
stop:
43
-
- '!'
44
-
include_stop_sequence: true
36
+
--8<-- "./examples/tutorial/calling_llm.pdl"
45
37
```
46
38
47
-
In this program ([file](https://github.com/IBM/prompt-declaration-language//blob/main/examples/tutorial/calling_llm.pdl)), the `text` starts with the word `Hello,`, and we call a model (`watsonx/ibm/granite-34b-code-instruct`) with this as input prompt. Notice the Watsonx model id on LiteLLM.
48
-
The model is passed some parameters including the `decoding_method` and `stop`, which corresponds to the `stop_sequences` parameter in Watsonx. The stop sequences are to be included in the output.
39
+
In this program ([file](https://github.com/IBM/prompt-declaration-language//blob/main/examples/tutorial/calling_llm.pdl)), the `text` starts with the word `Hello,`, and we call a model (`watsonx/ibm/granite-34b-code-instruct`) with this as input prompt. Notice the watsonx model id on LiteLLM.
40
+
The model is passed some parameters including the `decoding_method` and `stop`, which corresponds to the `stop_sequences` parameter in watsonx. The stop sequences are to be included in the output.
49
41
50
42
A PDL program computes 2 data structures. The first is a JSON corresponding to the result of the overall program, obtained by aggregating the results of each block. This is what is printed by default when we run the interpreter. The second is a conversational background context, which is a list of role/content pairs, where we implicitly keep track of roles and content for the purpose of communicating with models that support chat APIs. The contents in the latter correspond to the results of each block. The conversational background context is what is used to make calls to LLMs via LiteLLM.
51
43
@@ -62,12 +54,7 @@ where the portion ` world!` has been generated by Granite.
62
54
63
55
Here's another of model call that includes an `input` field ([file](https://github.com/IBM/prompt-declaration-language//blob/main/examples/tutorial/calling_llm_with_input.pdl)):
In this case, we make a call to the granite multilingual model, and the input passed to the model is the sentence: `Translate the word 'world' to French` and nothing else from the surrounding document. When we execute this program, we obtain:
@@ -78,9 +65,9 @@ Le mot 'world' en français est 'monde'.
78
65
```
79
66
where everything after the `:` including it were generated by the model.
80
67
81
-
### Parameter defaults for Watsonx Granite models
68
+
### Parameter defaults for watsonx Granite models
82
69
83
-
PDL provides the following defaults for Watsonx Granite models, when the following parameters are missing:
70
+
PDL provides the following defaults for watsonx Granite models, when the following parameters are missing:
84
71
-`decoding_method`: `greedy`
85
72
-`max_new_tokens`: 1024
86
73
-`min_new_tokens`: 1
@@ -128,18 +115,7 @@ GEN is equal to: world!
128
115
In PDL, we can declaratively chain models together as in the following example ([file](https://github.com/IBM/prompt-declaration-language//blob/main/examples/tutorial/model_chaining.pdl)):
129
116
130
117
```yaml
131
-
description: Model chaining
132
-
text:
133
-
- Hello,
134
-
- model: watsonx/ibm/granite-34b-code-instruct
135
-
parameters:
136
-
stop: ["!"]
137
-
include_stop_sequence: true
138
-
- "\nTranslate this to French\n"
139
-
- model: watsonx/ibm/granite-20b-multilingual
140
-
parameters:
141
-
stop: ["!"]
142
-
include_stop_sequence: true
118
+
--8<-- "./examples/tutorial/model_chaining.pdl"
143
119
```
144
120
145
121
In this program, the first call is to a granite model to complete the sentence `Hello, world!`. The following block in the document prints out the sentence: `Translate this to French`. The final line of the program takes the entire document produced so far and passes it as input to the granite multilingual model. Notice that the input passed to this model is the document up to that point, represented as a conversation. This makes it easy to chain models together and continue building on previous interactions.
0 commit comments