qtnx commited on
Commit
0cb51e1
1 Parent(s): 57dc89c

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +42 -2
README.md CHANGED
@@ -7,9 +7,9 @@ pipeline_tag: image-text-to-text
7
 
8
  # llama-3.1-8B-vision-378
9
 
10
- THIS IS A SLAPPED-TOGETHER RELEASE; IF IT WORKS, IT IS A MIRACLE OF LATENT SPACE
11
 
12
- ## usage
13
 
14
  ```python
15
  import torch
@@ -38,6 +38,46 @@ print(
38
  )
39
  ```
40
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
  ```
42
  .x+=:.
43
  z` ^% .uef^"
 
7
 
8
  # llama-3.1-8B-vision-378
9
 
10
+ Projection module trained to add vision capabilties to Llama 3 using SigLIP, then applied to LLama-3.1-8B-Instruct. Built by [@yeswondwerr](https://x.com/yeswondwerr) and [@qtnx_](https://x.com/qtnx_).
11
 
12
+ ## Usage
13
 
14
  ```python
15
  import torch
 
38
  )
39
  ```
40
 
41
+ ## 4-bit quantization
42
+
43
+ ```python
44
+ import torch
45
+ from PIL import Image
46
+ from transformers import AutoModelForCausalLM, AutoTokenizer
47
+ from transformers import BitsAndBytesConfig
48
+ import requests
49
+ from io import BytesIO
50
+
51
+
52
+ url = "https://huggingface.co/qresearch/llama-3-vision-alpha-hf/resolve/main/assets/demo-2.jpg"
53
+ response = requests.get(url)
54
+ image = Image.open(BytesIO(response.content))
55
+
56
+ bnb_cfg = BitsAndBytesConfig(
57
+ load_in_4bit=True,
58
+ bnb_4bit_compute_dtype=torch.float16,
59
+ llm_int8_skip_modules=["mm_projector", "vision_model"],
60
+ )
61
+
62
+ model = AutoModelForCausalLM.from_pretrained(
63
+ "qresearch/llama-3.1-8B-vision-378",
64
+ trust_remote_code=True,
65
+ torch_dtype=torch.float16,
66
+ quantization_config=bnb_cfg,
67
+ )
68
+
69
+ tokenizer = AutoTokenizer.from_pretrained(
70
+ "qresearch/llama-3.1-8B-vision-378",
71
+ use_fast=True,
72
+ )
73
+
74
+ print(
75
+ model.answer_question(
76
+ image, "Briefly describe the image", tokenizer, max_new_tokens=128, do_sample=True, temperature=0.3
77
+ ),
78
+ )
79
+ ```
80
+
81
  ```
82
  .x+=:.
83
  z` ^% .uef^"