Vector Embedding Retrieval Adaptation
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file tune_vera-0.0.1.tar.gz.
File metadata
- Download URL: tune_vera-0.0.1.tar.gz
- Upload date:
- Size: 25.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f8602346e39b33d3be09ce52b652e297f3740fcb392291f871e0ba2cb7257fc2
|
|
| MD5 |
c260d08e8653950cc43de08188467f8d
|
|
| BLAKE2b-256 |
1a98da24a4ce28690fb84beb4781353b041f40ed14959547f74ecbc6547d1cf2
|
File details
Details for the file tune_vera-0.0.1-py3-none-any.whl.
File metadata
- Download URL: tune_vera-0.0.1-py3-none-any.whl
- Upload date:
- Size: 27.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
91232f39dee18d9616b5272e9ce2772b2445c06375eb2239226dfb5af720043b
|
|
| MD5 |
2dd5b8e87cc72337d015fd7ef5235453
|
|
| BLAKE2b-256 |
17823743679aec24c293e28e6821bae4748af8fa63ad7c6c0182203d3170ead8
|