Views
No views yet
transformers:1
2from transformers import T5Tokenizer, T5ForConditionalGeneration
3
4tokenizer = T5Tokenizer.from_pretrained("kaist-ai/CoT-T5-3B")
5model = T5ForConditionalGeneration.from_pretrained("kaist-ai/CoT-T5-3B")
6
7input_text = "Read the Directions and try to pick among A,B,C,D.\n\nDirecitons: A good way to figure out the relationship in a given question is to make up a sentence that describes the relationship between the first two words. Then, try to use the same sentence to find out which of the answer choices completes the same relationship with the third word.\nQuestion: Odometer is to mileage as compass is to?\nOptions: (A) speed, (B) hiking, (C) needle, (D) direction.\nLet's think step by step.\n"
8input_ids = tokenizer(input_text, return_tensors="pt").input_ids
9
10outputs = model.generate(input_ids)
11print(tokenizer.decode(outputs[0]))1# pip install accelerate
2from transformers import T5Tokenizer, T5ForConditionalGeneration
3
4tokenizer = T5Tokenizer.from_pretrained("kaist-ai/CoT-T5-3B")
5model = T5ForConditionalGeneration.from_pretrained("kaist-ai/CoT-T5-3B", device_map="auto")
6
7input_text = "Read the Directions and try to pick among A,B,C,D.\n\nDirecitons: A good way to figure out the relationship in a given question is to make up a sentence that describes the relationship between the first two words. Then, try to use the same sentence to find out which of the answer choices completes the same relationship with the third word.\nQuestion: Odometer is to mileage as compass is to?\nOptions: (A) speed, (B) hiking, (C) needle, (D) direction.\nLet's think step by step.\n"
8input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to("cuda")
9
10outputs = model.generate(input_ids)
11print(tokenizer.decode(outputs[0]))1# pip install accelerate
2import torch
3from transformers import T5Tokenizer, T5ForConditionalGeneration
4
5tokenizer = T5Tokenizer.from_pretrained("kaist-ai/CoT-T5-3B")
6model = T5ForConditionalGeneration.from_pretrained("kaist-ai/CoT-T5-3B", device_map="auto", torch_dtype=torch.float16)
7
8input_text = "Read the Directions and try to pick among A,B,C,D.\n\nDirecitons: A good way to figure out the relationship in a given question is to make up a sentence that describes the relationship between the first two words. Then, try to use the same sentence to find out which of the answer choices completes the same relationship with the third word.\nQuestion: Odometer is to mileage as compass is to?\nOptions: (A) speed, (B) hiking, (C) needle, (D) direction.\nLet's think step by step.\n"
9input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to("cuda")
10
11outputs = model.generate(input_ids)
12print(tokenizer.decode(outputs[0]))1# pip install bitsandbytes accelerate
2from transformers import T5Tokenizer, T5ForConditionalGeneration
3
4tokenizer = T5Tokenizer.from_pretrained("kaist-ai/CoT-T5-3B")
5model = T5ForConditionalGeneration.from_pretrained("kaist-ai/CoT-T5-3B", device_map="auto", load_in_8bit=True)
6
7input_text = "Read the Directions and try to pick among A,B,C,D.\n\nDirecitons: A good way to figure out the relationship in a given question is to make up a sentence that describes the relationship between the first two words. Then, try to use the same sentence to find out which of the answer choices completes the same relationship with the third word.\nQuestion: Odometer is to mileage as compass is to?\nOptions: (A) speed, (B) hiking, (C) needle, (D) direction.\nLet's think step by step.\n"
8input_ids = tokenizer(input_text, return_tensors="pt").input_ids.to("cuda")
9
10outputs = model.generate(input_ids)
11print(tokenizer.decode(outputs[0]))1@article{kim2023cot,
2 title={The CoT Collection: Improving Zero-shot and Few-shot Learning of Language Models via Chain-of-Thought Fine-Tuning},
3 author={Kim, Seungone and Joo, Se June and Kim, Doyoung and Jang, Joel and Ye, Seonghyeon and Shin, Jamin and Seo, Minjoon},
4 journal={arXiv preprint arXiv:2305.14045},
5 year={2023}
6}