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
Download code/pilot/test_core.py from mrtineu/thinkingcap-test-submission: direct link, hf CLI and curl.
- Browser
- Download file 2.8 kB
-
https://huggingface.co/mrtineu/thinkingcap-test-submission/resolve/main/code/pilot/test_core.py
- Command line
-
hf download hf://mrtineu/thinkingcap-test-submission/code/pilot/test_core.py
-
curl -L -o test_core.py https://huggingface.co/mrtineu/thinkingcap-test-submission/resolve/main/code/pilot/test_core.py
2.8 kB
| 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)]) | |
| 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 | |