Views
No views yet

rinna/bilingual-gpt-neox-4b and BLIP-2.rinna/bilingual-gpt-neox-4b (A 36-layer, 2816-hidden-size transformer-based language model) is used as the LLM instead of Vicuna, which is used in the original Vision-CAIR/MiniGPT-4.| Variant | Link |
|---|---|
| Bilingual 4B MiniGPT4 | https://huggingface.co/rinna/bilingual-gpt-neox-4b-minigpt4 |
| Bilingual 4B PPO | https://huggingface.co/rinna/bilingual-gpt-neox-4b-instruction-ppo |
| Bilingual 4B SFT | https://huggingface.co/rinna/bilingual-gpt-neox-4b-instruction-sft |
| Bilingual 4B 8K | https://huggingface.co/rinna/bilingual-gpt-neox-4b-8k |
| Bilingual 4B | https://huggingface.co/rinna/bilingual-gpt-neox-4b |
| Japanese 3.6B PPO | https://huggingface.co/rinna/japanese-gpt-neox-3.6b-instruction-ppo |
| Japanese 3.6B SFT-v2 | https://huggingface.co/rinna/japanese-gpt-neox-3.6b-instruction-sft-v2 |
| Japanese 3.6B SFT | https://huggingface.co/rinna/japanese-gpt-neox-3.6b-instruction-sft |
| Japanese 3.6B | https://huggingface.co/rinna/japanese-gpt-neox-3.6b |
ユーザー and システム."ユーザー" or "システム"), (2) a colon (":"), (3) a whitespace (" "), and (4) utterance text (e.g. "猫はどんな体勢をしていますか?")."ユーザー"), (2) a colon (":"), (3) a whitespace (" "), (4) a placeholder of the image ("<Img><ImageHere></Img>"), (5) another whitespace (" "), (6) utterance text (e.g. "What can you see?").
<ImageHere>) is automatically replaced with the embedding of an input image in the function get_context_emb."システム: " to acknowledge the model to generate a response.\n.1prompt = [
2 {
3 "speaker": "ユーザー",
4 "text": "<Img><ImageHere></Img> What can you see?"
5 },
6 {
7 "speaker": "システム",
8 "text": "a cat on a table with a laptop"
9 },
10 {
11 "speaker": "ユーザー",
12 "text": "猫はどんな体勢をしていますか?"
13 },
14]
15prompt = [
16 f"{uttr['speaker']}: {uttr['text']}"
17 for uttr in prompt
18]
19prompt = "\n".join(prompt)
20prompt = (
21 prompt
22 + "\n"
23 + "システム: "
24)
25print(prompt)
26"""
27ユーザー: <Img><ImageHere></Img> What can you see?
28システム: a cat on a table with a laptop
29ユーザー: 猫はどんな体勢をしていますか?
30システム:
31"""customized_mini_gpt4.py is a script to replace LLM from LLaMA architecture to GPT-NeoX one.checkpoint.pth is a finetuned weight of the linear layer (file size: 177 MB).1git clone https://github.com/Vision-CAIR/MiniGPT-4.git
2cd ./MiniGPT-4
3git checkout 22d8888 # latest version as of July 31, 2023.
4wget https://huggingface.co/rinna/bilingual-gpt-neox-4b-minigpt4/resolve/main/customized_mini_gpt4.py
5wget https://huggingface.co/rinna/bilingual-gpt-neox-4b-minigpt4/resolve/main/checkpoint.pthMiniGPT-4 directory.1import torch
2import requests
3from PIL import Image
4from minigpt4.processors.blip_processors import Blip2ImageEvalProcessor
5from customized_mini_gpt4 import CustomizedMiniGPT4
6
7ckpt_path = "./checkpoint.pth"
8
9model = CustomizedMiniGPT4(gpt_neox_model="rinna/bilingual-gpt-neox-4b")
10tokenizer = model.gpt_neox_tokenizer
11
12if torch.cuda.is_available():
13 model = model.to("cuda")
14
15if ckpt_path is not None:
16 print("Load BLIP2-LLM Checkpoint: {}".format(ckpt_path))
17 ckpt = torch.load(ckpt_path, map_location="cpu")
18 model.load_state_dict(ckpt['model'], strict=False)
19
20vis_processor = Blip2ImageEvalProcessor()
21
22image_url = "https://huggingface.co/rinna/bilingual-gpt-neox-4b-minigpt4/resolve/main/sample.jpg"
23raw_image = Image.open(requests.get(image_url, stream=True).raw).convert('RGB')
24image = vis_processor(raw_image).unsqueeze(0).to(model.device)
25image_emb = model.encode_img(image)
26
27embs = model.get_context_emb(prompt, [image_emb])
28
29output_ids = model.gpt_neox_model.generate(
30 inputs_embeds=embs,
31 max_new_tokens=512,
32 do_sample=True,
33 temperature=1.0,
34 top_p=0.85,
35 pad_token_id=tokenizer.pad_token_id,
36 bos_token_id=tokenizer.bos_token_id,
37 eos_token_id=tokenizer.eos_token_id
38)
39
40output = tokenizer.decode(output_ids.tolist()[0], skip_special_tokens=True)
41print(output)
42"""横になっています。"""1@misc{rinna-bilingual-gpt-neox-4b-minigpt4,
2 title = {rinna/bilingual-gpt-neox-4b-minigpt4},
3 author = {Mitsuda, Koh and Zhao, Tianyu and Sawada, Kei},
4 url = {https://huggingface.co/rinna/bilingual-gpt-neox-4b-minigpt4}
5}
6
7@inproceedings{sawada2024release,
8 title = {Release of Pre-Trained Models for the {J}apanese Language},
9 author = {Sawada, Kei and Zhao, Tianyu and Shing, Makoto and Mitsui, Kentaro and Kaga, Akio and Hono, Yukiya and Wakatsuki, Toshiaki and Mitsuda, Koh},
10 booktitle = {Proceedings of the 2024 Joint International Conference on Computational Linguistics, Language Resources and Evaluation (LREC-COLING 2024)},
11 month = {5},
12 year = {2024},
13 pages = {13898--13905},
14 url = {https://aclanthology.org/2024.lrec-main.1213},
15 note = {\url{https://arxiv.org/abs/2404.01657}}
16}