Skip to content

Commit

Permalink
πŸ“ Update Jinja README.md (#424)
Browse files Browse the repository at this point in the history
`apply_chat_template` is no longer async.
  • Loading branch information
xenova authored Dec 18, 2023
1 parent 0affec2 commit 67a605b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/jinja/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,14 @@ const chat = [
{ role: "user", content: "I'd like to show off how chat templating works!" },
];

const text = await tokenizer.apply_chat_template(chat, { tokenize: false });
const text = tokenizer.apply_chat_template(chat, { tokenize: false });
// "<s>[INST] Hello, how are you? [/INST]I'm doing great. How can I help you today?</s> [INST] I'd like to show off how chat templating works! [/INST]"
```

Notice how the entire chat is condensed into a single string. If you would instead like to return the tokenized version (i.e., a list of token IDs), you can use the following:

```js
const input_ids = await tokenizer.apply_chat_template(chat, { tokenize: true, return_tensor: false });
const input_ids = tokenizer.apply_chat_template(chat, { tokenize: true, return_tensor: false });
// [1, 733, 16289, 28793, 22557, 28725, 910, 460, 368, 28804, 733, 28748, 16289, 28793, 28737, 28742, 28719, 2548, 1598, 28723, 1602, 541, 315, 1316, 368, 3154, 28804, 2, 28705, 733, 16289, 28793, 315, 28742, 28715, 737, 298, 1347, 805, 910, 10706, 5752, 1077, 3791, 28808, 733, 28748, 16289, 28793]
```

Expand Down

0 comments on commit 67a605b

Please sign in to comment.