Instructions to use mrtineu/thinkingcap-test-submission with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use mrtineu/thinkingcap-test-submission with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="mrtineu/thinkingcap-test-submission") 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("mrtineu/thinkingcap-test-submission") model = AutoModelForCausalLM.from_pretrained("mrtineu/thinkingcap-test-submission", 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 mrtineu/thinkingcap-test-submission with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "mrtineu/thinkingcap-test-submission" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "mrtineu/thinkingcap-test-submission", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/mrtineu/thinkingcap-test-submission
- SGLang
How to use mrtineu/thinkingcap-test-submission 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 "mrtineu/thinkingcap-test-submission" \ --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": "mrtineu/thinkingcap-test-submission", "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 "mrtineu/thinkingcap-test-submission" \ --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": "mrtineu/thinkingcap-test-submission", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use mrtineu/thinkingcap-test-submission with Docker Model Runner:
docker model run hf.co/mrtineu/thinkingcap-test-submission
File size: 2,796 Bytes
6361ca2 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | from fractions import Fraction
from types import SimpleNamespace
import torch
from torch import nn
from common import ReasoningMLP,attach_adapter,extract_answer,numeric,score_tokens,summarize
def test_final_answer_only():
assert extract_answer('I think 8') is None
assert extract_answer('8</think>We used 8 operations.') is None
assert extract_answer('wrong 99</think>\\boxed{42}')==42
assert extract_answer('</think>\\boxed{\\frac{3}{2}}')==Fraction(3,2)
assert numeric('1,234.50')==Fraction(2469,2)
def test_adapter_identity_and_gradient_flow():
class Toy(nn.Module):
def __init__(self):
super().__init__()
self.config=SimpleNamespace(hidden_size=8)
self.model=nn.Module();self.model.layers=nn.ModuleList([nn.Linear(8,8),nn.Linear(8,8)])
@property
def device(self):return next(self.parameters()).device
def forward(self,x):
for layer in self.model.layers:x=layer(x)
return x
torch.manual_seed(1);model=Toy();x=torch.randn(2,8)
original={n:p.detach().clone() for n,p in model.named_parameters()}
with torch.no_grad():expected=model(x)
adapter,handle=attach_adapter(model,0,3)
assert torch.equal(model(x),expected)
optimizer=torch.optim.AdamW(adapter.parameters(),lr=.01)
for _ in range(2):
optimizer.zero_grad();model(x).square().mean().backward();optimizer.step()
assert adapter.up.weight.grad is not None and adapter.up.weight.grad.abs().sum()>0
assert adapter.down.weight.grad is not None and adapter.down.weight.grad.abs().sum()>0
assert not torch.equal(model(x),expected)
for name,p in model.named_parameters():
if name in original:
assert torch.equal(p,original[name])
assert p.grad is None
handle.remove()
assert torch.equal(model(x),expected)
def test_truncation_cannot_count_as_correct():
class Tokenizer:
eos_token_id=9
def convert_tokens_to_ids(self,x):return {'</think>':3,'<|im_end|>':9}[x]
def decode(self,ids,**kwargs):return 'reason</think>\\boxed{42}'
t=Tokenizer()
assert not score_tokens([1,3,4],t,'42',3)['correct']
result=score_tokens([1,3,4,9,9],t,'42',3)
assert result['correct'] and result['thinking_tokens']==1 and result['final_tokens']==1
def test_compute_metrics_include_first_and_final_attempts():
common=dict(correct=True,thinking_closed=True,thinking_tokens=2,total_tokens=4,
truncated=False,finished=True,parsed_answer='42',seconds=3)
rows=[{**common,'initial_attempt':{'seconds':2}},
{**common,'total_compute_seconds':7,'initial_attempt':{'seconds':4}}]
metrics=summarize(rows)
assert metrics['total_compute_seconds']==12
assert metrics['mean_seconds']==3
|