Skip to main content

Entanglement Enhanced NLP 🌌

PyPI - Version PyPI Downloads Python Version License: Commercial Docs

A groundbreaking framework that integrates quantum entanglement concepts into Natural Language Processing (NLP) models, enabling more nuanced understanding of semantic relationships, superior context awareness, and highly efficient processing of complex linguistic data.

Author: Krishna Bajpai (bajpaikrishna715@gmail.com)

🚀 Features

  • EntangledEmbedding: Custom embedding class modeling entangled word-pairs using shared vector states and non-local attention
  • QuantumContextualizer: Layer that enhances token embeddings using quantum-state evolution principles
  • Entanglement-aware Transformers: HuggingFace transformer extensions with entangled attention layers
  • Non-local Correlation Scoring: Sentence and document-level correlation analysis
  • Quantum Simulator Backend: Optional numpy/pennylane backend for quantum-like behavior emulation
  • CLI Tool: eenlp-cli for entangled text analysis
  • Visualization: Token entanglement graphs and correlation heatmaps
  • Export Support: JSON results and comprehensive reporting

🔬 Quantum-Inspired Mechanisms

This framework emulates key quantum mechanical properties in classical NLP:

  • Entanglement: Non-local correlations between semantically related tokens
  • Superposition: Probabilistic token states enabling multiple semantic interpretations
  • Decoherence: Gradual loss of quantum coherence modeling context decay
  • Quantum State Evolution: Dynamic embedding updates based on quantum evolution principles

📦 Installation

pip install entanglement-enhanced-nlp

Development Installation

git clone https://github.com/your-repo/entanglement-enhanced-nlp.git
cd entanglement-enhanced-nlp
pip install -e .

🔧 Quick Start

from entanglement_enhanced_nlp import EntangledEmbedding, QuantumContextualizer
import torch

# Create entangled embeddings
embedder = EntangledEmbedding(
    vocab_size=10000,
    embedding_dim=768,
    entanglement_depth=3,
    correlation_strength=0.8
)

# Initialize quantum contextualizer
contextualizer = QuantumContextualizer(
    hidden_dim=768,
    num_qubits=8,
    decoherence_rate=0.1
)

# Process text with quantum-enhanced embeddings
text_ids = torch.tensor([[1, 2, 3, 4, 5]])
entangled_embeddings = embedder(text_ids)
quantum_context = contextualizer(entangled_embeddings)

🎯 Use Cases

  • Enhanced Semantic Understanding: Better capture of nuanced word relationships
  • Context-Aware Processing: Superior long-range dependency modeling
  • Multilingual Applications: Cross-lingual entanglement for translation tasks
  • Quantum NLP Research: Testbed for quantum-classical hybrid approaches
  • Advanced Chatbots: More human-like language comprehension

📊 CLI Usage

# Analyze text file with entanglement scoring
eenlp-cli analyze --input text.txt --output results.json --visualize

# Process dataset with quantum contextualizer
eenlp-cli process --dataset data.csv --model-config config.yaml

# Generate entanglement visualization
eenlp-cli visualize --input results.json --output entanglement_graph.png

🧪 Examples

Check out the examples/ directory for comprehensive Jupyter notebooks demonstrating:

  • Basic entangled embedding usage
  • Quantum contextualizer integration
  • HuggingFace transformer extensions
  • Visualization and analysis workflows
  • Performance benchmarking

🔬 Mathematical Foundation

The framework implements quantum-inspired operations:

Entanglement Correlation

|ψ⟩ = α|00⟩ + β|11⟩
Correlation(i,j) = ⟨ψᵢ|ψⱼ⟩ · exp(-γ·d(i,j))

Quantum State Evolution

|ψ(t+1)⟩ = U(θ)|ψ(t)⟩
U(θ) = exp(-iH·θ)

Decoherence Modeling

ρ(t) = (1-λ)ρ(t-1) + λ·I/d

🧪 Testing

pytest tests/ -v

📄 License

Open to free and commercial use under the Commercial License. See LICENSE.md file for details.

🤝 Contributing

Contributions welcome! Please read CONTRIBUTING.md for guidelines.

📚 Citation

If you use this framework in your research, please cite:

@software{entanglement_enhanced_nlp,
  title={Entanglement Enhanced NLP: Quantum-Inspired Natural Language Processing},
  author={Krishna Bajpai},
  year={2025},
  url={https://github.com/your-repo/entanglement-enhanced-nlp}
}

🌟 Acknowledgments

This work bridges quantum mechanics and NLP, inspired by the potential for quantum-classical hybrid approaches in advancing AI comprehension capabilities.


Note: This is a classical simulation of quantum-inspired mechanisms designed for research and educational purposes. While it emulates quantum properties, it runs on classical hardware.

Metadata

Release files for entanglement-enhanced-nlp 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for entanglement-enhanced-nlp 2.0.0
File Size Uploaded
entanglement_enhanced_nlp-2.0.0.tar.gz 51.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for entanglement-enhanced-nlp 2.0.0
File Interpreter ABI Platform
entanglement_enhanced_nlp-2.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 103.0 kB

Release files / entanglement_enhanced_nlp-2.0.0.tar.gz

Download URL entanglement_enhanced_nlp-2.0.0.tar.gz
Size 51.0 kB
Tags Source
SHA-256 checksum
How to use checksums
6fc3aac89b65e32072642c5524677c11b460c6f26c0b9c728cb0196a776f3527
BLAKE2b-256 checksum
How to use checksums
d03ae86b1cd321d976eaa0ab672d610350bc851784475e80a02ae6d9fa2aa2e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.1

Release files / entanglement_enhanced_nlp-2.0.0-py3-none-any.whl

Download URL entanglement_enhanced_nlp-2.0.0-py3-none-any.whl
Size 52.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
46a651ccae196dc94390d6acb4d8e4bc4d6dfc8d9d306dad238cacf839a9fe18
BLAKE2b-256 checksum
How to use checksums
91fa15d4ce8aea5b6cde7c8d785f8c47dd40be899d6ec450c9eea0f024674a0e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.1

Release history Release notifications | RSS feed

This release

2.0.0 This release

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page