Instructions to use webAI-Official/TwIL-LM with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use webAI-Official/TwIL-LM with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="webAI-Official/TwIL-LM") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("webAI-Official/TwIL-LM") model = AutoModelForCausalLM.from_pretrained("webAI-Official/TwIL-LM", 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=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use webAI-Official/TwIL-LM with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf webAI-Official/TwIL-LM:Q4_K_M # Run inference directly in the terminal: llama cli -hf webAI-Official/TwIL-LM:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf webAI-Official/TwIL-LM:Q4_K_M # Run inference directly in the terminal: llama cli -hf webAI-Official/TwIL-LM:Q4_K_M
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf webAI-Official/TwIL-LM:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf webAI-Official/TwIL-LM:Q4_K_M
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf webAI-Official/TwIL-LM:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf webAI-Official/TwIL-LM:Q4_K_M
Use Docker
docker model run hf.co/webAI-Official/TwIL-LM:Q4_K_M
- LM Studio
- Jan
- vLLM
How to use webAI-Official/TwIL-LM with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "webAI-Official/TwIL-LM" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "webAI-Official/TwIL-LM", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/webAI-Official/TwIL-LM:Q4_K_M
- SGLang
How to use webAI-Official/TwIL-LM 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 "webAI-Official/TwIL-LM" \ --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": "webAI-Official/TwIL-LM", "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 "webAI-Official/TwIL-LM" \ --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": "webAI-Official/TwIL-LM", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Ollama
How to use webAI-Official/TwIL-LM with Ollama:
ollama run hf.co/webAI-Official/TwIL-LM:Q4_K_M
- Unsloth Studio
How to use webAI-Official/TwIL-LM with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for webAI-Official/TwIL-LM to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for webAI-Official/TwIL-LM to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for webAI-Official/TwIL-LM to start chatting
- Docker Model Runner
How to use webAI-Official/TwIL-LM with Docker Model Runner:
docker model run hf.co/webAI-Official/TwIL-LM:Q4_K_M
- Lemonade
How to use webAI-Official/TwIL-LM with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull webAI-Official/TwIL-LM:Q4_K_M
Run and chat with the model
lemonade run user.TwIL-LM-Q4_K_M
List all available models
lemonade list
- Atomic Chat
# Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("webAI-Official/TwIL-LM")
model = AutoModelForCausalLM.from_pretrained("webAI-Official/TwIL-LM", 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=40)
print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:]))TwIL-LM2
A 1.7B reasoning model for formal logic tasks, built from
HuggingFaceTB/SmolLM2-1.7B-Instruct
through LoRA supervised fine-tuning, checkpoint fusion, WiSE-FT weight interpolation, and
entropy-weighted GRPO reinforcement learning.
It raises in-domain formal-logic performance by +49% relative over its base model (macro gate 0.263 โ 0.393) while holding held-out general capability roughly flat.
Its larger sibling, TwIL-LM3 (3B, from SmolLM3), trades a smaller in-domain gain for strictly better held-out retention. If you care about not regressing on general benchmarks, prefer that one.
Results
Track A โ in-domain formal logic
The macro gate is the mean of five objective scores: entailment labelling, multiple-choice
answering, procedural reasoning, Lean proof critique, and rule induction (scored by its
continuous derivation score). MCQ and procedural are credited as max(exact_match, loose_match).
n = 200 prompts per objective, greedy decoding, 2048 max new tokens.
| objective | SmolLM2-1.7B-Instruct | TwIL-LM2 | ฮ |
|---|---|---|---|
| entailment_label | 0.245 | 0.585 | +0.340 |
| rule_induction | 0.135 | 0.514 | +0.379 |
| lean_critic | 0.490 | 0.525 | +0.035 |
| mcq_answer | 0.290 | 0.270 | โ0.020 |
| procedural | 0.155 | 0.070 | โ0.085 |
| macro gate | 0.2630 | 0.3927 | +0.1297 |
The gain is concentrated in entailment labelling and rule induction. MCQ answering and procedural reasoning regressed, and that is not hidden by the macro โ it is averaged into the number above.
Track B โ held-out benchmarks
Nothing in this suite was trained on. Scores are re-derived from saved generations with delimiter-aware answer extractors rather than read from harness metrics.
| SmolLM2-1.7B-Instruct | TwIL-LM2 | ฮ | |
|---|---|---|---|
| core average | 0.499 | 0.508 | +0.009 |
| suite average (14 datasets) | 0.384 | 0.374 | โ0.010 |
Per-dataset, largest moves in each direction:
| dataset | base | TwIL-LM2 | ฮ |
|---|---|---|---|
| GSM-Symbolic | 0.220 | 0.260 | +0.040 |
| CommonsenseQA | 0.397 | 0.433 | +0.037 |
| LogicBench BQA | 0.507 | 0.540 | +0.033 |
| MATH-500 | 0.190 | 0.210 | +0.020 |
| IFEval (strict) | 0.470 | 0.430 | โ0.040 |
| SVAMP | 0.487 | 0.383 | โ0.103 |
| MuSR | 0.422 | 0.313 | โ0.109 |
This model does not pass a no-regression bar on held-out tasks. MuSR and SVAMP lose about ten points each. The suite average is slightly negative. The honest summary is that in-domain logic improves substantially and general capability is approximately preserved on average, with real losses on multi-step narrative and word-problem reasoning.
Usage
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "webAI-Official/TwIL-LM"
tok = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id, torch_dtype=torch.bfloat16, device_map="auto"
)
messages = [{"role": "user", "content":
"Does 'All dogs are mammals. Rex is a dog.' entail 'Rex is a mammal'? "
"Answer entailment, contradiction, or neutral."}]
inputs = tok.apply_chat_template(
messages, add_generation_prompt=True,
return_tensors="pt", return_dict=True,
).to(model.device)
out = model.generate(**inputs, max_new_tokens=2048, do_sample=False)
print(tok.decode(out[0][inputs["input_ids"].shape[-1]:], skip_special_tokens=True))
return_dict=True matters on transformers 5.x, where apply_chat_template returns a
BatchEncoding rather than a bare tensor; the above works on both 4.x and 5.x.
The model was trained and evaluated with greedy decoding (do_sample=False) and a
2048-token generation budget. It usually opens a <think>...</think> reasoning block before
answering, so give it room โ the reported numbers assume at least 2048 new tokens, and a shorter
budget truncates reasoning and scores far worse.
Limitations and caveats
Truncation. At a 2048-token budget, 6.9% of Track A generations hit the cap (down from
11.7% for the base). Our protocol marks a comparison rankable only below 2% truncation, so
both the base and this model are formally not rankable on Track A and the macro gate should
be read as indicative rather than exact. A truncated response scores zero regardless of whether
its reasoning was sound, so both numbers are pessimistic โ the base more so.
Scope. Tuned for formal logic. The Track B suite does not cover code generation or tool use (HumanEval, LiveCodeBench and BFCL were not run for this model or its base), so this release makes no claim about those.
Not a chat model. It was optimised against automatic verifiers on logic tasks. It has had no safety tuning beyond whatever the base model carries, and no instruction-following alignment work โ IFEval in fact regressed.
Failed consolidation stage. A post-RL self-distillation round (SDFT) was attempted to recover
held-out capability and made both tracks worse at every budget tried. It is not part of this
model. See the accompanying SDFT_RESULT.md in the project repository.
Evaluation protocol
- Track A:
n = 200per objective, greedy (temperature = 0),max_new_tokens = 2048, one retry at 4096 for truncated rows,max_seq_len = 8192, seed 42. - Track B: 300 examples per task, greedy,
max_gen_toks = 4096,max_model_len = 8192,repetition_penalty = 1.0, chat template applied, vLLM backend. - Both tracks use the same protocol for the model and its base, in a paired run over identical sampled rows.
repetition_penalty = 1.0 is load-bearing. A 1.1 penalty produced apparent 20-point swings on
Track B that were pure decoding artefact; the decoding kwargs are hashed into the protocol
identity so a mismatched runner fails loudly instead of quietly producing a different number.
Relationship to prior releases
main holds TwIL-LM2: a full merged model from later in the pipeline โ after fusion,
WiSE-FT interpolation and MGPO reinforcement learning โ so it is loaded directly with
AutoModelForCausalLM, with no adapter and no base checkpoint required.
The original TwIL-LM (v1) release โ a PEFT LoRA adapter plus GGUF builds for the supervised
fine-tuning stage only โ is archived on the TwIL-LM1
branch (and matching tag). Load it with revision="TwIL-LM1".
The two are scored on different protocols and their headline numbers are not directly comparable: v1 reports a macro-primary average, while this card reports the five-component macro gate described above.
License and attribution
Released under the webAI Non-Commercial License ver. 1.0 โ see LICENSE.md in this
repository.
The base model,
HuggingFaceTB/SmolLM2-1.7B-Instruct,
is Apache 2.0; its licence text is retained as apache-2.0-LICENSE.txt and all credit for the
base model goes to the HuggingFaceTB team. Apache 2.0 permits distributing derivative works
under different terms provided attribution is preserved, which is what the pair of licence files
in this repository does.
- Downloads last month
- 519
Model tree for webAI-Official/TwIL-LM
Base model
HuggingFaceTB/SmolLM2-1.7B
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="webAI-Official/TwIL-LM") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)