SwaFlow-3B-EMA-Instruct
Riemannian flow instruction-tuned language model
2 min readupdated
SwaFlow-3B-EMA-Instruct is a 3.74B-parameter version of the SwaFlow-3B-EMA language model, fine-tuned on the Dolci-Instruct-SFT dataset for one epoch. The model utilizes Riemannian flow principles (Riemannian flow language model — generative models describing data evolution as a continuous flow on a manifold), generating text by integrating a flow on a sphere starting from noise. It was developed by researchers from AIST and the Institute of Science Tokyo under the national FRONTia program. The model is tailored for research tasks and exploring non-autoregressive approaches in text generation rather than production applications.
Key features
- Based on the hyperspherical flow architecture with exponential moving average (EMA — a method of averaging model weights over several training steps to improve stability) of final checkpoints.
- Total parameter count is 3.74B (28 layers, hidden size 3072, 24 attention heads).
- Context length is 2,048 tokens using the SmolLM2 tokenizer.
- Instruction-tuned (SFT — fine-tuning a model on labeled pairs of instructions and responses) on the Dolci-Instruct-SFT dataset (1.16B tokens).
What you can do
- Run inference and text generation using specialized code from the torchtitan library and the swaflow-suite repository.
- Use the model in research experiments exploring flow matching language models instead of traditional autoregression.
- Analyze how Riemannian flow models operate and compare their quality with traditional LLMs.
Example
import torch
from tokenizers import Tokenizer
from torchtitan.models.swaflow.hf import from_pretrained
from torchtitan.models.swaflow.sampling import SamplerConfig, generate
tokenizer = Tokenizer.from_pretrained("HuggingFaceTB/SmolLM2-135M")
model = from_pretrained("tokyotech-llm/SwaFlow-3B-EMA-Instruct", device="cuda").eval()
ids = tokenizer.encode("User: What is the capital of France?\n\n").ids + tokenizer.encode("Assistant:").ids
prefix = torch.tensor([ids], device="cuda")
with torch.no_grad():
out = generate(model, num_samples=1, seq_len=prefix.shape[1] + 256,
config=SamplerConfig(steps=64), prefix_tokens=prefix,
prefix_lengths=torch.tensor([prefix.shape[1]], device="cuda"))
tokens = out[0, prefix.shape[1]:].tolist()
if 0 in tokens:
tokens = tokens[: tokens.index(0)]
print(tokenizer.decode(tokens))
Read more
DetailsParameters: 3.74B parameters, FFN 8192, vocabulary size 49,152 tokens.
Training: Dolci-Instruct-SFT, 1 epoch, 1,107 steps, AdamW optimizer (LR 3e-5).
Limitations: The model is at an early research stage, generated text is often incoherent, and there is no safeguard against generating harmful content.










Comments