Text Generation
Transformers
Safetensors
GGUF
English
llama
formal-logic
reasoning
lora
model-merging
wise-ft
reinforcement-learning
grpo
smollm2
twil-lm
conversational
text-generation-inference
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
Update model card for TwIL-LM2 on main
Browse filesDrop obsolete TwIL-LM2 revision pins and the How it was built section; point the prior release at TwIL-LM1.
README.md
CHANGED
|
@@ -89,9 +89,9 @@ import torch
|
|
| 89 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 90 |
|
| 91 |
model_id = "webAI-Official/TwIL-LM"
|
| 92 |
-
tok = AutoTokenizer.from_pretrained(model_id
|
| 93 |
model = AutoModelForCausalLM.from_pretrained(
|
| 94 |
-
model_id,
|
| 95 |
)
|
| 96 |
|
| 97 |
messages = [{"role": "user", "content":
|
|
@@ -114,22 +114,6 @@ The model was trained and evaluated with **greedy decoding** (`do_sample=False`)
|
|
| 114 |
answering, so give it room — the reported numbers assume at least 2048 new tokens, and a shorter
|
| 115 |
budget truncates reasoning and scores far worse.
|
| 116 |
|
| 117 |
-
## How it was built
|
| 118 |
-
|
| 119 |
-
Four stages on top of the base model:
|
| 120 |
-
|
| 121 |
-
1. **LoRA supervised fine-tuning** on a synthetic formal-logic corpus covering the Track A
|
| 122 |
-
objectives (first-order-logic translation, entailment labelling, semantic parsing, Lean
|
| 123 |
-
formalisation and critique, procedural reasoning, rule induction).
|
| 124 |
-
2. **Checkpoint fusion** — parameter-space averaging of intermediate SFT checkpoints selected
|
| 125 |
-
by a diversity probe, rather than taking the final checkpoint.
|
| 126 |
-
3. **WiSE-FT interpolation** toward the pretrained base, `W = (1 − λ)·W_base + λ·W_finetuned`
|
| 127 |
-
with **λ = 0.75**. λ was chosen by constrained optimisation: maximise in-domain score
|
| 128 |
-
subject to minimal degradation on held-out benchmarks.
|
| 129 |
-
4. **MGPO** — entropy-weighted GRPO reinforcement learning against a programmatic verifier,
|
| 130 |
-
with partial credit for loose matches and token-F1 so that all-fail prompt groups still
|
| 131 |
-
produce gradient. Published checkpoint is **step 1680**.
|
| 132 |
-
|
| 133 |
## Limitations and caveats
|
| 134 |
|
| 135 |
**Truncation.** At a 2048-token budget, 6.9% of Track A generations hit the cap (down from
|
|
@@ -163,22 +147,24 @@ model. See the accompanying `SDFT_RESULT.md` in the project repository.
|
|
| 163 |
Track B that were pure decoding artefact; the decoding kwargs are hashed into the protocol
|
| 164 |
identity so a mismatched runner fails loudly instead of quietly producing a different number.
|
| 165 |
|
| 166 |
-
## Relationship to
|
|
|
|
|
|
|
|
|
|
|
|
|
| 167 |
|
| 168 |
-
The
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
reinforcement learning — so it is loaded directly with `AutoModelForCausalLM`, with no adapter
|
| 172 |
-
and no base checkpoint required.
|
| 173 |
|
| 174 |
The two are scored on different protocols and their headline numbers are not directly
|
| 175 |
-
comparable:
|
| 176 |
macro *gate* described above.
|
| 177 |
|
| 178 |
## License and attribution
|
| 179 |
|
| 180 |
Released under the **webAI Non-Commercial License ver. 1.0** — see `LICENSE.md` in this
|
| 181 |
-
repository.
|
| 182 |
|
| 183 |
The base model,
|
| 184 |
[`HuggingFaceTB/SmolLM2-1.7B-Instruct`](https://huggingface.co/HuggingFaceTB/SmolLM2-1.7B-Instruct),
|
|
|
|
| 89 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 90 |
|
| 91 |
model_id = "webAI-Official/TwIL-LM"
|
| 92 |
+
tok = AutoTokenizer.from_pretrained(model_id)
|
| 93 |
model = AutoModelForCausalLM.from_pretrained(
|
| 94 |
+
model_id, torch_dtype=torch.bfloat16, device_map="auto"
|
| 95 |
)
|
| 96 |
|
| 97 |
messages = [{"role": "user", "content":
|
|
|
|
| 114 |
answering, so give it room — the reported numbers assume at least 2048 new tokens, and a shorter
|
| 115 |
budget truncates reasoning and scores far worse.
|
| 116 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 117 |
## Limitations and caveats
|
| 118 |
|
| 119 |
**Truncation.** At a 2048-token budget, 6.9% of Track A generations hit the cap (down from
|
|
|
|
| 147 |
Track B that were pure decoding artefact; the decoding kwargs are hashed into the protocol
|
| 148 |
identity so a mismatched runner fails loudly instead of quietly producing a different number.
|
| 149 |
|
| 150 |
+
## Relationship to prior releases
|
| 151 |
+
|
| 152 |
+
`main` holds **TwIL-LM2**: a **full merged model** from later in the pipeline — after fusion,
|
| 153 |
+
WiSE-FT interpolation and MGPO reinforcement learning — so it is loaded directly with
|
| 154 |
+
`AutoModelForCausalLM`, with no adapter and no base checkpoint required.
|
| 155 |
|
| 156 |
+
The original TwIL-LM (v1) release — a PEFT **LoRA adapter** plus GGUF builds for the supervised
|
| 157 |
+
fine-tuning stage only — is archived on the [`TwIL-LM1`](https://huggingface.co/webAI-Official/TwIL-LM/tree/TwIL-LM1)
|
| 158 |
+
branch (and matching tag). Load it with `revision="TwIL-LM1"`.
|
|
|
|
|
|
|
| 159 |
|
| 160 |
The two are scored on different protocols and their headline numbers are not directly
|
| 161 |
+
comparable: v1 reports a macro-*primary* average, while this card reports the five-component
|
| 162 |
macro *gate* described above.
|
| 163 |
|
| 164 |
## License and attribution
|
| 165 |
|
| 166 |
Released under the **webAI Non-Commercial License ver. 1.0** — see `LICENSE.md` in this
|
| 167 |
+
repository.
|
| 168 |
|
| 169 |
The base model,
|
| 170 |
[`HuggingFaceTB/SmolLM2-1.7B-Instruct`](https://huggingface.co/HuggingFaceTB/SmolLM2-1.7B-Instruct),
|