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
File size: 1,335 Bytes
e1e980e | 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 | """`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):
@cached_property
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)
|