Skip to content

AICUBE Embedding2Embedding - Unlock advanced embedding translation between distinct vector spaces with the AICUBE Embedding2Embedding. Seamlessly transform embeddings across various domains to enhance the flexibility and precision of your AI models, enabling smarter integrations.

License

Notifications You must be signed in to change notification settings

aicubetechnology/aicube-embedding2embedding

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AICUBE Embedding2Embedding API

License Python FastAPI PyTorch Docker AICUBE

Overview

The AICUBE embedding2embedding is a powerful service developed in by AICUBE TECHNOLOGY LLC. This project allows the translation of embeddings between different vector spaces of natural language models, essentially converting the embedding vectors generated by a source model (such as BERT) into the corresponding vector in the space of a target model (such as T5), preserving the original semantic meaning.

This process is based on recent research demonstrating that it is possible to align distinct embedding spaces without requiring paired data or prior knowledge about the original content. The ability to convert embeddings between different models while maintaining a high cosine similarity opens new possibilities for interoperability between NLP systems that would otherwise not be compatible.

Illustrative Example:

Before: Embedding distributions generated by two different models (like T5 and BERT) are incompatible and cannot be compared directly.

After: After applying the unsupervised embedding translation model, these representations are aligned in a common latent space, preserving semantic relationships. This allows embeddings from different models to be compared and used together, enhancing flexibility and analytical capabilities.

The project is implemented as an isolated microservice, easy to scale and integrate, initially using pre-trained translation models (such as autoencoders or contrastive learning) to translate embeddings between popular models like BERT, RoBERTa, and T5. In the future, an evolution roadmap will enable the creation of custom translation models, expanding support for new vector spaces as needed.

Next Steps and Future Evolution:

Phase 1: Launch with pre-trained translation models.

Phase 2: Expand support to more models and optimize performance.

Phase 3: Implement custom translation training on demand.

Phase 4: Expand to multimodal (text, image, audio) translation and advanced features.

Technologies Used

  • FastAPI: High-performance web framework for building APIs
  • PyTorch: Deep learning framework for neural network implementation
  • MLP Architecture: Multi-Layer Perceptron with residual connections
  • SiLU Activation: Sigmoid Linear Unit for improved model performance
  • Layer Normalization: For training stability and convergence
  • Structured Logging: For comprehensive monitoring and debugging

Key Features

🚀 Optimized Performance

  • MLP-based architecture with residual connections
  • SiLU activation for better convergence
  • Layer normalization for stability
  • Batch processing support

🔄 Interoperability

  • Translation between popular models (BERT, T5, RoBERTa, GPT-2, OpenAI Ada-002)
  • Semantic similarity preservation (>90% cosine similarity)
  • Support for different embedding dimensionalities

📊 Advanced Monitoring

  • Structured logging with detailed metrics
  • Automatic health checks
  • Real-time usage statistics
  • Performance tracking

🔧 Flexibility

  • Configuration via environment variables
  • Dynamic model loading
  • Smart caching for optimization
  • RESTful API with OpenAPI documentation

Installation and Setup

Prerequisites

  • Python 3.11+
  • Docker (optional)
  • CUDA (optional, for GPU acceleration)

Installation with Docker (Recommended)

# Clone the repository
git clone <repository-url>
cd aicube-embedding2embedding

# Build the image
docker build -f aicube-Dockerfile -t aicube-embedding2embedding .

# Run with Docker Compose
docker-compose -f aicube-docker-compose.yml up -d

Manual Installation

# Create virtual environment
python -m venv aicube-venv
source aicube-venv/bin/activate  # Linux/Mac
# or
aicube-venv\Scripts\activate  # Windows

# Install dependencies
pip install -r aicube-requirements.txt

# Configure environment variables
cp aicube.env.example aicube.env
# Edit aicube.env as needed

# Run application
python aicube-app/aicube-main.py

API Usage

Main Endpoints

1. Translate Embedding

POST /api/v1/translate
Content-Type: application/json

{
  "origem": "bert_base_uncased",
  "destino": "t5_base", 
  "embedding": [0.12, 0.45, -0.67, 0.89, -0.23],
  "include_metadata": true
}

Response:

{
  "origem": "bert_base_uncased",
  "destino": "t5_base",
  "embedding_traduzido": [0.08, 0.33, -0.10, 0.71, -0.15],
  "aicube_technology": "AICUBE TECHNOLOGY LLC",
  "metadata": {
    "aicube_model_id": "aicube-bert-to-t5",
    "duration_ms": 15.2,
    "cosine_similarity": 0.94,
    "powered_by": ["Qube LCM Model", "Qube Neural Memory"]
  }
}

2. Batch Translation

POST /api/v1/translate/batch
Content-Type: application/json

{
  "origem": "bert_base_uncased",
  "destino": "t5_base",
  "embeddings": [
    [0.12, 0.45, -0.67],
    [0.89, -0.23, 0.56]
  ],
  "include_metadata": true
}

3. List Available Models

GET /api/v1/models

4. Health Check

GET /api/v1/health

5. Usage Statistics

GET /api/v1/statistics

Supported Models

Source Model Target Model AICUBE Translator Technology
bert_base_uncased t5_base aicube-bert-to-t5 Qube LCM Model
sentence_transformers_mpnet openai_ada002 aicube-mpnet-to-ada002 Qube Neural Memory
roberta_base gpt2_base aicube-roberta-to-gpt2 Qube Agentic Workflows

Architecture

Application Layers

┌─────────────────────────────────────┐
│        AICUBE API Layer             │
│  (FastAPI + Pydantic Validation)   │
└─────────────────────────────────────┘
                  │
┌─────────────────────────────────────┐
│      AICUBE Business Logic          │
│   (Model Manager + Validators)     │
└─────────────────────────────────────┘
                  │
┌─────────────────────────────────────┐
│     AICUBE ML Translation Layer     │
│  (Neural Networks + PyTorch)       │
└─────────────────────────────────────┘

Main Components

  • aicube-main.py: Main FastAPI application
  • aicube-model-manager.py: Translation model manager
  • aicube-embedding-translator.py: Neural translation models
  • aicube-endpoints.py: REST endpoint definitions
  • aicube-schemas.py: Data validation with Pydantic
  • aicube-logging.py: Structured logging system

Configuration

Environment Variables

Variable Description Default
AICUBE_API_NAME API name aicube-embedding2embedding
AICUBE_MODELS_PATH Models directory ./aicube-models
AICUBE_MAX_EMBEDDING_DIMENSION Maximum dimension 4096
AICUBE_MAX_BATCH_SIZE Maximum batch size 32
AICUBE_DEVICE Device (cpu/cuda) cpu

Logging

The system uses structured logging with AICUBE context:

{
  "timestamp": "2023-06-19T12:00:00Z",
  "level": "info",
  "message": "AICUBE Embedding Translation",
  "aicube_service": "aicube-embedding2embedding",
  "aicube_technology": "AICUBE TECHNOLOGY LLC",
  "source_model": "bert_base_uncased",
  "target_model": "t5_base",
  "duration_ms": 15.2,
  "cosine_similarity": 0.94
}

Development

Project Structure

aicube-embedding2embedding/
├── aicube-app/                    # Main code
│   ├── aicube-api/               # REST endpoints
│   ├── aicube-core/              # Core logic
│   ├── aicube-models/            # ML models
│   └── aicube-utils/             # Utilities
├── aicube-tests/                 # Tests
├── aicube-models/                # Pre-trained models
├── aicube-docs/                  # Documentation
├── aicube-configs/               # Configurations
└── aicube-scripts/               # Helper scripts

Running Tests

# Unit tests
pytest aicube-tests/aicube-unit/ -v

# Integration tests
pytest aicube-tests/aicube-integration/ -v

# Coverage
pytest --cov=aicube-app aicube-tests/

Adding New Model

  1. Train translation model
  2. Save in AICUBE format (.pt)
  3. Add entry to aicube-model-registry.json
  4. Update documentation

Metrics and Monitoring

Available Metrics

  • Latency: Response time per request
  • Throughput: Requests per second
  • Similarity: Translation quality (cosine similarity)
  • Model Usage: Statistics per model
  • Errors: Error rate and types

Dashboards

The API exposes Prometheus-format metrics at /metrics (port 8001):

# HELP aicube_translation_duration_seconds Time spent translating embeddings
# TYPE aicube_translation_duration_seconds histogram
aicube_translation_duration_seconds_bucket{model="aicube-bert-to-t5",le="0.01"} 150

Performance

Benchmarks

Model Dimension Latency (ms) Similarity Throughput (req/s)
BERT→T5 768→768 15.2 0.94 65
MPNet→Ada002 768→1536 23.1 0.93 43
RoBERTa→GPT2 768→768 18.7 0.92 53

Optimizations

  • Batch Processing: Process multiple embeddings together
  • Model Caching: Keep models loaded in memory
  • GPU Acceleration: Use CUDA when available
  • Quantization: Quantized models for lower latency

Use Cases

1. Financial Sector

  • Financial news sentiment analysis
  • Fraud detection in transactions
  • Specialized financial chatbots

2. Insurance Sector

  • Claims processing
  • Multimodal analysis (text + image)
  • Automatic complaint classification

3. Retail

  • Product recommendations
  • Multilingual semantic search
  • Customer review analysis

4. Legal

  • Case law research
  • Contract analysis
  • Automated e-discovery

Support and Contribution

Reporting Issues

To report bugs or request features, use the issue system with tags:

  • aicube-bug: For bugs
  • aicube-enhancement: For new features
  • aicube-question: For questions

Contributing

  1. Fork the repository
  2. Create branch with aicube-feature/ prefix
  3. Implement following AICUBE standards
  4. Add tests with aicube_test_ prefix
  5. Submit pull request

License

This project is licensed under the MIT License for Non-Commercial Use only.

Copyright (c) 2024 AICUBE TECHNOLOGY LLC

Permitted (Non-Commercial):

  • Personal use and learning
  • Academic research and education
  • Open source contributions
  • Non-profit organizations

Prohibited (Commercial):

  • Selling or monetizing the software
  • Commercial products or services
  • Revenue-generating activities

For commercial licensing, contact: contact@aicube.ca

See LICENSE file for full terms.


Developed by AICUBE TECHNOLOGY LLC
Powered by FastAPI, PyTorch, MLP Neural Networks, and Advanced ML Algorithms

About

AICUBE Embedding2Embedding - Unlock advanced embedding translation between distinct vector spaces with the AICUBE Embedding2Embedding. Seamlessly transform embeddings across various domains to enhance the flexibility and precision of your AI models, enabling smarter integrations.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published