Afrostnova commited on
Commit
3573523
·
verified ·
1 Parent(s): 7f9c0d7

Add model card

Browse files
Files changed (1) hide show
  1. README.md +58 -0
README.md ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: other
3
+ license_name: som-1.0
4
+ license_link: https://github.com/jxmorris12/vec2text/blob/master/LICENSE
5
+ library_name: vec2text
6
+ tags:
7
+ - vec2text
8
+ - embedding-inversion
9
+ - clip
10
+ - text-embedding-inversion
11
+ language:
12
+ - en
13
+ ---
14
+
15
+ # clip-text-msmarco-inversion
16
+
17
+ A **vec2text inversion (hypothesizer) model** that reconstructs text from the
18
+ embeddings produced by the **CLIP ViT-L/14 text encoder** (the text encoder used by
19
+ Stable Diffusion v1.5, identical to [`openai/clip-vit-large-patch14`](https://huggingface.co/openai/clip-vit-large-patch14)).
20
+
21
+ It is the first-stage model: given a CLIP text embedding, it produces an initial
22
+ text hypothesis. Pair it with the corrector model
23
+ [`Afrostnova/clip-text-msmarco-corrector`](https://huggingface.co/Afrostnova/clip-text-msmarco-corrector)
24
+ to iteratively refine that hypothesis.
25
+
26
+ - **Base architecture:** `vec2text` `InversionModel` (T5-based encoder–decoder)
27
+ - **Embedder:** `CLIPTextModel` — `openai/clip-vit-large-patch14`
28
+ - **Training data:** MS MARCO
29
+ - **Embedding transform:** `repeat` (`num_repeat_tokens=16`)
30
+
31
+ ## ⚠️ Requirements
32
+
33
+ This is **not** loadable with the upstream `pip install vec2text` package — upstream
34
+ does not support a `CLIPTextModel` embedder. You need the fork that adds CLIP support
35
+ (the one this model was trained with). With the wrong version, `from_pretrained` fails
36
+ because the `CLIPTextModel` embedder is unknown.
37
+
38
+ ## Usage
39
+
40
+ ```python
41
+ import vec2text
42
+
43
+ inv = vec2text.models.InversionModel.from_pretrained("Afrostnova/clip-text-msmarco-inversion")
44
+ cor = vec2text.models.CorrectorEncoderModel.from_pretrained("Afrostnova/clip-text-msmarco-corrector")
45
+ corrector = vec2text.load_corrector(inv, cor)
46
+
47
+ # `embeddings` = CLIP text-encoder last_hidden_state, pooled at the EOS position.
48
+ text = vec2text.invert_embeddings(
49
+ embeddings=embeddings, # (batch, hidden_dim) on the same device as the model
50
+ corrector=corrector,
51
+ num_steps=20,
52
+ sequence_beam_width=1,
53
+ )
54
+ ```
55
+
56
+ The CLIP text encoder is loaded automatically when the inversion model is instantiated.
57
+ On a clean machine it is fetched from `openai/clip-vit-large-patch14`; override with the
58
+ `CLIP_TEXT_ENCODER` environment variable if you want a local copy.