Skip to main content

Quantum entanglement-inspired Natural Language Processing framework

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

entanglement_enhanced_nlp-2.0.0.tar.gz (51.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

entanglement_enhanced_nlp-2.0.0-py3-none-any.whl (52.0 kB view details)

Uploaded Python 3

File details

Details for the file entanglement_enhanced_nlp-2.0.0.tar.gz.

File metadata

File hashes

Hashes for entanglement_enhanced_nlp-2.0.0.tar.gz
Algorithm Hash digest
SHA256 6fc3aac89b65e32072642c5524677c11b460c6f26c0b9c728cb0196a776f3527
MD5 be6098a473d133f59128740139b44a63
BLAKE2b-256 d03ae86b1cd321d976eaa0ab672d610350bc851784475e80a02ae6d9fa2aa2e9

See more details on using hashes here.

File details

Details for the file entanglement_enhanced_nlp-2.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for entanglement_enhanced_nlp-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 46a651ccae196dc94390d6acb4d8e4bc4d6dfc8d9d306dad238cacf839a9fe18
MD5 e1c37728830cec8c487409c110ade3ac
BLAKE2b-256 91fa15d4ce8aea5b6cde7c8d785f8c47dd40be899d6ec450c9eea0f024674a0e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page