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.
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.
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.
- 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
- MLP-based architecture with residual connections
- SiLU activation for better convergence
- Layer normalization for stability
- Batch processing support
- Translation between popular models (BERT, T5, RoBERTa, GPT-2, OpenAI Ada-002)
- Semantic similarity preservation (>90% cosine similarity)
- Support for different embedding dimensionalities
- Structured logging with detailed metrics
- Automatic health checks
- Real-time usage statistics
- Performance tracking
- Configuration via environment variables
- Dynamic model loading
- Smart caching for optimization
- RESTful API with OpenAPI documentation
- Python 3.11+
- Docker (optional)
- CUDA (optional, for GPU acceleration)
# 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
# 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
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"]
}
}
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
}
GET /api/v1/models
GET /api/v1/health
GET /api/v1/statistics
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 |
┌─────────────────────────────────────┐
│ AICUBE API Layer │
│ (FastAPI + Pydantic Validation) │
└─────────────────────────────────────┘
│
┌─────────────────────────────────────┐
│ AICUBE Business Logic │
│ (Model Manager + Validators) │
└─────────────────────────────────────┘
│
┌─────────────────────────────────────┐
│ AICUBE ML Translation Layer │
│ (Neural Networks + PyTorch) │
└─────────────────────────────────────┘
- 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
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 |
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
}
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
# Unit tests
pytest aicube-tests/aicube-unit/ -v
# Integration tests
pytest aicube-tests/aicube-integration/ -v
# Coverage
pytest --cov=aicube-app aicube-tests/
- Train translation model
- Save in AICUBE format (.pt)
- Add entry to
aicube-model-registry.json
- Update documentation
- Latency: Response time per request
- Throughput: Requests per second
- Similarity: Translation quality (cosine similarity)
- Model Usage: Statistics per model
- Errors: Error rate and types
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
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 |
- 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
- Financial news sentiment analysis
- Fraud detection in transactions
- Specialized financial chatbots
- Claims processing
- Multimodal analysis (text + image)
- Automatic complaint classification
- Product recommendations
- Multilingual semantic search
- Customer review analysis
- Case law research
- Contract analysis
- Automated e-discovery
To report bugs or request features, use the issue system with tags:
aicube-bug
: For bugsaicube-enhancement
: For new featuresaicube-question
: For questions
- Fork the repository
- Create branch with
aicube-feature/
prefix - Implement following AICUBE standards
- Add tests with
aicube_test_
prefix - Submit pull request
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