Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
test model
|
| 2 |
+
|
| 3 |
+
```python
|
| 4 |
+
!pip install -q bitsandbytes datasets accelerate loralib
|
| 5 |
+
!pip install -q git+https://github.com/huggingface/transformers.git@main git+https://github.com/huggingface/peft.git
|
| 6 |
+
!pip install -q geov
|
| 7 |
+
|
| 8 |
+
import torch
|
| 9 |
+
from peft import PeftModel, PeftConfig
|
| 10 |
+
from geov import GeoVForCausalLM, GeoVTokenizer
|
| 11 |
+
|
| 12 |
+
model = GeoVForCausalLM.from_pretrained(
|
| 13 |
+
"GeoV/GeoV-9b",
|
| 14 |
+
load_in_8bit=True,
|
| 15 |
+
low_cpu_mem_usage=True,
|
| 16 |
+
device_map='auto',
|
| 17 |
+
)
|
| 18 |
+
tokenizer = GeoVTokenizer.from_pretrained("GeoV/GeoV-9b")
|
| 19 |
+
peft_model_id = "crumb/GeoV-Instruct-LoRA"
|
| 20 |
+
model = PeftModel.from_pretrained(model, peft_model_id)
|
| 21 |
+
|
| 22 |
+
# Inference
|
| 23 |
+
|
| 24 |
+
batch = tokenizer("Your prompt here", return_tensors='pt')
|
| 25 |
+
with torch.cuda.amp.autocast():
|
| 26 |
+
output_tokens = model.generate(**batch, max_new_tokens=50)
|
| 27 |
+
print(tokenizer.decode(output_tokens[0], skip_special_tokens=True))
|
| 28 |
+
```
|