How to run on colab ?

#11
by deepakkaura26 - opened

import torch
from transformers import LlamaTokenizer, LlamaForCausalLM

model_path = 'openlm-research/open_llama_3b'

model_path = 'openlm-research/open_llama_7b'

tokenizer = LlamaTokenizer.from_pretrained(model_path)
model = LlamaForCausalLM.from_pretrained(
model_path, torch_dtype=torch.float16, device_map='auto',
)

prompt = 'Q: What is the largest animal?\nA:'
input_ids = tokenizer(prompt, return_tensors="pt").input_ids

generation_output = model.generate(
input_ids=input_ids, max_new_tokens=32
)
print(tokenizer.decode(generation_output[0]))

Can someone help me with this

"How to run above codes on colab, means... CPU or GPU and what libraries needs to install?"

Hi,

Please check this : Google colab notebook to run Openllama model

Enjoy.

Sign up or log in to comment