RichardErkhov commited on
Commit
aeb15df
·
verified ·
1 Parent(s): e35d850

uploaded readme

Browse files
Files changed (1) hide show
  1. README.md +106 -0
README.md ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Quantization made by Richard Erkhov.
2
+
3
+ [Github](https://github.com/RichardErkhov)
4
+
5
+ [Discord](https://discord.gg/pvy7H8DZMG)
6
+
7
+ [Request more models](https://github.com/RichardErkhov/quant_request)
8
+
9
+
10
+ Bunny-v1_0-3B - bnb 4bits
11
+ - Model creator: https://huggingface.co/BAAI/
12
+ - Original model: https://huggingface.co/BAAI/Bunny-v1_0-3B/
13
+
14
+
15
+
16
+
17
+ Original model description:
18
+ ---
19
+ inference: false
20
+ license: apache-2.0
21
+ ---
22
+
23
+ # Model Card
24
+
25
+ <p align="center">
26
+ <img src="./icon.png" alt="Logo" width="350">
27
+ </p>
28
+
29
+ 📖 [Technical report](https://arxiv.org/abs/2402.11530) | 🏠 [Code](https://github.com/BAAI-DCAI/Bunny) | 🐰 [Demo](https://wisemodel.cn/spaces/baai/Bunny)
30
+
31
+ This is the merged weights of [bunny-phi-2-siglip-lora](https://huggingface.co/BAAI/bunny-phi-2-siglip-lora).
32
+
33
+ Bunny is a family of lightweight but powerful multimodal models. It offers multiple plug-and-play vision encoders, like EVA-CLIP, SigLIP and language backbones, including Llama-3-8B, Phi-1.5, StableLM-2, Qwen1.5, MiniCPM and Phi-2. To compensate for the decrease in model size, we construct more informative training data by curated selection from a broader data source. Remarkably, our Bunny-v1.0-3B model built upon SigLIP and Phi-2 outperforms the state-of-the-art MLLMs, not only in comparison with models of similar size but also against larger MLLM frameworks (7B), and even achieves performance on par with 13B models.
34
+
35
+ The model is pretrained on LAION-2M and finetuned on Bunny-695K.
36
+ More details about this model can be found in [GitHub](https://github.com/BAAI-DCAI/Bunny).
37
+
38
+ ![comparison](comparison.png)
39
+
40
+ # Quickstart
41
+
42
+ Here we show a code snippet to show you how to use the model with transformers.
43
+
44
+ Before running the snippet, you need to install the following dependencies:
45
+
46
+ ```shell
47
+ pip install torch transformers accelerate pillow
48
+ ```
49
+
50
+ If the CUDA memory is enough, it would be faster to execute this snippet by setting `CUDA_VISIBLE_DEVICES=0`.
51
+
52
+ Users especially those in Chinese mainland may want to refer to a HuggingFace [mirror site](https://hf-mirror.com).
53
+
54
+
55
+ ```python
56
+ import torch
57
+ import transformers
58
+ from transformers import AutoModelForCausalLM, AutoTokenizer
59
+ from PIL import Image
60
+ import warnings
61
+
62
+ # disable some warnings
63
+ transformers.logging.set_verbosity_error()
64
+ transformers.logging.disable_progress_bar()
65
+ warnings.filterwarnings('ignore')
66
+
67
+ # set device
68
+ device = 'cuda' # or cpu
69
+ torch.set_default_device(device)
70
+
71
+ # create model
72
+ model = AutoModelForCausalLM.from_pretrained(
73
+ 'BAAI/Bunny-v1_0-3B',
74
+ torch_dtype=torch.float16, # float32 for cpu
75
+ device_map='auto',
76
+ trust_remote_code=True)
77
+ tokenizer = AutoTokenizer.from_pretrained(
78
+ 'BAAI/Bunny-v1_0-3B',
79
+ trust_remote_code=True)
80
+
81
+ # text prompt
82
+ prompt = 'Why is the image funny?'
83
+ text = f"A chat between a curious user and an artificial intelligence assistant. The assistant gives helpful, detailed, and polite answers to the user's questions. USER: <image>\n{prompt} ASSISTANT:"
84
+ text_chunks = [tokenizer(chunk).input_ids for chunk in text.split('<image>')]
85
+ input_ids = torch.tensor(text_chunks[0] + [-200] + text_chunks[1], dtype=torch.long).unsqueeze(0).to(device)
86
+
87
+ # image, sample images can be found in images folder
88
+ image = Image.open('example_2.png')
89
+ image_tensor = model.process_images([image], model.config).to(dtype=model.dtype, device=device)
90
+
91
+ # generate
92
+ output_ids = model.generate(
93
+ input_ids,
94
+ images=image_tensor,
95
+ max_new_tokens=100,
96
+ use_cache=True)[0]
97
+
98
+ print(tokenizer.decode(output_ids[input_ids.shape[1]:], skip_special_tokens=True).strip())
99
+ ```
100
+
101
+ # License
102
+ This project utilizes certain datasets and checkpoints that are subject to their respective original licenses. Users must comply with all terms and conditions of these original licenses.
103
+ The content of this project itself is licensed under the Apache license 2.0.
104
+
105
+
106
+