Skip to content

Commit

Permalink
updated description of input features (#356)
Browse files Browse the repository at this point in the history
* updated description of input features

* updates based on comments from Alex

* A few more updates based on comments from Alex

* Another check for more suggested changes

* Changes after Arnav's comments

* More changes after Arnav's comments

* Minor change suggested by Alex
  • Loading branch information
sanjaydasgupta authored Apr 2, 2024
1 parent eab5955 commit fd21ef6
Showing 1 changed file with 70 additions and 6 deletions.
76 changes: 70 additions & 6 deletions docs/configuration/large_language_model.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,20 +88,84 @@ ludwig train ...

## Input Features

Currently, the LLM model type only supports a single input feature of type `text`.
Because of the way LLMs work, they accept exactly one input, which is of type `text`.
This input can be built up from one or more columns of the input dataset and optional
interspersed static text. The following three examples illustrate the range of possibilities.

If no `prompt` template is provided, this feature must correspond to a column
in the input dataset. If a prompt template is provided, the rendered prompt
will be used as the input feature value during training and inference.
### Single Dataset Column Only

If it is intended for the input to the LLM to be just the content of a single dataset column (without
any other prefixed or suffixed text), no `prompt` template should be provided and the `name` of the
feature must correspond to that specific dataset column. See the following example.

```yaml
input_features:
- name: input
type: text
```

See [Text Features](./features/text_features.md) for
configuration options.
The value of the `name` attribute (`input` in the example) is the name of a
dataset column.

See [Text Features](./features/text_features.md) for configuration options.

### Single Dataset Column with Additional Text

If the input to the LLM must be created by prefixing and/or suffixing some static text
to the content of one dataset column, then a `prompt` `template` must be provided to specify how
the content of the chosen column should be formatted for the LLM. See the following example.

```yaml
prompt:
template: |
Translate into French
Input: {english_input}
Translation:
input_features:
- name: prompt
type: text
```

In the example above `english_input` is the name of a column in the input dataset.
In this case the `name` of the `input_feature` (`prompt`) is not the name of a
dataset column (as in the previous example). It is just a placeholder that is replaced
by the formatted text obtained by applying the template to the selected dataset column.
The actual name used has no significance, so you can choose any name that is intuitive
in the context of your application.

### Multiple Dataset Columns with Interspersed Static Text

This case is a generalization of the last example to situations that have to process
two or more dataset columns. See the example below.

```yaml
prompt:
template: |
[INST] <<SYS>>
You are a helpful, detailed, and polite AI assistant.
Answer the question using only the provided context.
<</SYS>>
### Context:
{context}
### Question:
{question}
### Response:
[/INST]
input_features:
- name: prompt
type: text
```

As in the previous example `context` and `question` are names of columns in the input dataset.
The `name` of the `input_feature` (`prompt` here) is again just a placeholder that will be
replaced by formatted text obtained by applying the template to the selected dataset columns.
The name used (`prompt`) is not significant, so any intuitive name could have been used without
changing the results obtained.

## Output Features

Expand Down

0 comments on commit fd21ef6

Please sign in to comment.