Elffuss BraidHub

kikocis/continue public

main · 8.6 KiBRawPermalink
1---
2title: "IBM WatsonX"
3description: "How to configure IBM's watsonx models in Continue, including authentication methods, deployment options, and support for chat, autocomplete, embeddings, and reranking models"
4---
5
6watsonx, developed by IBM, offers a variety of pre-trained AI foundation models that can be used for natural language processing (NLP), computer vision, and speech recognition tasks.
7
8## Setup
9
10Accessing watsonx models can be done either through watsonx SaaS on IBM Cloud or using a dedicated watsonx.ai Software instance.
11
12### watsonx.ai SaaS - IBM Cloud
13
14To get started with watsonx SaaS, visit the [registration page](https://dataplatform.cloud.ibm.com/registration/stepone?context=wx). If you do not have an existing IBM Cloud account, you can sign up for a free trial.
15
16To authenticate to watsonx.ai SaaS with Continue, you will need to create a project and [set up an API key](https://www.ibm.com/docs/en/mas-cd/continuous-delivery?topic=cli-creating-your-cloud-api-key). Then, in continue:
17
18- Set **apiBase** to your watsonx SaaS endpoint, e.g. `https://us-south.ml.cloud.ibm.com` for US South region.
19- Set **projectId** to your watsonx project ID.
20- Set **apiKey** to your watsonx API Key.
21
22### watsonx.ai Software
23
24To authenticate to your watsonx.ai Software instance with Continue, you can use either `username/password` or `ZenApiKey` method:
25
261. _Option 1_ (Recommended): using `ZenApiKey` authentication:
27 - Set **apiBase** to your watsonx software endpoint, e.g. `https://cpd-watsonx.apps.example.com`.
28 - Set **projectId** to your watsonx project ID.
29 - Set **apiKey** to your watsonx Zen API Key. To generate it:
30 1. Log in to the CPD web client.
31 2. From the toolbar, click your avatar.
32 3. Click **Profile and settings**.
33 4. Click **API key** > **Generate new key**.
34 5. Click **Generate**.
35 6. Click **Copy** and save your key somewhere safe. You cannot recover this key if you lose it.
36 7. Generate your ZenApiKey by running the following command in your preferred terminal: `echo "<username>:<apikey>" | base64`, replacing `<username>` with your CPD username and `<apikey>` with the API Key you just created.
372. _Option 2_: using `username/password` authentication:
38 - Set **apiBase** to your watsonx software endpoint, e.g. `https://cpd-watsonx.apps.example.com`.
39 - Set **projectId** to your watsonx project ID.
40 - Set **API Key** to your watsonx Username and Password using `username:password` as format.
41
42## Configuration
43
44Add the following configuration:
45
46<Tabs>
47 <Tab title="YAML">
48 ```yaml title="config.yaml"
49 models:
50 - name: watsonx - Model Name
51 provider: watsonx
52 model: model ID
53 apiBase: https://us-south.ml.cloud.ibm.com
54 apiKey: API_KEY/ZENAPI_KEY/USERNAME:PASSWORD
55 env:
56 projectId: PROJECT_ID
57 apiVersion: 2024-03-14
58 ```
59 </Tab>
60 <Tab title="JSON">
61 ```json title="config.json"
62 {
63 "models": [
64 {
65 "model": "model ID",
66 "title": "watsonx - Model Name",
67 "provider": "watsonx",
68 "apiBase": "https://us-south.ml.cloud.ibm.com",
69 "projectId": "PROJECT_ID",
70 "apiKey": "API_KEY/ZENAPI_KEY/USERNAME:PASSWORD",
71 "apiVersion": "2024-03-14"
72 }
73 ]
74 }
75 ```
76 </Tab>
77</Tabs>
78
79`apiVersion` is optional and defaults to the latest version.
80
81If you are using a custom deployment endpoint, set `deploymentID` to the model's deployment ID. You can find it in the watsonx.ai Prompt Lab UI by selecting the corresponding model and opening the `</>` tab on the right, which will display the endpoint's URL containing the deployment ID.
82
83<Tabs>
84 <Tab title="YAML">
85 ```yaml title="config.yaml"
86 models:
87 - name: watsonx - Model Name
88 provider: watsonx
89 model: model ID
90 apiBase: watsonx endpoint e.g. https://us-south.ml.cloud.ibm.com
91 apiKey: API_KEY/ZENAPI_KEY/USERNAME:PASSWORD
92 env:
93 apiVersion: 2024-03-14
94 deploymentId: DEPLOYMENT_ID
95 ```
96 </Tab>
97 <Tab title="JSON">
98 ```json title="config.json"
99 {
100 "models": [
101 {
102 "model": "model ID",
103 "title": "watsonx - Model Name",
104 "provider": "watsonx",
105 "apiBase": "watsonx endpoint e.g. https://us-south.ml.cloud.ibm.com",
106 "apiKey": "API_KEY/ZENAPI_KEY/USERNAME:PASSWORD",
107 "apiVersion": "2024-03-14",
108 "deploymentId": "DEPLOYMENT_ID"
109 }
110 ]
111 }
112 ```
113 </Tab>
114</Tabs>
115
116### Configuration Options
117
118Make sure to specify a template name, such as `granite` or `llama3`, and to set the `contextLength` to the model's context window size.
119You can also configure generation parameters, such as temperature, topP, topK, frequency penalty, and stop sequences:
120
121<Tabs>
122 <Tab title="YAML">
123 ```yaml title="config.yaml"
124 models:
125 - name: Granite Code 20b
126 provider: watsonx
127 model: ibm/granite-20b-code-instruct
128 apiBase: watsonx endpoint e.g. https://us-south.ml.cloud.ibm.com
129 apiKey: API_KEY/ZENAPI_KEY/USERNAME:PASSWORD
130 template: granite
131 defaultCompletionOptions:
132 contextLength: 8000
133 temperature: 0.1
134 topP: 0.3
135 topK: 20
136 maxTokens: 2000
137 frequencyPenalty: 1.1
138 stop:
139 - Question:
140 - "\n\n\n"
141 env:
142 projectId: PROJECT_ID
143 apiVersion: 2024-03-14
144
145 ```
146 </Tab>
147 <Tab title="JSON">
148 ```json title="config.json"
149 {
150 "models": [
151 {
152 "model": "ibm/granite-20b-code-instruct",
153 "title": "Granite Code 20b",
154 "provider": "watsonx",
155 "apiBase": "watsonx endpoint e.g. https://us-south.ml.cloud.ibm.com",
156 "projectId": "PROJECT_ID",
157 "apiKey": "API_KEY/ZENAPI_KEY/USERNAME:PASSWORD",
158 "apiVersion": "2024-03-14",
159 "template": "granite",
160 "contextLength": 8000,
161 "completionOptions": {
162 "temperature": 0.1,
163 "topP": 0.3,
164 "topK": 20,
165 "maxTokens": 2000,
166 "frequencyPenalty": 1.1,
167 "stop": ["Question:", "\n\n\n"]
168 }
169 }
170 ]
171 }
172 ```
173 </Tab>
174</Tabs>
175
176## Tab Auto Complete Model
177
178Granite models are recommended for tab auto complete. The configuration is similar to that of the chat models:
179
180<Tabs>
181 <Tab title="YAML">
182 ```yaml title="config.yaml"
183 models:
184 - name: Granite Code 8b
185 provider: watsonx
186 model: ibm/granite-8b-code-instruct
187 apiBase: watsonx endpoint e.g. https://us-south.ml.cloud.ibm.com
188 projectId: PROJECT_ID
189 apiKey: API_KEY/ZENAPI_KEY/USERNAME:PASSWORD
190 apiVersion: 2024-03-14
191 roles:
192 - autocomplete
193 ```
194 </Tab>
195 <Tab title="JSON">
196 ```json title="config.json"
197 {
198 "tabAutocompleteModel": {
199 "model": "ibm/granite-8b-code-instruct",
200 "title": "Granite Code 8b",
201 "provider": "watsonx",
202 "apiBase": "watsonx endpoint e.g. https://us-south.ml.cloud.ibm.com",
203 "projectId": "PROJECT_ID",
204 "apiKey": "API_KEY/ZENAPI_KEY/USERNAME:PASSWORD",
205 "apiVersion": "2024-03-14",
206 "contextLength": 4000
207 }
208 }
209 ```
210 </Tab>
211</Tabs>
212
213## Embeddings Model
214
215To view the list of available embeddings models, visit [this page](https://dataplatform.cloud.ibm.com/docs/content/wsj/analyze-data/fm-models-embed.html?context=wx&pos=2#ibm-provided).
216
217<Tabs>
218 <Tab title="YAML">
219 ```yaml title="config.yaml"
220 models:
221 - name: Watsonx Embedder
222 provider: watsonx
223 model: ibm/slate-30m-english-rtrvr-v2
224 apiBase: https://us-south.ml.cloud.ibm.com
225 projectId: PROJECT_ID
226 apiKey: API_KEY/ZENAPI_KEY/USERNAME:PASSWORD
227 apiVersion: 2024-03-14
228 roles:
229 - embed
230 ```
231 </Tab>
232 <Tab title="JSON">
233 ```json title="config.json"
234 {
235 "embeddingsProvider": {
236 "provider": "watsonx",
237 "model": "ibm/slate-30m-english-rtrvr-v2",
238 "apiBase": "watsonx endpoint e.g. https://us-south.ml.cloud.ibm.com",
239 "projectId": "PROJECT_ID",
240 "apiKey": "API_KEY/ZENAPI_KEY/USERNAME:PASSWORD",
241 "apiVersion": "2024-03-14"
242 }
243 }
244 ```
245 </Tab>
246</Tabs>
247
248## Reranker
249
250<Tabs>
251 <Tab title="YAML">
252 ```yaml title="config.yaml"
253 models:
254 - name: Watsonx Reranker
255 provider: watsonx
256 model: cross-encoder/ms-marco-minilm-l-12-v2
257 apiBase: https://us-south.ml.cloud.ibm.com
258 projectId: PROJECT_ID
259 apiKey: API_KEY/ZENAPI_KEY/USERNAME:PASSWORD
260 apiVersion: 2024-03-14
261 ```
262 </Tab>
263 <Tab title="JSON">
264 ```json title="config.json"
265 {
266 "reranker": {
267 "name": "watsonx",
268 "params": {
269 "model": "cross-encoder/ms-marco-minilm-l-12-v2",
270 "apiBase": "watsonx endpoint e.g. https://us-south.ml.cloud.ibm.com",
271 "projectId": "PROJECT_ID",
272 "apiKey": "API_KEY/ZENAPI_KEY/USERNAME:PASSWORD",
273 "apiVersion": "2024-03-14"
274 }
275 }
276 }
277 ```
278 </Tab>
279</Tabs>