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/user_guides/configuration-guide.md
+29-37Lines changed: 29 additions & 37 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -251,46 +251,51 @@ It is important to implement the following methods:
251
251
In other words, to create your custom LLM provider, you need to implement the following interface methods: `_call`, `_llm_type`, and optionally `_acall`, `_astream`, `_stream`, and `_identifying_params`. Here's how you can do it:
252
252
253
253
```python
254
-
from typing import Any, Dict, Iterator, List, Mapping, Optional
254
+
from typing import Any, Iterator, List, Optional
255
+
255
256
from langchain.base_language import BaseLanguageModel
256
-
from nemoguardrails.llm.providers import register_llm_provider
257
-
from langchain_core.callbacks.manager import CallbackManagerForLLMRun, AsyncCallbackManagerForLLMRun
257
+
from langchain_core.callbacks.manager import (
258
+
CallbackManagerForLLMRun,
259
+
AsyncCallbackManagerForLLMRun,
260
+
)
258
261
from langchain_core.outputs import GenerationChunk
259
262
263
+
from nemoguardrails.llm.providers import register_llm_provider
You can then use the custom LLM provider in your configuration:
@@ -301,31 +306,18 @@ models:
301
306
engine: custom_llm
302
307
```
303
308
304
-
```
305
-
306
309
### Configuring LLMs per Task
307
310
308
-
The interaction with the LLM is structured in a task-oriented manner. Each invocation of the LLM is associated with a specific task. These tasks are integral to the guardrails process and include:
311
+
The interaction with the LLM is structured in a task-oriented manner. Each invocation of the LLM is associated with a specific task. These tasks are integral to the guardrail process and include:
309
312
310
313
1. `generate_user_intent`: This task transforms the raw user utterance into a canonical form. For instance, "Hello there" might be converted to `express greeting`.
311
314
2. `generate_next_steps`: This task determines the bot's response or the action to be executed. Examples include `bot express greeting` or `bot respond to question`.
312
315
3. `generate_bot_message`: This task decides the exact bot message to be returned.
313
316
4. `general`: This task generates the next bot message based on the history of user and bot messages. It is used when there are no dialog rails defined (i.e., no user message canonical forms).
314
317
315
-
For a comprehensive list of tasks, refer to the [Task type](https://github.com/NVIDIA/NeMo-Guardrails/blob/develop/nemoguardrails/llm/types.py). Below we list some of the common tasks:
316
-
317
-
-`generate_intent_steps_message`
318
-
-`self_check_input`
319
-
-`self_check_output`
320
-
-`llama_guard_check_input`
321
-
-`llama_guard_check_output`
322
-
-`patronus_lynx_check_output_hallucination`
323
-
-`self_check_facts`
324
-
-`check_hallucination`
325
-
326
318
For a comprehensive list of tasks, refer to the [Task type](https://github.com/NVIDIA/NeMo-Guardrails/blob/develop/nemoguardrails/llm/types.py).
327
319
328
-
You have the flexibility of selecting models for specific tasks. For example, you can use a different model for the `self_check_input` and `self_check_output` tasks from various providers. Here's an example configuration:
320
+
You can use different LLM models for specific tasks. For example, you can use a different model for the `self_check_input` and `self_check_output` tasks from various providers. Here's an example configuration:
329
321
330
322
```yaml
331
323
@@ -337,11 +329,11 @@ models:
337
329
model: meta/llama3-8b-instruct
338
330
engine: nim
339
331
- type: self_check_output
340
-
model: meta/llama-3.1-405b-instruct
332
+
model: meta/llama-3.1-70b-instruct
341
333
engine: nim
342
334
```
343
335
344
-
as you can see for the `self_check_input` and `self_check_output` tasks, we are using different models. It is even possible to get more granular and use different models for a task like `generate_user_intent`.
336
+
In the previous example, the `self_check_input` and `self_check_output` tasks use different models. It is even possible to get more granular and use different models for a task like `generate_user_intent`:
0 commit comments