QELM
QELM is currently taking a backseat to Brain. Brain is currently exponentially ahead of the current Qelm structure, however Qelm is extremely useful for learning quantum circuits in NLP and understanding how brain was built and its core works. Qelm will be updated as soon as Brain is benchmarked against QWEN 3.6 27b.
QELM is not a classical language model with a small quantum circuit attached to it.
It is a complete language-model framework built around trainable quantum circuits, quantum channels, sub-bit encoding, next-token prediction, model training, dataset preparation, multiple backends, and direct user interfaces.
Main program: Qelm.exe or Qelm2.py
•
Chat interface: Main program folder QELMChatUI.py
•
Legacy implementations: Outdated/
Qiskit will eventually no longer be required for every local QELM path, but it will remain recommended and an important part of QELM's development. Qiskit, Qiskit Aer, and IBM Runtime will still be required for their related simulation and hardware features.
QSA will be taking over for local quantum computations.
QELM is a quantum-enhanced generative language-model architecture built to study how quantum-state information can be used directly inside language processing.
The goal is not to copy the scale or structure of modern large language models. The goal is to explore whether a much smaller architecture can use quantum states, trainable circuit parameters, phase information, channel-based processing, and hybrid memory systems to represent and learn language differently.
|
|
QELM also includes its own dataset preparation tools, model format, backend routing, memory systems, trainer, chat interface, error logging, model conversion experiments, and preserved legacy versions.
|
QELM treats quantum channels as active parts of the architecture rather than temporary circuit calls. Channels can encode information, preserve sub-bit states, apply gates, decode state information, reset, transfer information, and route through different backend types. |
QELM preserves both amplitude-related and phase-related information from a qubit state. Instead of immediately reducing every state to a single measured probability, QELM can expose two related computational features to the model. |
|
QELM is trained as a language model. It produces vocabulary logits, calculates next-token loss, estimates gradients, updates model parameters, measures perplexity, and saves the resulting model. |
The architecture, older versions, training paths, model files, benchmark material, and development history are public. The project can be downloaded, inspected, tested, and challenged for permitted noncommercial purposes. Modification, redistribution, and commercial use require separate written permission. |
A pure single-qubit state can be represented as:
QELM uses both coordinates of the state:
| Coordinate | Role | ||
|---|---|---|---|
| Controls the amplitude relationship between the $ | 0\rangle$ and $ | 1\rangle$ components | |
| Controls the relative phase between the state components |
In a quantum circuit, the state is prepared with:
RY(theta)
RZ(phi)
In local statevector mode, QELM constructs it directly:
alpha = np.cos(theta / 2.0)
beta = np.sin(theta / 2.0) * np.exp(1j * phi)
state = np.array([alpha, beta], dtype=np.complex128)When sub-bit encoding is enabled, QELM can preserve two derived paths:
| Feature | Meaning |
|---|---|
| Amplitude feature | Represents the probability-related structure of the state |
| Phase feature | Represents the relative phase structure of the state |
The current transformer path maps an incoming value into both coordinates:
sv = 1.0 / (1.0 + np.exp(-3.0 * value))
theta = 2.0 * np.arcsin(np.sqrt(sv))
phi = 2.0 * np.pi * svThis produces two nonlinear quantum-state features from one incoming value.
A planned extension will allow the two coordinates to be learned independently:
This will allow amplitude and phase to develop separate learned roles inside the model.
Input text
↓
Tokenizer and token IDs
↓
Classical embeddings
↓
Optional context, memory, position, or knowledge processing
↓
Sequence weighting and aggregation
↓
Quantum attention
↓
Quantum channels and state encoding
↓
Entanglement and trainable circuit operations
↓
Quantum feed-forward processing
↓
Residual and normalization paths
↓
Vocabulary projection
↓
Next-token logits
|
|
|
|
|
|
|
|
| Backend | Purpose | Status |
|---|---|---|
| CPU | Local QELM circuit and statevector processing | Supported |
| Qiskit Aer | Local quantum simulation | Supported |
| IBM Quantum | Real quantum hardware and Runtime paths | Supported |
| GPU | Accelerated simulation where compatible | Experimental |
| Cubit | Cubit and quantum-emulator integration | Experimental |
| Analog | Analog-style drift and state evolution | Experimental |
| Hybrid | Alternate logical-qubit representations | Experimental |
| Cluster / MBQC | Cluster-state and measurement-based paths | Experimental |
Not every feature behaves identically across every backend. Small models should be used before beginning large hardware or experimental runs.
pip install qelmgit clone https://github.com/R-D-BioTech-Alaska/QELM.git
cd QELMpython Qelm2.pyThe main interface controls:
- Model dimensions
- Backend selection
- Thread count
- Sub-bit encoding
- Amplitude encoding
- Entanglement
- Data reuploading
- Noise mitigation
- Memory and context
- Gradient method
- Dataset loading
- Training
- Model saving
Full installation instructions
- Python 3.11
- NumPy
- Tkinter
- Qiskit
- Qiskit Aer
- psutil
- datasets for Hugging Face preparation
- PyTorch for supported GPU and model-conversion paths
- TensorFlow only for older or experimental modules that still use it
python -m venv qelm_envLinux or macOS:
source qelm_env/bin/activateWindows:
qelm_env\Scripts\activatepython -m pip install --upgrade pip
pip install -r requirements.txtQELM includes command-line tools for preparing large token streams before training.
python Qelm2.py --qelm_prep_tokens \
--input Science.txt \
--output Science.tokensCreates a binary |
python Qelm2.py --qelm_prep_hf \
--dataset Salesforce/wikitext \
--config wikitext-2-raw-v1 \
--split train \
--output wikitext2.tokensAttempts streaming first and falls back to a normal dataset load when needed. |
QELM can train with:
- Parameter-shift gradients
- SPSA
- Adam updates
- Batch-shift processing
- Sampled gradient subsets
- Sampled metric subsets
- Parallel workers
- Gradient clipping
- Learning-rate control
- Optional data reuploading
During training, QELM can report:
| Training | Evaluation |
|---|---|
| Current epoch | Cross-entropy loss |
| Gradient progress | Perplexity |
| Gradient magnitude | Embedding coverage |
| Elapsed time | Estimated remaining time |
| Learning rate | Model and parameter status |
.qelmmodel file- Matching token-map file
- Training logs
- Loss and perplexity results
- Crash and soft-failure logs when needed
A .qelm model can contain:
|
|
Keep the model and matching token map together:
model_name.qelm
model_name_token_map.json
Run the separate chat interface with:
python QELMChatUI.pyThe interface includes:
- Model loading
- Token-map loading
- Message history
- Temperature control
- Maximum token control
- Theme settings
- Font settings
Qelm2.py contains the complete current quantum-enhanced training and model-execution architecture.
QELMChatUI.py is a lightweight interface for saved models and does not currently reconstruct every quantum circuit component used by the full trainer.
The example model shown in the interface is approximately 23 KB.
IBM Quantum setup
from qiskit_ibm_runtime import QiskitRuntimeService
service = QiskitRuntimeService(
channel="ibm_quantum",
token="YOUR_TOKEN"
)
backend = service.backend("BACKEND_NAME")Before submitting a hardware run:
- Confirm the backend is online
- Check available qubits
- Check queue time
- Check shot and runtime limits
- Save the local model
- Begin with a small circuit
Real quantum hardware behaves differently from local statevector simulation because of noise, measurement limits, queue delays, and backend restrictions.
QELM reports standard language-model and training measurements.
|
|
A useful QELM benchmark should include:
| Category | Required Information |
|---|---|
| Source | Commit or release tag |
| Data | Dataset, configuration, size, and tokenizer |
| Model | Vocabulary, embedding size, heads, hidden size, and blocks |
| Quantum | Encoding, entanglement, reuploading, and backend |
| Training | Optimizer, gradient method, learning rate, and epochs |
| Results | Loss, perplexity, runtime, and model size |
| Hardware | CPU, RAM, GPU, operating system, or QPU |
Results without their configuration are difficult to reproduce or compare.
Stable Core
|
Active Development
|
Experimental does not mean hidden or theoretical. QELM is public, usable, inspectable, and actively changing.
QELM has been developed publicly, with its source, releases, older implementations, benchmark files, and continued changes preserved in the repository.
The older files are kept intentionally because they show the progression of:
- Quantum channels
- Sub-bit encoding
- Circuit construction
- Training systems
- Backend experiments
- Model serialization
- Interfaces
- Benchmarks
The development history is part of QELM and preserves when its architecture and major features were introduced.
Repository structure
QELM/
├── Qelm2.py
├── QELMChatUI.py
├── Cubit.py
├── requirements.txt
├── setup.py
├── Benchmark/
├── Datasets/
├── Documentation/
├── Outdated/
├── badges/
├── docs/
│ └── images/
├── README.md
└── LICENSE
|
|
DOI: 10.13140/RG.2.2.11844.90243
Carter, Brenton. Quantum-Enhanced Language Model (QELM). R&D BioTech Alaska. DOI: 10.13140/RG.2.2.11844.90243
When citing a specific implementation or benchmark, include the Git commit or release tag used.
Issues, benchmark results, documentation corrections, and security reports are welcome. Code modifications and pull requests require prior written permission under the current source license.
Useful contributions include:
- Reproducing training runs
- Testing different systems
- Improving backend compatibility
- Adding benchmark configurations
- Improving gradient performance
- Adding unit tests
- Comparing sub-bit and standard encoding
- Improving documentation
Bug reports should include:
- Operating system
- Python version
- Qiskit and Aer versions
- Backend
- Model settings
- Dataset
- Full error message
- Steps needed to reproduce the issue
QELM is source-available under the PolyForm Strict License 1.0.0. Noncommercial use is permitted. Distribution, modification, derivative works, sublicensing, transfer, and commercial use require separate written permission.
See LICENSE, LICENSE_HISTORY.md, and COMMERCIAL_LICENSE.md. Earlier versions lawfully obtained under MIT remain under their original MIT terms.
contact@rdbiotechalaska.com • contact@qelm.org • GitHub • RDBioTech.org • Qelm.org
Join the QELM Discord • Follow on LinkedIn
QELM is a public research architecture under active development. Its current source is available for inspection and permitted noncommercial use under the PolyForm Strict License 1.0.0. Modification, redistribution, and commercial use require written permission.




