[instruction]
[optional input]
[response will start after two newlines]
1!pip install -q bitsandbytes datasets accelerate loralib
2!pip install -q git+https://github.com/huggingface/transformers.git@main git+https://github.com/huggingface/peft.git
3!pip install -q geov
4
5import torch
6from peft import PeftModel, PeftConfig
7from geov import GeoVForCausalLM, GeoVTokenizer
8
9model = GeoVForCausalLM.from_pretrained(
10 "GeoV/GeoV-9b",
11 load_in_8bit=True,
12 low_cpu_mem_usage=True,
13 device_map='auto',
14)
15tokenizer = GeoVTokenizer.from_pretrained("GeoV/GeoV-9b")
16peft_model_id = "crumb/GeoV-Instruct-LoRA"
17model = PeftModel.from_pretrained(model, peft_model_id)
18
19# Inference
20prompt = '''
21Describe the structure of an atom.
22
23'''
24batch = tokenizer(prompt, return_tensors='pt')
25with torch.cuda.amp.autocast():
26 output_tokens = model.generate(**batch, max_new_tokens=50)
27print(tokenizer.decode(output_tokens[0], skip_special_tokens=True))