LIF-CoT
an experimental model for continuous latent reasoning
2 min readupdated
The new research model LIF-CoT (Layerwise Injection and Feedback for Continuous Latent Reasoning) implements a continuous reasoning mechanism in latent space. The architecture combines two connected GPT-2 Small backbones, complemented by a layerwise state injection and feedback mechanism. The model (~436M parameters) was created to study hidden thought processes using mathematical problems as an example, without generating intermediate text. The development is intended for researchers in the field of interpretability and the working mechanisms of language models.
Key features
- Connected architecture: joint operation of two GPT-2 Small backbones with layerwise state injection.
- Continuous feedback: the normalized latent state is used as the next input during hidden steps.
- Seed checkpoints: three trained variants have been published for reproducibility (including the base seed 1234).
- Custom loader: the model requires a special loading script because the standard AutoModelForCausalLM does not support a reasoning loop.
What you can do
- Run inference: test text generation using hidden reasoning steps via the included Python script.
- Run benchmarks: explore the model results on GSM8K, SVAMP, MATH500, and BBH tasks.
- Study the mechanism: investigate the behavior of continuous latent representations and compare them with traditional explicit CoT.
Example
import sys
from huggingface_hub import snapshot_download
folder = snapshot_download(
"TheUserWW/LIF-CoT",
allow_patterns=[
"load_lif_cot.py", "config.json", "model.safetensors", "tokenizer/*"
],
)
sys.path.insert(0, folder)
from load_lif_cot import load_lif_cot, generate
model, tokenizer, config = load_lif_cot(folder, seed=1234, device="cuda")
result = generate(
model, tokenizer,
"A shop has 12 apples and sells 5. How many apples remain?",
latent_steps=6, max_new_tokens=128,
)
print(result["text"])Read more
Details• Architecture: two GPT-2 Small backbones (12 layers, hidden dimension 768)
• Hardware and precision: Float32 safetensors, requires CUDA with BF16 autocast
• Limitations: research checkpoints trained on a small amount of data, high inference latency
• License: MIT










Comments