Views
No views yet
BLACKSHEEP ~ With Vision:

1<|`BlackSheep`|>
2My Opinion: Black Sheep must comment on the image (not describe the image) based on the context of the entire chat history.
3 <|`BlackSheep`|>
4
5<|user|>\n"<s>", "<|im_start|>", "<|im_end|>", "You:"You: is in reference to your characters you dont want the ai to talk for as it does tend to continue conversations if you dont got the stop tokens.
The dataset is all conversations and comments about images by human curators who have contributed.<|user|>\n<|image_1|>\n{prompt}<|end|>\n<|assistant|>\n <|assistant|> . In case of multi-turn conversation, the prompt can be formatted as follows:<|user|>\n<|image_1|>\n{prompt_1}<|end|>\n<|assistant|>\n{response_1}<|end|>\n<|user|>\n{prompt_2}<|end|>\n<|assistant|>\n 1from PIL import Image
2import requests
3from transformers import AutoModelForCausalLM
4from transformers import AutoProcessor
5
6model_id = "Disobedient/BlackSheep-Vision"
7
8model = AutoModelForCausalLM.from_pretrained(model_id, device_map="cuda", trust_remote_code=True, torch_dtype="auto", _attn_implementation='flash_attention_2') # use _attn_implementation='eager' to disable flash attention
9
10processor = AutoProcessor.from_pretrained(model_id, trust_remote_code=True)
11
12messages = [
13 {"role": "user", "content": "<|image_1|>\nWhat is shown in this image?"},
14 {"role": "assistant", "content": "The chart displays the percentage of respondents who agree with various statements about their preparedness for meetings. It shows five categories: 'Having clear and pre-defined goals for meetings', 'Knowing where to find the information I need for a meeting', 'Understanding my exact role and responsibilities when I'm invited', 'Having tools to manage admin tasks like note-taking or summarization', and 'Having more focus time to sufficiently prepare for meetings'. Each category has an associated bar indicating the level of agreement, measured on a scale from 0% to 100%."},
15 {"role": "user", "content": "Provide insightful questions to spark discussion."}
16]
17
18url = "https://assets-c4akfrf5b4d3f4b7.z01.azurefd.net/assets/2024/04/BMDataViz_661fb89f3845e.png"
19image = Image.open(requests.get(url, stream=True).raw)
20
21prompt = processor.tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
22
23inputs = processor(prompt, [image], return_tensors="pt").to("cuda:0")
24
25generation_args = {
26 "max_new_tokens": 500,
27 "temperature": 0.0,
28 "do_sample": False,
29}
30
31generate_ids = model.generate(**inputs, eos_token_id=processor.tokenizer.eos_token_id, **generation_args)
32
33# remove input tokens
34generate_ids = generate_ids[:, inputs['input_ids'].shape[1]:]
35response = processor.batch_decode(generate_ids, skip_special_tokens=True, clean_up_tokenization_spaces=False)[0]
36
37print(response)