Text Classification
Transformers
Safetensors
English
lfm2_vl
feature-extraction
decision-model
typed-decisions
system-one
shell
guardrail
command-risk
lfm2
liquid
lora
custom_code
Eval Results (legacy)
Instructions to use yannelli/d1-3b-cli-command-risk with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use yannelli/d1-3b-cli-command-risk with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="yannelli/d1-3b-cli-command-risk", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoProcessor, AutoModel processor = AutoProcessor.from_pretrained("yannelli/d1-3b-cli-command-risk", trust_remote_code=True) model = AutoModel.from_pretrained("yannelli/d1-3b-cli-command-risk", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
Download modeling_d1.py from yannelli/d1-3b-cli-command-risk: direct link, hf CLI and curl.
- Browser
- Download file 1.34 kB
-
https://huggingface.co/yannelli/d1-3b-cli-command-risk/resolve/main/modeling_d1.py
- Command line
-
hf download hf://yannelli/d1-3b-cli-command-risk/modeling_d1.py
-
curl -L -o modeling_d1.py https://huggingface.co/yannelli/d1-3b-cli-command-risk/resolve/main/modeling_d1.py
1.34 kB
| """`AutoModel.from_pretrained(repo, trust_remote_code=True)`: LFM2-VL with the System One API. | |
| model.system_one(state, {name: question}, images=None) # one forward pass | |
| model.system_one_batch([(state, {name: question}), ...]) # many states, packed with no padding | |
| """ | |
| from __future__ import annotations | |
| from collections.abc import Mapping, Sequence | |
| from functools import cached_property | |
| from typing import Any | |
| from .lfm2_vl import Lfm2VlForConditionalGeneration | |
| from .runner import SystemOne | |
| class D1Model(Lfm2VlForConditionalGeneration): | |
| def engine(self) -> SystemOne: | |
| from transformers import AutoTokenizer | |
| return SystemOne(model=self.eval(), tokenizer=AutoTokenizer.from_pretrained(self.name_or_path)) | |
| def system_one(self, state: Any, questions: Mapping[str, Any], images: Sequence | None = None) -> dict: | |
| """Named questions over a state (text, JSON, or None with images alone): | |
| `{"answers": {name: answer}, "usage": {"input_tokens": n, "output_tokens": 0}}`.""" | |
| return self.engine.system_one(state, questions, images) | |
| def system_one_batch(self, requests: Sequence[tuple]) -> list[dict]: | |
| """`(state, questions)` or `(state, questions, images)` requests, one response each.""" | |
| return self.engine.system_one_batch(requests) | |