Views
No views yet
1from transformers import AutoTokenizer
2tokenizer = AutoTokenizer.from_pretrained("ai21labs/AI21-Jamba-1.5-Large")
3messages = [
4 {
5 "role": "user",
6 "content": "Who wrote Harry Potter?"
7 }
8]
9documents = [
10 {
11 "text": "Harry Potter is a series of seven fantasy novels written by British author J. K. Rowling.",
12 "title": "Harry Potter"
13 },
14 {
15 "text": "The Great Gatsby is a novel by American writer F. Scott Fitzgerald.",
16 "title": "The Great Gatsby",
17 "country": "United States",
18 "genre": "Novel"
19 }
20]
21prompt = tokenizer.apply_chat_template(
22 messages,
23 documents=documents,
24 tokenize=False,
25)
26# Output: J. K. Rowling