VERA - Vector Embedding Retrieval Adaptation
Adapt embeddings to your personalized data using ResNet with bottleneck blocks.
Installation
pip install tune-vera
With optional dependencies:
pip install tune-vera[openai] # OpenAI support
pip install tune-vera[huggingface] # HuggingFace/Sentence-Transformers
pip install tune-vera[faiss-cpu] # FAISS index (CPU)
pip install tune-vera[all] # Everything
Quick Start
import tunevera
# 1. Load your Q&A data
data = tunevera.load_data(
path="my_data.csv",
question_col="question",
answer_col="answer"
)
# 2. Create embedding model
model_emb = tunevera.embedding.openai(
api_key="sk-...",
model="text-embedding-3-small"
)
# 3. Generate embeddings dataset
data_emb = model_emb.emb_dataset(data, train_size=0.8, seed=42)
# 4. Create and train the adapter
model_adapter = tunevera.adapter(
embedding_dim=1536,
bottleneck_dim=256,
num_blocks=5,
epochs=10,
batch_size=32
)
model_adapter.fit(data_emb)
# 5. Create search index
index = tunevera.index(
embeddings=data_emb,
model_adapter=model_adapter,
model_embedding=model_emb
)
# 6. Search
results = index.search("How do I reset my password?", top_k=5)
for r in results:
print(f"{r.score:.3f}: {r.answer}")
How It Works
VERA trains a ResNet with bottleneck blocks to transform embeddings. The bottleneck architecture significantly reduces parameters:
Standard: 1536 x 1536 = 2,359,296 params per layer
Bottleneck: 1536 x 256 + 256 x 1536 = 786,432 params (~66% reduction)
The model learns to transform question embeddings to be similar to their corresponding answer embeddings using cosine similarity loss.
Embedding Providers
OpenAI
model_emb = tunevera.embedding.openai(api_key="...", model="text-embedding-3-small")
HuggingFace
model_emb = tunevera.embedding.huggingface(
model="sentence-transformers/all-MiniLM-L6-v2",
device="cuda"
)
Custom API
model_emb = tunevera.embedding.custom(
base_url="https://my-api.com/embed",
api_key="..."
)
Data Augmentation
Generate paraphrases to augment your training data:
model_text = tunevera.llm.openai(api_key="...", model="gpt-4o-mini")
data_emb = model_emb.emb_dataset(
data,
augmentation=True,
n_augmentations=5,
model_text=model_text
)
License
MIT
Release files for tune-vera 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| tune_vera-0.0.1.tar.gz | 25.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| tune_vera-0.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 52.6 kB
Release files / tune_vera-0.0.1.tar.gz
| Download URL | tune_vera-0.0.1.tar.gz |
|---|---|
| Size | 25.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f8602346e39b33d3be09ce52b652e297f3740fcb392291f871e0ba2cb7257fc2
|
|
BLAKE2b-256 checksum How to use checksums |
1a98da24a4ce28690fb84beb4781353b041f40ed14959547f74ecbc6547d1cf2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.11
|
Release files / tune_vera-0.0.1-py3-none-any.whl
| Download URL | tune_vera-0.0.1-py3-none-any.whl |
|---|---|
| Size | 27.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
91232f39dee18d9616b5272e9ce2772b2445c06375eb2239226dfb5af720043b
|
|
BLAKE2b-256 checksum How to use checksums |
17823743679aec24c293e28e6821bae4748af8fa63ad7c6c0182203d3170ead8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.11
|