Text Generation
Transformers
Safetensors
English
llama
small-language-model
efficient
edge-deployment
speculative-decoding
30m-parameters
kaggle-trained
educational
research
low-resource
cpu-inference
mobile-deployment
stentor2
tokenmonster
conversational
Eval Results (legacy)
text-generation-inference
Run this model with HF Jobs
Run StentorLabs/Stentor2-30M on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs and TRL to fine-tune https://huggingface.co/StentorLabs/Stentor2-30M. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/StentorLabs/Stentor2-30M on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Evaluate on a benchmark
Use HF Jobs to evaluate https://huggingface.co/StentorLabs/Stentor2-30M. Ask me which benchmark to run, then save the scores and the per-example results to a new dataset repo. Run `hf jobs --help` first to learn the CLI.
Quantize for lower memory use
Use HF Jobs to create a 4-bit version of https://huggingface.co/StentorLabs/Stentor2-30M. Push it to a new model repo, then reload it from there and report its memory footprint. Run `hf jobs --help` first to learn the CLI.
Instructions to use StentorLabs/Stentor2-30M with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use StentorLabs/Stentor2-30M with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="StentorLabs/Stentor2-30M") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("StentorLabs/Stentor2-30M") model = AutoModelForCausalLM.from_pretrained("StentorLabs/Stentor2-30M", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use StentorLabs/Stentor2-30M with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "StentorLabs/Stentor2-30M" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "StentorLabs/Stentor2-30M", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/StentorLabs/Stentor2-30M
- SGLang
How to use StentorLabs/Stentor2-30M 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 "StentorLabs/Stentor2-30M" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "StentorLabs/Stentor2-30M", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'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 "StentorLabs/Stentor2-30M" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "StentorLabs/Stentor2-30M", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use StentorLabs/Stentor2-30M with Docker Model Runner:
docker model run hf.co/StentorLabs/Stentor2-30M
Update README.md
Browse files83 unmodified lines84858687888990919293949596979899100101102103104105100 unmodified lines2062072082092102112122132146 unmodified lines2212222232242252262272282292302312322332346 unmodified lines2412422432442452462474 unmodified lines2522532542552562572582592602612622632642652662672683 unmodified lines272273274275276277278279280534 unmodified lines8158168178188198208214 unmodified lines82682782882983083183221 unmodified lines85485585685785885986086186286386486586686783 unmodified lines4. [Quick Start](#quick-start)5. [Important Limitations](#important-limitations)6. [Honest Notices](#-honest-notices)7. [PDF Tokens & The Replacement Character](#pdf-tokens--the-replacement-character)8. [Model Architecture β Full Specification](#model-architecture--full-specification)9. [The Tokenizer: TokenMonster](#the-tokenizer-tokenmonster)10. [Training Infrastructure](#training-infrastructure)11. [Training Hyperparameters β Complete Reference](#training-hyperparameters--complete-reference)12. [The T4 Mixed-Precision Recipe β Deep Dive](#the-t4-mixed-precision-recipe--deep-dive)13. [Data Pipeline](#data-pipeline)14. [Weight Initialization](#weight-initialization)15. [Evaluation & Results](#evaluation--results)16. [Training Dynamics](#training-dynamics)17. [Use Cases & Intended Uses](#use-cases--intended-uses)18. [Out-of-Scope Uses](#out-of-scope-uses)19. [Ethical Considerations & Societal Impact](#ethical-considerations--societal-impact)20. [Inference Guide](#inference-guide)21. [Free Inference β Try It Now](#-free-inference--try-it-now)22. [Real Model Responses](#real-model-responses)23. [Quantization](#quantization)24. [Format Conversion](#format-conversion)25. [Speculative Decoding](#speculative-decoding)100 unmodified linesattention_mask=attention_mask,max_new_tokens=80,do_sample=True,temperature=1.1,top_p=0.55,repetition_penalty=1.15,pad_token_id=tokenizer.pad_token_id,)6 unmodified lines| Parameter | Recommended Range | Personal Favorite | Notes ||---|---|---|---|| `temperature` | 0.6 β 0.9 | **0.8** | Below 0.6 causes heavy `<22>` (PDF token) output; above 0.9 gets chaotic || `top_p` | 0.6 β 0.8 | **0.7** | Below 0.6 also increases `<22>` tokens significantly || `repetition_penalty` | 1.1 β 1.4 | **1.2** | Without this the model will loop; 1.2β1.3 hits the sweet spot || `max_new_tokens` | 10 β 500 | β | Model stays mostly on topic but may drift at longer lengths |> β οΈ **Always use `repetition_penalty β₯ 1.1`.** Without it, this model will fall into repetitive loops.> β οΈ **Keep temperature and top_p above 0.6.** Going below this threshold causes the model to lean heavily on PDF-derived tokens that render as `<22>`. See [PDF Tokens](#pdf-tokens--the-replacement-character) for details.---6 unmodified lines- **English Only:** The TokenMonster vocabulary is English-specific.- **TokenMonster Required:** Uses a TokenMonster adapter. Make sure `tokenmonster` is installed (`pip install tokenmonster`). Standard `AutoModelForCausalLM` works β but the tokenmonster package is still required for the tokenizer.- **PDF Tokens (`<22>`):** The model was trained on data containing PDF-extracted text, and will sometimes generate tokens that render as `<22>` (the Unicode replacement character). See the [PDF Tokens](#pdf-tokens--the-replacement-character) section below.- **Repetition Without Penalty:** Without `repetition_penalty`, the model will fall into loops. Always use `repetition_penalty β₯ 1.1`.- **Shared Tensor Warning:** When saving or loading, you may see: `Removed shared tensor {'lm_head.weight'} while saving`. This is expected from tied word embeddings and is safe to ignore.---4 unmodified lines1. **Noticeably more coherent than Stentor-30M (v1).** With the same parameter count but a far more efficient vocabulary allocation and 800M training tokens, output quality is a clear step up.2. **Generates PDF tokens (`<22>`).** The model will sometimes output tokens that display as `<22>` β the Unicode replacement character. These are valid tokens from PDF-extracted training data. They are not a decoding error. See [PDF Tokens](#pdf-tokens--the-replacement-character) for details.3. **Prone to repetition without `repetition_penalty`.** Left unchecked, the model loops. With `repetition_penalty` set to 1.1β1.4, output quality is mostly stable.4. **No custom model loader required. π** This model loads with standard `AutoModelForCausalLM.from_pretrained()`. No special loading code needed.5. **You still need to install `tokenmonster`.** The tokenizer wraps TokenMonster and requires `pip install tokenmonster`. It's a one-line install, but it is a required dependency.6. **The model talks about education and academics β a lot.** Trained on FineWeb-HQ (a high-quality filtered web corpus with significant PDF and educational content) and StenCore (100% PDFs), the model has a strong prior toward academic language, school systems, curriculum, research, and formal writing.7. **This model will usually stop on its own.** Like Stentor2-12M, this model tends to emit an EOS token and halt before hitting `max_new_tokens`. The exact stopping point varies widely. It's still recommended to set a generous ceiling (e.g. `max_new_tokens=1000`) as a safety net.---3 unmodified linesAs a result, the model has learned to generate these tokens β and will do so, especially at lower temperatures or lower top-p values. When decoded, they render as **`<22>`** (U+FFFD, the Unicode replacement character), because most systems substitute this symbol for unrepresentable byte sequences.**How to reduce it:** Keep `temperature β₯ 0.6` and `top_p β₯ 0.6`. Below these thresholds, PDF token probability rises sharply. At well-tuned settings (temp 0.8, top_p 0.7), `<22>` tokens appear occasionally but do not dominate output.**This is not a bug.** Most language models are trained on clean text and never encounter these sequences. Stentor2-30M is unusual in that it can generate them β a side effect of training on real-world PDF-extracted data.---534 unmodified linestokenizer = AutoTokenizer.from_pretrained("StentorLabs/Stentor2-30M", trust_remote_code=True)model = model.to("cuda").eval()def generate(prompt, max_new_tokens=50, temperature=0.9, top_p=0.65):input_ids = torch.tensor([tokenizer.encode(prompt)], dtype=torch.long).to(model.device)attention_mask = torch.ones_like(input_ids)with torch.inference_mode():4 unmodified linesdo_sample=True,temperature=temperature,top_p=top_p,repetition_penalty=1.15,pad_token_id=tokenizer.pad_token_id,)new_ids = output[0][input_ids.shape[1]:].tolist()21 unmodified lines---## Real Model Responses> π **Sample outputs will be added shortly** once initial generation runs are complete. In the meantime, you can try the model yourself at the [free inference demo](https://huggingface.co/spaces/StentorLabs/StentorLabs-demo_space) or load it locally using the [Quick Start](#quick-start) guide above.>> For reference on what typical Stentor2 behavior looks like β including the academic register bias and PDF token artifacts β see the [Stentor2-12M model card](https://huggingface.co/StentorLabs/Stentor2-12M).---## Quantization### FP1683 unmodified lines84858687888990919293949596979899100101102103104105100 unmodified lines2062072082092102112122132146 unmodified lines2212222232242252262272282292302312322332346 unmodified lines2412422432442452462474 unmodified lines2522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413 unmodified lines345346347348349350351352353534 unmodified lines8888898908918928938944 unmodified lines89990090190290390490521 unmodified lines92792892993093193283 unmodified lines4. [Quick Start](#quick-start)5. [Important Limitations](#important-limitations)6. [Honest Notices](#-honest-notices)7. [Real Model Responses](#real-model-responses)8. [PDF Tokens & The Replacement Character](#pdf-tokens--the-replacement-character)9. [Model Architecture β Full Specification](#model-architecture--full-specification)10. [The Tokenizer: TokenMonster](#the-tokenizer-tokenmonster)11. [Training Infrastructure](#training-infrastructure)12. [Training Hyperparameters β Complete Reference](#training-hyperparameters--complete-reference)13. [The T4 Mixed-Precision Recipe β Deep Dive](#the-t4-mixed-precision-recipe--deep-dive)14. [Data Pipeline](#data-pipeline)15. [Weight Initialization](#weight-initialization)16. [Evaluation & Results](#evaluation--results)17. [Training Dynamics](#training-dynamics)18. [Use Cases & Intended Uses](#use-cases--intended-uses)19. [Out-of-Scope Uses](#out-of-scope-uses)20. [Ethical Considerations & Societal Impact](#ethical-considerations--societal-impact)21. [Inference Guide](#inference-guide)22. [Free Inference β Try It Now](#-free-inference--try-it-now)23. [Quantization](#quantization)24. [Format Conversion](#format-conversion)25. [Speculative Decoding](#speculative-decoding)100 unmodified linesattention_mask=attention_mask,max_new_tokens=80,do_sample=True,temperature=1.0,top_p=0.8,repetition_penalty=1.1,pad_token_id=tokenizer.pad_token_id,)6 unmodified lines| Parameter | Recommended Range | Personal Favorite | Notes ||---|---|---|---|| `temperature` | 0.6 β 1.0 | β | Although the model can handle up to 1.4 before output gets chaotic, lower temperatures keep it ever so slightly more on track with your prompt and subject matter || `top_p` | 0.6 β 0.85 | **0.8** | Going too low restricts the model's word choice and makes output plain or repetitive || `repetition_penalty` | 1.05 β 1.25 | **1.1** | Less prone to looping than 12M; 1.1 is the sweet spot || `max_new_tokens` | 10 β 500 | β | Model is highly coherent but rarely stays on topic; output remains readable throughout |> β οΈ **Always use `repetition_penalty β₯ 1.05`.** This model is less repetitive than Stentor2-12M but still benefits from a penalty. Values above 1.25 are generally unnecessary.> βΉοΈ **`<22>` token behavior is much improved.** Unlike Stentor2-12M, temperature and top_p have only minimal effect on PDF token frequency. Slightly lower values increase them marginally, but there is no hard lower threshold to worry about. `<22>` tokens are significantly rarer on this model overall.---6 unmodified lines- **English Only:** The TokenMonster vocabulary is English-specific.- **TokenMonster Required:** Uses a TokenMonster adapter. Make sure `tokenmonster` is installed (`pip install tokenmonster`). Standard `AutoModelForCausalLM` works β but the tokenmonster package is still required for the tokenizer.- **PDF Tokens (`<22>`):** The model was trained on data containing PDF-extracted text, and will sometimes generate tokens that render as `<22>` (the Unicode replacement character). See the [PDF Tokens](#pdf-tokens--the-replacement-character) section below.- **Repetition Without Penalty:** Without `repetition_penalty`, the model will fall into loops. Always use `repetition_penalty β₯ 1.05`.- **Shared Tensor Warning:** When saving or loading, you may see: `Removed shared tensor {'lm_head.weight'} while saving`. This is expected from tied word embeddings and is safe to ignore.---4 unmodified lines1. **Noticeably more coherent than Stentor-30M (v1).** With the same parameter count but a far more efficient vocabulary allocation and 800M training tokens, output quality is a clear step up.2. **Generates `<22>` PDF tokens much less often than Stentor2-12M.** This is likely because the model saw a higher ratio of clean web text relative to PDF-extracted content, and has also learned slightly better when it is and isn't appropriate to generate these tokens. They still appear, but are significantly rarer. See [PDF Tokens](#pdf-tokens--the-replacement-character) for details.3. **Less prone to repetition than Stentor2-12M, but still benefits from `repetition_penalty`.** A value of 1.05β1.25 covers the full useful range. The 12M needed up to 1.4; this model rarely needs more than 1.1β1.2.4. **Rarely stays on topic, but what it says is coherent and readable.** This model will frequently drift away from the subject of a prompt. However, what it does generate is grammatically sound, fluent, and readable β real words, real sentences, real structure.5. **Generates real words 99% of the time.** Unlike some smaller models, gibberish is extremely rare at any reasonable setting.6. **Temperature has less effect on output character than on the 12M.** The recommended range is 0.6β1.0. Although the model can handle up to 1.4 before output becomes chaotic, keeping temperature lower gives it a slightly better chance of staying adjacent to your prompt's subject matter. Too low still marginally increases `<22>` tokens, but nowhere near as severely as the 12M.7. **Top_p can safely go up to 0.85.** Previous Stentor models produced gibberish at higher top_p with high temperature. This model handles higher top_p much better. Going too low restricts the model's word choice and can make output plain or repetitive.8. **No custom model loader required. π** This model loads with standard `AutoModelForCausalLM.from_pretrained()`. No special loading code needed.9. **You still need to install `tokenmonster`.** The tokenizer wraps TokenMonster and requires `pip install tokenmonster`. It's a one-line install, but it is a required dependency.10. **Academic and educational framing is common, but less dominant than in Stentor2-12M.** Trained on FineWeb-HQ and StenCore (100% PDFs), the model has a prior toward academic language, school systems, curriculum, research, and formal writing. Prompts unrelated to education are still frequently redirected, though less often and less severely than with the 12M.11. **This model will usually stop on its own.** Like Stentor2-12M, this model tends to emit an EOS token and halt before hitting `max_new_tokens`. The exact stopping point varies widely. It's still recommended to set a generous ceiling (e.g. `max_new_tokens=1000`) as a safety net.---## Real Model ResponsesThe following are unfiltered outputs from Stentor2-30M. The first three are the very first generations run after settling on optimal settings (no cherry-picking), the fourth is a deliberately good prompt, and the fifth is a deliberately bad one.**Settings for all samples:** `top_p=0.8, repetition_penalty=1.1, temperature=1.0, max_new_tokens=45`---**Sample 1** β `Prompt: Climate change is````PDA's new MAP-based software program "Tools for PERFORMING" aims to help you make informeddecisions about your workplace. Our MAP-based system has```> Classic Stentor2 pivot β completely ignores the prompt and latches onto institutional/workplace language. No `<22>` tokens, no repetition, perfectly fluent non-sequitur.---**Sample 2** β `Prompt: The definition of biology is````How do animals make our lives so easy? What are they looking for? Do animals have their ears,noses or mouth? What is the job of animal owners? Does humans have their ears? How does this help```> Tangentially adjacent to biology (animals) but immediately derails into a chain of rhetorical questions. Grammatically fine, completely off-track β exactly typical Stentor2-30M behavior.---**Sample 3** β `Prompt: Research on Covid 19 shows````What can we do if we don't follow the CDC's guidelines for how to get help? We don't alwaysfollow the CDC's guidelines. We never give up on the recommendations or advice provided by our team.```> Marginally on-topic (CDC, guidelines), but flips from factual continuation into motivational framing instantly. Coherent prose, no artifacts.---**Sample 4 (Hand-Picked Good)** β `Prompt: About young children````Helping your child learn to read for pleasure is a valuable skill. To support your child'slearning, we recommend: * Ask them to read for pleasure to improve their reading skills by readingto them. Write in```> The closest to on-topic this model gets. Clean educational prose, correct grammar, sensible advice structure β this is what good Stentor2-30M output looks like.---**Sample 5 (Hand-Picked Bad)** β `Prompt: 1 + 1 =````Preparing for Success with WA State University - The College of Engineering & Technology(COE/HS) provides students with practical experience in the fields of science, engineering, andmathematics```> Given a pure arithmetic prompt, the model produces a university program description. Not a single digit generated. Illustrates the model's tendency to drift from topic β while still producing completely readable, artifact-free output.---3 unmodified linesAs a result, the model has learned to generate these tokens β and will do so, especially at lower temperatures or lower top-p values. When decoded, they render as **`<22>`** (U+FFFD, the Unicode replacement character), because most systems substitute this symbol for unrepresentable byte sequences.**How to reduce it:** Unlike Stentor2-12M, temperature and top_p have only a minimal effect on `<22>` token frequency for this model β slightly lower values produce marginally more of them, but there is no sharp threshold to worry about and no hard lower limit on either parameter. The primary improvement here is that `<22>` tokens are simply much rarer overall on this model, likely due to a higher ratio of clean web text in the training data and better learned context for when these tokens are appropriate.**This is not a bug.** Most language models are trained on clean text and never encounter these sequences. Stentor2-30M can generate them β a side effect of training on real-world PDF-extracted data β but does so far less aggressively than its smaller sibling.---534 unmodified linestokenizer = AutoTokenizer.from_pretrained("StentorLabs/Stentor2-30M", trust_remote_code=True)model = model.to("cuda").eval()def generate(prompt, max_new_tokens=50, temperature=1.0, top_p=0.8):input_ids = torch.tensor([tokenizer.encode(prompt)], dtype=torch.long).to(model.device)attention_mask = torch.ones_like(input_ids)with torch.inference_mode():4 unmodified linesdo_sample=True,temperature=temperature,top_p=top_p,repetition_penalty=1.1,pad_token_id=tokenizer.pad_token_id,)new_ids = output[0][input_ids.shape[1]:].tolist()21 unmodified lines---## Quantization### FP16
README.md+109-44