Q-TensorFormer / site /documentation.html
Premchandyadav369
feat(seo): maximize discoverability, Google Scholar metadata, interactive HF widget, LLM crawler schemas, zero em dashes, and one-click quickstart downloads
5175adb
Raw History Blame Contribute Delete
6.41 kB
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Documentation, Setup &amp; API Reference - Q-TensorFormer</title>
<meta name="description" content="Complete documentation, installation guide, and API reference for Q-TensorFormer across PyTorch, Hugging Face, GGUF, and ONNX.">
<link rel="canonical" href="https://premchan369.github.io/Q-TensorFormer/documentation.html">
<meta property="og:type" content="article">
<meta property="og:site_name" content="Q-TensorFormer Research Project">
<meta property="og:title" content="Documentation, Setup &amp; API Reference - Q-TensorFormer">
<meta property="og:description" content="Turnkey installation, research API usage, and Hugging Face integration examples.">
<meta property="og:url" content="https://premchan369.github.io/Q-TensorFormer/documentation.html">
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "TechArticle",
"headline": "Q-TensorFormer API Reference and Usage Documentation",
"description": "Comprehensive guide for PyTorch research API, Hugging Face AutoModel integration, and deployment tools.",
"url": "https://premchan369.github.io/Q-TensorFormer/documentation.html",
"author": { "@type": "Person", "name": "Premchand Yadav" },
"datePublished": "2026-10-13"
}
</script>
<link rel="stylesheet" href="assets/style.css">
</head>
<body>
<header>
<div class="header-container">
<div class="logo">
<a href="index.html"><span>Q-TensorFormer</span> Research</a>
</div>
<nav>
<a href="index.html">Overview</a>
<a href="architecture.html">Architecture</a>
<a href="methodology.html">Methodology</a>
<a href="benchmarks.html">Benchmarks</a>
<a href="edge-inference.html">Edge Inference</a>
<a href="training.html">Training</a>
<a href="documentation.html" class="active">Docs & API</a>
<a href="research.html">Research</a>
<a href="limitations.html">Limitations</a>
<a href="contributing.html">Contributing</a>
</nav>
</div>
</header>
<main class="container">
<h1>Documentation &amp; API Reference</h1>
<p class="lead">
Q-TensorFormer provides two first-class API interfaces: the <strong>Research API</strong> in <code>src/</code> for closed-loop dynamic systems experiments, and the <strong>Hugging Face API</strong> for standard <code>AutoModelForCausalLM</code> pipelines.
</p>
<section>
<h2>1. Installation</h2>
<p>Clone the repository and install dependencies:</p>
<pre><code>git clone https://huggingface.co/Premchan369/Q-TensorFormer
cd Q-TensorFormer
pip install -r requirements.txt</code></pre>
<p>Dependencies: <code>torch >= 2.0.0</code>, <code>transformers >= 4.35.0</code>, <code>numpy >= 1.24.0</code>, <code>pytest >= 7.0.0</code>.</p>
</section>
<section>
<h2>2. PyTorch Research API (src/)</h2>
<p>Load the verified canonical checkpoint and perform inference:</p>
<pre><code>import torch
from src.checkpoint import load_canonical_checkpoint
from src.tokenizer import QTensorFormerTokenizer
# 1. Load canonical tokenizer
tokenizer = QTensorFormerTokenizer.load("checkpoints/tokenizer/tokenizer.json")
# 2. Load canonical checkpoint with strict verification
model, info = load_canonical_checkpoint(
"checkpoints/qtensorformer_canonical_trained.pt",
strict=True,
require_trained=True,
tokenizer=tokenizer
)
# 3. Tokenize input text
prompt = "Transformer attention"
input_ids = torch.tensor([tokenizer.encode(prompt, add_bos=True)])
# 4. Generate with KV cache and deterministic greedy decoding
output_ids = model.generate(
input_ids,
max_new_tokens=15,
do_sample=False,
use_cache=True,
eos_token_id=tokenizer.eos_token_id,
pad_token_id=tokenizer.pad_token_id
)
print("Decoded Output:", tokenizer.decode(output_ids[0]))</code></pre>
</section>
<section>
<h2>3. Hugging Face Transformers API</h2>
<p>Use Q-TensorFormer with the standard Hugging Face pipeline:</p>
<pre><code>from transformers import AutoConfig, AutoModelForCausalLM
# Load model from the canonical checkpoint directory
model_path = "checkpoints/hf_canonical_trained"
config = AutoConfig.from_pretrained(model_path, trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained(model_path, trust_remote_code=True)
# Generate using Hugging Face .generate()
import torch
prompt_ids = torch.tensor([[1, 25, 42, 10]])
generated = model.generate(prompt_ids, max_new_tokens=10, do_sample=False)
print("Generated Token IDs:", generated)</code></pre>
</section>
<section>
<h2>4. Deployment &amp; Export Tools</h2>
<div class="grid">
<div class="card">
<h3>GGUF v3 Binary Export</h3>
<p>Export the model to Ollama / llama.cpp compatible GGUF format:</p>
<pre><code>python qtensorformer_to_gguf.py \
--checkpoint checkpoints/qtensorformer_canonical_trained.pt \
--output qtensorformer.gguf \
--strict</code></pre>
</div>
<div class="card">
<h3>ONNX Graph Export</h3>
<p>Export Tensor-Train linear layers to ONNX for edge runtime acceleration:</p>
<pre><code>python export_onnx.py \
--output qtensorformer.onnx \
--batch_size 1 \
--seq_len 32</code></pre>
</div>
</div>
</section>
<section>
<h2>5. Running Unit Tests &amp; Smoke Tests</h2>
<p>Verify that your environment matches our benchmark findings:</p>
<pre><code># Run full pytest suite (94 passing tests)
pytest -v
# Run deterministic smoke test
python scripts/smoke_test.py</code></pre>
</section>
</main>
<footer>
<div class="footer-links">
<a href="index.html">Home</a>
<a href="architecture.html">Architecture</a>
<a href="methodology.html">Methodology</a>
<a href="benchmarks.html">Benchmarks</a>
<a href="documentation.html">Docs</a>
<a href="limitations.html">Limitations</a>
<a href="sitemap.xml">Sitemap</a>
<a href="llms.txt">llms.txt</a>
<a href="https://huggingface.co/Premchan369/Q-TensorFormer">Hugging Face</a>
</div>
<p>&copy; 2026 Premchand Yadav. Licensed under Apache-2.0.</p>
</footer>
</body>
</html>