Instructions to use Blackroot/TensorProduct-Microllama with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Blackroot/TensorProduct-Microllama with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Blackroot/TensorProduct-Microllama")# Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("Blackroot/TensorProduct-Microllama", dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps
- vLLM
How to use Blackroot/TensorProduct-Microllama with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Blackroot/TensorProduct-Microllama" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Blackroot/TensorProduct-Microllama", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker
docker model run hf.co/Blackroot/TensorProduct-Microllama
- SGLang
How to use Blackroot/TensorProduct-Microllama with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "Blackroot/TensorProduct-Microllama" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Blackroot/TensorProduct-Microllama", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "Blackroot/TensorProduct-Microllama" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Blackroot/TensorProduct-Microllama", "prompt": "Once upon a time,", "max_tokens": 512, "temperature": 0.5 }' - Docker Model Runner
How to use Blackroot/TensorProduct-Microllama with Docker Model Runner:
docker model run hf.co/Blackroot/TensorProduct-Microllama
# Load model directly
from transformers import AutoModel
model = AutoModel.from_pretrained("Blackroot/TensorProduct-Microllama", dtype="auto")From scratch pretraining on english only no synthetic data, no code, 3 epochs of 1 gig of data for the ~125M param model.
Test network using Tensor Product Attention. Other than some alterations to the attention, such as 16 heads insted of 9 and using TPA, this is the same setup as https://huggingface.co/HuggingFaceTB/SmolLM2-135M-Instruct
Scripts:
inference.pyto run the model with some test promptstest_train.pyruns with the exact configurations used to train this model and is the reproduction script. Data is assumed to be in JSONL format with"text":"example text", "text":"..."
Notes:
One of the primary reported benefits for TPA are for inference which are not really being leveraged at all, although you can probably fit a larger bsz than traditional MHA/GQA with this. This did save about 5% on params, that amount should scale much more as the network size increases. The run time is very similar to MHA/GQA at this scale.
Training Metrics
Dataset Information
- Training data per epoch: 1 GB
- Total tokens trained: 48,261,120
- No sythetic data
Training Results
- Final Train Loss: 3.0421
- Final Train Perplexity: 20.95
Code
The code for tensor product attn is available at: https://github.com/tensorgi/T6.

# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Blackroot/TensorProduct-Microllama")