File size: 7,722 Bytes
f0f769f 5ad0b7d b8c3a6e 5b57197 0ae2e56 c668e4c 36051b1 c668e4c 0ae2e56 71534a8 7e6e14c c668e4c f8c84a4 2778c70 b1d4d73 890d3f0 b1d4d73 f76c18e c6a0b9f b1d4d73 b7aa116 c6a0b9f c668e4c 79aee36 c668e4c 56992ea c668e4c 56992ea c668e4c 56992ea c668e4c 56992ea c668e4c 56992ea c668e4c 56992ea c668e4c 56992ea c668e4c 56992ea c668e4c 56992ea c668e4c 56992ea c668e4c 56992ea 68d93a7 c668e4c eac8908 c668e4c 36051b1 c668e4c 36051b1 4be6ba8 36051b1 c668e4c 2778c70 c668e4c 2778c70 b00ab69 71c410d b00ab69 71c410d b00ab69 c668e4c 0c18c79 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
---
language:
- en
pipeline_tag: text2text-generation
inference: false
license: mit
---
# ViPE-M-CTX7
<!-- Provide a quick summary of what the model is/does. -->
ViPE: Visualize Pretty-much Everything, is the first automated model for translating any arbitrary piece of text into a visualizable prompt.
It helps any text-to-image model in figurative or non-lexical language visualizations. It has been shown to be more robust than GPT3.5 Turbo (ChatGPT)
in generating depictable and semantically meaningful prompts.
### Model Description
<!-- Provide a longer summary of what this model is. -->
- **Developed by:** [Computer Graphics Group, University of Tuebingen](https://uni-tuebingen.de/fakultaeten/mathematisch-naturwissenschaftliche-fakultaet/fachbereiche/informatik/lehrstuehle/computergrafik/lehrstuhl/)
- **Model type:** Auto-Regressive
- **Language:** English
- **License:** MIT
- **Based on:** [GPT2-Medium](https://huggingface.co/gpt2-medium)
- **Versions:** [ViPE-M-CTX7](https://huggingface.co/fittar/ViPE-M-CTX7) (355M parameters) and [ViPE-S-CTX7](https://huggingface.co/fittar/ViPE-S-CTX7) (117M parameters)
### Model Sources
<!-- Provide the basic links for the model. -->
- **Repository:** [Github](https://github.com/Hazel1994/ViPE)
- **Paper:** [ViPE: Visualise Pretty-much Everything](https://aclanthology.org/2023.emnlp-main.333/) (**Outstanding Paper Award at EMNLP 2023**)
### Down Stream Applications
ViPE provides a robust backbone for many practical applications such as music video generation and creative writing.
- #### Music Video Genrations
- **Repository:** [Github](https://github.com/Hazel1994/ViPE-Videos)
- **Example Videos:** [ViPE Videos](https://www.youtube.com/playlist?list=PLvLHdI48ZdfaDMxPZIGHXrvsRkdADcMUh)
- #### Creative Writing
- **Demo:** [Hugging Face Playground](https://huggingface.co/spaces/fittar/ViPE)
- #### Summagery: Document Summarization through Images
- **Demo:** [Hugging Face Playground](https://huggingface.co/spaces/fittar/summagary)
- **Repository:** [Github](https://github.com/Hazel1994/summagary)
- **Examples:** [Summagery Videos](https://www.youtube.com/watch?v=mFMkE2waYGQ)
### Direct Use
<!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
You can directly use the model to generate detailed prompts for any arbitrary text.
```python
from transformers import GPT2LMHeadModel, GPT2Tokenizer
def generate(text, model, tokenizer,device,do_sample,top_k=100, epsilon_cutoff=.00005, temperature=1):
#mark the text with special tokens
text=[tokenizer.eos_token + i + tokenizer.eos_token for i in text]
batch=tokenizer(text, padding=True, return_tensors="pt")
input_ids = batch["input_ids"].to(device)
attention_mask = batch["attention_mask"].to(device)
#how many new tokens to generate at max
max_prompt_length=50
generated_ids = model.generate(input_ids=input_ids,attention_mask=attention_mask, max_new_tokens=max_prompt_length, do_sample=do_sample,top_k=top_k, epsilon_cutoff=epsilon_cutoff, temperature=temperature)
#return only the generated prompts
pred_caps = tokenizer.batch_decode(generated_ids[:, -(generated_ids.shape[1] - input_ids.shape[1]):], skip_special_tokens=True)
return pred_caps
device='cpu'
model = GPT2LMHeadModel.from_pretrained('fittar/ViPE-M-CTX7')
model.to(device)
#ViPE-M's tokenizer is identical to that of GPT2-Medium
tokenizer = GPT2Tokenizer.from_pretrained('gpt2-medium')
tokenizer.pad_token = tokenizer.eos_token
# A list of abstract/figurative or any arbitrary combinations of keywords
texts=['lalala', 'I wanna start learning', 'free your mind; you will see the other side of life', 'brave; fantasy']
prompts=generate(texts,model,tokenizer,do_sample=True,device=device)
for t,p in zip(texts,prompts):
print('{} --> {}'.format(t,p))
lalala --> A group of people chanting "la la la" around a bonfire on a beach at night
I wanna start learning --> A child sitting in a library surrounded by books, excitedly flipping through pages of a book
free your mind; you will see the other side of life --> An astronaut floating in space with a sense of floating weightlessness, looking down towards the earth
brave; fantasy --> A brave knight with shining armor fighting a fierce dragon in a misty forest
```
### Recommendations
You can use either a comma or a semicolon to combine multiple keywords. for example ['dark, fantasy, brave'] or ['This is gonna be the best day of my life; do you agree?'].
However, a semicolon draws a stronger boundary between the keywords and encourages the model to transfer the last keyword in a given context (previous keywords).
### Training Data
<!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
- [LyricCanvas dataset](https://huggingface.co/datasets/fittar/lyric_canvas): a synthetically generated dataset based on lyrics and synthetically generated prompts
### Training Procedure
ViPE has been trained in the standard auto-regressive procedure: given a line (or lines) of lyrics as a prefix, the objective is to generate a plausible
prompt that is both despicable and semantically related to the given lyric(c). The loss function does not include the tokens corresponding to the lyrics. So ViPE
never generates any original lyrics and only learns to generate visually related prompts.
<!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
## Evaluation
In all of the following evaluations, ViPE consistently demonstrates its robustness compared to ChatGPT and achieves performance that is competitive with that of human experts.
- ***Intrinsic evaluations***
- General understanding of figurative language using [Fig-QA dataset](https://huggingface.co/datasets/nightingal3/fig-qa)
- ***Extrinsic evaluations***
- Image-text Retrieval on the [HAIVMet dataset](https://aclanthology.org/2023.findings-acl.465.pdf)
- Emotion visualizations: How well does ViPE transfer emotionally charged tweets into a depictable description of a scene in comparison with
ChatGPT. The [Emotion dataset](https://huggingface.co/datasets/dair-ai/emotion) is utilized.
- ***Human evaluations***
- We conducted a user study involving 30 native English-speaking participants aged between 20 and 40. Participants were
presented with 3 images and a metaphor from the HAIVMet dataset. They were asked to select the images that matches the metaphor the best.
The images were generated using prompts from ViPE, ChatGPT, and human experts (HAIVMet).
<!-- This section describes the evaluation protocols and provides the results. -->
## Citation
If you find ViPE useful, please cite our paper.
```
@inproceedings{shahmohammadi-etal-2023-vipe,
title = "{V}i{PE}: Visualise Pretty-much Everything",
author = "Shahmohammadi, Hassan and
Ghosh, Adhiraj and
Lensch, Hendrik",
editor = "Bouamor, Houda and
Pino, Juan and
Bali, Kalika",
booktitle = "Proceedings of the 2023 Conference on Empirical Methods in Natural Language Processing",
month = dec,
year = "2023",
address = "Singapore",
publisher = "Association for Computational Linguistics",
url = "https://aclanthology.org/2023.emnlp-main.333",
pages = "5477--5494"
}
```
<!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
## Model Card Contact
[Hassan Shahmohammadi](https://fittar.me/) |