Noise-robust variant of the Vec2Text BART inversion model. Fine-tuned with embedding perturbations (cosine similarity 0.65-0.95) for robustness to noisy/approximate embeddings.
Have you ever ... | Chapter 8: A Symbol of Quality in America
Have you ever made a garment inside yo... | 0.481 |
| Less than 30% of the 36 million cat owners in the U.S. know that the beautiful s... | According to the U.S.G.A.S., 30% of cat owners know that their cats can kill mor... | 0.545 |
| The key ingredients of Turkish meals are meat, vegetables, and legumes.... | The main ingredients of Turkish meals include meat, vegetables, and legumes.... | 0.867 |
| The platform will then generate a list of available options with prices, travel ... | The platform will then provide available options such as travel time, amenities,... | 0.708 |
1import torch, torch.nn as nn, transformers
2from safetensors.torch import load_file
3
4# Load model
5model = transformers.AutoModelForSeq2SeqLM.from_pretrained("facebook/bart-base")
6tokenizer = transformers.AutoTokenizer.from_pretrained("facebook/bart-base")
7hidden = model.config.hidden_size
8
9embedding_transform = nn.Sequential(
10 nn.Linear(4096, 4096), nn.LayerNorm(4096), nn.Dropout(0.1), nn.GELU(),
11 nn.Linear(4096, hidden * 16),
12)
13
14# Load weights (download from this repo)
15state = load_file("model.safetensors") # or torch.load("bart_noisy.pt")
16et_state = {k.replace("embedding_transform.", ""): v for k, v in state.items() if k.startswith("embedding_transform.")}
17embedding_transform.load_state_dict(et_state)
18ed_state = {k.replace("encoder_decoder.", ""): v for k, v in state.items() if k.startswith("encoder_decoder.")}
19model.load_state_dict(ed_state, strict=False)
20
21# Invert a Qwen3-Embedding-8B embedding (4096-dim)
22device = torch.device("cuda")
23model, embedding_transform = model.to(device).eval(), embedding_transform.to(device).eval()
24
25with torch.no_grad():
26 emb = torch.tensor(your_embedding, dtype=torch.float32).unsqueeze(0).to(device)
27 proj = embedding_transform(emb).reshape(1, 16, hidden)
28 out = model.generate(inputs_embeds=proj, attention_mask=torch.ones(1, 16, device=device),
29 max_length=128, num_beams=4, early_stopping=True)
30 text = tokenizer.decode(out[0], skip_special_tokens=True)