Text Generation
Transformers
Safetensors
English
llama
small-language-model
efficient
edge-deployment
speculative-decoding
150m-parameters
tpu-trained
research
low-resource
portimbria
gqa
fineweb
conversational
Eval Results (legacy)
text-generation-inference
Instructions to use StentorLabs/Portimbria-150M with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use StentorLabs/Portimbria-150M with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="StentorLabs/Portimbria-150M") 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/Portimbria-150M") model = AutoModelForCausalLM.from_pretrained("StentorLabs/Portimbria-150M", 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/Portimbria-150M with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "StentorLabs/Portimbria-150M" # 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/Portimbria-150M", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/StentorLabs/Portimbria-150M
- SGLang
How to use StentorLabs/Portimbria-150M 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/Portimbria-150M" \ --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/Portimbria-150M", "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/Portimbria-150M" \ --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/Portimbria-150M", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use StentorLabs/Portimbria-150M with Docker Model Runner:
docker model run hf.co/StentorLabs/Portimbria-150M
Update README.md
Browse files
README.md
CHANGED
|
@@ -707,45 +707,141 @@ The table below compares Portimbria-150M against models of similar scale using p
|
|
| 707 |
|
| 708 |
### Evaluation Setup (for Portimbria-150M)
|
| 709 |
|
| 710 |
-
|
| 711 |
|
| 712 |
```python
|
| 713 |
-
import os
|
| 714 |
-
|
| 715 |
-
|
| 716 |
-
|
| 717 |
-
|
| 718 |
-
|
| 719 |
-
|
| 720 |
-
os.environ["
|
| 721 |
-
|
| 722 |
-
|
| 723 |
-
|
| 724 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 725 |
```
|
| 726 |
|
| 727 |
-
**
|
| 728 |
|
| 729 |
-
|
| 730 |
-
|
| 731 |
-
|
| 732 |
-
|
| 733 |
-
|
| 734 |
-
|
| 735 |
-
|
| 736 |
-
``
|
| 737 |
-
|
| 738 |
-
|
| 739 |
-
|
| 740 |
-
``
|
| 741 |
-
|
| 742 |
-
--model hf \
|
| 743 |
-
--model_args pretrained=StentorLabs/Portimbria-150M,dtype=float16,trust_remote_code=True \
|
| 744 |
-
--tasks gsm8k \
|
| 745 |
-
--num_fewshot 5 \
|
| 746 |
-
--batch_size auto \
|
| 747 |
-
--output_path ./portimbria_gsm8k_results
|
| 748 |
-
```
|
| 749 |
|
| 750 |
---
|
| 751 |
|
|
|
|
| 707 |
|
| 708 |
### Evaluation Setup (for Portimbria-150M)
|
| 709 |
|
| 710 |
+
Benchmarks were run on Kaggle with 2× Tesla T4 GPUs using the script below. No API token is required — the model is public. Each benchmark block runs independently so a single failure never stops the rest.
|
| 711 |
|
| 712 |
```python
|
| 713 |
+
import os, time, subprocess, sys, json
|
| 714 |
+
from pathlib import Path
|
| 715 |
+
|
| 716 |
+
os.environ["WANDB_DISABLED"] = "true"
|
| 717 |
+
os.environ["NCCL_P2P_DISABLE"] = "1"
|
| 718 |
+
os.environ["NCCL_IB_DISABLE"] = "1"
|
| 719 |
+
os.environ["TOKENIZERS_PARALLELISM"] = "false"
|
| 720 |
+
os.environ["CUDA_LAUNCH_BLOCKING"] = "0"
|
| 721 |
+
|
| 722 |
+
subprocess.run([sys.executable, "-m", "pip", "install", "-q", "-U", "accelerate", "transformers"], check=True)
|
| 723 |
+
subprocess.run([sys.executable, "-m", "pip", "install", "-q", "-U",
|
| 724 |
+
"git+https://github.com/EleutherAI/lm-evaluation-harness.git"], check=True)
|
| 725 |
+
|
| 726 |
+
MODEL = "StentorLabs/Portimbria-150M"
|
| 727 |
+
DTYPE = "float16"
|
| 728 |
+
BATCH = "auto:64"
|
| 729 |
+
SEED = 42
|
| 730 |
+
GEN_GREEDY = "temperature=0,do_sample=False,max_new_tokens=1024"
|
| 731 |
+
OUT = "./results"
|
| 732 |
+
MODEL_ARGS = f"pretrained={MODEL},dtype={DTYPE},trust_remote_code=True"
|
| 733 |
+
NUM_PROCS = 2
|
| 734 |
+
|
| 735 |
+
LAUNCH_BASE = [
|
| 736 |
+
"accelerate", "launch",
|
| 737 |
+
"--multi_gpu", f"--num_processes={NUM_PROCS}",
|
| 738 |
+
"-m", "lm_eval",
|
| 739 |
+
"--model", "hf",
|
| 740 |
+
"--model_args", MODEL_ARGS,
|
| 741 |
+
"--batch_size", BATCH,
|
| 742 |
+
"--seed", str(SEED),
|
| 743 |
+
"--log_samples",
|
| 744 |
+
"--show_config",
|
| 745 |
+
"--cache_requests", "true",
|
| 746 |
+
]
|
| 747 |
+
|
| 748 |
+
results_summary = {}
|
| 749 |
+
|
| 750 |
+
def banner(n, total, title, note=""):
|
| 751 |
+
print(f"\n{'='*60}")
|
| 752 |
+
print(f" BLOCK {n}/{total} — {title}")
|
| 753 |
+
if note:
|
| 754 |
+
print(f" {note}")
|
| 755 |
+
print(f"{'='*60}\n")
|
| 756 |
+
|
| 757 |
+
def run_block(block_name, n, total, title, note, tasks, num_fewshot,
|
| 758 |
+
output_subdir, extra_args=None):
|
| 759 |
+
banner(n, total, title, note)
|
| 760 |
+
t0 = time.time()
|
| 761 |
+
cmd = LAUNCH_BASE + [
|
| 762 |
+
"--tasks", tasks,
|
| 763 |
+
"--num_fewshot", str(num_fewshot),
|
| 764 |
+
"--output_path", f"{OUT}/{output_subdir}",
|
| 765 |
+
]
|
| 766 |
+
if extra_args:
|
| 767 |
+
cmd += extra_args
|
| 768 |
+
try:
|
| 769 |
+
subprocess.run(cmd, check=True, text=True)
|
| 770 |
+
elapsed = (time.time() - t0) / 60
|
| 771 |
+
print(f"\n ✅ {block_name} done in {elapsed:.1f} min")
|
| 772 |
+
results_summary[block_name] = {"status": "ok", "elapsed_min": round(elapsed, 1)}
|
| 773 |
+
return True
|
| 774 |
+
except subprocess.CalledProcessError as e:
|
| 775 |
+
elapsed = (time.time() - t0) / 60
|
| 776 |
+
print(f"\n ❌ {block_name} FAILED (exit code {e.returncode}) after {elapsed:.1f} min")
|
| 777 |
+
print(f" Re-run command:\n {' '.join(cmd)}\n")
|
| 778 |
+
results_summary[block_name] = {
|
| 779 |
+
"status": "failed", "exit_code": e.returncode,
|
| 780 |
+
"elapsed_min": round(elapsed, 1), "rerun_cmd": " ".join(cmd),
|
| 781 |
+
}
|
| 782 |
+
return False
|
| 783 |
+
except Exception as exc:
|
| 784 |
+
elapsed = (time.time() - t0) / 60
|
| 785 |
+
results_summary[block_name] = {"status": "failed", "error": str(exc), "elapsed_min": round(elapsed, 1)}
|
| 786 |
+
return False
|
| 787 |
+
|
| 788 |
+
Path(OUT).mkdir(parents=True, exist_ok=True)
|
| 789 |
+
|
| 790 |
+
run_block("block1_0shot", 1, 7, "0-shot", "PIQA · OpenBookQA · TruthfulQA",
|
| 791 |
+
tasks="piqa,openbookqa,truthfulqa_mc2", num_fewshot=0, output_subdir="block1_0shot")
|
| 792 |
+
run_block("block2_5shot", 2, 7, "5-shot", "Winogrande · CommonsenseQA",
|
| 793 |
+
tasks="winogrande,commonsense_qa", num_fewshot=5, output_subdir="block2_5shot")
|
| 794 |
+
run_block("block3_10shot", 3, 7, "10-shot", "HellaSwag",
|
| 795 |
+
tasks="hellaswag", num_fewshot=10, output_subdir="block3_10shot")
|
| 796 |
+
run_block("block4_25shot", 4, 7, "25-shot", "ARC-Easy · ARC-Challenge",
|
| 797 |
+
tasks="arc_easy,arc_challenge", num_fewshot=25, output_subdir="block4_25shot")
|
| 798 |
+
run_block("block5_mmlu", 5, 7, "5-shot", "MMLU — 57 subtask aggregate",
|
| 799 |
+
tasks="mmlu", num_fewshot=5, output_subdir="block5_mmlu")
|
| 800 |
+
run_block("block6_triviaqa", 6, 7, "5-shot greedy", "TriviaQA",
|
| 801 |
+
tasks="triviaqa", num_fewshot=5, output_subdir="block6_triviaqa",
|
| 802 |
+
extra_args=["--gen_kwargs", GEN_GREEDY])
|
| 803 |
+
run_block("block7_gsm8k", 7, 7, "5-shot CoT greedy", "GSM8K",
|
| 804 |
+
tasks="gsm8k_cot", num_fewshot=5, output_subdir="block7_gsm8k",
|
| 805 |
+
extra_args=["--gen_kwargs", GEN_GREEDY])
|
| 806 |
+
|
| 807 |
+
passed = [k for k, v in results_summary.items() if v["status"] == "ok"]
|
| 808 |
+
failed = [k for k, v in results_summary.items() if v["status"] == "failed"]
|
| 809 |
+
|
| 810 |
+
print(f"\n{'='*60}\n ALL BLOCKS ATTEMPTED — {len(passed)}/7 succeeded\n{'='*60}")
|
| 811 |
+
for block, info in results_summary.items():
|
| 812 |
+
icon = "✅" if info["status"] == "ok" else "❌"
|
| 813 |
+
print(f" {icon} {block:<22} {info.get('elapsed_min', '—')} min")
|
| 814 |
+
|
| 815 |
+
if failed:
|
| 816 |
+
print(f"\n Failed blocks:")
|
| 817 |
+
for f in failed:
|
| 818 |
+
info = results_summary[f]
|
| 819 |
+
print(f" • {f}")
|
| 820 |
+
if "rerun_cmd" in info:
|
| 821 |
+
print(f" {info['rerun_cmd']}")
|
| 822 |
+
|
| 823 |
+
with open(f"{OUT}/run_summary.json", "w") as fh:
|
| 824 |
+
json.dump(results_summary, fh, indent=2)
|
| 825 |
+
|
| 826 |
+
if failed:
|
| 827 |
+
sys.exit(1)
|
| 828 |
```
|
| 829 |
|
| 830 |
+
**Metrics to report per task:**
|
| 831 |
|
| 832 |
+
| Task | Metric |
|
| 833 |
+
|---|---|
|
| 834 |
+
| PIQA | `acc_norm` |
|
| 835 |
+
| OpenBookQA | `acc_norm` |
|
| 836 |
+
| TruthfulQA | `mc2` |
|
| 837 |
+
| Winogrande | `acc` |
|
| 838 |
+
| CommonsenseQA | `acc` |
|
| 839 |
+
| HellaSwag | `acc_norm` |
|
| 840 |
+
| ARC-Easy | `acc_norm` |
|
| 841 |
+
| ARC-Challenge | `acc_norm` |
|
| 842 |
+
| MMLU | `acc` |
|
| 843 |
+
| TriviaQA | `exact_match` |
|
| 844 |
+
| GSM8K | `exact_match` |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 845 |
|
| 846 |
---
|
| 847 |
|