embedding-adapter
A lightweight open-source package to fine-tune embedding models.
Science Score: 44.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (11.6%) to scientific vocabulary
Repository
A lightweight open-source package to fine-tune embedding models.
Basic Info
Statistics
- Stars: 18
- Watchers: 3
- Forks: 1
- Open Issues: 0
- Releases: 0
Metadata Files
README.md
Embedding Adapter 💬 📐
Finetune embedding models in just 4 lines of code.
Quick Start ⚡
Installation
bash
pip install embedding_adapter
Usage
python
from embedding_adapter import EmbeddingAdapter
adapter = EmbeddingAdapter()
adapter.fit(query_embeddings, document_embeddings, labels)
adapter.transform(new_embeddings)
Once you've trained the adapter, you can use patch your pre-trained embedding model.
python
patch = adapter.patch()
adapted_embeddings = patch(original_embedding_fn("SAMPLE_TEXT"))
Use Cases/Why do I need to tune my embeddings ❓
Embeddings are predominantly utilized for Retrieval Augmented Generation (RAG) or semantic search applications. However, their effectiveness can significantly vary depending on the context. This is where the need for tuning comes into play.
Consider training an adaptor for your pre-trained embedding model, such as OpenAI's text-embedding-3-small or the open-source gte-large. This customization enables your model to interpret tokens accurately within the specific context of your application. For example, the word "Pandas" 🐼 could refer to the animal or the widely used Python library for data manipulation. Without tuning, your model may not distinguish between these vastly different contexts.
Moreover, tuning your embeddings is crucial if you aim to utilize a smaller model—perhaps due to hardware constraints like the absence of GPUs for inference. In such cases, an adaptor can enhance retrieval performance, ensuring efficiency without compromising on accuracy.
Synthetic Label Generation 🧪
No user feedback to use as labels? 🤔 Create synthetic labels with the LabelGenerator util
python
from embedding_adapter.utils import LabelGenerator
generator = LabelGenerator()
generator.run()
Note: This requires an OpenAI API key saved as an OPENAI_API_KEY env var.
License 📄
This project is licensed under the MIT License.
Owner
- Login: gabrielchua
- Kind: user
- Location: Singapore
- Repositories: 1
- Profile: https://github.com/gabrielchua
Citation (CITATION.cff)
cff-version: 1.2.0
message: "If you use this software, please cite it as below."
title: "Embedding Adaptor"
version: 0.1.1
date-released: 2024-01-31
authors:
- family-names: Chua
given-names: Gabriel
repository-code: "https://github.com/gabrielchua/RAGxplorer"
license: MIT
references:
- type: course
authors:
- family-names: Troynikov
given-names: Anton
title: "Advanced Retrieval for AI with Chroma"
year: 2023
publisher: DeepLearning.AI
url: https://www.deeplearning.ai/short-courses/advanced-retrieval-for-ai/
GitHub Events
Total
- Watch event: 6
- Fork event: 1
Last Year
- Watch event: 6
- Fork event: 1
Issues and Pull Requests
Last synced: over 1 year ago
All Time
- Total issues: 0
- Total pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Total issue authors: 0
- Total pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels
Dependencies
- Jinja2 ==3.1.3
- MarkupSafe ==2.1.4
- annotated-types ==0.6.0
- anyio ==4.2.0
- certifi ==2023.11.17
- distro ==1.9.0
- filelock ==3.13.1
- fsspec ==2023.12.2
- h11 ==0.14.0
- httpcore ==1.0.2
- httpx ==0.26.0
- idna ==3.6
- mpmath ==1.3.0
- networkx ==3.2.1
- numpy ==1.26.3
- openai ==1.10.0
- pydantic ==2.5.3
- pydantic_core ==2.14.6
- sniffio ==1.3.0
- sympy ==1.12
- torch ==2.1.2
- tqdm ==4.66.1
- typing_extensions ==4.9.0
- numpy *
- openai *
- pydantic *
- torch *
- tqdm *