ravithejads commited on
Commit
1c1a1e6
·
verified ·
1 Parent(s): 2e8c897

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +18 -3
README.md CHANGED
@@ -105,10 +105,25 @@ messages = [
105
  {"role": "user", "content": """Context:\nArchitecturally, the school has a Catholic character. Atop the Main Building\'s gold dome is a golden statue of the Virgin Mary. Immediately in front of the Main Building and facing it, is a copper statue of Christ with arms upraised with the legend "Venite Ad Me Omnes". Next to the Main Building is the Basilica of the Sacred Heart. Immediately behind the basilica is the Grotto, a Marian place of prayer and reflection. It is a replica of the grotto at Lourdes, France where the Virgin Mary reputedly appeared to Saint Bernadette Soubirous in 1858. At the end of the main drive (and in a direct line that connects through 3 statues and the Gold Dome), is a simple, modern stone statue of Mary.\n\nTo whom did the Virgin Mary allegedly appear in 1858 in Lourdes France?"""},
106
  ]
107
 
108
- input_ids = tokenizer.apply_chat_template(messages, return_tensors="pt", return_dict=True).to("cuda")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
109
 
110
- outputs = model.generate(**input_ids, max_new_tokens=256)
111
- print(tokenizer.decode(outputs[0]))
112
  ```
113
 
114
 
 
105
  {"role": "user", "content": """Context:\nArchitecturally, the school has a Catholic character. Atop the Main Building\'s gold dome is a golden statue of the Virgin Mary. Immediately in front of the Main Building and facing it, is a copper statue of Christ with arms upraised with the legend "Venite Ad Me Omnes". Next to the Main Building is the Basilica of the Sacred Heart. Immediately behind the basilica is the Grotto, a Marian place of prayer and reflection. It is a replica of the grotto at Lourdes, France where the Virgin Mary reputedly appeared to Saint Bernadette Soubirous in 1858. At the end of the main drive (and in a direct line that connects through 3 statues and the Gold Dome), is a simple, modern stone statue of Mary.\n\nTo whom did the Virgin Mary allegedly appear in 1858 in Lourdes France?"""},
106
  ]
107
 
108
+ text = tokenizer.apply_chat_template(
109
+ messages,
110
+ tokenize=False,
111
+ add_generation_prompt=True
112
+ )
113
+
114
+ model_inputs = tokenizer([text], return_tensors="pt").to("cuda")
115
+
116
+ generated_ids = model.generate(
117
+ model_inputs.input_ids,
118
+ max_new_tokens=256
119
+ )
120
+ generated_ids = [
121
+ output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
122
+ ]
123
+
124
+ response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
125
 
126
+ print(response)
 
127
  ```
128
 
129