Feature Extraction
Transformers
Safetensors
English
system_one
multi-task-classification
synthetic-data
research
custom-code
custom_code
Instructions to use DavidHatley/system-one-mini with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use DavidHatley/system-one-mini with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="DavidHatley/system-one-mini", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("DavidHatley/system-one-mini", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Download inference.py from DavidHatley/system-one-mini: direct link, hf CLI and curl.
- Browser
- Download file 1.48 kB
-
https://huggingface.co/DavidHatley/system-one-mini/resolve/main/inference.py
- Command line
-
hf download hf://DavidHatley/system-one-mini/inference.py
-
curl -L -o inference.py https://huggingface.co/DavidHatley/system-one-mini/resolve/main/inference.py
1.48 kB
| import torch | |
| from transformers import AutoModel, AutoTokenizer | |
| def load_model(repo_id, device=None, revision=None): | |
| device = device or ('cuda' if torch.cuda.is_available() else 'cpu') | |
| tokenizer = AutoTokenizer.from_pretrained(repo_id, revision=revision) | |
| model = AutoModel.from_pretrained( | |
| repo_id, | |
| revision=revision, | |
| trust_remote_code=True, | |
| use_safetensors=True, | |
| attn_implementation='sdpa', | |
| ).to(device).eval() | |
| return model, tokenizer | |
| def predict(model, tokenizer, states, calibrated=True): | |
| if isinstance(states, str): | |
| states = [states] | |
| if calibrated and model.config.temperatures is None: | |
| raise RuntimeError('This model has no fitted calibration parameters') | |
| device = next(model.parameters()).device | |
| tokens = tokenizer( | |
| states, | |
| padding=True, | |
| truncation=True, | |
| max_length=model.config.max_length, | |
| return_tensors='pt', | |
| ).to(device) | |
| logits = model(**tokens).logits | |
| temperatures = model.config.temperatures if calibrated else [1.0] * len(logits) | |
| probabilities = [torch.softmax(head.float() / value, dim=-1).cpu() | |
| for head, value in zip(logits, temperatures)] | |
| return [ | |
| { | |
| spec['name']: dict(zip(spec['options'], values[row].tolist())) | |
| for spec, values in zip(model.config.decisions, probabilities) | |
| } | |
| for row in range(len(states)) | |
| ] | |